From 43509370272898f7a346de7e2f4c8a012d00f621 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Fri, 20 Dec 2013 14:27:51 +0100 Subject: [PATCH 001/398] Merge branch 'master' of sapi/phpdbg into PHP-5.6 Including phpdbg. --- .gdbinit | 10 + .gitignore | 5 + .phpdbginit | 105 ++ .travis.yml | 3 + Changelog.md | 52 + Makefile.frag | 28 + README.md | 83 ++ config.m4 | 61 ++ config.w32 | 19 + phpdbg.c | 1308 +++++++++++++++++++++++ phpdbg.h | 187 ++++ phpdbg.init.d | 122 +++ phpdbg_bp.c | 1661 +++++++++++++++++++++++++++++ phpdbg_bp.h | 146 +++ phpdbg_break.c | 155 +++ phpdbg_break.h | 58 + phpdbg_cmd.c | 669 ++++++++++++ phpdbg_cmd.h | 169 +++ phpdbg_frame.c | 206 ++++ phpdbg_frame.h | 30 + phpdbg_help.c | 603 +++++++++++ phpdbg_help.h | 92 ++ phpdbg_info.c | 355 ++++++ phpdbg_info.h | 49 + phpdbg_list.c | 279 +++++ phpdbg_list.h | 47 + phpdbg_opcode.c | 361 +++++++ phpdbg_opcode.h | 31 + phpdbg_print.c | 258 +++++ phpdbg_print.h | 51 + phpdbg_prompt.c | 1328 +++++++++++++++++++++++ phpdbg_prompt.h | 68 ++ phpdbg_set.c | 208 ++++ phpdbg_set.h | 47 + phpdbg_utils.c | 386 +++++++ phpdbg_utils.h | 110 ++ test.php | 51 + tests/commands/0001_basic.test | 8 + tests/commands/0002_set.test | 23 + tests/commands/0101_info.test | 19 + tests/commands/0102_print.test | 28 + tests/commands/0103_register.test | 28 + tests/commands/0104_clean.test | 15 + tests/commands/0105_clear.test | 18 + tests/commands/0106_compile.test | 19 + tests/run-tests.php | 583 ++++++++++ travis/ci.sh | 9 + web-bootstrap.php | 64 ++ 48 files changed, 10215 insertions(+) create mode 100644 .gdbinit create mode 100644 .gitignore create mode 100644 .phpdbginit create mode 100644 .travis.yml create mode 100644 Changelog.md create mode 100644 Makefile.frag create mode 100644 README.md create mode 100644 config.m4 create mode 100644 config.w32 create mode 100644 phpdbg.c create mode 100644 phpdbg.h create mode 100755 phpdbg.init.d create mode 100644 phpdbg_bp.c create mode 100644 phpdbg_bp.h create mode 100644 phpdbg_break.c create mode 100644 phpdbg_break.h create mode 100644 phpdbg_cmd.c create mode 100644 phpdbg_cmd.h create mode 100644 phpdbg_frame.c create mode 100644 phpdbg_frame.h create mode 100644 phpdbg_help.c create mode 100644 phpdbg_help.h create mode 100644 phpdbg_info.c create mode 100644 phpdbg_info.h create mode 100644 phpdbg_list.c create mode 100644 phpdbg_list.h create mode 100644 phpdbg_opcode.c create mode 100644 phpdbg_opcode.h create mode 100644 phpdbg_print.c create mode 100644 phpdbg_print.h create mode 100644 phpdbg_prompt.c create mode 100644 phpdbg_prompt.h create mode 100644 phpdbg_set.c create mode 100644 phpdbg_set.h create mode 100644 phpdbg_utils.c create mode 100644 phpdbg_utils.h create mode 100644 test.php create mode 100644 tests/commands/0001_basic.test create mode 100644 tests/commands/0002_set.test create mode 100644 tests/commands/0101_info.test create mode 100644 tests/commands/0102_print.test create mode 100644 tests/commands/0103_register.test create mode 100644 tests/commands/0104_clean.test create mode 100644 tests/commands/0105_clear.test create mode 100644 tests/commands/0106_compile.test create mode 100644 tests/run-tests.php create mode 100755 travis/ci.sh create mode 100644 web-bootstrap.php diff --git a/.gdbinit b/.gdbinit new file mode 100644 index 00000000000..401a4bb88c0 --- /dev/null +++ b/.gdbinit @@ -0,0 +1,10 @@ +define ____phpdbg_globals + if basic_functions_module.zts + if !$tsrm_ls + set $tsrm_ls = ts_resource_ex(0, 0) + end + set $phpdbg = ((zend_phpdbg_globals*) (*((void ***) $tsrm_ls))[phpdbg_globals_id-1]) + else + set $phpdbg = phpdbg_globals + end +end diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..297efcbc420 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.libs/ +./phpdbg +*.lo +*.o +build diff --git a/.phpdbginit b/.phpdbginit new file mode 100644 index 00000000000..1ad35218ede --- /dev/null +++ b/.phpdbginit @@ -0,0 +1,105 @@ +########################################################## +# .phpdbginit +# +# Lines starting with # are ignored +# Code must start and end with <: and :> respectively +########################################################## +# Place initialization commands one per line +########################################################## +# exec sapi/phpdbg/test.php +# set color prompt white-bold +# set color notice green +# set color error red + +########################################################## +# Embedding code in .phpdbginit +########################################################## +<: +/* +* This embedded PHP is executed at init time +*/ + +/* +* Functions defined and registered by init +* will persist across cleans +*/ + +/* +function my_debugging_function() +{ + var_dump(func_get_args()); +} +*/ + +/* phpdbg_break(PHPDBG_METHOD, "phpdbg::method"); */ +/* phpdbg_break(PHPDBG_FUNC, "my_global_function"); */ +/* phpdbg_break(PHPDBG_FILE, "/path/to/file.php:10"); */ + +/* + If readline is loaded, you might want to setup completion: +*/ +if (function_exists('readline_completion_function')) { + readline_completion_function(function(){ + return array_merge( + get_defined_functions()['user'], + array_keys(get_defined_constants()) + ); + }); +} + +/* + Setting argv made trivial ... + + argv 1 2 3 4 + ^ set argv for next execution + + argv + ^ unset argv for next execution + +*/ +function argv() +{ + $argv = func_get_args(); + + if (!$argv) { + $_SERVER['argv'] = array(); + $_SERVER['argc'] = 0; + return; + } + + $_SERVER['argv'] = array_merge + ( + array("phpdbg"), + $argv + ); + $_SERVER['argc'] = count($_SERVER['argv']); + + return $_SERVER['argv']; +} +:> +########################################################## +# Now carry on initializing phpdbg ... +########################################################## +# R my_debugging_function +# R argv + +########################################################## +# PHP has many functions that might be useful +# ... you choose ... +########################################################## +# R touch +# R unlink +# R scandir +# R glob + +########################################################## +# Remember: *you have access to the shell* +########################################################## +# The output of registered function calls is not, +# by default, very pretty (unless you implement +# and register a new implementation for phpdbg) +# The output of shell commands will usually be more +# readable on the console +########################################################## +# TLDR; if you have a good shell, use it ... +########################################################## diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000000..353402858e0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +language: c + +script: ./travis/ci.sh diff --git a/Changelog.md b/Changelog.md new file mode 100644 index 00000000000..c5d8b51514b --- /dev/null +++ b/Changelog.md @@ -0,0 +1,52 @@ +ChangeLog for phpdbg +==================== + +Version 0.3.0 2013-00-00 +------------------------ + +1. Added ability to disable an enable a single breakpoint +2. Added ability to override SAPI name +3. Added extended conditional breakpoint support "break at" +4. Fix loading of zend extnsions with -z +5. Fix crash when loading .phpdbginit with command line switch +6. Fix crash on startup errors +7. Added init.d for remote console (redhat) +8. Added phpdbg_exec userland function +9. Added testing facilities +10. Added break on n-th opline support +11. Improved trace output + +Version 0.2.0 2013-11-31 +------------------------ + +1. Added "break delete " command +2. Added "break opcode " command +3. Added "set" command - control prompt and console colors +4. .phpdbginit now searched in (additional) ini dirs +5. Added source command - load additional .phpdbginit script during session +6. Added remote console mode +7. Added info memory command + +Version 0.1.0 2013-11-23 +------------------------ + +1. New commands: + - until (continue until the current line is executed) + - frame (switch to a frame in the current stack for inspection) + - info (quick access to useful information on the console) + - finish (continue until the current function has returned) + - leave (continue until the current function is returning) + - shell (shell a command) + - register (register a function for use as a command) +2. Added printers for class and method +3. Make uniform commands and aliases where possible +4. Include all alias information and sub-command information in help +5. Added signal handling to break execution (ctrl-c) +6. Fixed #13 (Output Buffering Control seems fail) +7. Fixed #14 (Fixed typo in Makefile.frag) + + +Version 0.0.1 2013-11-15 +------------------------ + +1. Initial features diff --git a/Makefile.frag b/Makefile.frag new file mode 100644 index 00000000000..5be6d5b00f4 --- /dev/null +++ b/Makefile.frag @@ -0,0 +1,28 @@ +phpdbg: $(BUILD_BINARY) + +phpdbg-shared: $(BUILD_SHARED) + +$(BUILD_SHARED): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_PHPDBG_OBJS) + $(BUILD_PHPDBG_SHARED) + +$(BUILD_BINARY): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_PHPDBG_OBJS) + $(BUILD_PHPDBG) + +install-phpdbg: $(BUILD_BINARY) + @echo "Installing phpdbg binary: $(INSTALL_ROOT)$(bindir)/" + @$(mkinstalldirs) $(INSTALL_ROOT)$(bindir) + @$(mkinstalldirs) $(INSTALL_ROOT)$(localstatedir)/log + @$(mkinstalldirs) $(INSTALL_ROOT)$(localstatedir)/run + @$(INSTALL) -m 0755 $(BUILD_BINARY) $(INSTALL_ROOT)$(bindir)/$(program_prefix)phpdbg$(program_suffix)$(EXEEXT) + +clean-phpdbg: + @echo "Cleaning phpdbg object files ..." + find sapi/phpdbg/ -name *.lo -o -name *.o | xargs rm -f + +test-phpdbg: + @echo "Running phpdbg tests ..." + @$(top_builddir)/sapi/cli/php sapi/phpdbg/tests/run-tests.php --phpdbg sapi/phpdbg/phpdbg + +.PHONY: clean-phpdbg test-phpdbg + + diff --git a/README.md b/README.md new file mode 100644 index 00000000000..e7e5c731a80 --- /dev/null +++ b/README.md @@ -0,0 +1,83 @@ +The interactive PHP debugger +============================ + +Implemented as a SAPI module, phpdbg can excert complete control over the environment without impacting the functionality or performance of your code. + +phpdbg aims to be a lightweight, powerful, easy to use debugging platform for PHP 5.4+ + +[![phpdbg on travis-ci](https://travis-ci.org/krakjoe/phpdbg.png?branch=master)](https://travis-ci.org/krakjoe/phpdbg) + +Features +======== + + - Stepthrough Debugging + - Flexible Breakpoints (Class Method, Function, File:Line, Address, Opcode) + - Easy Access to PHP with built-in eval() + - Easy Access to Currently Executing Code + - Userland API + - SAPI Agnostic - Easily Integrated + - PHP Configuration File Support + - JIT Super Globals - Set Your Own!! + - Optional readline Support - Comfortable Terminal Operation + - Remote Debugging Support - Bundled Java GUI + - Easy Operation - See Help :) + +Planned +======= + + - Improve Everything :) + +Installation +============ + +To install **phpdbg**, you must compile the source against your PHP installation sources, and enable the SAPI with the configure command. + +``` +cd /usr/src/php-src/sapi +git clone https://github.com/krakjoe/phpdbg +cd ../ +./buildconf --force +./configure --enable-phpdbg +make -j8 +make install-phpdbg +``` + +Where the source directory has been used previously to build PHP, there exists a file named *config.nice* which can be used to invoke configure with the same +parameters as were used by the last execution of *configure*. + +**Note:** PHP must be configured with the switch --with-readline for phpdbg to support history, autocompletion, tab-listing etc. + +Command Line Options +==================== + +The following switches are implemented (just like cli SAPI): + + - -n ignore php ini + - -c search for php ini in path + - -z load zend extension + - -d define php ini entry + +The following switches change the default behaviour of phpdbg: + + - -v disables quietness + - -s enabled stepping + - -e sets execution context + - -b boring - disables use of colour on the console + - -I ignore .phpdbginit (default init file) + - -i override .phpgdbinit location (implies -I) + - -O set oplog output file + - -q do not print banner on startup + - -r jump straight to run + - -E enable step through eval() + - -l listen ports for remote mode + - -a listen address for remote mode + - -S override SAPI name + +**Note:** Passing -rr will cause phpdbg to quit after execution, rather than returning to the console. + +Getting Started +=============== + +See the website for tutorials/documentation + +http://phpdbg.com diff --git a/config.m4 b/config.m4 new file mode 100644 index 00000000000..274e6409d04 --- /dev/null +++ b/config.m4 @@ -0,0 +1,61 @@ +dnl +dnl $Id$ +dnl + +PHP_ARG_ENABLE(phpdbg, for phpdbg support, +[ --enable-phpdbg Build phpdbg], yes, yes) + +PHP_ARG_ENABLE(phpdbg-debug, for phpdbg debug build, +[ --enable-phpdbg-debug Build phpdbg in debug mode], no, no) + +if test "$PHP_PHPDBG" != "no"; then + AC_DEFINE(HAVE_PHPDBG, 1, [ ]) + + if test "$PHP_PHPDBG_DEBUG" != "no"; then + AC_DEFINE(PHPDBG_DEBUG, 1, [ ]) + else + AC_DEFINE(PHPDBG_DEBUG, 0, [ ]) + fi + + PHP_PHPDBG_CFLAGS="-D_GNU_SOURCE" + PHP_PHPDBG_FILES="phpdbg.c phpdbg_prompt.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_info.c phpdbg_cmd.c phpdbg_set.c phpdbg_frame.c" + + PHP_SUBST(PHP_PHPDBG_CFLAGS) + PHP_SUBST(PHP_PHPDBG_FILES) + + PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/sapi/phpdbg/Makefile.frag]) + PHP_SELECT_SAPI(phpdbg, program, $PHP_PHPDBG_FILES, $PHP_PHPDBG_CFLAGS, [$(SAPI_PHPDBG_PATH)]) + + BUILD_BINARY="sapi/phpdbg/phpdbg" + BUILD_SHARED="sapi/phpdbg/libphpdbg.la" + + BUILD_PHPDBG="\$(LIBTOOL) --mode=link \ + \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \ + \$(PHP_GLOBAL_OBJS) \ + \$(PHP_BINARY_OBJS) \ + \$(PHP_PHPDBG_OBJS) \ + \$(EXTRA_LIBS) \ + \$(PHPDBG_EXTRA_LIBS) \ + \$(ZEND_EXTRA_LIBS) \ + -o \$(BUILD_BINARY)" + + BUILD_PHPDBG_SHARED="\$(LIBTOOL) --mode=link \ + \$(CC) -shared -Wl,-soname,libphpdbg.so -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \ + \$(PHP_GLOBAL_OBJS) \ + \$(PHP_BINARY_OBJS) \ + \$(PHP_PHPDBG_OBJS) \ + \$(EXTRA_LIBS) \ + \$(PHPDBG_EXTRA_LIBS) \ + \$(ZEND_EXTRA_LIBS) \ + \-DPHPDBG_SHARED \ + -o \$(BUILD_SHARED)" + + PHP_SUBST(BUILD_BINARY) + PHP_SUBST(BUILD_SHARED) + PHP_SUBST(BUILD_PHPDBG) + PHP_SUBST(BUILD_PHPDBG_SHARED) +fi + +dnl ## Local Variables: +dnl ## tab-width: 4 +dnl ## End: diff --git a/config.w32 b/config.w32 new file mode 100644 index 00000000000..29031507b31 --- /dev/null +++ b/config.w32 @@ -0,0 +1,19 @@ +ARG_ENABLE('phpdbg', 'Build phpdbg', 'yes'); +ARG_ENABLE('phpdbgs', 'Build phpdbg shared', 'no'); + +PHPDBG_SOURCES='phpdbg.c phpdbg_prompt.c phpdbg_cmd.c phpdbg_info.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_set.c phpdbg_frame.c'; +PHPDBG_DLL='php' + PHP_VERSION + 'phpdbg.dll'; +PHPDBG_EXE='phpdbg.exe'; + +if (PHP_PHPDBG == "yes") { + /* build phpdbg binary */ + SAPI('phpdbg', PHPDBG_SOURCES, PHPDBG_EXE); + ADD_FLAG("LIBS_PHPDBG", "ws2_32.lib user32.lib"); +} + +if (PHP_PHPDBGS == "yes") { + SAPI('phpdbgs', PHPDBG_SOURCES, PHPDBG_DLL, '/D PHP_PHPDBG_EXPORTS /I win32'); + ADD_FLAG("LIBS_PHPDBGS", "ws2_32.lib user32.lib"); +} + + diff --git a/phpdbg.c b/phpdbg.c new file mode 100644 index 00000000000..17193ed244c --- /dev/null +++ b/phpdbg.c @@ -0,0 +1,1308 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + +----------------------------------------------------------------------+ +*/ + +#ifndef ZEND_SIGNALS +# include +#endif +#include "phpdbg.h" +#include "phpdbg_prompt.h" +#include "phpdbg_bp.h" +#include "phpdbg_break.h" +#include "phpdbg_utils.h" +#include "phpdbg_set.h" + +/* {{{ remote console headers */ +#ifndef _WIN32 +# include +# include +# include +# include +# include +# include +#endif /* }}} */ + +ZEND_DECLARE_MODULE_GLOBALS(phpdbg); + +static zend_bool phpdbg_booted = 0; + +#if PHP_VERSION_ID >= 50500 +void (*zend_execute_old)(zend_execute_data *execute_data TSRMLS_DC); +#else +void (*zend_execute_old)(zend_op_array *op_array TSRMLS_DC); +#endif + +static inline void php_phpdbg_globals_ctor(zend_phpdbg_globals *pg) /* {{{ */ +{ + pg->prompt[0] = NULL; + pg->prompt[1] = NULL; + + pg->colors[0] = NULL; + pg->colors[1] = NULL; + pg->colors[2] = NULL; + + pg->exec = NULL; + pg->exec_len = 0; + pg->ops = NULL; + pg->vmret = 0; + pg->bp_count = 0; + pg->lcmd = NULL; + pg->flags = PHPDBG_DEFAULT_FLAGS; + pg->oplog = NULL; + pg->io[PHPDBG_STDIN] = NULL; + pg->io[PHPDBG_STDOUT] = NULL; + pg->io[PHPDBG_STDERR] = NULL; + memset(&pg->lparam, 0, sizeof(phpdbg_param_t)); + pg->frame.num = 0; +} /* }}} */ + +static PHP_MINIT_FUNCTION(phpdbg) /* {{{ */ +{ + ZEND_INIT_MODULE_GLOBALS(phpdbg, php_phpdbg_globals_ctor, NULL); +#if PHP_VERSION_ID >= 50500 + zend_execute_old = zend_execute_ex; + zend_execute_ex = phpdbg_execute_ex; +#else + zend_execute_old = zend_execute; + zend_execute = phpdbg_execute_ex; +#endif + + REGISTER_STRINGL_CONSTANT("PHPDBG_VERSION", PHPDBG_VERSION, sizeof(PHPDBG_VERSION)-1, CONST_CS|CONST_PERSISTENT); + + REGISTER_LONG_CONSTANT("PHPDBG_FILE", FILE_PARAM, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("PHPDBG_METHOD", METHOD_PARAM, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("PHPDBG_LINENO", NUMERIC_PARAM, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("PHPDBG_FUNC", STR_PARAM, CONST_CS|CONST_PERSISTENT); + + REGISTER_LONG_CONSTANT("PHPDBG_COLOR_PROMPT", PHPDBG_COLOR_PROMPT, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("PHPDBG_COLOR_NOTICE", PHPDBG_COLOR_NOTICE, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("PHPDBG_COLOR_ERROR", PHPDBG_COLOR_ERROR, CONST_CS|CONST_PERSISTENT); + + return SUCCESS; +} /* }}} */ + +static void php_phpdbg_destroy_bp_file(void *brake) /* {{{ */ +{ + zend_hash_destroy((HashTable*)brake); +} /* }}} */ + +static void php_phpdbg_destroy_bp_symbol(void *brake) /* {{{ */ +{ + efree((char*)((phpdbg_breaksymbol_t*)brake)->symbol); +} /* }}} */ + +static void php_phpdbg_destroy_bp_opcode(void *brake) /* {{{ */ +{ + efree((char*)((phpdbg_breakop_t*)brake)->name); +} /* }}} */ + + +static void php_phpdbg_destroy_bp_methods(void *brake) /* {{{ */ +{ + zend_hash_destroy((HashTable*)brake); +} /* }}} */ + +static void php_phpdbg_destroy_bp_condition(void *data) /* {{{ */ +{ + phpdbg_breakcond_t *brake = (phpdbg_breakcond_t*) data; + + if (brake) { + if (brake->ops) { + TSRMLS_FETCH(); + + destroy_op_array( + brake->ops TSRMLS_CC); + efree(brake->ops); + } + efree((char*)brake->code); + } +} /* }}} */ + +static void php_phpdbg_destroy_registered(void *data) /* {{{ */ +{ + TSRMLS_FETCH(); + + zend_function *function = (zend_function*) data; + + destroy_zend_function( + function TSRMLS_CC); +} /* }}} */ + +static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */ +{ + zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], 8, NULL, php_phpdbg_destroy_bp_file, 0); + zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], 8, NULL, php_phpdbg_destroy_bp_symbol, 0); + zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], 8, NULL, php_phpdbg_destroy_bp_methods, 0); + zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], 8, NULL, php_phpdbg_destroy_bp_methods, 0); + zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE], 8, NULL, php_phpdbg_destroy_bp_methods, 0); + zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], 8, NULL, NULL, 0); + zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], 8, NULL, php_phpdbg_destroy_bp_opcode, 0); + zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], 8, NULL, php_phpdbg_destroy_bp_methods, 0); + zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], 8, NULL, php_phpdbg_destroy_bp_condition, 0); + zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], 8, NULL, NULL, 0); + + zend_hash_init(&PHPDBG_G(seek), 8, NULL, NULL, 0); + zend_hash_init(&PHPDBG_G(registered), 8, NULL, php_phpdbg_destroy_registered, 0); + + return SUCCESS; +} /* }}} */ + +static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */ +{ + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE]); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM]); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE]); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE]); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE]); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE]); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD]); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_COND]); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP]); + zend_hash_destroy(&PHPDBG_G(seek)); + zend_hash_destroy(&PHPDBG_G(registered)); + + if (PHPDBG_G(exec)) { + efree(PHPDBG_G(exec)); + PHPDBG_G(exec) = NULL; + } + + if (PHPDBG_G(prompt)[0]) { + free(PHPDBG_G(prompt)[0]); + } + if (PHPDBG_G(prompt)[1]) { + free(PHPDBG_G(prompt)[1]); + } + + PHPDBG_G(prompt)[0] = NULL; + PHPDBG_G(prompt)[1] = NULL; + + if (PHPDBG_G(oplog)) { + fclose( + PHPDBG_G(oplog)); + PHPDBG_G(oplog) = NULL; + } + + if (PHPDBG_G(ops)) { + destroy_op_array(PHPDBG_G(ops) TSRMLS_CC); + efree(PHPDBG_G(ops)); + PHPDBG_G(ops) = NULL; + } + + return SUCCESS; +} /* }}} */ + +/* {{{ proto mixed phpdbg_exec(string context) + Attempt to set the execution context for phpdbg + If the execution context was set previously it is returned + If the execution context was not set previously boolean true is returned + If the request to set the context fails, boolean false is returned, and an E_WARNING raised */ +static PHP_FUNCTION(phpdbg_exec) +{ + char *exec = NULL; + zend_ulong exec_len = 0L; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &exec, &exec_len) == FAILURE) { + return; + } + + { + struct stat sb; + zend_bool result = 1; + + if (VCWD_STAT(exec, &sb) != FAILURE) { + if (sb.st_mode & (S_IFREG|S_IFLNK)) { + if (PHPDBG_G(exec)) { + ZVAL_STRINGL(return_value, PHPDBG_G(exec), PHPDBG_G(exec_len), 1); + efree(PHPDBG_G(exec)); + result = 0; + } + + PHPDBG_G(exec) = estrndup(exec, exec_len); + PHPDBG_G(exec_len) = exec_len; + + if (result) + ZVAL_BOOL(return_value, 1); + } else { + zend_error( + E_WARNING, "Failed to set execution context (%s), not a regular file or symlink", exec); + ZVAL_BOOL(return_value, 0); + } + } else { + zend_error( + E_WARNING, "Failed to set execution context (%s) the file does not exist", exec); + + ZVAL_BOOL(return_value, 0); + } + } +} /* }}} */ + +/* {{{ proto void phpdbg_break([integer type, string expression]) + instructs phpdbg to insert a breakpoint at the next opcode */ +static PHP_FUNCTION(phpdbg_break) +{ + if (ZEND_NUM_ARGS() > 0) { + long type; + char *expr = NULL; + zend_uint expr_len = 0; + phpdbg_param_t param; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &type, &expr, &expr_len) == FAILURE) { + return; + } + + phpdbg_parse_param(expr, expr_len, ¶m TSRMLS_CC); + + switch (type) { + case METHOD_PARAM: + phpdbg_do_break_method(¶m, NULL TSRMLS_CC); + break; + + case FILE_PARAM: + phpdbg_do_break_file(¶m, NULL TSRMLS_CC); + break; + + case NUMERIC_PARAM: + phpdbg_do_break_lineno(¶m, NULL TSRMLS_CC); + break; + + case STR_PARAM: + phpdbg_do_break_func(¶m, NULL TSRMLS_CC); + break; + + default: zend_error( + E_WARNING, "unrecognized parameter type %ld", type); + } + + phpdbg_clear_param(¶m TSRMLS_CC); + + } else if (EG(current_execute_data) && EG(active_op_array)) { + zend_ulong opline_num = (EG(current_execute_data)->opline - + EG(active_op_array)->opcodes); + + phpdbg_set_breakpoint_opline_ex( + &EG(active_op_array)->opcodes[opline_num+1] TSRMLS_CC); + } +} /* }}} */ + +/* {{{ proto void phpdbg_clear(void) + instructs phpdbg to clear breakpoints */ +static PHP_FUNCTION(phpdbg_clear) +{ + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_COND]); +} /* }}} */ + +/* {{{ proto void phpdbg_color(integer element, string color) */ +static PHP_FUNCTION(phpdbg_color) +{ + long element; + char *color; + zend_uint color_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &element, &color, &color_len) == FAILURE) { + return; + } + + switch (element) { + case PHPDBG_COLOR_NOTICE: + case PHPDBG_COLOR_ERROR: + case PHPDBG_COLOR_PROMPT: + phpdbg_set_color_ex(element, color, color_len TSRMLS_CC); + break; + + default: zend_error(E_ERROR, "phpdbg detected an incorrect color constant"); + } +} /* }}} */ + +/* {{{ proto void phpdbg_prompt(string prompt) */ +static PHP_FUNCTION(phpdbg_prompt) +{ + char *prompt; + zend_uint prompt_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &prompt, &prompt_len) == FAILURE) { + return; + } + + phpdbg_set_prompt(prompt TSRMLS_CC); +} /* }}} */ + +ZEND_BEGIN_ARG_INFO_EX(phpdbg_break_arginfo, 0, 0, 0) + ZEND_ARG_INFO(0, type) + ZEND_ARG_INFO(0, expression) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(phpdbg_color_arginfo, 0, 0, 0) + ZEND_ARG_INFO(0, element) + ZEND_ARG_INFO(0, color) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(phpdbg_prompt_arginfo, 0, 0, 0) + ZEND_ARG_INFO(0, string) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(phpdbg_exec_arginfo, 0, 0, 0) + ZEND_ARG_INFO(0, context) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(phpdbg_clear_arginfo, 0, 0, 0) +ZEND_END_ARG_INFO() + +zend_function_entry phpdbg_user_functions[] = { + PHP_FE(phpdbg_clear, phpdbg_clear_arginfo) + PHP_FE(phpdbg_break, phpdbg_break_arginfo) + PHP_FE(phpdbg_exec, phpdbg_exec_arginfo) + PHP_FE(phpdbg_color, phpdbg_color_arginfo) + PHP_FE(phpdbg_prompt, phpdbg_prompt_arginfo) +#ifdef PHP_FE_END + PHP_FE_END +#else + {NULL,NULL,NULL} +#endif +}; + +static zend_module_entry sapi_phpdbg_module_entry = { + STANDARD_MODULE_HEADER, + PHPDBG_NAME, + phpdbg_user_functions, + PHP_MINIT(phpdbg), + NULL, + PHP_RINIT(phpdbg), + PHP_RSHUTDOWN(phpdbg), + NULL, + PHPDBG_VERSION, + STANDARD_MODULE_PROPERTIES +}; + +static inline int php_sapi_phpdbg_module_startup(sapi_module_struct *module) /* {{{ */ +{ + if (php_module_startup(module, &sapi_phpdbg_module_entry, 1) == FAILURE) { + return FAILURE; + } + + phpdbg_booted=1; + + return SUCCESS; +} /* }}} */ + +static char* php_sapi_phpdbg_read_cookies(TSRMLS_D) /* {{{ */ +{ + return NULL; +} /* }}} */ + +static int php_sapi_phpdbg_header_handler(sapi_header_struct *h, sapi_header_op_enum op, sapi_headers_struct *s TSRMLS_DC) /* {{{ */ +{ + return 0; +} +/* }}} */ + +static int php_sapi_phpdbg_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) /* {{{ */ +{ + /* We do nothing here, this function is needed to prevent that the fallback + * header handling is called. */ + return SAPI_HEADER_SENT_SUCCESSFULLY; +} +/* }}} */ + +static void php_sapi_phpdbg_send_header(sapi_header_struct *sapi_header, void *server_context TSRMLS_DC) /* {{{ */ +{ +} +/* }}} */ + +static void php_sapi_phpdbg_log_message(char *message TSRMLS_DC) /* {{{ */ +{ + /* + * We must not request TSRM before being boot + */ + if (phpdbg_booted) { + phpdbg_error("%s", message); + } else fprintf(stdout, "%s\n", message); +} +/* }}} */ + +static int php_sapi_phpdbg_deactivate(TSRMLS_D) /* {{{ */ +{ + fflush(stdout); + if(SG(request_info).argv0) { + free(SG(request_info).argv0); + SG(request_info).argv0 = NULL; + } + return SUCCESS; +} +/* }}} */ + +static void php_sapi_phpdbg_register_vars(zval *track_vars_array TSRMLS_DC) /* {{{ */ +{ + unsigned int len; + char *docroot = ""; + + /* In phpdbg mode, we consider the environment to be a part of the server variables + */ + php_import_environment_variables(track_vars_array TSRMLS_CC); + + if (PHPDBG_G(exec)) { + len = PHPDBG_G(exec_len); + if (sapi_module.input_filter(PARSE_SERVER, "PHP_SELF", + &PHPDBG_G(exec), PHPDBG_G(exec_len), &len TSRMLS_CC)) { + php_register_variable("PHP_SELF", PHPDBG_G(exec), + track_vars_array TSRMLS_CC); + } + if (sapi_module.input_filter(PARSE_SERVER, "SCRIPT_NAME", + &PHPDBG_G(exec), PHPDBG_G(exec_len), &len TSRMLS_CC)) { + php_register_variable("SCRIPT_NAME", PHPDBG_G(exec), + track_vars_array TSRMLS_CC); + } + + if (sapi_module.input_filter(PARSE_SERVER, "SCRIPT_FILENAME", + &PHPDBG_G(exec), PHPDBG_G(exec_len), &len TSRMLS_CC)) { + php_register_variable("SCRIPT_FILENAME", PHPDBG_G(exec), + track_vars_array TSRMLS_CC); + } + if (sapi_module.input_filter(PARSE_SERVER, "PATH_TRANSLATED", + &PHPDBG_G(exec), PHPDBG_G(exec_len), &len TSRMLS_CC)) { + php_register_variable("PATH_TRANSLATED", PHPDBG_G(exec), + track_vars_array TSRMLS_CC); + } + } + + /* any old docroot will doo */ + len = 0U; + if (sapi_module.input_filter(PARSE_SERVER, "DOCUMENT_ROOT", + &docroot, len, &len TSRMLS_CC)) { + php_register_variable("DOCUMENT_ROOT", docroot, track_vars_array TSRMLS_CC); + } +} +/* }}} */ + +static inline int php_sapi_phpdbg_ub_write(const char *message, unsigned int length TSRMLS_DC) /* {{{ */ +{ + return phpdbg_write("%s", message); +} /* }}} */ + +#if PHP_VERSION_ID >= 50700 +static inline void php_sapi_phpdbg_flush(void *context TSRMLS_DC) /* {{{ */ +{ +#else +static inline void php_sapi_phpdbg_flush(void *context) /* {{{ */ +{ + TSRMLS_FETCH(); +#endif + + fflush(PHPDBG_G(io)[PHPDBG_STDOUT]); +} /* }}} */ + +/* {{{ sapi_module_struct phpdbg_sapi_module +*/ +static sapi_module_struct phpdbg_sapi_module = { + "phpdbg", /* name */ + "phpdbg", /* pretty name */ + + php_sapi_phpdbg_module_startup, /* startup */ + php_module_shutdown_wrapper, /* shutdown */ + + NULL, /* activate */ + php_sapi_phpdbg_deactivate, /* deactivate */ + + php_sapi_phpdbg_ub_write, /* unbuffered write */ + php_sapi_phpdbg_flush, /* flush */ + NULL, /* get uid */ + NULL, /* getenv */ + + php_error, /* error handler */ + + php_sapi_phpdbg_header_handler, /* header handler */ + php_sapi_phpdbg_send_headers, /* send headers handler */ + php_sapi_phpdbg_send_header, /* send header handler */ + + NULL, /* read POST data */ + php_sapi_phpdbg_read_cookies, /* read Cookies */ + + php_sapi_phpdbg_register_vars, /* register server variables */ + php_sapi_phpdbg_log_message, /* Log message */ + NULL, /* Get request time */ + NULL, /* Child terminate */ + STANDARD_SAPI_MODULE_PROPERTIES +}; +/* }}} */ + +const opt_struct OPTIONS[] = { /* {{{ */ + {'c', 1, "ini path override"}, + {'d', 1, "define ini entry on command line"}, + {'n', 0, "no php.ini"}, + {'z', 1, "load zend_extension"}, + /* phpdbg options */ + {'q', 0, "no banner"}, + {'e', 1, "exec"}, + {'v', 0, "disable quietness"}, + {'s', 0, "enable stepping"}, + {'b', 0, "boring colours"}, + {'i', 1, "specify init"}, + {'I', 0, "ignore init"}, + {'O', 1, "opline log"}, + {'r', 0, "run"}, + {'E', 0, "step-through-eval"}, + {'S', 1, "sapi-name"}, +#ifndef _WIN32 + {'l', 1, "listen"}, + {'a', 1, "address-or-any"}, +#endif + {'V', 0, "version"}, + {'-', 0, NULL} +}; /* }}} */ + +const char phpdbg_ini_hardcoded[] = +"html_errors=Off\n" +"register_argc_argv=On\n" +"implicit_flush=On\n" +"display_errors=Off\n" +"log_errors=On\n" +"max_execution_time=0\n" +"max_input_time=-1\n\0"; + +/* overwriteable ini defaults must be set in phpdbg_ini_defaults() */ +#define INI_DEFAULT(name, value) \ + Z_SET_REFCOUNT(tmp, 0); \ + Z_UNSET_ISREF(tmp); \ + ZVAL_STRINGL(&tmp, zend_strndup(value, sizeof(value)-1), sizeof(value)-1, 0); \ + zend_hash_update(configuration_hash, name, sizeof(name), &tmp, sizeof(zval), NULL); + +void phpdbg_ini_defaults(HashTable *configuration_hash) /* {{{ */ +{ + zval tmp; + INI_DEFAULT("report_zend_debug", "0"); +} /* }}} */ + +static void phpdbg_welcome(zend_bool cleaning TSRMLS_DC) /* {{{ */ +{ + /* print blurb */ + if (!cleaning) { + phpdbg_notice("Welcome to phpdbg, the interactive PHP debugger, v%s", + PHPDBG_VERSION); + phpdbg_writeln("To get help using phpdbg type \"help\" and press enter"); + phpdbg_notice("Please report bugs to <%s>", PHPDBG_ISSUES); + } else { + phpdbg_notice("Clean Execution Environment"); + + phpdbg_writeln("Classes\t\t\t%d", zend_hash_num_elements(EG(class_table))); + phpdbg_writeln("Functions\t\t%d", zend_hash_num_elements(EG(function_table))); + phpdbg_writeln("Constants\t\t%d", zend_hash_num_elements(EG(zend_constants))); + phpdbg_writeln("Includes\t\t%d", zend_hash_num_elements(&EG(included_files))); + } +} /* }}} */ + +static inline void phpdbg_sigint_handler(int signo) /* {{{ */ +{ + TSRMLS_FETCH(); + + if (EG(in_execution)) { + /* set signalled only when not interactive */ + if (!(PHPDBG_G(flags) & PHPDBG_IS_INTERACTIVE)) { + PHPDBG_G(flags) |= PHPDBG_IS_SIGNALED; + } + } else { + PHPDBG_G(flags) |= PHPDBG_IS_QUITTING; + zend_bailout(); + } +} /* }}} */ + +#ifndef _WIN32 +int phpdbg_open_socket(const char *interface, short port) /* {{{ */ +{ + int fd = socket(AF_INET, SOCK_STREAM, 0); + + switch (fd) { + case -1: + return -1; + + default: { + int reuse = 1; + + switch (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*) &reuse, sizeof(reuse))) { + case -1: + close(fd); + return -2; + + default: { + struct sockaddr_in address; + + memset(&address, 0, sizeof(address)); + + address.sin_port = htons(port); + address.sin_family = AF_INET; + + if ((*interface == '*')) { + address.sin_addr.s_addr = htonl(INADDR_ANY); + } else if (!inet_pton(AF_INET, interface, &address.sin_addr)) { + close(fd); + return -3; + } + + switch (bind(fd, (struct sockaddr *)&address, sizeof(address))) { + case -1: + close(fd); + return -4; + + default: { + listen(fd, 5); + } + } + } + } + } + } + + return fd; +} /* }}} */ + +static inline void phpdbg_close_sockets(int (*socket)[2], FILE *streams[2]) /* {{{ */ +{ + if ((*socket)[0] >= 0) { + shutdown( + (*socket)[0], SHUT_RDWR); + close((*socket)[0]); + } + + if (streams[0]) { + fclose(streams[0]); + } + + if ((*socket)[1] >= 0) { + shutdown( + (*socket)[1], SHUT_RDWR); + close((*socket)[1]); + } + + if (streams[1]) { + fclose(streams[1]); + } +} /* }}} */ + +/* don't inline this, want to debug it easily, will inline when done */ + +int phpdbg_open_sockets(char *address, int port[2], int (*listen)[2], int (*socket)[2], FILE* streams[2]) /* {{{ */ +{ + if (((*listen)[0]) < 0 && ((*listen)[1]) < 0) { + ((*listen)[0]) = phpdbg_open_socket(address, (short)port[0]); + ((*listen)[1]) = phpdbg_open_socket(address, (short)port[1]); + } + + streams[0] = NULL; + streams[1] = NULL; + + if ((*listen)[0] < 0 || (*listen)[1] < 0) { + if ((*listen)[0] < 0) { + phpdbg_rlog(stderr, + "console failed to initialize (stdin) on %s:%d", address, port[0]); + } + + if ((*listen)[1] < 0) { + phpdbg_rlog(stderr, + "console failed to initialize (stdout) on %s:%d", address, port[1]); + } + + if ((*listen)[0] >= 0) { + close((*listen)[0]); + } + + if ((*listen)[1] >= 0) { + close((*listen)[1]); + } + + return FAILURE; + } + + phpdbg_close_sockets(socket, streams); + + phpdbg_rlog(stderr, + "accepting connections on %s:%d/%d", address, port[0], port[1]); + { + struct sockaddr_in address; + socklen_t size = sizeof(address); + char buffer[20] = {0}; + + { + memset(&address, 0, size); + (*socket)[0] = accept( + (*listen)[0], (struct sockaddr *) &address, &size); + inet_ntop(AF_INET, &address.sin_addr, buffer, sizeof(buffer)); + + phpdbg_rlog(stderr, "connection (stdin) from %s", buffer); + } + + { + memset(&address, 0, size); + (*socket)[1] = accept( + (*listen)[1], (struct sockaddr *) &address, &size); + inet_ntop(AF_INET, &address.sin_addr, buffer, sizeof(buffer)); + + phpdbg_rlog(stderr, "connection (stdout) from %s", buffer); + } + } + + dup2((*socket)[0], fileno(stdin)); + dup2((*socket)[1], fileno(stdout)); + + setbuf(stdout, NULL); + + streams[0] = fdopen((*socket)[0], "r"); + streams[1] = fdopen((*socket)[1], "w"); + + return SUCCESS; +} /* }}} */ +#endif + +int main(int argc, char **argv) /* {{{ */ +{ + sapi_module_struct *phpdbg = &phpdbg_sapi_module; + char *sapi_name; + char *ini_entries; + int ini_entries_len; + char **zend_extensions = NULL; + zend_ulong zend_extensions_len = 0L; + zend_bool ini_ignore; + char *ini_override; + char *exec; + size_t exec_len; + char *init_file; + size_t init_file_len; + zend_bool init_file_default; + char *oplog_file; + size_t oplog_file_len; + zend_ulong flags; + char *php_optarg; + int php_optind, opt, show_banner = 1; + long cleaning = 0; + zend_bool remote = 0; + int run = 0; + int step = 0; + char *bp_tmp_file; +#ifndef _WIN32 + char *address; + int listen[2]; + int server[2]; + int socket[2]; + FILE* streams[2] = {NULL, NULL}; +#endif + +#ifdef ZTS + void ***tsrm_ls; +#endif + +#ifndef _WIN32 + address = strdup("127.0.0.1"); + socket[0] = -1; + socket[1] = -1; + listen[0] = -1; + listen[1] = -1; + server[0] = -1; + server[1] = -1; + streams[0] = NULL; + streams[1] = NULL; +#endif + +#ifdef PHP_WIN32 + _fmode = _O_BINARY; /* sets default for file streams to binary */ + setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */ + setmode(_fileno(stdout), O_BINARY); /* make the stdio mode be binary */ + setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */ +#endif + +#ifdef ZTS + tsrm_startup(1, 1, 0, NULL); + + tsrm_ls = ts_resource(0); +#endif + +phpdbg_main: + if (!cleaning) { + bp_tmp_file = malloc(L_tmpnam); + tmpnam(bp_tmp_file); + if (bp_tmp_file == NULL) { + phpdbg_error("Unable to create temporary file"); + } + } + ini_entries = NULL; + ini_entries_len = 0; + ini_ignore = 0; + ini_override = NULL; + zend_extensions = NULL; + zend_extensions_len = 0L; + exec = NULL; + exec_len = 0; + init_file = NULL; + init_file_len = 0; + init_file_default = 1; + oplog_file = NULL; + oplog_file_len = 0; + flags = PHPDBG_DEFAULT_FLAGS; + php_optarg = NULL; + php_optind = 1; + opt = 0; + run = 0; + step = 0; + sapi_name = NULL; + + + while ((opt = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) { + switch (opt) { + case 'r': + run++; + break; + case 'n': + ini_ignore = 1; + break; + case 'c': + if (ini_override) { + free(ini_override); + } + ini_override = strdup(php_optarg); + break; + case 'd': { + int len = strlen(php_optarg); + char *val; + + if ((val = strchr(php_optarg, '='))) { + val++; + if (!isalnum(*val) && *val != '"' && *val != '\'' && *val != '\0') { + ini_entries = realloc(ini_entries, ini_entries_len + len + sizeof("\"\"\n\0")); + memcpy(ini_entries + ini_entries_len, php_optarg, (val - php_optarg)); + ini_entries_len += (val - php_optarg); + memcpy(ini_entries + ini_entries_len, "\"", 1); + ini_entries_len++; + memcpy(ini_entries + ini_entries_len, val, len - (val - php_optarg)); + ini_entries_len += len - (val - php_optarg); + memcpy(ini_entries + ini_entries_len, "\"\n\0", sizeof("\"\n\0")); + ini_entries_len += sizeof("\n\0\"") - 2; + } else { + ini_entries = realloc(ini_entries, ini_entries_len + len + sizeof("\n\0")); + memcpy(ini_entries + ini_entries_len, php_optarg, len); + memcpy(ini_entries + ini_entries_len + len, "\n\0", sizeof("\n\0")); + ini_entries_len += len + sizeof("\n\0") - 2; + } + } else { + ini_entries = realloc(ini_entries, ini_entries_len + len + sizeof("=1\n\0")); + memcpy(ini_entries + ini_entries_len, php_optarg, len); + memcpy(ini_entries + ini_entries_len + len, "=1\n\0", sizeof("=1\n\0")); + ini_entries_len += len + sizeof("=1\n\0") - 2; + } + } break; + + case 'z': + zend_extensions_len++; + if (zend_extensions) { + zend_extensions = realloc(zend_extensions, sizeof(char*) * zend_extensions_len); + } else zend_extensions = malloc(sizeof(char*) * zend_extensions_len); + zend_extensions[zend_extensions_len-1] = strdup(php_optarg); + break; + + /* begin phpdbg options */ + + case 'e': { /* set execution context */ + exec_len = strlen(php_optarg); + if (exec_len) { + if (exec) { + free(exec); + } + exec = strdup(php_optarg); + } + } break; + + case 'S': { /* set SAPI name */ + if (sapi_name) { + free(sapi_name); + } + sapi_name = strdup(php_optarg); + } break; + + case 'I': { /* ignore .phpdbginit */ + init_file_default = 0; + } break; + + case 'i': { /* set init file */ + if (init_file) { + free(init_file); + } + + init_file_len = strlen(php_optarg); + if (init_file_len) { + init_file = strdup(php_optarg); + } + } break; + + case 'O': { /* set oplog output */ + oplog_file_len = strlen(php_optarg); + if (oplog_file_len) { + oplog_file = strdup(php_optarg); + } + } break; + + case 'v': /* set quietness off */ + flags &= ~PHPDBG_IS_QUIET; + break; + + case 's': /* set stepping on */ + step = 1; + break; + + case 'E': /* stepping through eval on */ + flags |= PHPDBG_IS_STEPONEVAL; + break; + + case 'b': /* set colours off */ + flags &= ~PHPDBG_IS_COLOURED; + break; + + case 'q': /* hide banner */ + show_banner = 0; + break; + +#ifndef _WIN32 + /* if you pass a listen port, we will accept input on listen port */ + /* and write output to listen port * 2 */ + + case 'l': { /* set listen ports */ + if (sscanf(php_optarg, "%d/%d", &listen[0], &listen[1]) != 2) { + if (sscanf(php_optarg, "%d", &listen[0]) != 1) { + /* default to hardcoded ports */ + listen[0] = 4000; + listen[1] = 8000; + } else { + listen[1] = (listen[0] * 2); + } + } + } break; + + case 'a': { /* set bind address */ + free(address); + if (!php_optarg) { + address = strdup("*"); + } else address = strdup(php_optarg); + } break; +#endif + + case 'V': { + sapi_startup(phpdbg); + phpdbg->startup(phpdbg); + printf( + "phpdbg %s (built: %s %s)\nCopyright (c) 2013 %s\nPHP %s, Copyright (c) 1997-2013 The PHP Group\n%s", + PHPDBG_VERSION, + __DATE__, + __TIME__, + PHPDBG_AUTHORS, + PHP_VERSION, + get_zend_version() + ); + sapi_deactivate(TSRMLS_C); + sapi_shutdown(); + return 0; + } break; + } + } + +#ifndef _WIN32 + /* setup remote server if necessary */ + if (!cleaning && + (listen[0] > 0 && listen[1] > 0)) { + if (phpdbg_open_sockets(address, listen, &server, &socket, streams) == FAILURE) { + remote = 0; + exit(0); + } + /* set remote flag to stop service shutting down upon quit */ + remote = 1; + } +#endif + + if (sapi_name) { + phpdbg->name = sapi_name; + } + + phpdbg->ini_defaults = phpdbg_ini_defaults; + phpdbg->phpinfo_as_text = 1; + phpdbg->php_ini_ignore_cwd = 1; + + sapi_startup(phpdbg); + + phpdbg->executable_location = argv[0]; + phpdbg->phpinfo_as_text = 1; + phpdbg->php_ini_ignore = ini_ignore; + phpdbg->php_ini_path_override = ini_override; + + if (ini_entries) { + ini_entries = realloc(ini_entries, ini_entries_len + sizeof(phpdbg_ini_hardcoded)); + memmove(ini_entries + sizeof(phpdbg_ini_hardcoded) - 2, ini_entries, ini_entries_len + 1); + memcpy(ini_entries, phpdbg_ini_hardcoded, sizeof(phpdbg_ini_hardcoded) - 2); + } else { + ini_entries = malloc(sizeof(phpdbg_ini_hardcoded)); + memcpy(ini_entries, phpdbg_ini_hardcoded, sizeof(phpdbg_ini_hardcoded)); + } + ini_entries_len += sizeof(phpdbg_ini_hardcoded) - 2; + + if (zend_extensions_len) { + zend_ulong zend_extension = 0L; + + while (zend_extension < zend_extensions_len) { + const char *ze = zend_extensions[zend_extension]; + size_t ze_len = strlen(ze); + + ini_entries = realloc( + ini_entries, ini_entries_len + (ze_len + (sizeof("zend_extension=\n")))); + memcpy(&ini_entries[ini_entries_len], "zend_extension=", (sizeof("zend_extension=\n")-1)); + ini_entries_len += (sizeof("zend_extension=")-1); + memcpy(&ini_entries[ini_entries_len], ze, ze_len); + ini_entries_len += ze_len; + memcpy(&ini_entries[ini_entries_len], "\n", (sizeof("\n") - 1)); + + free(zend_extensions[zend_extension]); + zend_extension++; + } + + free(zend_extensions); + } + + phpdbg->ini_entries = ini_entries; + + if (phpdbg->startup(phpdbg) == SUCCESS) { + + zend_activate(TSRMLS_C); + + /* do not install sigint handlers for remote consoles */ + /* sending SIGINT then provides a decent way of shutting down the server */ +#ifdef ZEND_SIGNALS +# ifndef _WIN32 + if (listen[0] < 0) { +# endif + zend_try { + zend_signal_activate(TSRMLS_C); + zend_signal(SIGINT, phpdbg_sigint_handler TSRMLS_CC); + } zend_end_try(); +# ifndef _WIN32 + } +# endif +#else +# ifndef _WIN32 + if (listen[0] < 0) { +# endif + signal(SIGINT, phpdbg_sigint_handler); +#ifndef _WIN32 + } +#endif +#endif + + PG(modules_activated) = 0; + + /* set flags from command line */ + PHPDBG_G(flags) = flags; + +#ifndef _WIN32 + /* setup io here */ + if (streams[0] && streams[1]) { + PHPDBG_G(flags) |= PHPDBG_IS_REMOTE; + + signal(SIGPIPE, SIG_IGN); + } +#endif + + PHPDBG_G(io)[PHPDBG_STDIN] = stdin; + PHPDBG_G(io)[PHPDBG_STDOUT] = stdout; + PHPDBG_G(io)[PHPDBG_STDERR] = stderr; + + if (exec) { /* set execution context */ + PHPDBG_G(exec) = phpdbg_resolve_path( + exec TSRMLS_CC); + PHPDBG_G(exec_len) = strlen(PHPDBG_G(exec)); + + free(exec); + } + + if (oplog_file) { /* open oplog */ + PHPDBG_G(oplog) = fopen(oplog_file, "w+"); + if (!PHPDBG_G(oplog)) { + phpdbg_error( + "Failed to open oplog %s", oplog_file); + } + free(oplog_file); + } + + /* set default colors */ + phpdbg_set_color_ex(PHPDBG_COLOR_PROMPT, PHPDBG_STRL("white-bold") TSRMLS_CC); + phpdbg_set_color_ex(PHPDBG_COLOR_ERROR, PHPDBG_STRL("red-bold") TSRMLS_CC); + phpdbg_set_color_ex(PHPDBG_COLOR_NOTICE, PHPDBG_STRL("green") TSRMLS_CC); + + /* 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 */ + zend_try { + PHPDBG_G(flags) |= PHPDBG_IS_INITIALIZING; + phpdbg_init(init_file, init_file_len, init_file_default TSRMLS_CC); + phpdbg_try_file_init(bp_tmp_file, strlen(bp_tmp_file), 0 TSRMLS_CC); + PHPDBG_G(flags) &= ~PHPDBG_IS_INITIALIZING; + } zend_catch { + PHPDBG_G(flags) &= ~PHPDBG_IS_INITIALIZING; + if (PHPDBG_G(flags) & PHPDBG_IS_QUITTING) { + goto phpdbg_out; + } + } zend_end_try(); + + /* step from here, not through init */ + if (step) { + PHPDBG_G(flags) |= PHPDBG_IS_STEPPING; + } + + if (run) { + /* no need to try{}, run does it ... */ + PHPDBG_COMMAND_HANDLER(run)(NULL, NULL TSRMLS_CC); + if (run > 1) { + /* if -r is on the command line more than once just quit */ + goto phpdbg_out; + } + } + +phpdbg_interact: + /* phpdbg main() */ + do { + zend_try { + phpdbg_interactive(TSRMLS_C); + } zend_catch { + if ((PHPDBG_G(flags) & PHPDBG_IS_CLEANING)) { + FILE *bp_tmp_fp = fopen(bp_tmp_file, "w"); + phpdbg_export_breakpoints(bp_tmp_fp TSRMLS_CC); + fclose(bp_tmp_fp); + cleaning = 1; + goto phpdbg_out; + } else { + cleaning = 0; + } +#ifndef _WIN32 + /* remote client disconnected */ + if ((PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED)) { + + /* renegociate connections */ + phpdbg_open_sockets( + address, listen, &server, &socket, streams); + + /* set streams */ + if (streams[0] && streams[1]) { + PHPDBG_G(flags) &= ~PHPDBG_IS_QUITTING; + } + + /* this must be forced */ + CG(unclean_shutdown) = 0; + } +#endif + if (PHPDBG_G(flags) & PHPDBG_IS_QUITTING) { + goto phpdbg_out; + } + } zend_end_try(); + } while(!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)); + + /* this must be forced */ + CG(unclean_shutdown) = 0; + +phpdbg_out: +#ifndef _WIN32 + if (PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED) { + PHPDBG_G(flags) &= ~PHPDBG_IS_DISCONNECTED; + goto phpdbg_interact; + } +#endif + +#ifndef ZTS + /* force cleanup of auto and core globals */ + zend_hash_clean(CG(auto_globals)); + memset( + &core_globals, 0, sizeof(php_core_globals)); +#endif + + if (ini_entries) { + free(ini_entries); + } + + if (ini_override) { + free(ini_override); + } + + 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 + + zend_try { + php_module_shutdown(TSRMLS_C); + } zend_end_try(); + + sapi_shutdown(); + } + + if (cleaning || remote) { + goto phpdbg_main; + } + +#ifdef ZTS + /* bugggy */ + /* tsrm_shutdown(); */ +#endif + +#ifndef _WIN32 + if (address) { + free(address); + } +#endif + + if (sapi_name) { + free(sapi_name); + } + + free(bp_tmp_file); + + return 0; +} /* }}} */ diff --git a/phpdbg.h b/phpdbg.h new file mode 100644 index 00000000000..f0a59ce4731 --- /dev/null +++ b/phpdbg.h @@ -0,0 +1,187 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHPDBG_H +#define PHPDBG_H + +#ifdef PHP_WIN32 +# define PHPDBG_API __declspec(dllexport) +#elif defined(__GNUC__) && __GNUC__ >= 4 +# define PHPDBG_API __attribute__ ((visibility("default"))) +#else +# define PHPDBG_API +#endif + +#include "php.h" +#include "php_globals.h" +#include "php_variables.h" +#include "php_getopt.h" +#include "zend_builtin_functions.h" +#include "zend_extensions.h" +#include "zend_modules.h" +#include "zend_globals.h" +#include "zend_ini_scanner.h" +#include "zend_stream.h" +#include "SAPI.h" +#include +#include +#if defined(_WIN32) && !defined(__MINGW32__) +# include +# include "config.w32.h" +# undef strcasecmp +# undef strncasecmp +# define strcasecmp _stricmp +# define strncasecmp _strnicmp +#else +# include "php_config.h" +#endif +#ifndef O_BINARY +# define O_BINARY 0 +#endif +#include "php_main.h" + +#ifdef ZTS +# include "TSRM.h" +#endif + +#ifdef HAVE_LIBREADLINE +# include +# include +#endif + +#include "phpdbg_cmd.h" +#include "phpdbg_utils.h" + +#ifdef ZTS +# define PHPDBG_G(v) TSRMG(phpdbg_globals_id, zend_phpdbg_globals *, v) +#else +# define PHPDBG_G(v) (phpdbg_globals.v) +#endif + +#define PHPDBG_NEXT 2 +#define PHPDBG_UNTIL 3 +#define PHPDBG_FINISH 4 +#define PHPDBG_LEAVE 5 + +/* + BEGIN: DO NOT CHANGE DO NOT CHANGE DO NOT CHANGE +*/ + +/* {{{ tables */ +#define PHPDBG_BREAK_FILE 0 +#define PHPDBG_BREAK_SYM 1 +#define PHPDBG_BREAK_OPLINE 2 +#define PHPDBG_BREAK_METHOD 3 +#define PHPDBG_BREAK_COND 4 +#define PHPDBG_BREAK_OPCODE 5 +#define PHPDBG_BREAK_FUNCTION_OPLINE 6 +#define PHPDBG_BREAK_METHOD_OPLINE 7 +#define PHPDBG_BREAK_FILE_OPLINE 8 +#define PHPDBG_BREAK_MAP 9 +#define PHPDBG_BREAK_TABLES 10 /* }}} */ + +/* {{{ flags */ +#define PHPDBG_HAS_FILE_BP (1<<1) +#define PHPDBG_HAS_SYM_BP (1<<2) +#define PHPDBG_HAS_OPLINE_BP (1<<3) +#define PHPDBG_HAS_METHOD_BP (1<<4) +#define PHPDBG_HAS_COND_BP (1<<5) +#define PHPDBG_HAS_OPCODE_BP (1<<6) +#define PHPDBG_HAS_FUNCTION_OPLINE_BP (1<<7) +#define PHPDBG_HAS_METHOD_OPLINE_BP (1<<8) +#define PHPDBG_HAS_FILE_OPLINE_BP (1<<9) /* }}} */ + +/* + END: DO NOT CHANGE DO NOT CHANGE DO NOT CHANGE +*/ + +#define PHPDBG_IN_COND_BP (1<<10) +#define PHPDBG_IN_EVAL (1<<11) + +#define PHPDBG_IS_STEPPING (1<<12) +#define PHPDBG_IS_QUIET (1<<13) +#define PHPDBG_IS_QUITTING (1<<14) +#define PHPDBG_IS_COLOURED (1<<15) +#define PHPDBG_IS_CLEANING (1<<16) + +#define PHPDBG_IN_UNTIL (1<<17) +#define PHPDBG_IN_FINISH (1<<18) +#define PHPDBG_IN_LEAVE (1<<19) + +#define PHPDBG_IS_REGISTERED (1<<20) +#define PHPDBG_IS_STEPONEVAL (1<<21) +#define PHPDBG_IS_INITIALIZING (1<<22) +#define PHPDBG_IS_SIGNALED (1<<23) +#define PHPDBG_IS_INTERACTIVE (1<<24) +#define PHPDBG_IS_BP_ENABLED (1<<25) +#define PHPDBG_IS_REMOTE (1<<26) +#define PHPDBG_IS_DISCONNECTED (1<<27) + +#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) + +#ifndef _WIN32 +# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_COLOURED|PHPDBG_IS_BP_ENABLED) +#else +# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_BP_ENABLED) +#endif /* }}} */ + +/* {{{ strings */ +#define PHPDBG_NAME "phpdbg" +#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.0" +#define PHPDBG_INIT_FILENAME ".phpdbginit" +/* }}} */ + +/* {{{ output descriptors */ +#define PHPDBG_STDIN 0 +#define PHPDBG_STDOUT 1 +#define PHPDBG_STDERR 2 +#define PHPDBG_IO_FDS 3 /* }}} */ + +/* {{{ structs */ +ZEND_BEGIN_MODULE_GLOBALS(phpdbg) + HashTable bp[PHPDBG_BREAK_TABLES]; /* break points */ + HashTable registered; /* registered */ + HashTable seek; /* seek oplines */ + phpdbg_frame_t frame; /* frame */ + + char *exec; /* file to execute */ + size_t exec_len; /* size of exec */ + zend_op_array *ops; /* op_array */ + zval *retval; /* return value */ + int bp_count; /* breakpoint count */ + int vmret; /* return from last opcode handler execution */ + + FILE *oplog; /* opline log */ + FILE *io[PHPDBG_IO_FDS]; /* io */ + + char *prompt[2]; /* prompt */ + const phpdbg_color_t *colors[PHPDBG_COLORS]; /* colors */ + + phpdbg_command_t *lcmd; /* last command */ + phpdbg_param_t lparam; /* last param */ + + zend_ulong flags; /* phpdbg flags */ +ZEND_END_MODULE_GLOBALS(phpdbg) /* }}} */ + +#endif /* PHPDBG_H */ diff --git a/phpdbg.init.d b/phpdbg.init.d new file mode 100755 index 00000000000..99a1ab328b8 --- /dev/null +++ b/phpdbg.init.d @@ -0,0 +1,122 @@ +################################################################ +# File: /etc/init.d/phpdbg # +# Author: krakjoe # +# Purpose: Daemonize phpdbg automatically on boot # +# chkconfig: 2345 07 09 # +# description: Starts, stops and restarts phpdbg daemon # +################################################################ +LOCKFILE=/var/lock/subsys/phpdbg +PIDFILE=/var/run/phpdbg.pid +STDIN=4000 +STDOUT=8000 +################################################################ +# Either set path to phpdbg here or rely on phpdbg in ENV/PATH # +################################################################ +if [ "x${PHPDBG}" == "x" ]; then + PHPDBG=$(which phpdbg 2>/dev/null) +fi +################################################################ +# Options to pass to phpdbg upon boot # +################################################################ +OPTIONS= +LOGFILE=/var/log/phpdbg.log +################################################################ +# STOP EDITING STOP EDITING STOP EDITING STOP EDITING # +################################################################ +. /etc/rc.d/init.d/functions +RETVAL=1 +################################################################ +insanity() +{ + if [ "x${PHPDBG}" == "x" ]; then + PHPDBG=$(which phpdbg 2>>/dev/null) + if [ $? != 0 ]; then + echo -n $"Fatal: cannot find phpdbg ${PHPDBG}" + echo_failure + echo + return 1 + fi + else + if [ ! -x ${PHPDBG} ]; then + echo -n $"Fatal: cannot execute phpdbg ${PHPDBG}" + echo_failure + echo + return 1 + fi + fi + + return 0 +} + +start() +{ + insanity + + if [ $? -eq 1 ]; then + return $RETVAL + fi + + echo -n $"Starting: phpdbg ${OPTIONS} on ${STDIN}/${STDOUT} " + nohup ${PHPDBG} -l${STDIN}/${STDOUT} ${OPTIONS} 2>>${LOGFILE} 1>/dev/null $PIDFILE + echo_success + else + echo_failure + fi + echo + [ $RETVAL = 0 ] && touch ${LOCKFILE} + return $RETVAL +} + +stop() +{ + insanity + + if [ $? -eq 1 ]; then + return $RETVAL + fi + + if [ -f ${LOCKFILE} ] && [ -f ${PIDFILE} ] + then + echo -n $"Stopping: phpdbg ${OPTIONS} on ${STDIN}/${STDOUT} " + kill -s TERM $(cat $PIDFILE) + RETVAL=$? + if [ $RETVAL -eq 0 ]; then + echo_success + else + echo_failure + fi + echo + [ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PIDFILE} + else + echo -n $"Error: phpdbg not running" + echo_failure + echo + [ $RETVAL = 1 ] + fi + return $RETVAL +} +################################################################## +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + status $PHPDBG + ;; + restart) + $0 stop + $0 start + ;; + *) + echo "usage: $0 start|stop|restart|status" + ;; +esac +################################################################### +exit $RETVAL diff --git a/phpdbg_bp.c b/phpdbg_bp.c new file mode 100644 index 00000000000..69e0fa7086d --- /dev/null +++ b/phpdbg_bp.c @@ -0,0 +1,1661 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#include "zend.h" +#include "zend_hash.h" +#include "phpdbg.h" +#include "phpdbg_bp.h" +#include "phpdbg_utils.h" +#include "phpdbg_opcode.h" +#include "zend_globals.h" + +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); + +/* {{{ private api functions */ +static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_file(zend_op_array* TSRMLS_DC); +static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_symbol(zend_function* TSRMLS_DC); +static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_method(zend_op_array* TSRMLS_DC); +static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_opline(phpdbg_opline_ptr_t TSRMLS_DC); +static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_opcode(zend_uchar TSRMLS_DC); +static inline phpdbg_breakbase_t *phpdbg_find_conditional_breakpoint(zend_execute_data *execute_data TSRMLS_DC); /* }}} */ + +/* +* Note: +* A break point must always set the correct id and type +* A set breakpoint function must always map new points +*/ +static inline void _phpdbg_break_mapping(int id, HashTable *table TSRMLS_DC) +{ + zend_hash_index_update( + &PHPDBG_G(bp)[PHPDBG_BREAK_MAP], (id), (void**) &table, sizeof(void*), NULL); +} + +#define PHPDBG_BREAK_MAPPING(id, table) _phpdbg_break_mapping(id, table TSRMLS_CC) +#define PHPDBG_BREAK_UNMAPPING(id) \ + zend_hash_index_del(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], (id)) + +#define PHPDBG_BREAK_INIT(b, t) do {\ + b.id = PHPDBG_G(bp_count)++; \ + b.type = t; \ + b.disabled = 0;\ + b.hits = 0; \ +} while(0) + +static void phpdbg_file_breaks_dtor(void *data) /* {{{ */ +{ + phpdbg_breakfile_t *bp = (phpdbg_breakfile_t*) data; + + efree((char*)bp->filename); +} /* }}} */ + +static void phpdbg_class_breaks_dtor(void *data) /* {{{ */ +{ + phpdbg_breakmethod_t *bp = (phpdbg_breakmethod_t*) data; + + efree((char*)bp->class_name); + efree((char*)bp->func_name); +} /* }}} */ + +static void phpdbg_opline_class_breaks_dtor(void *data) /* {{{ */ +{ + zend_hash_destroy((HashTable *)data); +} /* }}} */ + +static void phpdbg_opline_breaks_dtor(void *data) /* {{{ */ +{ + phpdbg_breakopline_t *bp = (phpdbg_breakopline_t *) data; + + if (bp->class_name) { + efree((char*)bp->class_name); + } + if (bp->func_name) { + efree((char*)bp->func_name); + } +} /* }}} */ + +PHPDBG_API void phpdbg_reset_breakpoints(TSRMLS_D) /* {{{ */ +{ + if (zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP])) { + HashPosition position[2]; + HashTable **table = NULL; + + for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], &position[0]); + zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], (void**)&table, &position[0]) == SUCCESS; + zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], &position[0])) { + phpdbg_breakbase_t *brake; + + for (zend_hash_internal_pointer_reset_ex((*table), &position[1]); + zend_hash_get_current_data_ex((*table), (void**)&brake, &position[1]) == SUCCESS; + zend_hash_move_forward_ex((*table), &position[1])) { + brake->hits = 0; + } + } + } +} /* }}} */ + +PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */ +{ + HashPosition position[2]; + HashTable **table = NULL; + zend_ulong id = 0L; + + if (zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP])) { + phpdbg_notice( + "Exporting %d breakpoints", + zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP])); + /* this only looks like magic, it isn't */ + for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], &position[0]); + zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], (void**)&table, &position[0]) == SUCCESS; + zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], &position[0])) { + phpdbg_breakbase_t *brake; + + zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], NULL, NULL, &id, 0, &position[0]); + + for (zend_hash_internal_pointer_reset_ex((*table), &position[1]); + zend_hash_get_current_data_ex((*table), (void**)&brake, &position[1]) == SUCCESS; + zend_hash_move_forward_ex((*table), &position[1])) { + if (brake->id == id) { + switch (brake->type) { + case PHPDBG_BREAK_FILE: { + fprintf(handle, + "break file %s:%lu\n", + ((phpdbg_breakfile_t*)brake)->filename, + ((phpdbg_breakfile_t*)brake)->line); + } break; + + case PHPDBG_BREAK_SYM: { + fprintf(handle, + "break func %s\n", + ((phpdbg_breaksymbol_t*)brake)->symbol); + } break; + + case PHPDBG_BREAK_METHOD: { + fprintf(handle, + "break method %s::%s\n", + ((phpdbg_breakmethod_t*)brake)->class_name, + ((phpdbg_breakmethod_t*)brake)->func_name); + } break; + + case PHPDBG_BREAK_METHOD_OPLINE: { + fprintf(handle, + "break address %s::%s#%ld\n", + ((phpdbg_breakopline_t*)brake)->class_name, + ((phpdbg_breakopline_t*)brake)->func_name, + ((phpdbg_breakopline_t*)brake)->opline_num); + } break; + + case PHPDBG_BREAK_FUNCTION_OPLINE: { + fprintf(handle, + "break address %s#%ld\n", + ((phpdbg_breakopline_t*)brake)->func_name, + ((phpdbg_breakopline_t*)brake)->opline_num); + } break; + + case PHPDBG_BREAK_FILE_OPLINE: { + fprintf(handle, + "break address %s:%ld\n", + ((phpdbg_breakopline_t*)brake)->class_name, + ((phpdbg_breakopline_t*)brake)->opline_num); + } break; + + case PHPDBG_BREAK_OPCODE: { + fprintf(handle, + "break op %s\n", + ((phpdbg_breakop_t*)brake)->name); + } break; + + case PHPDBG_BREAK_COND: { + phpdbg_breakcond_t *conditional = (phpdbg_breakcond_t*) brake; + + if (conditional->paramed) { + switch (conditional->param.type) { + case STR_PARAM: + fprintf(handle, + "break at %s if %s\n", conditional->param.str, conditional->code); + break; + + case METHOD_PARAM: + fprintf(handle, + "break at %s::%s if %s\n", + conditional->param.method.class, conditional->param.method.name, + conditional->code); + break; + + case FILE_PARAM: + fprintf(handle, + "break at %s:%lu if %s\n", + conditional->param.file.name, conditional->param.file.line, + conditional->code); + break; + + default: { /* do nothing */ } break; + } + } else { + fprintf( + handle, "break on %s\n", conditional->code); + } + } break; + } + } + } + } + } +} /* }}} */ + +PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRMLS_DC) /* {{{ */ +{ + struct stat sb; + + if (VCWD_STAT(path, &sb) != FAILURE) { + if (sb.st_mode & (S_IFREG|S_IFLNK)) { + HashTable *broken; + phpdbg_breakfile_t new_break; + size_t path_len = strlen(path); + + if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], + path, path_len, (void**)&broken) == FAILURE) { + HashTable breaks; + + zend_hash_init(&breaks, 8, NULL, phpdbg_file_breaks_dtor, 0); + + zend_hash_update(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], + path, path_len, &breaks, sizeof(HashTable), + (void**)&broken); + } + + if (!zend_hash_index_exists(broken, line_num)) { + PHPDBG_G(flags) |= PHPDBG_HAS_FILE_BP; + + PHPDBG_BREAK_INIT(new_break, PHPDBG_BREAK_FILE); + new_break.filename = estrndup(path, path_len); + new_break.line = line_num; + + zend_hash_index_update( + broken, line_num, (void**)&new_break, sizeof(phpdbg_breakfile_t), NULL); + + phpdbg_notice("Breakpoint #%d added at %s:%ld", + new_break.id, new_break.filename, new_break.line); + + PHPDBG_BREAK_MAPPING(new_break.id, broken); + } else { + phpdbg_error("Breakpoint at %s:%ld exists", path, line_num); + } + + } else { + phpdbg_error("Cannot set breakpoint in %s, it is not a regular file", path); + } + } else { + phpdbg_error("Cannot stat %s, it does not exist", path); + } +} /* }}} */ + +PHPDBG_API void phpdbg_set_breakpoint_symbol(const char *name, size_t name_len TSRMLS_DC) /* {{{ */ +{ + if (!zend_hash_exists(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], name, name_len)) { + phpdbg_breaksymbol_t new_break; + + PHPDBG_G(flags) |= PHPDBG_HAS_SYM_BP; + + PHPDBG_BREAK_INIT(new_break, PHPDBG_BREAK_SYM); + new_break.symbol = estrndup(name, name_len); + + zend_hash_update(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], new_break.symbol, + name_len, &new_break, sizeof(phpdbg_breaksymbol_t), NULL); + + phpdbg_notice("Breakpoint #%d added at %s", + new_break.id, new_break.symbol); + + PHPDBG_BREAK_MAPPING(new_break.id, &PHPDBG_G(bp)[PHPDBG_BREAK_SYM]); + } else { + phpdbg_notice("Breakpoint exists at %s", name); + } +} /* }}} */ + +PHPDBG_API void phpdbg_set_breakpoint_method(const char *class_name, const char *func_name TSRMLS_DC) /* {{{ */ +{ + HashTable class_breaks, *class_table; + size_t class_len = strlen(class_name); + size_t func_len = strlen(func_name); + char *lcname = zend_str_tolower_dup(func_name, func_len); + + if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], class_name, + class_len, (void**)&class_table) != SUCCESS) { + zend_hash_init(&class_breaks, 8, NULL, phpdbg_class_breaks_dtor, 0); + zend_hash_update( + &PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], + class_name, class_len, + (void**)&class_breaks, sizeof(HashTable), (void**)&class_table); + } + + if (!zend_hash_exists(class_table, lcname, func_len)) { + phpdbg_breakmethod_t new_break; + + PHPDBG_G(flags) |= PHPDBG_HAS_METHOD_BP; + + PHPDBG_BREAK_INIT(new_break, PHPDBG_BREAK_METHOD); + new_break.class_name = estrndup(class_name, class_len); + new_break.class_len = class_len; + new_break.func_name = estrndup(func_name, func_len); + new_break.func_len = func_len; + + zend_hash_update(class_table, lcname, func_len, + &new_break, sizeof(phpdbg_breakmethod_t), NULL); + + phpdbg_notice("Breakpoint #%d added at %s::%s", + new_break.id, class_name, func_name); + + PHPDBG_BREAK_MAPPING(new_break.id, class_table); + } else { + phpdbg_notice("Breakpoint exists at %s::%s", class_name, func_name); + } + + efree(lcname); +} /* }}} */ + +PHPDBG_API void phpdbg_set_breakpoint_opline(zend_ulong opline TSRMLS_DC) /* {{{ */ +{ + if (!zend_hash_index_exists(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], opline)) { + phpdbg_breakline_t new_break; + + PHPDBG_G(flags) |= PHPDBG_HAS_OPLINE_BP; + + PHPDBG_BREAK_INIT(new_break, PHPDBG_BREAK_OPLINE); + new_break.name = NULL; + new_break.opline = opline; + new_break.base = NULL; + + zend_hash_index_update(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], opline, + &new_break, sizeof(phpdbg_breakline_t), NULL); + + phpdbg_notice("Breakpoint #%d added at %#lx", + new_break.id, new_break.opline); + PHPDBG_BREAK_MAPPING(new_break.id, &PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]); + } else { + phpdbg_notice("Breakpoint exists at %#lx", opline); + } +} /* }}} */ + +PHPDBG_API int phpdbg_resolve_op_array_break(phpdbg_breakopline_t *brake, zend_op_array *op_array TSRMLS_DC) /* {{{ */ +{ + phpdbg_breakline_t opline_break; + if (op_array->last < brake->opline_num) { + if (brake->class_name == NULL) { + phpdbg_error("There are only %d oplines in function %s (breaking at opline %ld impossible)", op_array->last, brake->func_name, brake->opline_num); + } else if (brake->func_name == NULL) { + phpdbg_error("There are only %d oplines in file %s (breaking at opline %ld impossible)", op_array->last, brake->class_name, brake->opline_num); + } else { + phpdbg_error("There are only %d oplines in method %s::%s (breaking at opline %ld impossible)", op_array->last, brake->class_name, brake->func_name, brake->opline_num); + } + + return FAILURE; + } + + opline_break.disabled = 0; + opline_break.hits = 0; + opline_break.id = brake->id; + opline_break.opline = brake->opline = (zend_ulong)(op_array->opcodes + brake->opline_num); + opline_break.name = NULL; + opline_break.base = brake; + if (op_array->scope) { + opline_break.type = PHPDBG_BREAK_METHOD_OPLINE; + } else if (op_array->function_name) { + opline_break.type = PHPDBG_BREAK_FUNCTION_OPLINE; + } else { + opline_break.type = PHPDBG_BREAK_FILE_OPLINE; + } + + PHPDBG_G(flags) |= PHPDBG_HAS_OPLINE_BP; + + zend_hash_index_update(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], opline_break.opline, &opline_break, sizeof(phpdbg_breakline_t), NULL); + + return SUCCESS; +} /* }}} */ + +PHPDBG_API void phpdbg_resolve_op_array_breaks(zend_op_array *op_array TSRMLS_DC) /* {{{ */ +{ + HashTable *func_table = &PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE]; + HashTable *oplines_table; + HashPosition position; + phpdbg_breakopline_t *brake; + + if (op_array->scope != NULL && + zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], op_array->scope->name, op_array->scope->name_length, (void **)&func_table) == FAILURE) { + return; + } + + if (op_array->function_name == NULL) { + if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE], op_array->filename, strlen(op_array->filename), (void **)&oplines_table) == FAILURE) { + return; + } + } else if (zend_hash_find(func_table, op_array->function_name?op_array->function_name:"", op_array->function_name?strlen(op_array->function_name):0, (void **)&oplines_table) == FAILURE) { + return; + } + + for (zend_hash_internal_pointer_reset_ex(oplines_table, &position); + zend_hash_get_current_data_ex(oplines_table, (void**) &brake, &position) == SUCCESS; + zend_hash_move_forward_ex(oplines_table, &position)) { + if (phpdbg_resolve_op_array_break(brake, op_array TSRMLS_CC) == SUCCESS) { + phpdbg_breakline_t *opline_break; + + zend_hash_internal_pointer_end(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]); + zend_hash_get_current_data(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], (void **)&opline_break); + + phpdbg_notice("Breakpoint #%d resolved at %s%s%s#%ld (opline %#lx)", + brake->id, + brake->class_name?brake->class_name:"", + brake->class_name&&brake->func_name?"::":"", + brake->func_name?brake->func_name:"", + brake->opline_num, + brake->opline); + } + } +} /* }}} */ + +PHPDBG_API int phpdbg_resolve_opline_break(phpdbg_breakopline_t *new_break TSRMLS_DC) /* {{{ */ +{ + HashTable *func_table = EG(function_table); + zend_function *func; + + if (new_break->func_name == NULL) { + if (EG(current_execute_data) == NULL) { + if (PHPDBG_G(ops) != NULL && !memcmp(PHPDBG_G(ops)->filename, new_break->class_name, new_break->class_len)) { + if (phpdbg_resolve_op_array_break(new_break, PHPDBG_G(ops) TSRMLS_CC) == SUCCESS) { + return SUCCESS; + } else { + return 2; + } + } + return FAILURE; + } else { + zend_execute_data *execute_data = EG(current_execute_data); + do { + if (execute_data->op_array->function_name == NULL && execute_data->op_array->scope == NULL && !memcmp(execute_data->op_array->filename, new_break->class_name, new_break->class_len)) { + if (phpdbg_resolve_op_array_break(new_break, execute_data->op_array TSRMLS_CC) == SUCCESS) { + return SUCCESS; + } else { + return 2; + } + } + } while ((execute_data = execute_data->prev_execute_data) != NULL); + return FAILURE; + } + } + + if (new_break->class_name != NULL) { + zend_class_entry **ce; + if (zend_hash_find(EG(class_table), zend_str_tolower_dup(new_break->class_name, new_break->class_len), new_break->class_len + 1, (void **)&ce) == FAILURE) { + return FAILURE; + } + func_table = &(*ce)->function_table; + } + + if (zend_hash_find(func_table, zend_str_tolower_dup(new_break->func_name, new_break->func_len), new_break->func_len + 1, (void **)&func) == FAILURE) { + if (new_break->class_name != NULL && new_break->func_name != NULL) { + phpdbg_error("Method %s doesn't exist in class %s", new_break->func_name, new_break->class_name); + return 2; + } + return FAILURE; + } + + if (func->type != ZEND_USER_FUNCTION) { + if (new_break->class_name == NULL) { + phpdbg_error("%s is not an user defined function, no oplines exist", new_break->func_name); + } else { + phpdbg_error("%s::%s is not an user defined method, no oplines exist", new_break->class_name, new_break->func_name); + } + return 2; + } + + if (phpdbg_resolve_op_array_break(new_break, &func->op_array TSRMLS_CC) == FAILURE) { + return 2; + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_API void phpdbg_set_breakpoint_method_opline(const char *class, const char *method, zend_ulong opline TSRMLS_DC) /* {{{ */ +{ + phpdbg_breakopline_t new_break; + HashTable class_breaks, *class_table; + HashTable method_breaks, *method_table; + + PHPDBG_BREAK_INIT(new_break, PHPDBG_BREAK_METHOD_OPLINE); + new_break.func_len = strlen(method); + new_break.func_name = estrndup(method, new_break.func_len); + new_break.class_len = strlen(class); + new_break.class_name = estrndup(class, new_break.class_len); + new_break.opline_num = opline; + new_break.opline = 0; + + switch (phpdbg_resolve_opline_break(&new_break TSRMLS_CC)) { + case FAILURE: + phpdbg_notice("Pending breakpoint #%d at %s::%s#%ld", new_break.id, new_break.class_name, new_break.func_name, opline); + break; + + case SUCCESS: + phpdbg_notice("Breakpoint #%d added at %s::%s#%ld", new_break.id, new_break.class_name, new_break.func_name, opline); + break; + + case 2: + return; + } + + if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], new_break.class_name, new_break.class_len, (void **)&class_table) == FAILURE) { + zend_hash_init(&class_breaks, 8, NULL, phpdbg_opline_class_breaks_dtor, 0); + zend_hash_update( + &PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], + new_break.class_name, + new_break.class_len, + (void **)&class_breaks, sizeof(HashTable), (void **)&class_table); + } + + if (zend_hash_find(class_table, new_break.func_name, new_break.func_len, (void **)&method_table) == FAILURE) { + zend_hash_init(&method_breaks, 8, NULL, phpdbg_opline_breaks_dtor, 0); + zend_hash_update( + class_table, + new_break.func_name, + new_break.func_len, + (void **)&method_breaks, sizeof(HashTable), (void **)&method_table); + } + + if (zend_hash_index_exists(method_table, opline)) { + phpdbg_notice("Breakpoint already exists for %s::%s#%ld", new_break.class_name, new_break.func_name, opline); + efree((char*)new_break.func_name); + efree((char*)new_break.class_name); + PHPDBG_G(bp_count)--; + return; + } + + PHPDBG_G(flags) |= PHPDBG_HAS_METHOD_OPLINE_BP; + + PHPDBG_BREAK_MAPPING(new_break.id, method_table); + + zend_hash_index_update(method_table, opline, &new_break, sizeof(phpdbg_breakopline_t), NULL); +} + +PHPDBG_API void phpdbg_set_breakpoint_function_opline(const char *function, zend_ulong opline TSRMLS_DC) /* {{{ */ +{ + phpdbg_breakopline_t new_break; + HashTable func_breaks, *func_table; + + PHPDBG_BREAK_INIT(new_break, PHPDBG_BREAK_FUNCTION_OPLINE); + new_break.func_len = strlen(function); + new_break.func_name = estrndup(function, new_break.func_len); + new_break.class_len = 0; + new_break.class_name = NULL; + new_break.opline_num = opline; + new_break.opline = 0; + + switch (phpdbg_resolve_opline_break(&new_break TSRMLS_CC)) { + case FAILURE: + phpdbg_notice("Pending breakpoint #%d at %s#%ld", new_break.id, new_break.func_name, opline); + break; + + case SUCCESS: + phpdbg_notice("Breakpoint #%d added at %s#%ld", new_break.id, new_break.func_name, opline); + break; + + case 2: + return; + } + + if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], new_break.func_name, new_break.func_len, (void **)&func_table) == FAILURE) { + zend_hash_init(&func_breaks, 8, NULL, phpdbg_opline_breaks_dtor, 0); + zend_hash_update( + &PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], + new_break.func_name, + new_break.func_len, + (void **)&func_breaks, sizeof(HashTable), (void **)&func_table); + } + + if (zend_hash_index_exists(func_table, opline)) { + phpdbg_notice("Breakpoint already exists for %s#%ld", new_break.func_name, opline); + efree((char*)new_break.func_name); + PHPDBG_G(bp_count)--; + return; + } + + PHPDBG_BREAK_MAPPING(new_break.id, func_table); + + PHPDBG_G(flags) |= PHPDBG_HAS_FUNCTION_OPLINE_BP; + + zend_hash_index_update(func_table, opline, &new_break, sizeof(phpdbg_breakopline_t), NULL); +} + +PHPDBG_API void phpdbg_set_breakpoint_file_opline(const char *file, zend_ulong opline TSRMLS_DC) /* {{{ */ +{ + phpdbg_breakopline_t new_break; + HashTable file_breaks, *file_table; + + PHPDBG_BREAK_INIT(new_break, PHPDBG_BREAK_FILE_OPLINE); + new_break.func_len = 0; + new_break.func_name = NULL; + new_break.class_len = strlen(file); + new_break.class_name = estrndup(file, new_break.class_len); + new_break.opline_num = opline; + new_break.opline = 0; + + switch (phpdbg_resolve_opline_break(&new_break TSRMLS_CC)) { + case FAILURE: + phpdbg_notice("Pending breakpoint #%d at %s:%ld", new_break.id, new_break.class_name, opline); + break; + + case SUCCESS: + phpdbg_notice("Breakpoint #%d added at %s:%ld", new_break.id, new_break.class_name, opline); + break; + + case 2: + return; + } + + if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE], new_break.class_name, new_break.class_len, (void **)&file_table) == FAILURE) { + zend_hash_init(&file_breaks, 8, NULL, phpdbg_opline_breaks_dtor, 0); + zend_hash_update( + &PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE], + new_break.class_name, + new_break.class_len, + (void **)&file_breaks, sizeof(HashTable), (void **)&file_table); + } + + if (zend_hash_index_exists(file_table, opline)) { + phpdbg_notice("Breakpoint already exists for %s:%ld", new_break.class_name, opline); + efree((char*)new_break.class_name); + PHPDBG_G(bp_count)--; + return; + } + + PHPDBG_BREAK_MAPPING(new_break.id, file_table); + + PHPDBG_G(flags) |= PHPDBG_HAS_FILE_OPLINE_BP; + + zend_hash_index_update(file_table, opline, &new_break, sizeof(phpdbg_breakopline_t), NULL); +} + +PHPDBG_API void phpdbg_set_breakpoint_opcode(const char *name, size_t name_len TSRMLS_DC) /* {{{ */ +{ + phpdbg_breakop_t new_break; + zend_ulong hash = zend_hash_func(name, name_len); + + if (zend_hash_index_exists(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], hash)) { + phpdbg_notice( + "Breakpoint exists for %s", name); + return; + } + + PHPDBG_BREAK_INIT(new_break, PHPDBG_BREAK_OPCODE); + new_break.hash = hash; + new_break.name = estrndup(name, name_len); + + zend_hash_index_update(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], hash, + &new_break, sizeof(phpdbg_breakop_t), NULL); + + PHPDBG_G(flags) |= PHPDBG_HAS_OPCODE_BP; + + phpdbg_notice("Breakpoint #%d added at %s", new_break.id, name); + PHPDBG_BREAK_MAPPING(new_break.id, &PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE]); +} /* }}} */ + +PHPDBG_API void phpdbg_set_breakpoint_opline_ex(phpdbg_opline_ptr_t opline TSRMLS_DC) /* {{{ */ +{ + if (!zend_hash_index_exists(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], (zend_ulong) opline)) { + phpdbg_breakline_t new_break; + + PHPDBG_G(flags) |= PHPDBG_HAS_OPLINE_BP; + + PHPDBG_BREAK_INIT(new_break, PHPDBG_BREAK_OPLINE); + new_break.opline = (zend_ulong) opline; + + zend_hash_index_update(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], + (zend_ulong) opline, &new_break, sizeof(phpdbg_breakline_t), NULL); + + phpdbg_notice("Breakpoint #%d added at %#lx", + new_break.id, new_break.opline); + PHPDBG_BREAK_MAPPING(new_break.id, &PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]); + } +} /* }}} */ + +static inline void phpdbg_create_conditional_break(phpdbg_breakcond_t *brake, const phpdbg_param_t *param, const char *expr, size_t expr_len, zend_ulong hash TSRMLS_DC) /* {{{ */ +{ + phpdbg_breakcond_t new_break; + zend_uint cops = CG(compiler_options); + zval pv; + + PHPDBG_BREAK_INIT(new_break, PHPDBG_BREAK_COND); + new_break.hash = hash; + + if (param) { + new_break.paramed = 1; + phpdbg_copy_param( + param, &new_break.param TSRMLS_CC); + } else { + new_break.paramed = 0; + } + + cops = CG(compiler_options); + + CG(compiler_options) = ZEND_COMPILE_DEFAULT_FOR_EVAL; + + new_break.code = estrndup(expr, expr_len); + new_break.code_len = expr_len; + + Z_STRLEN(pv) = expr_len + sizeof("return ;") - 1; + Z_STRVAL(pv) = emalloc(Z_STRLEN(pv) + 1); + memcpy(Z_STRVAL(pv), "return ", sizeof("return ") - 1); + memcpy(Z_STRVAL(pv) + sizeof("return ") - 1, expr, expr_len); + Z_STRVAL(pv)[Z_STRLEN(pv) - 1] = ';'; + Z_STRVAL(pv)[Z_STRLEN(pv)] = '\0'; + Z_TYPE(pv) = IS_STRING; + + new_break.ops = zend_compile_string( + &pv, "Conditional Breakpoint Code" TSRMLS_CC); + + zval_dtor(&pv); + + if (new_break.ops) { + zend_hash_index_update( + &PHPDBG_G(bp)[PHPDBG_BREAK_COND], hash, &new_break, + sizeof(phpdbg_breakcond_t), (void**)&brake); + + phpdbg_notice("Conditional breakpoint #%d added %s/%p", + brake->id, brake->code, brake->ops); + + PHPDBG_G(flags) |= PHPDBG_HAS_COND_BP; + PHPDBG_BREAK_MAPPING(new_break.id, &PHPDBG_G(bp)[PHPDBG_BREAK_COND]); + } else { + phpdbg_error( + "Failed to compile code for expression %s", expr); + efree((char*)new_break.code); + PHPDBG_G(bp_count)--; + } + CG(compiler_options) = cops; +} /* }}} */ + +PHPDBG_API void phpdbg_set_breakpoint_expression(const char *expr, size_t expr_len TSRMLS_DC) /* {{{ */ +{ + zend_ulong expr_hash = zend_inline_hash_func(expr, expr_len); + phpdbg_breakcond_t new_break; + + if (!zend_hash_index_exists(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], expr_hash)) { + phpdbg_create_conditional_break( + &new_break, NULL, expr, expr_len, expr_hash TSRMLS_CC); + } else { + phpdbg_notice("Conditional break %s exists", expr); + } +} /* }}} */ + +PHPDBG_API void phpdbg_set_breakpoint_at(const phpdbg_param_t *param, const phpdbg_input_t *input TSRMLS_DC) /* {{{ */ +{ + if (input->argc > 3 && phpdbg_argv_is(2, "if")) { + phpdbg_breakcond_t new_break; + phpdbg_param_t new_param; + + zend_ulong expr_hash = 0L; + size_t expr_len; + const char *join = strstr(input->string, "if"); + const char *expr = (join) + sizeof("if"); + + expr_len = strlen(expr); + expr = phpdbg_trim(expr, expr_len, &expr_len); + expr_hash = zend_inline_hash_func(expr, expr_len); + + { + /* get a clean parameter from input string */ + size_t sparam_len = 0L; + char *sparam = input->string; + + sparam[ + strstr(input->string, " ") - input->string] = 0; + sparam_len = strlen(sparam); + + switch (phpdbg_parse_param(sparam, sparam_len, &new_param TSRMLS_CC)) { + case EMPTY_PARAM: + case NUMERIC_PARAM: + phpdbg_clear_param( + &new_param TSRMLS_CC); + goto usage; + + default: { /* do nothing */ } break; + } + + expr_hash += phpdbg_hash_param(&new_param TSRMLS_CC); + } + + if (!zend_hash_index_exists(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], expr_hash)) { + phpdbg_create_conditional_break( + &new_break, &new_param, expr, expr_len, expr_hash TSRMLS_CC); + } else { + phpdbg_notice( + "Conditional break %s exists at the specified location", expr); + } + + phpdbg_clear_param(&new_param TSRMLS_CC); + } else { +usage: + phpdbg_error("usage: break at if "); + } +} /* }}} */ + +static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_file(zend_op_array *op_array TSRMLS_DC) /* {{{ */ +{ + HashTable *breaks; + phpdbg_breakbase_t *brake; + size_t name_len = strlen(op_array->filename); + + if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], op_array->filename, + name_len, (void**)&breaks) == FAILURE) { + return NULL; + } + + if (zend_hash_index_find(breaks, (*EG(opline_ptr))->lineno, (void**)&brake) == SUCCESS) { + return brake; + } + + return NULL; +} /* }}} */ + +static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_symbol(zend_function *fbc TSRMLS_DC) /* {{{ */ +{ + const char *fname; + zend_op_array *ops; + phpdbg_breakbase_t *brake; + + if (fbc->type != ZEND_USER_FUNCTION) { + return NULL; + } + + ops = (zend_op_array*)fbc; + + if (ops->scope) { + /* find method breaks here */ + return phpdbg_find_breakpoint_method(ops TSRMLS_CC); + } + + fname = ops->function_name; + + if (!fname) { + fname = "main"; + } + + if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], fname, strlen(fname), (void**)&brake) == SUCCESS) { + return brake; + } + + return NULL; +} /* }}} */ + +static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_method(zend_op_array *ops TSRMLS_DC) /* {{{ */ +{ + HashTable *class_table; + phpdbg_breakbase_t *brake; + + if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], ops->scope->name, + ops->scope->name_length, (void**)&class_table) == SUCCESS) { + char *lcname = zend_str_tolower_dup(ops->function_name, strlen(ops->function_name)); + size_t lcname_len = strlen(lcname); + + if (zend_hash_find( + class_table, + lcname, + lcname_len, (void**)&brake) == SUCCESS) { + efree(lcname); + return brake; + } + + efree(lcname); + } + + return NULL; +} /* }}} */ + +static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_opline(phpdbg_opline_ptr_t opline TSRMLS_DC) /* {{{ */ +{ + phpdbg_breakline_t *brake; + + if (zend_hash_index_find(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], + (zend_ulong) opline, (void**)&brake) == SUCCESS) { + return (brake->base?(phpdbg_breakbase_t *)brake->base:(phpdbg_breakbase_t *)brake); + } + + return NULL; +} /* }}} */ + +static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_opcode(zend_uchar opcode TSRMLS_DC) /* {{{ */ +{ + phpdbg_breakbase_t *brake; + const char *opname = phpdbg_decode_opcode(opcode); + + if (memcmp(opname, PHPDBG_STRL("UNKNOWN")) == 0) { + return NULL; + } + + if (zend_hash_index_find(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], + zend_hash_func(opname, strlen(opname)), (void**)&brake) == SUCCESS) { + return brake; + } + return NULL; +} /* }}} */ + +static inline zend_bool phpdbg_find_breakpoint_param(phpdbg_param_t *param, zend_execute_data *execute_data TSRMLS_DC) /* {{{ */ +{ + zend_function *function = (zend_function*) execute_data->function_state.function; + + switch (param->type) { + case NUMERIC_FUNCTION_PARAM: + case STR_PARAM: { + /* function breakpoint */ + + if (function->type != ZEND_USER_FUNCTION) { + return 0; + } + + { + const char *str = NULL; + size_t len = 0L; + zend_op_array *ops = (zend_op_array*)function; + str = ops->function_name ? ops->function_name : "main"; + len = strlen(str); + + if (len == param->len && memcmp(param->str, str, len) == SUCCESS) { + return param->type == STR_PARAM || execute_data->opline - ops->opcodes == param->num; + } + } + } break; + + case FILE_PARAM: { + if (param->file.line == zend_get_executed_lineno(TSRMLS_C)) { + const char *str = zend_get_executed_filename(TSRMLS_C); + size_t lengths[2] = {strlen(param->file.name), strlen(str)}; + + if (lengths[0] == lengths[1]) { + return (memcmp( + param->file.name, str, lengths[0]) == SUCCESS); + } + } + } break; + + case NUMERIC_METHOD_PARAM: + case METHOD_PARAM: { + if (function->type != ZEND_USER_FUNCTION) { + return 0; + } + + { + zend_op_array *ops = (zend_op_array*) function; + + if (ops->scope) { + size_t lengths[2] = {strlen(param->method.class), ops->scope->name_length}; + if (lengths[0] == lengths[1] && memcmp(param->method.class, ops->scope->name, lengths[0]) == SUCCESS) { + lengths[0] = strlen(param->method.name); + lengths[1] = strlen(ops->function_name); + + if (lengths[0] == lengths[1] && memcmp(param->method.name, ops->function_name, lengths[0]) == SUCCESS) { + return param->type == METHOD_PARAM || (execute_data->opline - ops->opcodes) == param->num; + } + } + } + } + } break; + + case ADDR_PARAM: { + return ((zend_ulong)(phpdbg_opline_ptr_t)execute_data->opline == param->addr); + } break; + + default: { + /* do nothing */ + } break; + } + return 0; +} /* }}} */ + +static inline phpdbg_breakbase_t *phpdbg_find_conditional_breakpoint(zend_execute_data *execute_data TSRMLS_DC) /* {{{ */ +{ + phpdbg_breakcond_t *bp; + HashPosition position; + int breakpoint = FAILURE; + + for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], &position); + zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], (void*)&bp, &position) == SUCCESS; + zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], &position)) { + zval *retval = NULL; + int orig_interactive = CG(interactive); + zval **orig_retval = EG(return_value_ptr_ptr); + zend_op_array *orig_ops = EG(active_op_array); + zend_op **orig_opline = EG(opline_ptr); + + if (((phpdbg_breakbase_t*)bp)->disabled) { + continue; + } + + if (bp->paramed) { + if (!phpdbg_find_breakpoint_param(&bp->param, execute_data TSRMLS_CC)) { + continue; + } + } + + ALLOC_INIT_ZVAL(retval); + + EG(return_value_ptr_ptr) = &retval; + EG(active_op_array) = bp->ops; + EG(no_extensions) = 1; + + if (!EG(active_symbol_table)) { + zend_rebuild_symbol_table(TSRMLS_C); + } + + CG(interactive) = 0; + + zend_try { + PHPDBG_G(flags) |= PHPDBG_IN_COND_BP; + zend_execute(EG(active_op_array) TSRMLS_CC); +#if PHP_VERSION_ID >= 50700 + if (zend_is_true(retval TSRMLS_CC)) { +#else + if (zend_is_true(retval)) { +#endif + breakpoint = SUCCESS; + } + } zend_catch { + CG(interactive) = orig_interactive; + + EG(no_extensions)=1; + EG(return_value_ptr_ptr) = orig_retval; + EG(active_op_array) = orig_ops; + EG(opline_ptr) = orig_opline; + PHPDBG_G(flags) &= ~PHPDBG_IN_COND_BP; + } zend_end_try(); + + CG(interactive) = orig_interactive; + + EG(no_extensions)=1; + EG(return_value_ptr_ptr) = orig_retval; + EG(active_op_array) = orig_ops; + EG(opline_ptr) = orig_opline; + PHPDBG_G(flags) &= ~PHPDBG_IN_COND_BP; + + if (breakpoint == SUCCESS) { + break; + } + } + + return (breakpoint == SUCCESS) ? ((phpdbg_breakbase_t*)bp) : NULL; +} /* }}} */ + +PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakpoint(zend_execute_data* execute_data TSRMLS_DC) /* {{{ */ +{ + phpdbg_breakbase_t *base = NULL; + + if (!(PHPDBG_G(flags) & PHPDBG_IS_BP_ENABLED)) { + return NULL; + } + + /* conditions cannot be executed by eval()'d code */ + if (!(PHPDBG_G(flags) & PHPDBG_IN_EVAL) && + (PHPDBG_G(flags) & PHPDBG_HAS_COND_BP) && + (base = phpdbg_find_conditional_breakpoint(execute_data TSRMLS_CC))) { + goto result; + } + + if ((PHPDBG_G(flags) & PHPDBG_HAS_FILE_BP) && + (base = phpdbg_find_breakpoint_file(execute_data->op_array TSRMLS_CC))) { + goto result; + } + + if (PHPDBG_G(flags) & (PHPDBG_HAS_METHOD_BP|PHPDBG_HAS_SYM_BP)) { + /* check we are at the beginning of the stack */ + if (execute_data->opline == EG(active_op_array)->opcodes) { + if ((base = phpdbg_find_breakpoint_symbol( + execute_data->function_state.function TSRMLS_CC))) { + goto result; + } + } + } + + if ((PHPDBG_G(flags) & PHPDBG_HAS_OPLINE_BP) && + (base = phpdbg_find_breakpoint_opline(execute_data->opline TSRMLS_CC))) { + goto result; + } + + if ((PHPDBG_G(flags) & PHPDBG_HAS_OPCODE_BP) && + (base = phpdbg_find_breakpoint_opcode(execute_data->opline->opcode TSRMLS_CC))) { + goto result; + } + + return NULL; + +result: + /* we return nothing for disable breakpoints */ + if (base->disabled) { + return NULL; + } + + return base; +} /* }}} */ + +PHPDBG_API void phpdbg_delete_breakpoint(zend_ulong num TSRMLS_DC) /* {{{ */ +{ + HashTable **table; + HashPosition position; + phpdbg_breakbase_t *brake; + + if ((brake = phpdbg_find_breakbase_ex(num, &table, &position TSRMLS_CC))) { + char *key; + zend_uint klen; + zend_ulong idx; + int type = brake->type; + char *name = NULL; + size_t name_len = 0L; + + switch (type) { + case PHPDBG_BREAK_FILE: + case PHPDBG_BREAK_METHOD: + if (zend_hash_num_elements((*table)) == 1) { + name = estrdup(brake->name); + name_len = strlen(name); + if (zend_hash_num_elements(&PHPDBG_G(bp)[type]) == 1) { + PHPDBG_G(flags) &= ~(1<<(brake->type+1)); + } + } + break; + + default: { + if (zend_hash_num_elements((*table)) == 1) { + PHPDBG_G(flags) &= ~(1<<(brake->type+1)); + } + } + } + + switch (type) { + case PHPDBG_BREAK_FILE_OPLINE: + case PHPDBG_BREAK_FUNCTION_OPLINE: + case PHPDBG_BREAK_METHOD_OPLINE: + if (zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]) == 1) { + PHPDBG_G(flags) &= PHPDBG_HAS_OPLINE_BP; + } + zend_hash_index_del(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], ((phpdbg_breakopline_t*)brake)->opline); + } + + switch (zend_hash_get_current_key_ex( + (*table), &key, &klen, &idx, 0, &position)) { + + case HASH_KEY_IS_STRING: + zend_hash_del((*table), key, klen); + break; + + default: + zend_hash_index_del((*table), idx); + } + + switch (type) { + case PHPDBG_BREAK_FILE: + case PHPDBG_BREAK_METHOD: + if (name) { + zend_hash_del(&PHPDBG_G(bp)[type], name, name_len); + efree(name); + } + break; + } + + phpdbg_notice("Deleted breakpoint #%ld", num); + PHPDBG_BREAK_UNMAPPING(num); + } else { + phpdbg_error("Failed to find breakpoint #%ld", num); + } +} /* }}} */ + +PHPDBG_API void phpdbg_clear_breakpoints(TSRMLS_D) /* {{{ */ +{ + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_COND]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP]); + + PHPDBG_G(flags) &= ~PHPDBG_BP_MASK; + + PHPDBG_G(bp_count) = 0; +} /* }}} */ + +PHPDBG_API void phpdbg_hit_breakpoint(phpdbg_breakbase_t *brake, zend_bool output TSRMLS_DC) /* {{{ */ +{ + brake->hits++; + + if (output) { + phpdbg_print_breakpoint(brake TSRMLS_CC); + } +} /* }}} */ + +PHPDBG_API void phpdbg_print_breakpoint(phpdbg_breakbase_t *brake TSRMLS_DC) /* {{{ */ +{ + if (!brake) + goto unknown; + + switch (brake->type) { + case PHPDBG_BREAK_FILE: { + phpdbg_notice("Breakpoint #%d at %s:%ld, hits: %lu", + ((phpdbg_breakfile_t*)brake)->id, + ((phpdbg_breakfile_t*)brake)->filename, + ((phpdbg_breakfile_t*)brake)->line, + ((phpdbg_breakfile_t*)brake)->hits); + } break; + + case PHPDBG_BREAK_SYM: { + phpdbg_notice("Breakpoint #%d in %s() at %s:%u, hits: %lu", + ((phpdbg_breaksymbol_t*)brake)->id, + ((phpdbg_breaksymbol_t*)brake)->symbol, + zend_get_executed_filename(TSRMLS_C), + zend_get_executed_lineno(TSRMLS_C), + ((phpdbg_breakfile_t*)brake)->hits); + } break; + + case PHPDBG_BREAK_OPLINE: { + phpdbg_notice("Breakpoint #%d in %#lx at %s:%u, hits: %lu", + ((phpdbg_breakline_t*)brake)->id, + ((phpdbg_breakline_t*)brake)->opline, + zend_get_executed_filename(TSRMLS_C), + zend_get_executed_lineno(TSRMLS_C), + ((phpdbg_breakline_t*)brake)->hits); + } break; + + case PHPDBG_BREAK_METHOD_OPLINE: { + phpdbg_notice("Breakpoint #%d in %s::%s()#%lu at %s:%u, hits: %lu", + ((phpdbg_breakopline_t*)brake)->id, + ((phpdbg_breakopline_t*)brake)->class_name, + ((phpdbg_breakopline_t*)brake)->func_name, + ((phpdbg_breakopline_t*)brake)->opline_num, + zend_get_executed_filename(TSRMLS_C), + zend_get_executed_lineno(TSRMLS_C), + ((phpdbg_breakopline_t*)brake)->hits); + } break; + + case PHPDBG_BREAK_FUNCTION_OPLINE: { + phpdbg_notice("Breakpoint #%d in %s()#%lu at %s:%u, hits: %lu", + ((phpdbg_breakopline_t*)brake)->id, + ((phpdbg_breakopline_t*)brake)->func_name, + ((phpdbg_breakopline_t*)brake)->opline_num, + zend_get_executed_filename(TSRMLS_C), + zend_get_executed_lineno(TSRMLS_C), + ((phpdbg_breakopline_t*)brake)->hits); + } break; + + case PHPDBG_BREAK_FILE_OPLINE: { + phpdbg_notice("Breakpoint #%d in %s:%lu at %s:%u, hits: %lu", + ((phpdbg_breakopline_t*)brake)->id, + ((phpdbg_breakopline_t*)brake)->class_name, + ((phpdbg_breakopline_t*)brake)->opline_num, + zend_get_executed_filename(TSRMLS_C), + zend_get_executed_lineno(TSRMLS_C), + ((phpdbg_breakopline_t*)brake)->hits); + } break; + + case PHPDBG_BREAK_OPCODE: { + phpdbg_notice("Breakpoint #%d in %s at %s:%u, hits: %lu", + ((phpdbg_breakop_t*)brake)->id, + ((phpdbg_breakop_t*)brake)->name, + zend_get_executed_filename(TSRMLS_C), + zend_get_executed_lineno(TSRMLS_C), + ((phpdbg_breakop_t*)brake)->hits); + } break; + + case PHPDBG_BREAK_METHOD: { + phpdbg_notice("Breakpoint #%d in %s::%s() at %s:%u, hits: %lu", + ((phpdbg_breakmethod_t*)brake)->id, + ((phpdbg_breakmethod_t*)brake)->class_name, + ((phpdbg_breakmethod_t*)brake)->func_name, + zend_get_executed_filename(TSRMLS_C), + zend_get_executed_lineno(TSRMLS_C), + ((phpdbg_breakmethod_t*)brake)->hits); + } break; + + case PHPDBG_BREAK_COND: { + if (((phpdbg_breakcond_t*)brake)->paramed) { + char *param; + phpdbg_notice("Conditional breakpoint #%d: at %s if %s %s:%u, hits: %lu", + ((phpdbg_breakcond_t*)brake)->id, + phpdbg_param_tostring(&((phpdbg_breakcond_t*)brake)->param, ¶m TSRMLS_CC), + ((phpdbg_breakcond_t*)brake)->code, + zend_get_executed_filename(TSRMLS_C), + zend_get_executed_lineno(TSRMLS_C), + ((phpdbg_breakcond_t*)brake)->hits); + if (param) + free(param); + } else { + phpdbg_notice("Conditional breakpoint #%d: on %s == true %s:%u, hits: %lu", + ((phpdbg_breakcond_t*)brake)->id, + ((phpdbg_breakcond_t*)brake)->code, + zend_get_executed_filename(TSRMLS_C), + zend_get_executed_lineno(TSRMLS_C), + ((phpdbg_breakcond_t*)brake)->hits); + } + + } break; + + default: { +unknown: + phpdbg_notice("Unknown breakpoint at %s:%u", + zend_get_executed_filename(TSRMLS_C), + zend_get_executed_lineno(TSRMLS_C)); + } + } +} /* }}} */ + +PHPDBG_API void phpdbg_enable_breakpoint(zend_ulong id TSRMLS_DC) /* {{{ */ +{ + phpdbg_breakbase_t *brake = phpdbg_find_breakbase(id TSRMLS_CC); + + if (brake) { + brake->disabled = 0; + } +} /* }}} */ + +PHPDBG_API void phpdbg_disable_breakpoint(zend_ulong id TSRMLS_DC) /* {{{ */ +{ + phpdbg_breakbase_t *brake = phpdbg_find_breakbase(id TSRMLS_CC); + + if (brake) { + brake->disabled = 1; + } +} /* }}} */ + +PHPDBG_API void phpdbg_enable_breakpoints(TSRMLS_D) /* {{{ */ +{ + PHPDBG_G(flags) |= PHPDBG_IS_BP_ENABLED; +} /* }}} */ + +PHPDBG_API void phpdbg_disable_breakpoints(TSRMLS_D) { /* {{{ */ + PHPDBG_G(flags) &= ~PHPDBG_IS_BP_ENABLED; +} /* }}} */ + +PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase(zend_ulong id TSRMLS_DC) /* {{{ */ +{ + HashTable **table; + HashPosition position; + + return phpdbg_find_breakbase_ex(id, &table, &position TSRMLS_CC); +} /* }}} */ + +PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase_ex(zend_ulong id, HashTable ***table, HashPosition *position TSRMLS_DC) /* {{{ */ +{ + if (zend_hash_index_find(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], id, (void**)table) == SUCCESS) { + phpdbg_breakbase_t *brake; + + for (zend_hash_internal_pointer_reset_ex((**table), position); + zend_hash_get_current_data_ex((**table), (void**)&brake, position) == SUCCESS; + zend_hash_move_forward_ex((**table), position)) { + + if (brake->id == id) { + return brake; + } + } + } + return NULL; +} /* }}} */ + +PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ +{ + switch (type) { + case PHPDBG_BREAK_SYM: if ((PHPDBG_G(flags) & PHPDBG_HAS_SYM_BP)) { + HashPosition position; + phpdbg_breaksymbol_t *brake; + + phpdbg_writeln(SEPARATE); + phpdbg_writeln("Function Breakpoints:"); + for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], &position); + zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], (void**) &brake, &position) == SUCCESS; + zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], &position)) { + phpdbg_writeln("#%d\t\t%s%s", + brake->id, brake->symbol, + ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); + } + } break; + + case PHPDBG_BREAK_METHOD: if ((PHPDBG_G(flags) & PHPDBG_HAS_METHOD_BP)) { + HashPosition position[2]; + HashTable *class_table; + char *class_name = NULL; + zend_uint class_len = 0; + zend_ulong class_idx = 0L; + + phpdbg_writeln(SEPARATE); + phpdbg_writeln("Method Breakpoints:"); + for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], &position[0]); + zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], (void**) &class_table, &position[0]) == SUCCESS; + zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], &position[0])) { + + if (zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], + &class_name, &class_len, &class_idx, 0, &position[0]) == HASH_KEY_IS_STRING) { + phpdbg_breakmethod_t *brake; + + for (zend_hash_internal_pointer_reset_ex(class_table, &position[1]); + zend_hash_get_current_data_ex(class_table, (void**)&brake, &position[1]) == SUCCESS; + zend_hash_move_forward_ex(class_table, &position[1])) { + phpdbg_writeln("#%d\t\t%s::%s%s", + brake->id, brake->class_name, brake->func_name, + ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); + } + } + + } + } break; + + case PHPDBG_BREAK_FILE: if ((PHPDBG_G(flags) & PHPDBG_HAS_FILE_BP)) { + HashPosition position[2]; + HashTable *points; + + phpdbg_writeln(SEPARATE); + phpdbg_writeln("File Breakpoints:"); + for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], &position[0]); + zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], (void**) &points, &position[0]) == SUCCESS; + zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], &position[0])) { + phpdbg_breakfile_t *brake; + + for (zend_hash_internal_pointer_reset_ex(points, &position[1]); + zend_hash_get_current_data_ex(points, (void**)&brake, &position[1]) == SUCCESS; + zend_hash_move_forward_ex(points, &position[1])) { + phpdbg_writeln("#%d\t\t%s:%lu%s", + brake->id, brake->filename, brake->line, + ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); + } + } + + } break; + + case PHPDBG_BREAK_OPLINE: if ((PHPDBG_G(flags) & PHPDBG_HAS_OPLINE_BP)) { + HashPosition position; + phpdbg_breakline_t *brake; + + phpdbg_writeln(SEPARATE); + phpdbg_writeln("Opline Breakpoints:"); + for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], &position); + zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], (void**) &brake, &position) == SUCCESS; + zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], &position)) { + switch (brake->type) { + case PHPDBG_BREAK_METHOD_OPLINE: + case PHPDBG_BREAK_FUNCTION_OPLINE: + case PHPDBG_BREAK_FILE_OPLINE: + phpdbg_writeln("#%d\t\t%#lx\t\t(%s breakpoint)%s", brake->id, brake->opline, + brake->type == PHPDBG_BREAK_METHOD_OPLINE?"method": + brake->type == PHPDBG_BREAK_FUNCTION_OPLINE?"function": + brake->type == PHPDBG_BREAK_FILE_OPLINE?"file": + "--- error ---", + ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); + break; + + default: + phpdbg_writeln("#%d\t\t%#lx", brake->id, brake->opline); + break; + } + } + } break; + + case PHPDBG_BREAK_METHOD_OPLINE: if ((PHPDBG_G(flags) & PHPDBG_HAS_METHOD_OPLINE_BP)) { + HashPosition position[3]; + HashTable *class_table, *method_table; + char *class_name = NULL, *method_name = NULL; + zend_uint class_len = 0, method_len = 0; + zend_ulong class_idx = 0L, method_idx = 0L; + + phpdbg_writeln(SEPARATE); + phpdbg_writeln("Method opline Breakpoints:"); + for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], &position[0]); + zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], (void**) &class_table, &position[0]) == SUCCESS; + zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], &position[0])) { + + if (zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], + &class_name, &class_len, &class_idx, 0, &position[0]) == HASH_KEY_IS_STRING) { + + for (zend_hash_internal_pointer_reset_ex(class_table, &position[1]); + zend_hash_get_current_data_ex(class_table, (void**) &method_table, &position[1]) == SUCCESS; + zend_hash_move_forward_ex(class_table, &position[1])) { + + if (zend_hash_get_current_key_ex(class_table, + &method_name, &method_len, &method_idx, 0, &position[0]) == HASH_KEY_IS_STRING) { + + phpdbg_breakopline_t *brake; + + for (zend_hash_internal_pointer_reset_ex(method_table, &position[2]); + zend_hash_get_current_data_ex(method_table, (void**)&brake, &position[2]) == SUCCESS; + zend_hash_move_forward_ex(method_table, &position[2])) { + phpdbg_writeln("#%d\t\t%s::%s opline %ld%s", + brake->id, brake->class_name, brake->func_name, brake->opline_num, + ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); + } + } + } + } + + } + } break; + + case PHPDBG_BREAK_FUNCTION_OPLINE: if ((PHPDBG_G(flags) & PHPDBG_HAS_FUNCTION_OPLINE_BP)) { + HashPosition position[2]; + HashTable *function_table; + char *function_name = NULL; + zend_uint function_len = 0; + zend_ulong function_idx = 0L; + + phpdbg_writeln(SEPARATE); + phpdbg_writeln("Function opline Breakpoints:"); + for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], &position[0]); + zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], (void**) &function_table, &position[0]) == SUCCESS; + zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], &position[0])) { + + if (zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], + &function_name, &function_len, &function_idx, 0, &position[0]) == HASH_KEY_IS_STRING) { + + phpdbg_breakopline_t *brake; + + for (zend_hash_internal_pointer_reset_ex(function_table, &position[1]); + zend_hash_get_current_data_ex(function_table, (void**)&brake, &position[1]) == SUCCESS; + zend_hash_move_forward_ex(function_table, &position[1])) { + phpdbg_writeln("#%d\t\t%s opline %ld%s", + brake->id, brake->func_name, brake->opline_num, + ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); + } + } + + } + } break; + + case PHPDBG_BREAK_FILE_OPLINE: if ((PHPDBG_G(flags) & PHPDBG_HAS_FILE_OPLINE_BP)) { + HashPosition position[2]; + HashTable *file_table; + char *file_name = NULL; + zend_uint file_len = 0; + zend_ulong file_idx = 0L; + + phpdbg_writeln(SEPARATE); + phpdbg_writeln("File opline Breakpoints:"); + for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE], &position[0]); + zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE], (void**) &file_table, &position[0]) == SUCCESS; + zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE], &position[0])) { + + if (zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE], + &file_name, &file_len, &file_idx, 0, &position[0]) == HASH_KEY_IS_STRING) { + + phpdbg_breakopline_t *brake; + + for (zend_hash_internal_pointer_reset_ex(file_table, &position[1]); + zend_hash_get_current_data_ex(file_table, (void**)&brake, &position[1]) == SUCCESS; + zend_hash_move_forward_ex(file_table, &position[1])) { + phpdbg_writeln("#%d\t\t%s opline %ld%s", + brake->id, brake->class_name, brake->opline_num, + ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); + } + } + } + } break; + + case PHPDBG_BREAK_COND: if ((PHPDBG_G(flags) & PHPDBG_HAS_COND_BP)) { + HashPosition position; + phpdbg_breakcond_t *brake; + + phpdbg_writeln(SEPARATE); + phpdbg_writeln("Conditional Breakpoints:"); + for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], &position); + zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], (void**) &brake, &position) == SUCCESS; + zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], &position)) { + if (brake->paramed) { + switch (brake->param.type) { + case STR_PARAM: + phpdbg_writeln("#%d\t\tat %s if %s%s", + brake->id, + brake->param.str, + brake->code, + ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); + break; + + case NUMERIC_FUNCTION_PARAM: + phpdbg_writeln("#%d\t\tat %s#%ld if %s%s", + brake->id, + brake->param.str, + brake->param.num, + brake->code, + ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); + break; + + case METHOD_PARAM: + phpdbg_writeln("#%d\t\tat %s::%s if %s%s", + brake->id, + brake->param.method.class, + brake->param.method.name, + brake->code, + ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); + break; + + case NUMERIC_METHOD_PARAM: + phpdbg_writeln("#%d\t\tat %s::%s#%ld if %s%s", + brake->id, + brake->param.method.class, + brake->param.method.name, + brake->param.num, + brake->code, + ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); + break; + + case FILE_PARAM: + phpdbg_writeln("#%d\t\tat %s:%lu if %s%s", + brake->id, + brake->param.file.name, + brake->param.file.line, + brake->code, + ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); + break; + + case ADDR_PARAM: + phpdbg_writeln("#%d\t\tat #%lx if %s%s", + brake->id, + brake->param.addr, + brake->code, + ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); + break; + + default: + phpdbg_error("Invalid parameter type for conditional breakpoint"); + return; + } + } else { + phpdbg_writeln("#%d\t\tif %s%s", + brake->id, brake->code, + ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); + } + } + } break; + + case PHPDBG_BREAK_OPCODE: if (PHPDBG_G(flags) & PHPDBG_HAS_OPCODE_BP) { + HashPosition position; + phpdbg_breakop_t *brake; + + phpdbg_writeln(SEPARATE); + phpdbg_writeln("Opcode Breakpoints:"); + for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], &position); + zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], (void**) &brake, &position) == SUCCESS; + zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], &position)) { + phpdbg_writeln("#%d\t\t%s%s", + brake->id, brake->name, + ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); + } + } break; + } +} /* }}} */ diff --git a/phpdbg_bp.h b/phpdbg_bp.h new file mode 100644 index 00000000000..ed1b413f6d3 --- /dev/null +++ b/phpdbg_bp.h @@ -0,0 +1,146 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHPDBG_BP_H +#define PHPDBG_BP_H + +/* {{{ */ +typedef struct _zend_op *phpdbg_opline_ptr_t; /* }}} */ + +/* {{{ breakpoint base structure */ +#define phpdbg_breakbase(name) \ + int id; \ + zend_uchar type; \ + zend_ulong hits; \ + zend_bool disabled; \ + const char *name /* }}} */ + +/* {{{ breakpoint base */ +typedef struct _phpdbg_breakbase_t { + phpdbg_breakbase(name); +} phpdbg_breakbase_t; /* }}} */ + +/** + * Breakpoint file-based representation + */ +typedef struct _phpdbg_breakfile_t { + phpdbg_breakbase(filename); + long line; +} phpdbg_breakfile_t; + +/** + * Breakpoint symbol-based representation + */ +typedef struct _phpdbg_breaksymbol_t { + phpdbg_breakbase(symbol); +} phpdbg_breaksymbol_t; + +/** + * Breakpoint method based representation + */ +typedef struct _phpdbg_breakmethod_t { + phpdbg_breakbase(class_name); + size_t class_len; + const char *func_name; + size_t func_len; +} phpdbg_breakmethod_t; + +/** + * Breakpoint opline num based representation + */ +typedef struct _phpdbg_breakopline_t { + phpdbg_breakbase(func_name); + size_t func_len; + const char *class_name; + size_t class_len; + zend_ulong opline_num; + zend_ulong opline; +} phpdbg_breakopline_t; + +/** + * Breakpoint opline based representation + */ +typedef struct _phpdbg_breakline_t { + phpdbg_breakbase(name); + zend_ulong opline; + phpdbg_breakopline_t *base; +} phpdbg_breakline_t; + +/** + * Breakpoint opcode based representation + */ +typedef struct _phpdbg_breakop_t { + phpdbg_breakbase(name); + zend_ulong hash; +} phpdbg_breakop_t; + +/** + * Breakpoint condition based representation + */ +typedef struct _phpdbg_breakcond_t { + phpdbg_breakbase(code); + size_t code_len; + zend_bool paramed; + phpdbg_param_t param; + zend_ulong hash; + zend_op_array *ops; +} phpdbg_breakcond_t; + +/* {{{ Opline breaks API */ +PHPDBG_API void phpdbg_resolve_op_array_breaks(zend_op_array *op_array TSRMLS_DC); +PHPDBG_API int phpdbg_resolve_op_array_break(phpdbg_breakopline_t *brake, zend_op_array *op_array TSRMLS_DC); +PHPDBG_API int phpdbg_resolve_opline_break(phpdbg_breakopline_t *new_break TSRMLS_DC); /* }}} */ + +/* {{{ Breakpoint Creation API */ +PHPDBG_API void phpdbg_set_breakpoint_file(const char* filename, long lineno TSRMLS_DC); +PHPDBG_API void phpdbg_set_breakpoint_symbol(const char* func_name, size_t func_name_len TSRMLS_DC); +PHPDBG_API void phpdbg_set_breakpoint_method(const char* class_name, const char* func_name TSRMLS_DC); +PHPDBG_API void phpdbg_set_breakpoint_opcode(const char* opname, size_t opname_len TSRMLS_DC); +PHPDBG_API void phpdbg_set_breakpoint_opline(zend_ulong opline TSRMLS_DC); +PHPDBG_API void phpdbg_set_breakpoint_opline_ex(phpdbg_opline_ptr_t opline TSRMLS_DC); +PHPDBG_API void phpdbg_set_breakpoint_method_opline(const char *class, const char *method, zend_ulong opline TSRMLS_DC); +PHPDBG_API void phpdbg_set_breakpoint_function_opline(const char *function, zend_ulong opline TSRMLS_DC); +PHPDBG_API void phpdbg_set_breakpoint_file_opline(const char *file, zend_ulong opline TSRMLS_DC); +PHPDBG_API void phpdbg_set_breakpoint_expression(const char* expression, size_t expression_len TSRMLS_DC); +PHPDBG_API void phpdbg_set_breakpoint_at(const phpdbg_param_t *param, const phpdbg_input_t *input TSRMLS_DC); /* }}} */ + +/* {{{ Breakpoint Detection API */ +PHPDBG_API phpdbg_breakbase_t* phpdbg_find_breakpoint(zend_execute_data* TSRMLS_DC); /* }}} */ + +/* {{{ Misc Breakpoint API */ +PHPDBG_API void phpdbg_hit_breakpoint(phpdbg_breakbase_t* brake, zend_bool output TSRMLS_DC); +PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC); +PHPDBG_API void phpdbg_print_breakpoint(phpdbg_breakbase_t* brake TSRMLS_DC); +PHPDBG_API void phpdbg_reset_breakpoints(TSRMLS_D); +PHPDBG_API void phpdbg_clear_breakpoints(TSRMLS_D); +PHPDBG_API void phpdbg_delete_breakpoint(zend_ulong num TSRMLS_DC); +PHPDBG_API void phpdbg_enable_breakpoints(TSRMLS_D); +PHPDBG_API void phpdbg_enable_breakpoint(zend_ulong id TSRMLS_DC); +PHPDBG_API void phpdbg_disable_breakpoint(zend_ulong id TSRMLS_DC); +PHPDBG_API void phpdbg_disable_breakpoints(TSRMLS_D); /* }}} */ + +/* {{{ Breakbase API */ +PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase(zend_ulong id TSRMLS_DC); +PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase_ex(zend_ulong id, HashTable ***table, HashPosition *position TSRMLS_DC); /* }}} */ + +/* {{{ Breakpoint Exportation API */ +PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC); /* }}} */ + +#endif /* PHPDBG_BP_H */ diff --git a/phpdbg_break.c b/phpdbg_break.c new file mode 100644 index 00000000000..1423b960e66 --- /dev/null +++ b/phpdbg_break.c @@ -0,0 +1,155 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#include "phpdbg.h" +#include "phpdbg_print.h" +#include "phpdbg_utils.h" +#include "phpdbg_opcode.h" +#include "phpdbg_break.h" +#include "phpdbg_bp.h" + +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); + +PHPDBG_BREAK(file) /* {{{ */ +{ + switch (param->type) { + case FILE_PARAM: + phpdbg_set_breakpoint_file(param->file.name, param->file.line TSRMLS_CC); + break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_BREAK(method) /* {{{ */ +{ + switch (param->type) { + case METHOD_PARAM: + phpdbg_set_breakpoint_method(param->method.class, param->method.name TSRMLS_CC); + break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_BREAK(address) /* {{{ */ +{ + switch (param->type) { + case ADDR_PARAM: + phpdbg_set_breakpoint_opline(param->addr TSRMLS_CC); + break; + + case NUMERIC_METHOD_PARAM: + phpdbg_set_breakpoint_method_opline(param->method.class, param->method.name, param->num TSRMLS_CC); + break; + + case NUMERIC_FUNCTION_PARAM: + phpdbg_set_breakpoint_function_opline(param->str, param->num TSRMLS_CC); + break; + + case FILE_PARAM: + phpdbg_set_breakpoint_file_opline(param->file.name, param->file.line TSRMLS_CC); + break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_BREAK(on) /* {{{ */ +{ + switch (param->type) { + case STR_PARAM: + phpdbg_set_breakpoint_expression(param->str, param->len TSRMLS_CC); + break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_BREAK(at) /* {{{ */ +{ + phpdbg_set_breakpoint_at(param, input TSRMLS_CC); + + return SUCCESS; +} /* }}} */ + +PHPDBG_BREAK(lineno) /* {{{ */ +{ + switch (param->type) { + case NUMERIC_PARAM: { + if (PHPDBG_G(exec)) { + phpdbg_set_breakpoint_file(phpdbg_current_file(TSRMLS_C), param->num TSRMLS_CC); + } else { + phpdbg_error("Execution context not set!"); + } + } break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_BREAK(func) /* {{{ */ +{ + switch (param->type) { + case STR_PARAM: + phpdbg_set_breakpoint_symbol(param->str, param->len TSRMLS_CC); + break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_BREAK(op) /* {{{ */ +{ + switch (param->type) { + case STR_PARAM: + phpdbg_set_breakpoint_opcode(param->str, param->len TSRMLS_CC); + break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_BREAK(del) /* {{{ */ +{ + switch (param->type) { + case NUMERIC_PARAM: { + phpdbg_delete_breakpoint(param->num TSRMLS_CC); + } break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ diff --git a/phpdbg_break.h b/phpdbg_break.h new file mode 100644 index 00000000000..04abeb6805f --- /dev/null +++ b/phpdbg_break.h @@ -0,0 +1,58 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHPDBG_BREAK_H +#define PHPDBG_BREAK_H + +#include "TSRM.h" +#include "phpdbg_cmd.h" + +#define PHPDBG_BREAK(name) PHPDBG_COMMAND(break_##name) + +/** + * Printer Forward Declarations + */ +PHPDBG_BREAK(file); +PHPDBG_BREAK(func); +PHPDBG_BREAK(method); +PHPDBG_BREAK(address); +PHPDBG_BREAK(at); +PHPDBG_BREAK(op); +PHPDBG_BREAK(on); +PHPDBG_BREAK(lineno); +PHPDBG_BREAK(del); + +/** + * Commands + */ +static const phpdbg_command_t phpdbg_break_commands[] = { + PHPDBG_COMMAND_D_EX(file, "specify breakpoint by file:line", 'F', break_file, NULL, 1), + PHPDBG_COMMAND_D_EX(func, "specify breakpoint by global function name", 'f', break_func, NULL, 1), + PHPDBG_COMMAND_D_EX(method, "specify breakpoint by class::method", 'm', break_method, NULL, 1), + PHPDBG_COMMAND_D_EX(address, "specify breakpoint by address", 'a', break_address, NULL, 1), + PHPDBG_COMMAND_D_EX(op, "specify breakpoint by opcode", 'O', break_op, NULL, 1), + PHPDBG_COMMAND_D_EX(on, "specify breakpoint by condition", 'o', break_on, NULL, 1), + PHPDBG_COMMAND_D_EX(at, "specify breakpoint by location and condition", 'A', break_at, NULL, 1), + PHPDBG_COMMAND_D_EX(lineno, "specify breakpoint by line of currently executing file", 'l', break_lineno, NULL, 1), + PHPDBG_COMMAND_D_EX(del, "delete breakpoint by identifier number", 'd', break_del, NULL, 1), + PHPDBG_END_COMMAND +}; + +#endif /* PHPDBG_BREAK_H */ diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c new file mode 100644 index 00000000000..9f052d6f6f3 --- /dev/null +++ b/phpdbg_cmd.c @@ -0,0 +1,669 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#include "phpdbg.h" +#include "phpdbg_cmd.h" +#include "phpdbg_utils.h" +#include "phpdbg_set.h" + +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); + +PHPDBG_API const char *phpdbg_get_param_type(const phpdbg_param_t *param TSRMLS_DC) /* {{{ */ +{ + switch (param->type) { + case EMPTY_PARAM: + return "empty"; + case ADDR_PARAM: + return "address"; + case NUMERIC_PARAM: + return "numeric"; + case METHOD_PARAM: + return "method"; + case NUMERIC_FUNCTION_PARAM: + return "function opline"; + case NUMERIC_METHOD_PARAM: + return "method opline"; + case FILE_PARAM: + return "file or file opline"; + case STR_PARAM: + return "string"; + default: /* this is bad */ + return "unknown"; + } +} + +PHPDBG_API phpdbg_param_type phpdbg_parse_param(const char *str, size_t len, phpdbg_param_t *param TSRMLS_DC) /* {{{ */ +{ + char *class_name, *func_name; + + if (len == 0) { + param->type = EMPTY_PARAM; + goto parsed; + } + + if (phpdbg_is_addr(str)) { + param->addr = strtoul(str, 0, 16); + param->type = ADDR_PARAM; + goto parsed; + + } else if (phpdbg_is_numeric(str)) { + param->num = strtol(str, NULL, 0); + param->type = NUMERIC_PARAM; + goto parsed; + + } else if (phpdbg_is_class_method(str, len+1, &class_name, &func_name)) { + param->method.class = class_name; + param->method.name = func_name; + param->type = METHOD_PARAM; + goto parsed; + } else { + char *line_pos = strrchr(str, ':'); + + if (line_pos && phpdbg_is_numeric(line_pos+1)) { + if (strchr(str, ':') == line_pos) { + char path[MAXPATHLEN]; + + memcpy(path, str, line_pos - str); + path[line_pos - str] = 0; + *line_pos = 0; + param->file.name = phpdbg_resolve_path(path TSRMLS_CC); + param->file.line = strtol(line_pos+1, NULL, 0); + param->type = FILE_PARAM; + + goto parsed; + } + } + + line_pos = strrchr(str, '#'); + + if (line_pos && phpdbg_is_numeric(line_pos+1)) { + if (strchr(str, '#') == line_pos) { + param->num = strtol(line_pos + 1, NULL, 0); + + if (phpdbg_is_class_method(str, line_pos - str, &class_name, &func_name)) { + param->method.class = class_name; + param->method.name = func_name; + param->type = NUMERIC_METHOD_PARAM; + } else { + param->len = line_pos - str; + param->str = estrndup(str, param->len); + param->type = NUMERIC_FUNCTION_PARAM; + } + + goto parsed; + } + } + } + + param->str = estrndup(str, len); + param->len = len; + param->type = STR_PARAM; + +parsed: + phpdbg_debug("phpdbg_parse_param(\"%s\", %lu): %s", + str, len, phpdbg_get_param_type(param TSRMLS_CC)); + return param->type; +} /* }}} */ + +PHPDBG_API void phpdbg_clear_param(phpdbg_param_t *param TSRMLS_DC) /* {{{ */ +{ + if (param) { + switch (param->type) { + case FILE_PARAM: + efree(param->file.name); + break; + case METHOD_PARAM: + efree(param->method.class); + efree(param->method.name); + break; + case STR_PARAM: + efree(param->str); + break; + default: + break; + } + } + +} /* }}} */ + +PHPDBG_API char* phpdbg_param_tostring(const phpdbg_param_t *param, char **pointer TSRMLS_DC) /* {{{ */ +{ + switch (param->type) { + case STR_PARAM: + asprintf(pointer, + "%s", param->str); + break; + + case ADDR_PARAM: + asprintf(pointer, + "%#lx", param->addr); + break; + + case NUMERIC_PARAM: + asprintf(pointer, + "%li", + param->num); + break; + + case METHOD_PARAM: + asprintf(pointer, + "%s::%s", + param->method.class, + param->method.name); + break; + + case FILE_PARAM: + if (param->num) { + asprintf(pointer, + "%s:%lu#%lu", + param->file.name, + param->file.line, + param->num); + } else { + asprintf(pointer, + "%s:%lu", + param->file.name, + param->file.line); + } + break; + + case NUMERIC_FUNCTION_PARAM: + asprintf(pointer, + "%s#%lu", param->str, param->num); + break; + + case NUMERIC_METHOD_PARAM: + asprintf(pointer, + "%s::%s#%lu", + param->method.class, + param->method.name, + param->num); + break; + + default: + asprintf(pointer, + "%s", "unknown"); + } + + return *pointer; +} /* }}} */ + +PHPDBG_API void phpdbg_copy_param(const phpdbg_param_t* src, phpdbg_param_t* dest TSRMLS_DC) /* {{{ */ +{ + switch ((dest->type = src->type)) { + case STR_PARAM: + dest->str = estrndup(src->str, src->len); + dest->len = src->len; + break; + + case ADDR_PARAM: + dest->addr = src->addr; + break; + + case NUMERIC_PARAM: + dest->num = src->num; + break; + + case METHOD_PARAM: + dest->method.class = estrdup(src->method.class); + dest->method.name = estrdup(src->method.name); + break; + + case FILE_PARAM: + dest->file.name = estrdup(src->file.name); + dest->file.line = src->file.line; + if (src->num) + dest->num = src->num; + break; + + case NUMERIC_FUNCTION_PARAM: + dest->str = estrndup(src->str, src->len); + dest->num = src->num; + dest->len = src->len; + break; + + case NUMERIC_METHOD_PARAM: + dest->method.class = estrdup(src->method.class); + dest->method.name = estrdup(src->method.name); + dest->num = src->num; + break; + + case EMPTY_PARAM: { /* do nothing */ } break; + } +} /* }}} */ + +PHPDBG_API zend_ulong phpdbg_hash_param(const phpdbg_param_t *param TSRMLS_DC) /* {{{ */ +{ + zend_ulong hash = param->type; + + switch (param->type) { + case STR_PARAM: + hash += zend_inline_hash_func(param->str, param->len); + break; + + case METHOD_PARAM: + hash += zend_inline_hash_func(param->method.class, strlen(param->method.class)); + hash += zend_inline_hash_func(param->method.name, strlen(param->method.name)); + break; + + case FILE_PARAM: + hash += zend_inline_hash_func(param->file.name, strlen(param->file.name)); + hash += param->file.line; + if (param->num) + hash += param->num; + break; + + case ADDR_PARAM: + hash += param->addr; + break; + + case NUMERIC_PARAM: + hash += param->num; + break; + + case NUMERIC_FUNCTION_PARAM: + hash += zend_inline_hash_func(param->str, param->len); + hash += param->num; + break; + + case NUMERIC_METHOD_PARAM: + hash += zend_inline_hash_func(param->method.class, strlen(param->method.class)); + hash += zend_inline_hash_func(param->method.name, strlen(param->method.name)); + if (param->num) + hash+= param->num; + break; + + case EMPTY_PARAM: { /* do nothing */ } break; + } + + return hash; +} /* }}} */ + +PHPDBG_API zend_bool phpdbg_match_param(const phpdbg_param_t *l, const phpdbg_param_t *r TSRMLS_DC) /* {{{ */ +{ + if (l && r) { + if (l->type == r->type) { + switch (l->type) { + + case NUMERIC_FUNCTION_PARAM: + if (l->num != r->num) { + break; + } + /* break intentionally omitted */ + + case STR_PARAM: + return (l->len == r->len) && + (memcmp(l->str, r->str, l->len) == SUCCESS); + + case NUMERIC_PARAM: + return (l->num == r->num); + + case ADDR_PARAM: + return (l->addr == r->addr); + + case FILE_PARAM: { + if (l->file.line == r->file.line) { + size_t lengths[2] = { + strlen(l->file.name), strlen(r->file.name)}; + + if (lengths[0] == lengths[1]) { + if ((!l->num && !r->num) || (l->num == r->num)) { + return (memcmp( + l->file.name, r->file.name, lengths[0]) == SUCCESS); + } + } + } + } break; + + case NUMERIC_METHOD_PARAM: + if (l->num != r->num) { + break; + } + /* break intentionally omitted */ + + case METHOD_PARAM: { + size_t lengths[2] = { + strlen(l->method.class), strlen(r->method.class)}; + if (lengths[0] == lengths[1]) { + if (memcmp(l->method.class, r->method.class, lengths[0]) == SUCCESS) { + lengths[0] = strlen(l->method.name); + lengths[1] = strlen(r->method.name); + + if (lengths[0] == lengths[1]) { + return (memcmp( + l->method.name, r->method.name, lengths[0]) == SUCCESS); + } + } + } + } break; + + case EMPTY_PARAM: + return 1; + } + } + } + return 0; +} /* }}} */ + +PHPDBG_API phpdbg_input_t **phpdbg_read_argv(char *buffer, int *argc TSRMLS_DC) /* {{{ */ +{ + char *p; + char b[PHPDBG_MAX_CMD]; + int l=0; + enum states { + IN_BETWEEN, + IN_WORD, + IN_STRING + } state = IN_BETWEEN; + phpdbg_input_t **argv = NULL; + + argv = (phpdbg_input_t**) emalloc(sizeof(phpdbg_input_t*)); + (*argc) = 0; + +#define RESET_STATE() do { \ + phpdbg_input_t *arg = emalloc(sizeof(phpdbg_input_t)); \ + if (arg) { \ + b[l]=0; \ + arg->length = l; \ + arg->string = estrndup(b, arg->length); \ + arg->argv = NULL; \ + arg->argc = 0; \ + argv = (phpdbg_input_t**) erealloc(argv, sizeof(phpdbg_input_t*) * ((*argc)+1)); \ + argv[(*argc)++] = arg; \ + l = 0; \ + } \ + state = IN_BETWEEN; \ +} while (0) + + for (p = buffer; *p != '\0'; p++) { + int c = (unsigned char) *p; + switch (state) { + case IN_BETWEEN: + if (isspace(c)) { + continue; + } + if (c == '"') { + state = IN_STRING; + continue; + } + state = IN_WORD; + b[l++]=c; + continue; + + case IN_STRING: + if (c == '"') { + if (buffer[(p - buffer)-1] == '\\') { + b[l-1]=c; + continue; + } + RESET_STATE(); + } else { + b[l++]=c; + } + continue; + + case IN_WORD: + if (isspace(c)) { + RESET_STATE(); + } else { + b[l++]=c; + } + continue; + } + } + + switch (state) { + case IN_WORD: { + RESET_STATE(); + } break; + + case IN_STRING: + phpdbg_error( + "Malformed command line (unclosed quote) @ %ld: %s!", + (p - buffer)-1, &buffer[(p - buffer)-1]); + break; + + case IN_BETWEEN: + break; + } + + if ((*argc) == 0) { + /* not needed */ + efree(argv); + + /* to be sure */ + return NULL; + } + + return argv; +} /* }}} */ + +PHPDBG_API phpdbg_input_t *phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */ +{ + phpdbg_input_t *buffer = NULL; + char *cmd = NULL; + + if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { + if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && + (buffered == NULL)) { + fflush(PHPDBG_G(io)[PHPDBG_STDOUT]); + } + + if (buffered == NULL) { +#ifndef HAVE_LIBREADLINE + char buf[PHPDBG_MAX_CMD]; + if ((!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && !phpdbg_write(phpdbg_get_prompt(TSRMLS_C))) || + !fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) { + /* the user has gone away */ + phpdbg_error("Failed to read console!"); + PHPDBG_G(flags) |= (PHPDBG_IS_QUITTING|PHPDBG_IS_DISCONNECTED); + zend_bailout(); + return NULL; + } + + cmd = buf; +#else + if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { + char buf[PHPDBG_MAX_CMD]; + if (fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) { + cmd = buf; + } else cmd = NULL; + } else cmd = readline(phpdbg_get_prompt(TSRMLS_C)); + + if (!cmd) { + /* the user has gone away */ + phpdbg_error("Failed to read console!"); + PHPDBG_G(flags) |= (PHPDBG_IS_QUITTING|PHPDBG_IS_DISCONNECTED); + zend_bailout(); + return NULL; + } + + if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { + add_history(cmd); + } +#endif + } else cmd = buffered; + + /* allocate and sanitize buffer */ + buffer = (phpdbg_input_t*) ecalloc(1, sizeof(phpdbg_input_t)); + if (!buffer) { + return NULL; + } + + buffer->string = phpdbg_trim(cmd, strlen(cmd), &buffer->length); + + /* store constant pointer to start of buffer */ + buffer->start = (char* const*) buffer->string; + + buffer->argv = phpdbg_read_argv( + buffer->string, &buffer->argc TSRMLS_CC); + +#ifdef PHPDBG_DEBUG + if (buffer->argc) { + int arg = 0; + + while (arg < buffer->argc) { + phpdbg_debug( + "argv %d=%s", arg, buffer->argv[arg]->string); + arg++; + } + } +#endif + +#ifdef HAVE_LIBREADLINE + if (!buffered && cmd && + !(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { + free(cmd); + } +#endif + + return buffer; + } + + return NULL; +} /* }}} */ + +PHPDBG_API void phpdbg_destroy_argv(phpdbg_input_t **argv, int argc TSRMLS_DC) /* {{{ */ +{ + if (argv) { + if (argc) { + int arg; + for (arg=0; argstring) { + efree((*input)->string); + } + + phpdbg_destroy_argv( + (*input)->argv, (*input)->argc TSRMLS_CC); + + efree(*input); + } +} /* }}} */ + +PHPDBG_API int phpdbg_do_cmd(const phpdbg_command_t *command, phpdbg_input_t *input TSRMLS_DC) /* {{{ */ +{ + int rc = FAILURE; + + if (input->argc > 0) { + while (command && command->name && command->handler) { + if (((command->name_len == input->argv[0]->length) && + (memcmp(command->name, input->argv[0]->string, command->name_len) == SUCCESS)) || + (command->alias && + (input->argv[0]->length == 1) && + (command->alias == *input->argv[0]->string))) { + + phpdbg_param_t param; + + param.type = EMPTY_PARAM; + + if (input->argc > 1) { + if (command->subs) { + phpdbg_input_t sub = *input; + + sub.string += input->argv[0]->length; + sub.length -= input->argv[0]->length; + + sub.string = phpdbg_trim( + sub.string, sub.length, &sub.length); + + sub.argc--; + sub.argv++; + + phpdbg_debug( + "trying sub commands in \"%s\" for \"%s\" with %d arguments", + command->name, sub.argv[0]->string, sub.argc-1); + + if (phpdbg_do_cmd(command->subs, &sub TSRMLS_CC) == SUCCESS) { + efree(sub.string); + return SUCCESS; + } + + efree(sub.string); + } + + /* no sub command found */ + { + char *store = input->string; + + input->string += input->argv[0]->length; + input->length -= input->argv[0]->length; + + input->string = phpdbg_trim( + input->string, input->length, &input->length); + + efree(store); + } + + /* pass parameter on */ + phpdbg_parse_param( + input->string, + input->length, + ¶m TSRMLS_CC); + } + + phpdbg_debug( + "found command %s for %s with %d arguments", + command->name, input->argv[0]->string, input->argc-1); + { + int arg; + for (arg=1; argargc; arg++) { + phpdbg_debug( + "\t#%d: [%s=%zu]", + arg, + input->argv[arg]->string, + input->argv[arg]->length); + } + } + + rc = command->handler(¶m, 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; + } + break; + } + command++; + } + } else { + /* this should NEVER happen */ + phpdbg_error( + "No function executed!!"); + } + + return rc; +} /* }}} */ + diff --git a/phpdbg_cmd.h b/phpdbg_cmd.h new file mode 100644 index 00000000000..e779fd4b55d --- /dev/null +++ b/phpdbg_cmd.h @@ -0,0 +1,169 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHPDBG_CMD_H +#define PHPDBG_CMD_H + +#include "TSRM.h" + +typedef struct _phpdbg_command_t phpdbg_command_t; + +/* {{{ Command and Parameter */ +enum { + NO_ARG = 0, + REQUIRED_ARG, + OPTIONAL_ARG +}; + +typedef enum { + EMPTY_PARAM = 0, + ADDR_PARAM, + FILE_PARAM, + METHOD_PARAM, + STR_PARAM, + NUMERIC_PARAM, + NUMERIC_FUNCTION_PARAM, + NUMERIC_METHOD_PARAM +} phpdbg_param_type; + +typedef struct _phpdbg_input_t phpdbg_input_t; + +struct _phpdbg_input_t { + char * const *start; + char *string; + size_t length; + phpdbg_input_t **argv; + int argc; +}; + +typedef struct _phpdbg_param { + phpdbg_param_type type; + long num; + zend_ulong addr; + struct { + char *name; + long line; + } file; + struct { + char *class; + char *name; + } method; + char *str; + size_t len; +} phpdbg_param_t; + +typedef int (*phpdbg_command_handler_t)(const phpdbg_param_t*, const phpdbg_input_t* TSRMLS_DC); + +struct _phpdbg_command_t { + const char *name; /* Command name */ + size_t name_len; /* Command name length */ + const char *tip; /* Menu tip */ + size_t tip_len; /* Menu tip length */ + char alias; /* Alias */ + phpdbg_command_handler_t handler; /* Command handler */ + const phpdbg_command_t *subs; /* Sub Commands */ + char arg_type; /* Accept args? */ +}; +/* }}} */ + +/* {{{ misc */ +#define PHPDBG_STRL(s) s, sizeof(s)-1 +#define PHPDBG_MAX_CMD 500 +#define PHPDBG_FRAME(v) (PHPDBG_G(frame).v) +#define PHPDBG_EX(v) (EG(current_execute_data)->v) + +typedef struct { + int num; + zend_execute_data *execute_data; +} phpdbg_frame_t; +/* }}} */ + + + +/* +* Workflow: +* 1) read input +* input takes the line from console, creates argc/argv +* 2) parse parameters into suitable types based on arg_type +* takes input from 1) and arg_type and creates parameters +* 3) do command +* executes commands +* 4) destroy parameters +* cleans up what was allocated by creation of parameters +* 5) destroy input +* cleans up what was allocated by creation of input +*/ + +/* +* Input Management +*/ +PHPDBG_API phpdbg_input_t* phpdbg_read_input(char *buffered TSRMLS_DC); +PHPDBG_API void phpdbg_destroy_input(phpdbg_input_t** TSRMLS_DC); + +/* +* Argument Management +*/ +PHPDBG_API phpdbg_input_t** phpdbg_read_argv(char *buffer, int *argc TSRMLS_DC); +PHPDBG_API void phpdbg_destroy_argv(phpdbg_input_t **argv, int argc TSRMLS_DC); +#define phpdbg_argv_is(n, s) \ + (memcmp(input->argv[n]->string, s, input->argv[n]->length) == SUCCESS) + +/* +* Parameter Management +*/ +PHPDBG_API phpdbg_param_type phpdbg_parse_param(const char*, size_t, phpdbg_param_t* TSRMLS_DC); +PHPDBG_API void phpdbg_clear_param(phpdbg_param_t* TSRMLS_DC); +PHPDBG_API void phpdbg_copy_param(const phpdbg_param_t*, phpdbg_param_t* TSRMLS_DC); +PHPDBG_API zend_bool phpdbg_match_param(const phpdbg_param_t *, const phpdbg_param_t * TSRMLS_DC); +PHPDBG_API zend_ulong phpdbg_hash_param(const phpdbg_param_t * TSRMLS_DC); +PHPDBG_API const char* phpdbg_get_param_type(const phpdbg_param_t* TSRMLS_DC); +PHPDBG_API char* phpdbg_param_tostring(const phpdbg_param_t *param, char **pointer TSRMLS_DC); + +/* +* Command Executor +*/ +PHPDBG_API int phpdbg_do_cmd(const phpdbg_command_t*, phpdbg_input_t* TSRMLS_DC); + +/** + * Command Declarators + */ +#define PHPDBG_COMMAND_HANDLER(name) phpdbg_do_##name + +#define PHPDBG_COMMAND_D_EX(name, tip, alias, handler, children, has_args) \ + {PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##handler, children, has_args} + +#define PHPDBG_COMMAND_D(name, tip, alias, children, has_args) \ + {PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##name, children, has_args} + +#define PHPDBG_COMMAND(name) int phpdbg_do_##name(const phpdbg_param_t *param, const phpdbg_input_t *input TSRMLS_DC) + +#define PHPDBG_COMMAND_ARGS param, input TSRMLS_CC + +#define PHPDBG_END_COMMAND {NULL, 0, NULL, 0, '\0', NULL, NULL, '\0'} + +/* +* Default Switch Case +*/ +#define phpdbg_default_switch_case() \ + default: \ + phpdbg_error("Unsupported parameter type (%s) for command", phpdbg_get_param_type(param TSRMLS_CC)); \ + break + +#endif /* PHPDBG_CMD_H */ diff --git a/phpdbg_frame.c b/phpdbg_frame.c new file mode 100644 index 00000000000..24aff59dd92 --- /dev/null +++ b/phpdbg_frame.c @@ -0,0 +1,206 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#include "zend.h" +#include "phpdbg.h" +#include "phpdbg_utils.h" +#include "phpdbg_frame.h" +#include "phpdbg_list.h" + +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); + +void phpdbg_restore_frame(TSRMLS_D) /* {{{ */ +{ + if (PHPDBG_FRAME(num) == 0) { + return; + } + + PHPDBG_FRAME(num) = 0; + + /* move things back */ + EG(current_execute_data) = PHPDBG_FRAME(execute_data); + + EG(opline_ptr) = &PHPDBG_EX(opline); + EG(active_op_array) = PHPDBG_EX(op_array); + EG(return_value_ptr_ptr) = PHPDBG_EX(original_return_value); + EG(active_symbol_table) = PHPDBG_EX(symbol_table); + EG(This) = PHPDBG_EX(current_this); + EG(scope) = PHPDBG_EX(current_scope); + EG(called_scope) = PHPDBG_EX(current_called_scope); +} /* }}} */ + +void phpdbg_switch_frame(int frame TSRMLS_DC) /* {{{ */ +{ + zend_execute_data *execute_data = PHPDBG_FRAME(num)?PHPDBG_FRAME(execute_data):EG(current_execute_data); + int i = 0; + + if (PHPDBG_FRAME(num) == frame) { + phpdbg_notice("Already in frame #%d", frame); + return; + } + + while (execute_data) { + if (i++ == frame) { + break; + } + + do { + execute_data = execute_data->prev_execute_data; + } while (execute_data && execute_data->opline == NULL); + } + + if (execute_data == NULL) { + phpdbg_error("No frame #%d", frame); + return; + } + + phpdbg_restore_frame(TSRMLS_C); + + if (frame > 0) { + PHPDBG_FRAME(num) = frame; + + /* backup things and jump back */ + PHPDBG_FRAME(execute_data) = EG(current_execute_data); + EG(current_execute_data) = execute_data; + + EG(opline_ptr) = &PHPDBG_EX(opline); + EG(active_op_array) = PHPDBG_EX(op_array); + PHPDBG_FRAME(execute_data)->original_return_value = EG(return_value_ptr_ptr); + EG(return_value_ptr_ptr) = PHPDBG_EX(original_return_value); + EG(active_symbol_table) = PHPDBG_EX(symbol_table); + EG(This) = PHPDBG_EX(current_this); + EG(scope) = PHPDBG_EX(current_scope); + EG(called_scope) = PHPDBG_EX(current_called_scope); + } + + phpdbg_notice("Switched to frame #%d", frame); + 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 + ); +} /* }}} */ + +static void phpdbg_dump_prototype(zval **tmp TSRMLS_DC) /* {{{ */ +{ + zval **funcname, **class, **type, **args, **argstmp; + char is_class; + + zend_hash_find(Z_ARRVAL_PP(tmp), "function", sizeof("function"), + (void **)&funcname); + + if ((is_class = zend_hash_find(Z_ARRVAL_PP(tmp), + "object", sizeof("object"), (void **)&class)) == FAILURE) { + is_class = zend_hash_find(Z_ARRVAL_PP(tmp), "class", sizeof("class"), + (void **)&class); + } else { + zend_get_object_classname(*class, (const char **)&Z_STRVAL_PP(class), + (zend_uint *)&Z_STRLEN_PP(class) TSRMLS_CC); + } + + if (is_class == SUCCESS) { + zend_hash_find(Z_ARRVAL_PP(tmp), "type", sizeof("type"), (void **)&type); + } + + phpdbg_write("%s%s%s(", + is_class == FAILURE?"":Z_STRVAL_PP(class), + is_class == FAILURE?"":Z_STRVAL_PP(type), + Z_STRVAL_PP(funcname) + ); + + if (zend_hash_find(Z_ARRVAL_PP(tmp), "args", sizeof("args"), + (void **)&args) == SUCCESS) { + HashPosition iterator; + const zend_function *func = phpdbg_get_function( + Z_STRVAL_PP(funcname), is_class == FAILURE ? NULL : Z_STRVAL_PP(class) TSRMLS_CC); + const zend_arg_info *arginfo = func ? func->common.arg_info : NULL; + int j = 0, m = func ? func->common.num_args : 0; + zend_bool is_variadic = 0; + + zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(args), &iterator); + while (zend_hash_get_current_data_ex(Z_ARRVAL_PP(args), + (void **) &argstmp, &iterator) == SUCCESS) { + if (j) { + phpdbg_write(", "); + } + if (m && j < m) { +#if PHP_VERSION_ID >= 50600 + is_variadic = arginfo[j].is_variadic; +#endif + phpdbg_write("%s=%s", + arginfo[j].name, is_variadic ? "[": ""); + } + ++j; + + zend_print_flat_zval_r(*argstmp TSRMLS_CC); + zend_hash_move_forward_ex(Z_ARRVAL_PP(args), &iterator); + } + if (is_variadic) { + phpdbg_write("]"); + } + } + phpdbg_write(")"); +} + +void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */ +{ + zval zbacktrace; + zval **tmp; + zval **file, **line; + HashPosition position; + int i = 1, limit = num; + int user_defined; + + if (limit < 0) { + phpdbg_error("Invalid backtrace size %d", limit); + } + + zend_fetch_debug_backtrace( + &zbacktrace, 0, 0, limit TSRMLS_CC); + + zend_hash_internal_pointer_reset_ex(Z_ARRVAL(zbacktrace), &position); + zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), (void**)&tmp, &position); + while (1) { + user_defined = zend_hash_find(Z_ARRVAL_PP(tmp), "file", sizeof("file"), (void **)&file); + zend_hash_find(Z_ARRVAL_PP(tmp), "line", sizeof("line"), (void **)&line); + zend_hash_move_forward_ex(Z_ARRVAL(zbacktrace), &position); + + if (zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), + (void**)&tmp, &position) == FAILURE) { + phpdbg_write("frame #0: {main} at %s:%ld", Z_STRVAL_PP(file), Z_LVAL_PP(line)); + break; + } + + if (user_defined == SUCCESS) { + phpdbg_write("frame #%d: ", i++); + phpdbg_dump_prototype(tmp TSRMLS_CC); + phpdbg_writeln(" at %s:%ld", Z_STRVAL_PP(file), Z_LVAL_PP(line)); + } else { + phpdbg_write(" => "); + phpdbg_dump_prototype(tmp TSRMLS_CC); + phpdbg_writeln(" (internal function)"); + } + } + + phpdbg_writeln(EMPTY); + zval_dtor(&zbacktrace); +} /* }}} */ diff --git a/phpdbg_frame.h b/phpdbg_frame.h new file mode 100644 index 00000000000..fbccd5404f5 --- /dev/null +++ b/phpdbg_frame.h @@ -0,0 +1,30 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHPDBG_FRAME_H +#define PHPDBG_FRAME_H + +#include "TSRM.h" + +void phpdbg_restore_frame(TSRMLS_D); +void phpdbg_switch_frame(int TSRMLS_DC); +void phpdbg_dump_backtrace(size_t TSRMLS_DC); + +#endif /* PHPDBG_FRAME_H */ diff --git a/phpdbg_help.c b/phpdbg_help.c new file mode 100644 index 00000000000..edb12659554 --- /dev/null +++ b/phpdbg_help.c @@ -0,0 +1,603 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#include "phpdbg.h" +#include "phpdbg_help.h" +#include "phpdbg_print.h" +#include "phpdbg_utils.h" +#include "phpdbg_break.h" +#include "phpdbg_list.h" +#include "phpdbg_info.h" +#include "phpdbg_set.h" + +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); + +PHPDBG_HELP(exec) /* {{{ */ +{ + phpdbg_help_header(); + phpdbg_writeln("\tWill attempt execution, if compilation has not yet taken place, it occurs now"); + phpdbg_writeln("The execution context must be set before execution can take place"); + phpdbg_help_footer(); + return SUCCESS; +} /* }}} */ + +PHPDBG_HELP(step) /* {{{ */ +{ + phpdbg_help_header(); + phpdbg_writeln("You can enable and disable stepping at any phpdbg prompt during execution"); + phpdbg_writeln(EMPTY); + phpdbg_notice("Examples"); + phpdbg_writeln("\t%sstepping 1", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%ss 1", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill enable stepping"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("While stepping is enabled you are presented with a prompt after the execution of each opcode"); + phpdbg_help_footer(); + return SUCCESS; +} /* }}} */ + +PHPDBG_HELP(next) /* {{{ */ +{ + phpdbg_help_header(); + phpdbg_write("Step back into the vm and execute the next opcode"); + phpdbg_writeln(EMPTY); + phpdbg_notice("Examples"); + phpdbg_writeln("\t%snext", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sn", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill cause control to be passed back to the vm, continuing execution"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("Note: is only useful while executing"); + phpdbg_help_footer(); + return SUCCESS; +} /* }}} */ + +PHPDBG_HELP(until) /* {{{ */ +{ + phpdbg_help_header(); + phpdbg_writeln("Step back into the vm, skipping breakpoints until the next source line"); + phpdbg_writeln(EMPTY); + phpdbg_notice("Examples"); + phpdbg_writeln("\t%suntil", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%su", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill cause control to be passed back to the vm, continuing execution"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("Note: is only useful while executing"); + phpdbg_help_footer(); + return SUCCESS; +} /* }}} */ + +PHPDBG_HELP(finish) /* {{{ */ +{ + phpdbg_help_header(); + phpdbg_writeln("Step back into the vm, skipping breakpoints until past the end of the current stack"); + phpdbg_writeln(EMPTY); + phpdbg_notice("Examples"); + phpdbg_writeln("\t%sfinish", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sF", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill cause control to be passed back to the vm, continuing execution"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("Note: this allows all breakpoints that would otherwise break execution in the current scope to be skipped"); + phpdbg_help_footer(); + return SUCCESS; +} /* }}} */ + +PHPDBG_HELP(leave) /* {{{ */ +{ + phpdbg_help_header(); + phpdbg_writeln("Step back into the vm, skipping breakpoints until the current stack is returning"); + phpdbg_writeln(EMPTY); + phpdbg_notice("Examples"); + phpdbg_writeln("\t%sleave", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sL", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill cause a break when instructed to leave the current context"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("Note: this allows inspection of the return value before it is returned"); + phpdbg_help_footer(); + return SUCCESS; +} /* }}} */ + +PHPDBG_HELP(compile) /* {{{ */ +{ + phpdbg_help_header(); + phpdbg_writeln("Pre-compilation of the execution context provides the opportunity to inspect opcodes before execution"); + phpdbg_writeln("The execution context must be set for compilation to succeed"); + phpdbg_writeln(EMPTY); + phpdbg_notice("Examples"); + phpdbg_writeln("\t%scompile", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sc", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill compile the current execution context, populating class/function/constant/etc tables"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("Note: It is a good idea to clean the environment between each compilation"); + phpdbg_help_footer(); + return SUCCESS; +} /* }}} */ + +PHPDBG_HELP(print) /* {{{ */ +{ + phpdbg_help_header(); + phpdbg_writeln("By default, print will show information about the current execution context"); + phpdbg_writeln("Other printing commands give access to instruction information"); + phpdbg_writeln(EMPTY); + phpdbg_notice("Examples"); + phpdbg_writeln("\t%sprint class \\my\\class", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sp c \\my\\class", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill print the instructions for the methods in \\my\\class"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("\t%sprint method \\my\\class::method", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sp m \\my\\class::method", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill print the instructions for \\my\\class::method"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("\t%sprint func .getSomething", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sp f .getSomething", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill print the instructions for ::getSomething in the active scope"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("\t%sprint func my_function", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sp f my_function", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill print the instructions for the global function my_function"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("\t%sprint opline", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sp o", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill print the instruction for the current opline"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("\t%sprint exec", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sp e", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill print the instructions for the execution context"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("\t%sprint stack", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sp s", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill print the instructions for the current stack"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("Specific printers loaded are show below:"); + phpdbg_notice("Commands"); + { + const phpdbg_command_t *print_command = phpdbg_print_commands; + + phpdbg_writeln("\tAlias\tCommand\t\tPurpose"); + while (print_command && print_command->name) { + if (print_command->alias) { + phpdbg_writeln("\t[%c]\t%s\t\t%s", print_command->alias, print_command->name, print_command->tip); + } else { + phpdbg_writeln("\t[ ]\t%s\t\t%s", print_command->name, print_command->tip); + } + ++print_command; + } + } + phpdbg_help_footer(); + return SUCCESS; +} /* }}} */ + +PHPDBG_HELP(run) /* {{{ */ +{ + phpdbg_help_header(); + phpdbg_writeln("Execute the current context inside the phpdbg vm"); + phpdbg_writeln(EMPTY); + phpdbg_notice("Examples"); + phpdbg_writeln("\t%srun", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sr", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill cause execution of the context, if it is set."); + phpdbg_writeln(EMPTY); + phpdbg_writeln("Note: The execution context must be set, but not necessarily compiled before execution occurs"); + phpdbg_help_footer(); + return SUCCESS; +} /* }}} */ + +PHPDBG_HELP(eval) /* {{{ */ +{ + phpdbg_help_header(); + phpdbg_writeln("Access to eval() allows you to change the environment during execution, careful though!!"); + phpdbg_writeln(EMPTY); + phpdbg_notice("Examples"); + phpdbg_writeln("\t%seval $variable", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sE $variable", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill print_r($variable) on the console, if it is defined"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("\t%seval $variable = \"Hello phpdbg :)\"", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sE $variable = \"Hello phpdbg :)\"", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill set $variable in the current scope"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("Note: eval() will always show the result; do not prefix the code with \"return\""); + phpdbg_help_footer(); + return SUCCESS; +} /* }}} */ + +PHPDBG_HELP(break) /* {{{ */ +{ + phpdbg_help_header(); + phpdbg_writeln("Setting a breakpoint stops execution at a specific stage"); + phpdbg_writeln(EMPTY); + phpdbg_notice("Examples"); + phpdbg_writeln("\t%sbreak [file] test.php:1", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sb [F] test.php:1", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill break execution on line 1 of test.php"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("\t%sbreak [func] my_function", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sb [f] my_function", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill break execution on entry to my_function"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("\t%sbreak [method] \\my\\class::method", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sb [m] \\my\\class::method", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill break execution on entry to \\my\\class::method"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("\t%sbreak [address] 0x7ff68f570e08", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sb [a] 0x7ff68f570e08", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill break at the opline with the address provided"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("\t%sbreak [address] my_function#1", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sb [a] my_function#1", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill break at the opline number 1 of the function my_function"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("\t%sbreak [address] \\my\\class::method#2", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sb [a] \\my\\class::method#2", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill break at the opline number 2 of the method \\my\\class::method"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("\t%sbreak address test.php:3", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sb a test.php:3", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill break at the opline number 3 of test.php"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("\t%sbreak [lineno] 200", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sb [l] 200", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill break at line 200 of the currently executing file"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("\t%sbreak on ($expression == true)", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sb on ($expression == true)", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill break when the condition evaluates to true"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("\t%sbreak at phpdbg::isGreat if ($expression == true)", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill break at every opcode in phpdbg::isGreat when the condition evaluates to true"); + phpdbg_writeln("\t%sbreak at test.php:20 if ($expression == true)", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill break at every opcode on line 20 of test.php when the condition evaluates to true"); + phpdbg_write("\t"); + phpdbg_notice("The location can be anything accepted by file, func, method, or address break commands"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("\t%sbreak op ZEND_ADD", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sb O ZEND_ADD", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill break on every occurence of the opcode provided"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("\t%sbreak del 1", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sb d 1", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill remove the breakpoint with the given identifier"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("Note: An address is only valid for the current compilation"); + phpdbg_writeln(EMPTY); + phpdbg_notice("The parameters enclosed by [] are usually optional, but help avoid ambigious commands"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("Specific breakers loaded are show below:"); + phpdbg_notice("Commands"); + { + const phpdbg_command_t *break_command = phpdbg_break_commands; + + phpdbg_writeln("\tAlias\tCommand\t\tPurpose"); + while (break_command && break_command->name) { + if (break_command->alias) { + phpdbg_writeln("\t[%c]\t%s\t\t%s", break_command->alias, break_command->name, break_command->tip); + } else { + phpdbg_writeln("\t[ ]\t%s\t\t%s", break_command->name, break_command->tip); + } + ++break_command; + } + } + phpdbg_writeln("Note: Conditional breaks are costly, use them sparingly!"); + phpdbg_help_footer(); + return SUCCESS; +} /* }}} */ + +PHPDBG_HELP(clean) /* {{{ */ +{ + phpdbg_help_header(); + phpdbg_writeln("While debugging you may experience errors because of attempts to redeclare classes, constants or functions"); + phpdbg_writeln("Cleaning the environment cleans these tables, so that files can be recompiled without exiting phpdbg"); + phpdbg_help_footer(); + return SUCCESS; +} /* }}} */ + +PHPDBG_HELP(clear) /* {{{ */ +{ + phpdbg_help_header(); + phpdbg_writeln("Clearing breakpoints means you can once again run code without interruption"); + phpdbg_writeln("Note: all breakpoints are lost; be sure debugging is complete before clearing"); + phpdbg_help_footer(); + return SUCCESS; +} /* }}} */ + +PHPDBG_HELP(info) /* {{{ */ +{ + phpdbg_help_header(); + phpdbg_writeln("info commands provide quick access to various types of information about the PHP environment"); + phpdbg_writeln("Specific info commands are show below:"); + phpdbg_notice("Commands"); + { + const phpdbg_command_t *info_command = phpdbg_info_commands; + + phpdbg_writeln("\tAlias\tCommand\t\tPurpose"); + while (info_command && info_command->name) { + if (info_command->alias) { + phpdbg_writeln("\t[%c]\t%s\t\t%s", info_command->alias, info_command->name, info_command->tip); + } else { + phpdbg_writeln("\t[ ]\t%s\t\t%s", info_command->name, info_command->tip); + } + ++info_command; + } + } + + phpdbg_help_footer(); + return SUCCESS; +} /* }}} */ + +PHPDBG_HELP(quiet) /* {{{ */ +{ + phpdbg_help_header(); + phpdbg_writeln("Setting quietness on will stop the OPLINE output during execution"); + phpdbg_writeln(EMPTY); + phpdbg_notice("Examples"); + phpdbg_writeln("\t%squiet 1", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sQ 1", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill silence OPLINE output, while"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("\t%squiet 0", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sQ 0", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill enable OPLINE output again"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("Note: Quietness is disabled automatically while stepping"); + phpdbg_help_footer(); + return SUCCESS; +} /* }}} */ + +PHPDBG_HELP(back) /* {{{ */ +{ + phpdbg_help_header(); + phpdbg_writeln("The backtrace is built with the default debug backtrace functionality"); + phpdbg_writeln(EMPTY); + phpdbg_notice("Examples"); + phpdbg_writeln("\t%sback 5", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%st 5", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill limit the number of frames to 5, the default is no limit"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("Note: it is not necessary for an exception to be thrown to show a backtrace"); + phpdbg_help_footer(); + return SUCCESS; +} /* }}} */ + +PHPDBG_HELP(frame) /* {{{ */ +{ + phpdbg_help_header(); + phpdbg_writeln("When viewing a backtrace, it is sometimes useful to jump to a frame in that trace"); + phpdbg_writeln(EMPTY); + phpdbg_notice("Examples"); + phpdbg_writeln("\t%sframe 2", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sf 2", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill go to frame 2, temporarily affecting scope and allowing access to the variables in that frame"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("Note: the current frame is restored when execution continues"); + phpdbg_help_footer(); + return SUCCESS; +} /* }}} */ + +PHPDBG_HELP(list) /* {{{ */ +{ + phpdbg_help_header(); + phpdbg_writeln("The list command displays source code for the given argument"); + phpdbg_writeln(EMPTY); + phpdbg_notice("Examples"); + phpdbg_writeln("\t%slist [lines] 2", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sl [l] 2", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill print next 2 lines from the current file"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("\t%slist [func] my_function", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sl [f] my_function", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill print the source of the global function \"my_function\""); + phpdbg_writeln(EMPTY); + phpdbg_writeln("\t%slist [func] .mine", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sl [f] .mine", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill print the source of the method \"mine\" from the active scope"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("\t%slist [method] my::method", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sl [m] my::method", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill print the source of \"my::method\""); + phpdbg_writeln(EMPTY); + phpdbg_writeln("\t%slist c myClass", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sl c myClass", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill print the source of \"myClass\""); + phpdbg_writeln(EMPTY); + phpdbg_writeln("Note: before listing functions you must have a populated function table, try compile!!"); + phpdbg_writeln(EMPTY); + phpdbg_notice("The parameters enclosed by [] are usually optional, but help avoid ambigious commands"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("Specific listers loaded are show below:"); + phpdbg_notice("Commands"); + { + const phpdbg_command_t *list_command = phpdbg_list_commands; + + phpdbg_writeln("\tAlias\tCommand\t\tPurpose"); + while (list_command && list_command->name) { + if (list_command->alias) { + phpdbg_writeln("\t[%c]\t%s\t\t%s", list_command->alias, list_command->name, list_command->tip); + } else { + phpdbg_writeln("\t[ ]\t%s\t\t%s", list_command->name, list_command->tip); + } + ++list_command; + } + } + phpdbg_help_footer(); + return SUCCESS; +} /* }}} */ + +PHPDBG_HELP(oplog) /* {{{ */ +{ + phpdbg_help_header(); + phpdbg_writeln("Even when quietness is enabled you may wish to save opline logs to a file"); + phpdbg_writeln("Setting a new oplog closes the previously open log"); + phpdbg_writeln("The log includes a high resolution timestamp on each entry"); + phpdbg_writeln(EMPTY); + phpdbg_notice("Examples"); + phpdbg_writeln("\t%soplog /path/to/my.oplog", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sO /path/to/my.oplog", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill open the file /path/to/my.oplog for writing, creating it if it does not exist"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("\t%soplog 0", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sO 0", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill close the currently open log file, disabling oplog"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("Note: upon failure to open a new oplog, the last oplog is held open"); + phpdbg_help_footer(); + return SUCCESS; +} /* }}} */ + +PHPDBG_HELP(set) /* {{{ */ +{ + phpdbg_help_header(); + phpdbg_writeln("Configure how phpdbg looks and behaves with the set command"); + phpdbg_writeln("Specific set commands are show below:"); + phpdbg_notice("Commands"); + { + const phpdbg_command_t *set_command = phpdbg_set_commands; + + phpdbg_writeln("\tAlias\tCommand\t\tPurpose"); + while (set_command && set_command->name) { + if (set_command->alias) { + phpdbg_writeln("\t[%c]\t%s\t\t%s", set_command->alias, set_command->name, set_command->tip); + } else { + phpdbg_writeln("\t[ ]\t%s\t\t%s", set_command->name, set_command->tip); + } + ++set_command; + } + } +#ifndef _WIN32 + phpdbg_notice("Colors"); + { + const phpdbg_color_t *color = phpdbg_get_colors(TSRMLS_C); + + if (PHPDBG_G(flags) & PHPDBG_IS_COLOURED) { + phpdbg_writeln("\t%-20s\t\tExample", "Name"); + } else { + phpdbg_writeln("\tName"); + } + + while (color && color->name) { + if (PHPDBG_G(flags) & PHPDBG_IS_COLOURED) { + phpdbg_writeln( + "\t%-20s\t\t\033[%smphpdbg rocks :)\033[0m", color->name, color->code); + } else { + phpdbg_writeln("\t%s", color->name); + } + ++color; + } + } + phpdbg_writeln("The for set color can be \"prompt\", \"notice\", or \"error\""); +#endif + phpdbg_help_footer(); + return SUCCESS; +} /* }}} */ + +PHPDBG_HELP(register) /* {{{ */ +{ + phpdbg_help_header(); + phpdbg_writeln("Register any global function for use as a command in phpdbg console"); + phpdbg_writeln(EMPTY); + phpdbg_notice("Examples"); + phpdbg_writeln("\t%sregister scandir", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%sR scandir", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill register the scandir function for use in phpdbg"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("Note: arguments passed as strings, return (if present) print_r'd on console"); + if (zend_hash_num_elements(&PHPDBG_G(registered))) { + HashPosition position; + char *name = NULL; + zend_uint name_len = 0; + + phpdbg_notice("Registered Functions (%d)", zend_hash_num_elements(&PHPDBG_G(registered))); + for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(registered), &position); + zend_hash_get_current_key_ex(&PHPDBG_G(registered), &name, &name_len, NULL, 1, &position) == HASH_KEY_IS_STRING; + zend_hash_move_forward_ex(&PHPDBG_G(registered), &position)) { + phpdbg_writeln("|-------> %s", name); + efree(name); + } + } + + phpdbg_help_footer(); + return SUCCESS; +} /* }}} */ + +PHPDBG_HELP(source) /* {{{ */ +{ + phpdbg_help_header(); + phpdbg_writeln("Sourcing a phpdbginit during your debugging session might save some time"); + phpdbg_writeln("The source command can also be used to export breakpoints to a phpdbginit file"); + phpdbg_writeln(EMPTY); + phpdbg_notice("Examples"); + phpdbg_writeln("\t%ssource /my/init", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%s. /my/init", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill execute the phpdbginit file at /my/init"); + phpdbg_writeln("\t%ssource export /my/init", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%s. export /my/init", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill export breakpoints to /my/init in phpdbginit file format"); + phpdbg_help_footer(); + return SUCCESS; +} /* }}} */ + +PHPDBG_HELP(shell) /* {{{ */ +{ + phpdbg_help_header(); + phpdbg_writeln("Direct access to shell commands saves having to switch windows/consoles"); + phpdbg_writeln(EMPTY); + phpdbg_notice("Examples"); + phpdbg_writeln("\t%sshell ls /usr/src/php-src", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\t%s- ls /usr/src/php-src", phpdbg_get_prompt(TSRMLS_C)); + phpdbg_writeln("\tWill execute ls /usr/src/php-src, displaying the output in the console"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("Note: read only commands please!"); + phpdbg_help_footer(); + return SUCCESS; +} /* }}} */ + +PHPDBG_HELP(options) /* {{{ */ +{ + phpdbg_help_header(); + phpdbg_writeln("Below are the command line options supported by phpdbg"); + phpdbg_notice("Command Line Options and Flags"); + phpdbg_writeln(" -c\t-c/my/php.ini\t\tSet php.ini file to load"); + phpdbg_writeln(" -d\t-dmemory_limit=4G\tSet a php.ini directive"); + phpdbg_writeln(" -n\tN/A\t\t\tDisable default php.ini"); + phpdbg_writeln(" -q\tN/A\t\t\tSupress welcome banner"); + phpdbg_writeln(" -e\t-emytest.php\t\tSet execution context"); + phpdbg_writeln(" -v\tN/A\t\t\tEnable oplog output"); + phpdbg_writeln(" -s\tN/A\t\t\tEnable stepping"); + phpdbg_writeln(" -b\tN/A\t\t\tDisable colour"); + phpdbg_writeln(" -i\t-imy.init\t\tSet .phpdbginit file"); + phpdbg_writeln(" -I\tN/A\t\t\tIgnore default .phpdbginit"); + phpdbg_writeln(" -O\t-Omy.oplog\t\tSets oplog output file"); + phpdbg_writeln(" -r\tN/A\t\t\tRun execution context"); + phpdbg_writeln(" -E\tN/A\t\t\tEnable step through eval, careful!"); + phpdbg_writeln(" -S\t-Scli\t\t\tOverride SAPI name, careful!"); +#ifndef _WIN32 + phpdbg_writeln(" -l\t-l4000\t\t\tSetup remote console ports"); + phpdbg_writeln(" -a\t-a192.168.0.3\t\tSetup remote console bind address"); +#endif + phpdbg_writeln(" -V\tN/A\t\t\tVersion number"); + phpdbg_notice("Passing -rr will quit automatically after execution"); +#ifndef _WIN32 + phpdbg_writeln("Remote Console Mode"); + phpdbg_notice("For security, phpdbg will bind only to the loopback interface by default"); + phpdbg_writeln("-a without an argument implies all; phpdbg will bind to all available interfaces."); + phpdbg_writeln("specify both stdin and stdout with -lstdin/stdout; by default stdout is stdin * 2."); + phpdbg_notice("Steps should be taken to secure this service if bound to a public interface/port"); +#endif + phpdbg_help_footer(); + return SUCCESS; +} /* }}} */ diff --git a/phpdbg_help.h b/phpdbg_help.h new file mode 100644 index 00000000000..012a1b49e73 --- /dev/null +++ b/phpdbg_help.h @@ -0,0 +1,92 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHPDBG_HELP_H +#define PHPDBG_HELP_H + +#include "TSRM.h" +#include "phpdbg.h" +#include "phpdbg_cmd.h" + +#define PHPDBG_HELP(name) PHPDBG_COMMAND(help_##name) + +/** + * Helper Forward Declarations + */ +PHPDBG_HELP(exec); +PHPDBG_HELP(compile); +PHPDBG_HELP(step); +PHPDBG_HELP(next); +PHPDBG_HELP(run); +PHPDBG_HELP(eval); +PHPDBG_HELP(until); +PHPDBG_HELP(finish); +PHPDBG_HELP(leave); +PHPDBG_HELP(print); +PHPDBG_HELP(break); +PHPDBG_HELP(clean); +PHPDBG_HELP(clear); +PHPDBG_HELP(info); +PHPDBG_HELP(back); +PHPDBG_HELP(frame); +PHPDBG_HELP(quiet); +PHPDBG_HELP(list); +PHPDBG_HELP(set); +PHPDBG_HELP(register); +PHPDBG_HELP(options); +PHPDBG_HELP(source); +PHPDBG_HELP(shell); + +/** + * Commands + */ +static const phpdbg_command_t phpdbg_help_commands[] = { + PHPDBG_COMMAND_D_EX(exec, "the execution context should be a valid path", 'e', help_exec, NULL, 0), + PHPDBG_COMMAND_D_EX(compile, "allow inspection of code before execution", 'c', help_compile, NULL, 0), + PHPDBG_COMMAND_D_EX(step, "step through execution to break at every opcode", 's', help_step, NULL, 0), + PHPDBG_COMMAND_D_EX(next, "continue executing while stepping or after breaking", 'n', help_next, NULL, 0), + PHPDBG_COMMAND_D_EX(run, "execute inside the phpdbg vm", 'r', help_run, NULL, 0), + PHPDBG_COMMAND_D_EX(eval, "access to eval() allows affecting the environment", 'E', help_eval, NULL, 0), + PHPDBG_COMMAND_D_EX(until, "continue until the current line is executed", 'u', help_until, NULL, 0), + PHPDBG_COMMAND_D_EX(finish, "continue until the current function has returned", 'F', help_finish, NULL, 0), + PHPDBG_COMMAND_D_EX(leave, "continue until the current function is returning", 'L', help_leave, NULL, 0), + PHPDBG_COMMAND_D_EX(print, "print context information or instructions", 'p', help_print, NULL, 0), + PHPDBG_COMMAND_D_EX(break, "breakpoints allow execution interruption", 'b', help_break, NULL, 0), + PHPDBG_COMMAND_D_EX(clean, "resetting the environment is useful while debugging", 'X', help_clean, NULL, 0), + PHPDBG_COMMAND_D_EX(clear, "reset breakpoints to execute without interruption", 'c', help_clear, NULL, 0), + PHPDBG_COMMAND_D_EX(info, "quick access to useful information on the console", 'i', help_info, NULL, 0), + PHPDBG_COMMAND_D_EX(back, "show debug backtrace information during execution", 't', help_back, NULL, 0), + PHPDBG_COMMAND_D_EX(frame, "switch to a frame in the current stack for inspection", 'f', help_frame, NULL, 0), + PHPDBG_COMMAND_D_EX(quiet, "be quiet during execution", 'Q', help_quiet, NULL, 0), + PHPDBG_COMMAND_D_EX(list, "list code gives you quick access to code", 'l', help_list, NULL, 0), + PHPDBG_COMMAND_D_EX(set, "configure how phpdbg looks and behaves", 'S', help_set, NULL, 0), + PHPDBG_COMMAND_D_EX(register, "register a function for use as a command", 'R', help_register,NULL, 0), + PHPDBG_COMMAND_D_EX(options, "show information about command line options", 'o', help_options, NULL, 0), + PHPDBG_COMMAND_D_EX(source, "load a phpdbginit file at the console", '.', help_source, NULL, 0), + PHPDBG_COMMAND_D_EX(shell, "execute system commands with direct shell access", '-', help_shell, NULL, 0), + PHPDBG_END_COMMAND +}; + +#define phpdbg_help_header() \ + phpdbg_notice("Welcome to phpdbg, the interactive PHP debugger, v%s", PHPDBG_VERSION); +#define phpdbg_help_footer() \ + phpdbg_notice("Please report bugs to <%s>", PHPDBG_ISSUES); + +#endif /* PHPDBG_HELP_H */ diff --git a/phpdbg_info.c b/phpdbg_info.c new file mode 100644 index 00000000000..1744f59215b --- /dev/null +++ b/phpdbg_info.c @@ -0,0 +1,355 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#include "php.h" +#include "phpdbg.h" +#include "phpdbg_utils.h" +#include "phpdbg_info.h" +#include "phpdbg_bp.h" + +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); + +PHPDBG_INFO(break) /* {{{ */ +{ + phpdbg_print_breakpoints(PHPDBG_BREAK_FILE TSRMLS_CC); + phpdbg_print_breakpoints(PHPDBG_BREAK_SYM TSRMLS_CC); + phpdbg_print_breakpoints(PHPDBG_BREAK_METHOD TSRMLS_CC); + phpdbg_print_breakpoints(PHPDBG_BREAK_OPLINE TSRMLS_CC); + phpdbg_print_breakpoints(PHPDBG_BREAK_FILE_OPLINE TSRMLS_CC); + phpdbg_print_breakpoints(PHPDBG_BREAK_FUNCTION_OPLINE TSRMLS_CC); + phpdbg_print_breakpoints(PHPDBG_BREAK_METHOD_OPLINE TSRMLS_CC); + phpdbg_print_breakpoints(PHPDBG_BREAK_COND TSRMLS_CC); + phpdbg_print_breakpoints(PHPDBG_BREAK_OPCODE TSRMLS_CC); + + return SUCCESS; +} /* }}} */ + +PHPDBG_INFO(files) /* {{{ */ +{ + HashPosition pos; + char *fname; + + phpdbg_notice("Included files: %d", + zend_hash_num_elements(&EG(included_files))); + + zend_hash_internal_pointer_reset_ex(&EG(included_files), &pos); + while (zend_hash_get_current_key_ex(&EG(included_files), &fname, + NULL, NULL, 0, &pos) == HASH_KEY_IS_STRING) { + phpdbg_writeln("File: %s", fname); + zend_hash_move_forward_ex(&EG(included_files), &pos); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_INFO(error) /* {{{ */ +{ + if (PG(last_error_message)) { + phpdbg_writeln("Last error: %s at %s line %d", + PG(last_error_message), PG(last_error_file), PG(last_error_lineno)); + } else { + phpdbg_notice("No error found!"); + } + return SUCCESS; +} /* }}} */ + +PHPDBG_INFO(vars) /* {{{ */ +{ + HashTable vars; + HashPosition pos; + char *var; + zval **data; + + if (!EG(active_op_array)) { + phpdbg_error("No active op array!"); + return SUCCESS; + } + + if (!EG(active_symbol_table)) { + zend_rebuild_symbol_table(TSRMLS_C); + + if (!EG(active_symbol_table)) { + phpdbg_error("No active symbol table!"); + return SUCCESS; + } + } + + zend_hash_init(&vars, 8, NULL, NULL, 0); + + zend_hash_internal_pointer_reset_ex(EG(active_symbol_table), &pos); + while (zend_hash_get_current_key_ex(EG(active_symbol_table), &var, + NULL, NULL, 0, &pos) == HASH_KEY_IS_STRING) { + zend_hash_get_current_data_ex(EG(active_symbol_table), (void **)&data, &pos); + if (*var != '_') { + zend_hash_update( + &vars, var, strlen(var)+1, (void**)data, sizeof(zval*), NULL); + } + zend_hash_move_forward_ex(EG(active_symbol_table), &pos); + } + + { + zend_op_array *ops = EG(active_op_array); + + if (ops->function_name) { + if (ops->scope) { + phpdbg_notice( + "Variables in %s::%s() (%d)", ops->scope->name, ops->function_name, zend_hash_num_elements(&vars)); + } else { + phpdbg_notice( + "Variables in %s() (%d)", ops->function_name, zend_hash_num_elements(&vars)); + } + } else { + if (ops->filename) { + phpdbg_notice( + "Variables in %s (%d)", ops->filename, zend_hash_num_elements(&vars)); + } else { + phpdbg_notice( + "Variables @ %p (%d)", ops, zend_hash_num_elements(&vars)); + } + } + } + + if (zend_hash_num_elements(&vars)) { + phpdbg_writeln("Address\t\tRefs\tType\t\tVariable"); + for (zend_hash_internal_pointer_reset_ex(&vars, &pos); + zend_hash_get_current_data_ex(&vars, (void**) &data, &pos) == SUCCESS; + zend_hash_move_forward_ex(&vars, &pos)) { + char *var; + + zend_hash_get_current_key_ex(&vars, &var, NULL, NULL, 0, &pos); + + if (*data) { + phpdbg_write( + "%p\t%d\t", + *data, + Z_REFCOUNT_PP(data)); + + switch (Z_TYPE_PP(data)) { + case IS_STRING: phpdbg_write("(string)\t"); break; + case IS_LONG: phpdbg_write("(integer)\t"); break; + case IS_DOUBLE: phpdbg_write("(float)\t"); break; + case IS_RESOURCE: phpdbg_write("(resource)\t"); break; + case IS_ARRAY: phpdbg_write("(array)\t"); break; + case IS_OBJECT: phpdbg_write("(object)\t"); break; + case IS_NULL: phpdbg_write("(null)\t"); break; + } + + if (Z_TYPE_PP(data) == IS_RESOURCE) { + int type; + + phpdbg_writeln( + "%s$%s", Z_ISREF_PP(data) ? "&": "", var); + if (zend_list_find(Z_RESVAL_PP(data), &type)) { + phpdbg_write( + "|-------(typeof)------> (%s)", + zend_rsrc_list_get_rsrc_type(type TSRMLS_CC)); + } else { + phpdbg_write( + "|-------(typeof)------> (unknown)"); + } + phpdbg_writeln(EMPTY); + } else if (Z_TYPE_PP(data) == IS_OBJECT) { + phpdbg_writeln( + "%s$%s", Z_ISREF_PP(data) ? "&": "", var); + phpdbg_write( + "|-----(instanceof)----> (%s)", Z_OBJCE_PP(data)->name); + phpdbg_writeln(EMPTY); + } else { + phpdbg_write( + "%s$%s", Z_ISREF_PP(data) ? "&": "", var); + } + } else { + phpdbg_write( + "n/a\tn/a\tn/a\t$%s", var); + } + phpdbg_writeln(EMPTY); + } + } + + zend_hash_destroy(&vars); + + return SUCCESS; +} /* }}} */ + +PHPDBG_INFO(literal) /* {{{ */ +{ + if ((EG(in_execution) && EG(active_op_array)) || PHPDBG_G(ops)) { + zend_op_array *ops = EG(active_op_array) ? EG(active_op_array) : PHPDBG_G(ops); + int literal = 0, count = ops->last_literal-1; + + if (ops->function_name) { + if (ops->scope) { + phpdbg_notice( + "Literal Constants in %s::%s() (%d)", ops->scope->name, ops->function_name, count); + } else { + phpdbg_notice( + "Literal Constants in %s() (%d)", ops->function_name, count); + } + } else { + if (ops->filename) { + phpdbg_notice( + "Literal Constants in %s (%d)", ops->filename, count); + } else { + phpdbg_notice( + "Literal Constants @ %p (%d)", ops, count); + } + } + + while (literal < ops->last_literal) { + if (Z_TYPE(ops->literals[literal].constant) != IS_NULL) { + phpdbg_write("|-------- C%u -------> [", literal); + zend_print_zval( + &ops->literals[literal].constant, 0); + phpdbg_write("]"); + phpdbg_writeln(EMPTY); + } + literal++; + } + } else { + phpdbg_error("Not executing!"); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_INFO(memory) /* {{{ */ +{ + if (is_zend_mm(TSRMLS_C)) { + phpdbg_notice("Memory Manager Information"); + phpdbg_notice("Current"); + phpdbg_writeln("|-------> Used:\t%.3f kB", + (float) (zend_memory_usage(0 TSRMLS_CC)/1024)); + phpdbg_writeln("|-------> Real:\t%.3f kB", + (float) (zend_memory_usage(1 TSRMLS_CC)/1024)); + phpdbg_notice("Peak"); + phpdbg_writeln("|-------> Used:\t%.3f kB", + (float) (zend_memory_peak_usage(0 TSRMLS_CC)/1024)); + phpdbg_writeln("|-------> Real:\t%.3f kB", + (float) (zend_memory_peak_usage(1 TSRMLS_CC)/1024)); + } else { + phpdbg_error("Memory Manager Disabled!"); + } + return SUCCESS; +} /* }}} */ + +static inline void phpdbg_print_class_name(zend_class_entry **ce TSRMLS_DC) /* {{{ */ +{ + phpdbg_write( + "%s %s %s (%d)", + ((*ce)->type == ZEND_USER_CLASS) ? + "User" : "Internal", + ((*ce)->ce_flags & ZEND_ACC_INTERFACE) ? + "Interface" : + ((*ce)->ce_flags & ZEND_ACC_ABSTRACT) ? + "Abstract Class" : + "Class", + (*ce)->name, zend_hash_num_elements(&(*ce)->function_table)); +} /* }}} */ + +PHPDBG_INFO(classes) /* {{{ */ +{ + HashPosition position; + zend_class_entry **ce; + HashTable classes; + + zend_hash_init(&classes, 8, NULL, NULL, 0); + + for (zend_hash_internal_pointer_reset_ex(EG(class_table), &position); + zend_hash_get_current_data_ex(EG(class_table), (void**)&ce, &position) == SUCCESS; + zend_hash_move_forward_ex(EG(class_table), &position)) { + + if ((*ce)->type == ZEND_USER_CLASS) { + zend_hash_next_index_insert( + &classes, ce, sizeof(ce), NULL); + } + } + + phpdbg_notice("User Classes (%d)", + zend_hash_num_elements(&classes)); + + for (zend_hash_internal_pointer_reset_ex(&classes, &position); + zend_hash_get_current_data_ex(&classes, (void**)&ce, &position) == SUCCESS; + zend_hash_move_forward_ex(&classes, &position)) { + + phpdbg_print_class_name(ce TSRMLS_CC); + phpdbg_writeln(EMPTY); + + if ((*ce)->parent) { + zend_class_entry *pce = (*ce)->parent; + do { + phpdbg_write("|-------- "); + phpdbg_print_class_name(&pce TSRMLS_CC); + phpdbg_writeln(EMPTY); + } while ((pce = pce->parent)); + } + + if ((*ce)->info.user.filename) { + phpdbg_writeln( + "|---- in %s on line %u", + (*ce)->info.user.filename, + (*ce)->info.user.line_start); + } else { + phpdbg_writeln("|---- no source code"); + } + phpdbg_writeln(EMPTY); + } + + zend_hash_destroy(&classes); + + return SUCCESS; +} /* }}} */ + +PHPDBG_INFO(funcs) /* {{{ */ +{ + HashPosition position; + zend_function *zf, **pzf; + HashTable functions; + + zend_hash_init(&functions, 8, NULL, NULL, 0); + + for (zend_hash_internal_pointer_reset_ex(EG(function_table), &position); + zend_hash_get_current_data_ex(EG(function_table), (void**)&zf, &position) == SUCCESS; + zend_hash_move_forward_ex(EG(function_table), &position)) { + + if (zf->type == ZEND_USER_FUNCTION) { + zend_hash_next_index_insert( + &functions, (void**) &zf, sizeof(zend_function), NULL); + } + } + + phpdbg_notice("User Functions (%d)", + zend_hash_num_elements(&functions)); + + for (zend_hash_internal_pointer_reset_ex(&functions, &position); + zend_hash_get_current_data_ex(&functions, (void**)&pzf, &position) == SUCCESS; + zend_hash_move_forward_ex(&functions, &position)) { + zend_op_array *op_array = &((*pzf)->op_array); + + phpdbg_writeln( + "|-------- %s in %s on line %d", + op_array->function_name ? op_array->function_name : "{main}", + op_array->filename ? op_array->filename : "(no source code)", + op_array->line_start); + } + + zend_hash_destroy(&functions); + + return SUCCESS; +} /* }}} */ diff --git a/phpdbg_info.h b/phpdbg_info.h new file mode 100644 index 00000000000..5d538123707 --- /dev/null +++ b/phpdbg_info.h @@ -0,0 +1,49 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHPDBG_INFO_H +#define PHPDBG_INFO_H + +#include "phpdbg_cmd.h" + +#define PHPDBG_INFO(name) PHPDBG_COMMAND(info_##name) + +PHPDBG_INFO(files); +PHPDBG_INFO(break); +PHPDBG_INFO(classes); +PHPDBG_INFO(funcs); +PHPDBG_INFO(error); +PHPDBG_INFO(vars); +PHPDBG_INFO(literal); +PHPDBG_INFO(memory); + +static const phpdbg_command_t phpdbg_info_commands[] = { + PHPDBG_COMMAND_D_EX(break, "show breakpoints", 'b', info_break, NULL, 0), + PHPDBG_COMMAND_D_EX(files, "show included files", 'F', info_files, NULL, 0), + PHPDBG_COMMAND_D_EX(classes, "show loaded classes", 'c', info_classes, NULL, 0), + PHPDBG_COMMAND_D_EX(funcs, "show loaded classes", 'f', info_funcs, NULL, 0), + PHPDBG_COMMAND_D_EX(error, "show last error", 'e', info_error, NULL, 0), + PHPDBG_COMMAND_D_EX(vars, "show active variables", 'v', info_vars, NULL, 0), + PHPDBG_COMMAND_D_EX(literal, "show active literal constants", 'l', info_literal, NULL, 0), + PHPDBG_COMMAND_D_EX(memory, "show memory manager stats", 'm', info_memory, NULL, 0), + PHPDBG_END_COMMAND +}; + +#endif /* PHPDBG_INFO_H */ diff --git a/phpdbg_list.c b/phpdbg_list.c new file mode 100644 index 00000000000..b49be857efa --- /dev/null +++ b/phpdbg_list.c @@ -0,0 +1,279 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#include +#include +#include +#ifndef _WIN32 +# include +# include +#endif +#include +#include "phpdbg.h" +#include "phpdbg_list.h" +#include "phpdbg_utils.h" + +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); + +PHPDBG_LIST(lines) /* {{{ */ +{ + if (!PHPDBG_G(exec) && !zend_is_executing(TSRMLS_C)) { + phpdbg_error("Not executing, and execution context not set"); + return SUCCESS; + } + + switch (param->type) { + case NUMERIC_PARAM: + case EMPTY_PARAM: + phpdbg_list_file(phpdbg_current_file(TSRMLS_C), + param->type == EMPTY_PARAM ? 0 : (param->num < 0 ? 1 - param->num : param->num), + (param->type != EMPTY_PARAM && param->num < 0 ? param->num : 0) + zend_get_executed_lineno(TSRMLS_C), + 0 TSRMLS_CC); + break; + case FILE_PARAM: + phpdbg_list_file(param->file.name, param->file.line, 0, 0 TSRMLS_CC); + break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_LIST(func) /* {{{ */ +{ + switch (param->type) { + case STR_PARAM: + phpdbg_list_function_byname( + param->str, param->len TSRMLS_CC); + break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_LIST(method) /* {{{ */ +{ + switch (param->type) { + case METHOD_PARAM: { + zend_class_entry **ce; + + if (zend_lookup_class(param->method.class, strlen(param->method.class), &ce TSRMLS_CC) == SUCCESS) { + zend_function *function; + char *lcname = zend_str_tolower_dup(param->method.name, strlen(param->method.name)); + + if (zend_hash_find(&(*ce)->function_table, lcname, strlen(lcname)+1, (void**) &function) == SUCCESS) { + phpdbg_list_function(function TSRMLS_CC); + } else { + phpdbg_error("Could not find %s::%s", param->method.class, param->method.name); + } + + efree(lcname); + } else { + phpdbg_error("Could not find the class %s", param->method.class); + } + } break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_LIST(class) /* {{{ */ +{ + switch (param->type) { + case STR_PARAM: { + zend_class_entry **ce; + + if (zend_lookup_class(param->str, param->len, &ce TSRMLS_CC) == SUCCESS) { + if ((*ce)->type == ZEND_USER_CLASS) { + if ((*ce)->info.user.filename) { + phpdbg_list_file( + (*ce)->info.user.filename, + (*ce)->info.user.line_end - (*ce)->info.user.line_start + 1, + (*ce)->info.user.line_start, 0 TSRMLS_CC + ); + } else { + phpdbg_error("The source of the requested class (%s) cannot be found", (*ce)->name); + } + } else { + phpdbg_error("The class requested (%s) is not user defined", (*ce)->name); + } + } else { + phpdbg_error("The requested class (%s) could not be found", param->str); + } + } break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +void phpdbg_list_file(const char *filename, long count, long offset, int highlight TSRMLS_DC) /* {{{ */ +{ + unsigned char *mem, *pos, *last_pos, *end_pos; + struct stat st; +#ifndef _WIN32 + int fd; +#else + HANDLE fd, map; +#endif + int all_content = (count == 0); + int line = 0, displayed = 0; + + if (VCWD_STAT(filename, &st) == FAILURE) { + phpdbg_error("Failed to stat file %s", filename); + return; + } + +#ifndef _WIN32 + if ((fd = VCWD_OPEN(filename, O_RDONLY)) == FAILURE) { + phpdbg_error("Failed to open file %s to list", filename); + return; + } + + pos = last_pos = mem = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0); + end_pos = mem + st.st_size; +#else + + fd = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (fd == INVALID_HANDLE_VALUE) { + phpdbg_error("Failed to open file!"); + return; + } + + map = CreateFileMapping(fd, NULL, PAGE_READONLY, 0, 0, NULL); + if (map == NULL) { + phpdbg_error("Failed to map file!"); + CloseHandle(fd); + return; + } + + pos = last_pos = mem = (char*) MapViewOfFile(map, FILE_MAP_READ, 0, 0, 0); + if (mem == NULL) { + phpdbg_error("Failed to map file in memory"); + CloseHandle(map); + CloseHandle(fd); + return; + } + end_pos = mem + st.st_size; +#endif + while (1) { + if (pos == end_pos) { + break; + } + + pos = memchr(last_pos, '\n', end_pos - last_pos); + + if (!pos) { + /* No more line breaks */ + pos = end_pos; + } + + ++line; + + if (!offset || offset <= line) { + /* Without offset, or offset reached */ + if (!highlight) { + phpdbg_writeln("%05u: %.*s", line, (int)(pos - last_pos), last_pos); + } else { + if (highlight != line) { + phpdbg_writeln(" %05u: %.*s", line, (int)(pos - last_pos), last_pos); + } else { + phpdbg_writeln(">%05u: %.*s", line, (int)(pos - last_pos), last_pos); + } + } + ++displayed; + } + + last_pos = pos + 1; + + if (!all_content && displayed == count) { + /* Reached max line to display */ + break; + } + } + +#ifndef _WIN32 + munmap(mem, st.st_size); + close(fd); +#else + UnmapViewOfFile(mem); + CloseHandle(map); + CloseHandle(fd); +#endif +} /* }}} */ + +void phpdbg_list_function(const zend_function *fbc TSRMLS_DC) /* {{{ */ +{ + const zend_op_array *ops; + + if (fbc->type != ZEND_USER_FUNCTION) { + phpdbg_error("The function requested (%s) is not user defined", fbc->common.function_name); + return; + } + + ops = (zend_op_array*)fbc; + + phpdbg_list_file(ops->filename, + ops->line_end - ops->line_start + 1, ops->line_start, 0 TSRMLS_CC); +} /* }}} */ + +void phpdbg_list_function_byname(const char *str, size_t len TSRMLS_DC) /* {{{ */ +{ + HashTable *func_table = EG(function_table); + zend_function* fbc; + char *func_name = (char*) str; + size_t func_name_len = len; + + /* search active scope if begins with period */ + if (func_name[0] == '.') { + if (EG(scope)) { + func_name++; + func_name_len--; + + func_table = &EG(scope)->function_table; + } else { + phpdbg_error("No active class"); + return; + } + } else if (!EG(function_table)) { + phpdbg_error("No function table loaded"); + return; + } else { + func_table = EG(function_table); + } + + /* use lowercase names, case insensitive */ + func_name = zend_str_tolower_dup(func_name, func_name_len); + + if (zend_hash_find(func_table, func_name, func_name_len+1, (void**)&fbc) == SUCCESS) { + phpdbg_list_function(fbc TSRMLS_CC); + } else { + phpdbg_error("Function %s not found", func_name); + } + + efree(func_name); +} /* }}} */ + diff --git a/phpdbg_list.h b/phpdbg_list.h new file mode 100644 index 00000000000..d6180271585 --- /dev/null +++ b/phpdbg_list.h @@ -0,0 +1,47 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHPDBG_LIST_H +#define PHPDBG_LIST_H + +#include "TSRM.h" +#include "phpdbg_cmd.h" + +#define PHPDBG_LIST(name) PHPDBG_COMMAND(list_##name) +#define PHPDBG_LIST_HANDLER(name) PHPDBG_COMMAND_HANDLER(list_##name) + +PHPDBG_LIST(lines); +PHPDBG_LIST(class); +PHPDBG_LIST(method); +PHPDBG_LIST(func); + +void phpdbg_list_function_byname(const char *, size_t TSRMLS_DC); +void phpdbg_list_function(const zend_function* TSRMLS_DC); +void phpdbg_list_file(const char*, long, long, int TSRMLS_DC); + +static const phpdbg_command_t phpdbg_list_commands[] = { + PHPDBG_COMMAND_D_EX(lines, "lists the specified lines", 'l', list_lines, NULL, 1), + PHPDBG_COMMAND_D_EX(class, "lists the specified class", 'c', list_class, NULL, 1), + PHPDBG_COMMAND_D_EX(method, "lists the specified method", 'm', list_method, NULL, 1), + PHPDBG_COMMAND_D_EX(func, "lists the specified function", 'f', list_func, NULL, 1), + PHPDBG_END_COMMAND +}; + +#endif /* PHPDBG_LIST_H */ diff --git a/phpdbg_opcode.c b/phpdbg_opcode.c new file mode 100644 index 00000000000..025d57a08dc --- /dev/null +++ b/phpdbg_opcode.c @@ -0,0 +1,361 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#include "phpdbg.h" +#include "zend_vm_opcodes.h" +#include "zend_compile.h" +#include "phpdbg_opcode.h" +#include "phpdbg_utils.h" + +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); + +static inline zend_uint phpdbg_decode_literal(zend_op_array *ops, zend_literal *literal TSRMLS_DC) /* {{{ */ +{ + int iter = 0; + + while (iter < ops->last_literal) { + if (literal == &ops->literals[iter]) { + return iter; + } + iter++; + } + + return 0; +} /* }}} */ + +static inline char *phpdbg_decode_op(zend_op_array *ops, znode_op *op, zend_uint type, HashTable *vars TSRMLS_DC) /* {{{ */ +{ + char *decode = NULL; + + switch (type &~ EXT_TYPE_UNUSED) { + case IS_CV: + asprintf(&decode, "$%s", ops->vars[op->var].name); + break; + + case IS_VAR: + case IS_TMP_VAR: { + zend_ulong id = 0, *pid = NULL; + if (zend_hash_index_find(vars, (zend_ulong) ops->vars - op->var, (void**) &pid) != SUCCESS) { + id = zend_hash_num_elements(vars); + zend_hash_index_update( + vars, (zend_ulong) ops->vars - op->var, + (void**) &id, + sizeof(zend_ulong), NULL); + } else id = *pid; + asprintf(&decode, "@%lu", id); + } break; + + case IS_CONST: + asprintf(&decode, "C%u", phpdbg_decode_literal(ops, op->literal TSRMLS_CC)); + break; + + case IS_UNUSED: + asprintf(&decode, ""); + break; + } + return decode; +} /* }}} */ + +char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars TSRMLS_DC) /*{{{ */ +{ + char *decode[4] = {NULL, NULL, NULL, NULL}; + + switch (op->opcode) { + case ZEND_JMP: +#ifdef ZEND_GOTO + case ZEND_GOTO: +#endif +#ifdef ZEND_FAST_CALL + case ZEND_FAST_CALL: +#endif + asprintf(&decode[1], "J%ld", op->op1.jmp_addr - ops->opcodes); + goto format; + + case ZEND_JMPZNZ: + decode[1] = phpdbg_decode_op(ops, &op->op1, op->op1_type, vars TSRMLS_CC); + asprintf( + &decode[2], "J%u or J%lu", op->op2.opline_num, op->extended_value); + goto result; + + case ZEND_JMPZ: + case ZEND_JMPNZ: + case ZEND_JMPZ_EX: + case ZEND_JMPNZ_EX: + +#ifdef ZEND_JMP_SET + case ZEND_JMP_SET: +#endif +#ifdef ZEND_JMP_SET_VAR + case ZEND_JMP_SET_VAR: +#endif + decode[1] = phpdbg_decode_op(ops, &op->op1, op->op1_type, vars TSRMLS_CC); + asprintf( + &decode[2], "J%ld", op->op2.jmp_addr - ops->opcodes); + goto result; + + case ZEND_RECV_INIT: + goto result; + + default: { + decode[1] = phpdbg_decode_op(ops, &op->op1, op->op1_type, vars TSRMLS_CC); + decode[2] = phpdbg_decode_op(ops, &op->op2, op->op2_type, vars TSRMLS_CC); +result: + decode[3] = phpdbg_decode_op(ops, &op->result, op->result_type, vars TSRMLS_CC); +format: + asprintf( + &decode[0], + "%-20s %-20s %-20s", + decode[1] ? decode[1] : "", + decode[2] ? decode[2] : "", + decode[3] ? decode[3] : ""); + } + } + + if (decode[1]) + free(decode[1]); + if (decode[2]) + free(decode[2]); + if (decode[3]) + free(decode[3]); + + return decode[0]; +} /* }}} */ + +void phpdbg_print_opline_ex(zend_execute_data *execute_data, HashTable *vars, zend_bool ignore_flags TSRMLS_DC) /* {{{ */ +{ + /* force out a line while stepping so the user knows what is happening */ + if (ignore_flags || + (!(PHPDBG_G(flags) & PHPDBG_IS_QUIET) || + (PHPDBG_G(flags) & PHPDBG_IS_STEPPING) || + (PHPDBG_G(oplog)))) { + + zend_op *opline = execute_data->opline; + char *decode = phpdbg_decode_opline(execute_data->op_array, opline, vars TSRMLS_CC); + + if (ignore_flags || (!(PHPDBG_G(flags) & PHPDBG_IS_QUIET) || (PHPDBG_G(flags) & PHPDBG_IS_STEPPING))) { + /* output line info */ + phpdbg_notice("L%-5u %16p %-30s %s %s", + opline->lineno, + opline, + phpdbg_decode_opcode(opline->opcode), + decode, + execute_data->op_array->filename ? execute_data->op_array->filename : "unknown"); + } + + if (!ignore_flags && PHPDBG_G(oplog)) { + phpdbg_log_ex(PHPDBG_G(oplog), "L%-5u %16p %-30s %s %s", + opline->lineno, + opline, + phpdbg_decode_opcode(opline->opcode), + decode, + execute_data->op_array->filename ? execute_data->op_array->filename : "unknown"); + } + + if (decode) { + free(decode); + } + } +} /* }}} */ + +void phpdbg_print_opline(zend_execute_data *execute_data, zend_bool ignore_flags TSRMLS_DC) /* {{{ */ +{ + phpdbg_print_opline_ex(execute_data, NULL, ignore_flags TSRMLS_CC); +} /* }}} */ + +const char *phpdbg_decode_opcode(zend_uchar opcode) /* {{{ */ +{ +#define CASE(s) case s: return #s + switch (opcode) { + CASE(ZEND_NOP); + CASE(ZEND_ADD); + CASE(ZEND_SUB); + CASE(ZEND_MUL); + CASE(ZEND_DIV); + CASE(ZEND_MOD); + CASE(ZEND_SL); + CASE(ZEND_SR); + CASE(ZEND_CONCAT); + CASE(ZEND_BW_OR); + CASE(ZEND_BW_AND); + CASE(ZEND_BW_XOR); + CASE(ZEND_BW_NOT); + CASE(ZEND_BOOL_NOT); + CASE(ZEND_BOOL_XOR); + CASE(ZEND_IS_IDENTICAL); + CASE(ZEND_IS_NOT_IDENTICAL); + CASE(ZEND_IS_EQUAL); + CASE(ZEND_IS_NOT_EQUAL); + CASE(ZEND_IS_SMALLER); + CASE(ZEND_IS_SMALLER_OR_EQUAL); + CASE(ZEND_CAST); + CASE(ZEND_QM_ASSIGN); + CASE(ZEND_ASSIGN_ADD); + CASE(ZEND_ASSIGN_SUB); + CASE(ZEND_ASSIGN_MUL); + CASE(ZEND_ASSIGN_DIV); + CASE(ZEND_ASSIGN_MOD); + CASE(ZEND_ASSIGN_SL); + CASE(ZEND_ASSIGN_SR); + CASE(ZEND_ASSIGN_CONCAT); + CASE(ZEND_ASSIGN_BW_OR); + CASE(ZEND_ASSIGN_BW_AND); + CASE(ZEND_ASSIGN_BW_XOR); + CASE(ZEND_PRE_INC); + CASE(ZEND_PRE_DEC); + CASE(ZEND_POST_INC); + CASE(ZEND_POST_DEC); + CASE(ZEND_ASSIGN); + CASE(ZEND_ASSIGN_REF); + CASE(ZEND_ECHO); + CASE(ZEND_PRINT); + CASE(ZEND_JMP); + CASE(ZEND_JMPZ); + CASE(ZEND_JMPNZ); + CASE(ZEND_JMPZNZ); + CASE(ZEND_JMPZ_EX); + CASE(ZEND_JMPNZ_EX); + CASE(ZEND_CASE); + CASE(ZEND_SWITCH_FREE); + CASE(ZEND_BRK); + CASE(ZEND_CONT); + CASE(ZEND_BOOL); + CASE(ZEND_INIT_STRING); + CASE(ZEND_ADD_CHAR); + CASE(ZEND_ADD_STRING); + CASE(ZEND_ADD_VAR); + CASE(ZEND_BEGIN_SILENCE); + CASE(ZEND_END_SILENCE); + CASE(ZEND_INIT_FCALL_BY_NAME); + CASE(ZEND_DO_FCALL); + CASE(ZEND_DO_FCALL_BY_NAME); + CASE(ZEND_RETURN); + CASE(ZEND_RECV); + CASE(ZEND_RECV_INIT); + CASE(ZEND_SEND_VAL); + CASE(ZEND_SEND_VAR); + CASE(ZEND_SEND_REF); + CASE(ZEND_NEW); + CASE(ZEND_INIT_NS_FCALL_BY_NAME); + CASE(ZEND_FREE); + CASE(ZEND_INIT_ARRAY); + CASE(ZEND_ADD_ARRAY_ELEMENT); + CASE(ZEND_INCLUDE_OR_EVAL); + CASE(ZEND_UNSET_VAR); + CASE(ZEND_UNSET_DIM); + CASE(ZEND_UNSET_OBJ); + CASE(ZEND_FE_RESET); + CASE(ZEND_FE_FETCH); + CASE(ZEND_EXIT); + CASE(ZEND_FETCH_R); + CASE(ZEND_FETCH_DIM_R); + CASE(ZEND_FETCH_OBJ_R); + CASE(ZEND_FETCH_W); + CASE(ZEND_FETCH_DIM_W); + CASE(ZEND_FETCH_OBJ_W); + CASE(ZEND_FETCH_RW); + CASE(ZEND_FETCH_DIM_RW); + CASE(ZEND_FETCH_OBJ_RW); + CASE(ZEND_FETCH_IS); + CASE(ZEND_FETCH_DIM_IS); + CASE(ZEND_FETCH_OBJ_IS); + CASE(ZEND_FETCH_FUNC_ARG); + CASE(ZEND_FETCH_DIM_FUNC_ARG); + CASE(ZEND_FETCH_OBJ_FUNC_ARG); + CASE(ZEND_FETCH_UNSET); + CASE(ZEND_FETCH_DIM_UNSET); + CASE(ZEND_FETCH_OBJ_UNSET); + CASE(ZEND_FETCH_DIM_TMP_VAR); + CASE(ZEND_FETCH_CONSTANT); + CASE(ZEND_GOTO); + CASE(ZEND_EXT_STMT); + CASE(ZEND_EXT_FCALL_BEGIN); + CASE(ZEND_EXT_FCALL_END); + CASE(ZEND_EXT_NOP); + CASE(ZEND_TICKS); + CASE(ZEND_SEND_VAR_NO_REF); + CASE(ZEND_CATCH); + CASE(ZEND_THROW); + CASE(ZEND_FETCH_CLASS); + CASE(ZEND_CLONE); + CASE(ZEND_RETURN_BY_REF); + CASE(ZEND_INIT_METHOD_CALL); + CASE(ZEND_INIT_STATIC_METHOD_CALL); + CASE(ZEND_ISSET_ISEMPTY_VAR); + CASE(ZEND_ISSET_ISEMPTY_DIM_OBJ); + CASE(ZEND_PRE_INC_OBJ); + CASE(ZEND_PRE_DEC_OBJ); + CASE(ZEND_POST_INC_OBJ); + CASE(ZEND_POST_DEC_OBJ); + CASE(ZEND_ASSIGN_OBJ); + CASE(ZEND_INSTANCEOF); + CASE(ZEND_DECLARE_CLASS); + CASE(ZEND_DECLARE_INHERITED_CLASS); + CASE(ZEND_DECLARE_FUNCTION); + CASE(ZEND_RAISE_ABSTRACT_ERROR); + CASE(ZEND_DECLARE_CONST); + CASE(ZEND_ADD_INTERFACE); + CASE(ZEND_DECLARE_INHERITED_CLASS_DELAYED); + CASE(ZEND_VERIFY_ABSTRACT_CLASS); + CASE(ZEND_ASSIGN_DIM); + CASE(ZEND_ISSET_ISEMPTY_PROP_OBJ); + CASE(ZEND_HANDLE_EXCEPTION); + CASE(ZEND_USER_OPCODE); +#ifdef ZEND_JMP_SET + CASE(ZEND_JMP_SET); +#endif + CASE(ZEND_DECLARE_LAMBDA_FUNCTION); +#ifdef ZEND_ADD_TRAIT + CASE(ZEND_ADD_TRAIT); +#endif +#ifdef ZEND_BIND_TRAITS + CASE(ZEND_BIND_TRAITS); +#endif +#ifdef ZEND_SEPARATE + CASE(ZEND_SEPARATE); +#endif +#ifdef ZEND_QM_ASSIGN_VAR + CASE(ZEND_QM_ASSIGN_VAR); +#endif +#ifdef ZEND_JMP_SET_VAR + CASE(ZEND_JMP_SET_VAR); +#endif +#ifdef ZEND_DISCARD_EXCEPTION + CASE(ZEND_DISCARD_EXCEPTION); +#endif +#ifdef ZEND_YIELD + CASE(ZEND_YIELD); +#endif +#ifdef ZEND_GENERATOR_RETURN + CASE(ZEND_GENERATOR_RETURN); +#endif +#ifdef ZEND_FAST_CALL + CASE(ZEND_FAST_CALL); +#endif +#ifdef ZEND_FAST_RET + CASE(ZEND_FAST_RET); +#endif +#ifdef ZEND_RECV_VARIADIC + CASE(ZEND_RECV_VARIADIC); +#endif + CASE(ZEND_OP_DATA); + default: + return "UNKNOWN"; + } +} /* }}} */ diff --git a/phpdbg_opcode.h b/phpdbg_opcode.h new file mode 100644 index 00000000000..5771488e707 --- /dev/null +++ b/phpdbg_opcode.h @@ -0,0 +1,31 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHPDBG_OPCODE_H +#define PHPDBG_OPCODE_H + +#include "zend_types.h" + +const char *phpdbg_decode_opcode(zend_uchar); +char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars TSRMLS_DC); +void phpdbg_print_opline(zend_execute_data *execute_data, zend_bool ignore_flags TSRMLS_DC); +void phpdbg_print_opline_ex(zend_execute_data *execute_data, HashTable *vars, zend_bool ignore_flags TSRMLS_DC); + +#endif /* PHPDBG_OPCODE_H */ diff --git a/phpdbg_print.c b/phpdbg_print.c new file mode 100644 index 00000000000..51edcfbf8da --- /dev/null +++ b/phpdbg_print.c @@ -0,0 +1,258 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#include "phpdbg.h" +#include "phpdbg_print.h" +#include "phpdbg_utils.h" +#include "phpdbg_opcode.h" +#include "phpdbg_prompt.h" + +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); + +PHPDBG_PRINT(opline) /* {{{ */ +{ + if (EG(in_execution) && EG(current_execute_data)) { + phpdbg_print_opline(EG(current_execute_data), 1 TSRMLS_CC); + } else { + phpdbg_error("Not Executing!"); + } + + return SUCCESS; +} /* }}} */ + +static inline void phpdbg_print_function_helper(zend_function *method TSRMLS_DC) /* {{{ */ +{ + switch (method->type) { + case ZEND_USER_FUNCTION: { + zend_op_array* op_array = &(method->op_array); + HashTable vars; + + if (op_array) { + zend_op *opline = &(op_array->opcodes[0]); + zend_uint opcode = 0, + end = op_array->last-1; + + if (method->common.scope) { + phpdbg_writeln("\tL%d-%d %s::%s() %s", + op_array->line_start, op_array->line_end, + method->common.scope->name, + method->common.function_name, + op_array->filename ? op_array->filename : "unknown"); + } else { + phpdbg_writeln("\tL%d-%d %s() %s", + method->common.function_name ? op_array->line_start : 0, + method->common.function_name ? op_array->line_end : 0, + method->common.function_name ? method->common.function_name : "{main}", + op_array->filename ? op_array->filename : "unknown"); + } + + zend_hash_init(&vars, op_array->last, NULL, NULL, 0); + do { + char *decode = phpdbg_decode_opline(op_array, opline, &vars TSRMLS_CC); + if (decode != NULL) { + phpdbg_writeln("\t\tL%u\t%p %-30s %s", + opline->lineno, + opline, + phpdbg_decode_opcode(opline->opcode), + decode); + free(decode); + } else { + phpdbg_error("\tFailed to decode opline %16p", opline); + } + opline++; + } while (++opcode < end); + zend_hash_destroy(&vars); + } + } break; + + default: { + if (method->common.scope) { + phpdbg_writeln("\tInternal %s::%s()", method->common.scope->name, method->common.function_name); + } else { + phpdbg_writeln("\tInternal %s()", method->common.function_name); + } + } + } +} /* }}} */ + +PHPDBG_PRINT(exec) /* {{{ */ +{ + if (PHPDBG_G(exec)) { + if (!PHPDBG_G(ops)) { + phpdbg_compile(TSRMLS_C); + } + + if (PHPDBG_G(ops)) { + phpdbg_notice("Context %s", PHPDBG_G(exec)); + + phpdbg_print_function_helper((zend_function*) PHPDBG_G(ops) TSRMLS_CC); + } + } else { + phpdbg_error("No execution context set"); + } + +return SUCCESS; +} /* }}} */ + +PHPDBG_PRINT(stack) /* {{{ */ +{ + zend_op_array *ops = EG(active_op_array); + + if (EG(in_execution) && ops) { + if (ops->function_name) { + if (ops->scope) { + phpdbg_notice("Stack in %s::%s()", ops->scope->name, ops->function_name); + } else { + phpdbg_notice("Stack in %s()", ops->function_name); + } + } else { + if (ops->filename) { + phpdbg_notice("Stack in %s", ops->filename); + } else { + phpdbg_notice("Stack @ %p", ops); + } + } + phpdbg_print_function_helper((zend_function*) ops TSRMLS_CC); + } else { + phpdbg_error("Not Executing!"); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_PRINT(class) /* {{{ */ +{ + zend_class_entry **ce; + + switch (param->type) { + case STR_PARAM: { + if (zend_lookup_class(param->str, param->len, &ce TSRMLS_CC) == SUCCESS) { + phpdbg_notice("%s %s: %s", + ((*ce)->type == ZEND_USER_CLASS) ? + "User" : "Internal", + ((*ce)->ce_flags & ZEND_ACC_INTERFACE) ? + "Interface" : + ((*ce)->ce_flags & ZEND_ACC_ABSTRACT) ? + "Abstract Class" : + "Class", + (*ce)->name); + + phpdbg_writeln("Methods (%d):", zend_hash_num_elements(&(*ce)->function_table)); + if (zend_hash_num_elements(&(*ce)->function_table)) { + HashPosition position; + zend_function *method; + + for (zend_hash_internal_pointer_reset_ex(&(*ce)->function_table, &position); + zend_hash_get_current_data_ex(&(*ce)->function_table, (void**) &method, &position) == SUCCESS; + zend_hash_move_forward_ex(&(*ce)->function_table, &position)) { + phpdbg_print_function_helper(method TSRMLS_CC); + } + } + } else { + phpdbg_error("The class %s could not be found", param->str); + } + } break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_PRINT(method) /* {{{ */ +{ + switch (param->type) { + case METHOD_PARAM: { + zend_class_entry **ce; + + if (zend_lookup_class(param->method.class, strlen(param->method.class), &ce TSRMLS_CC) == SUCCESS) { + zend_function *fbc; + char *lcname = zend_str_tolower_dup(param->method.name, strlen(param->method.name)); + + if (zend_hash_find(&(*ce)->function_table, lcname, strlen(lcname)+1, (void**)&fbc) == SUCCESS) { + phpdbg_notice("%s Method %s", + (fbc->type == ZEND_USER_FUNCTION) ? "User" : "Internal", + fbc->common.function_name); + + phpdbg_print_function_helper(fbc TSRMLS_CC); + } else { + phpdbg_error("The method %s could not be found", param->method.name); + } + + efree(lcname); + } else { + phpdbg_error("The class %s could not be found", param->method.class); + } + } break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_PRINT(func) /* {{{ */ +{ + switch (param->type) { + case STR_PARAM: { + HashTable *func_table = EG(function_table); + zend_function* fbc; + const char *func_name = param->str; + size_t func_name_len = param->len; + char *lcname; + /* search active scope if begins with period */ + if (func_name[0] == '.') { + if (EG(scope)) { + func_name++; + func_name_len--; + + func_table = &EG(scope)->function_table; + } else { + phpdbg_error("No active class"); + return SUCCESS; + } + } else if (!EG(function_table)) { + phpdbg_error("No function table loaded"); + return SUCCESS; + } else { + func_table = EG(function_table); + } + + lcname = zend_str_tolower_dup(func_name, func_name_len); + + if (zend_hash_find(func_table, lcname, strlen(lcname)+1, (void**)&fbc) == SUCCESS) { + phpdbg_notice("%s %s %s", + (fbc->type == ZEND_USER_FUNCTION) ? "User" : "Internal", + (fbc->common.scope) ? "Method" : "Function", + fbc->common.function_name); + + phpdbg_print_function_helper(fbc TSRMLS_CC); + } else { + phpdbg_error("The function %s could not be found", func_name); + } + + efree(lcname); + } break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ diff --git a/phpdbg_print.h b/phpdbg_print.h new file mode 100644 index 00000000000..1232f544d29 --- /dev/null +++ b/phpdbg_print.h @@ -0,0 +1,51 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHPDBG_PRINT_H +#define PHPDBG_PRINT_H + +#include "phpdbg_cmd.h" + +#define PHPDBG_PRINT(name) PHPDBG_COMMAND(print_##name) + +/** + * Printer Forward Declarations + */ +PHPDBG_PRINT(exec); +PHPDBG_PRINT(opline); +PHPDBG_PRINT(class); +PHPDBG_PRINT(method); +PHPDBG_PRINT(func); +PHPDBG_PRINT(stack); + +/** + * Commands + */ +static const phpdbg_command_t phpdbg_print_commands[] = { + PHPDBG_COMMAND_D_EX(exec, "print out the instructions in the execution context", 'e', print_exec, NULL, 0), + PHPDBG_COMMAND_D_EX(opline, "print out the instruction in the current opline", 'o', print_opline, NULL, 0), + PHPDBG_COMMAND_D_EX(class, "print out the instructions in the specified class", 'c', print_class, NULL, 1), + PHPDBG_COMMAND_D_EX(method, "print out the instructions in the specified method", 'm', print_method, NULL, 1), + PHPDBG_COMMAND_D_EX(func, "print out the instructions in the specified function", 'f', print_func, NULL, 1), + PHPDBG_COMMAND_D_EX(stack, "print out the instructions in the current stack", 's', print_stack, NULL, 0), + PHPDBG_END_COMMAND +}; + +#endif /* PHPDBG_PRINT_H */ diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c new file mode 100644 index 00000000000..f2f482b7ece --- /dev/null +++ b/phpdbg_prompt.c @@ -0,0 +1,1328 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#include +#include +#include "zend.h" +#include "zend_compile.h" +#include "phpdbg.h" +#include "phpdbg_help.h" +#include "phpdbg_print.h" +#include "phpdbg_info.h" +#include "phpdbg_break.h" +#include "phpdbg_bp.h" +#include "phpdbg_opcode.h" +#include "phpdbg_list.h" +#include "phpdbg_utils.h" +#include "phpdbg_prompt.h" +#include "phpdbg_cmd.h" +#include "phpdbg_set.h" +#include "phpdbg_frame.h" + +/* {{{ command declarations */ +const phpdbg_command_t phpdbg_prompt_commands[] = { + PHPDBG_COMMAND_D(exec, "set execution context", 'e', NULL, 1), + PHPDBG_COMMAND_D(compile, "attempt compilation", 'c', NULL, 0), + PHPDBG_COMMAND_D(step, "step through execution", 's', NULL, 1), + PHPDBG_COMMAND_D(next, "continue execution", 'n', NULL, 0), + PHPDBG_COMMAND_D(run, "attempt execution", 'r', NULL, 0), + PHPDBG_COMMAND_D(eval, "evaluate some code", 'E', NULL, 1), + PHPDBG_COMMAND_D(until, "continue past the current line", 'u', NULL, 0), + PHPDBG_COMMAND_D(finish, "continue past the end of the stack", 'F', NULL, 0), + PHPDBG_COMMAND_D(leave, "continue until the end of the stack", 'L', NULL, 0), + PHPDBG_COMMAND_D(print, "print something", 'p', phpdbg_print_commands, 2), + PHPDBG_COMMAND_D(break, "set breakpoint", 'b', phpdbg_break_commands, 1), + PHPDBG_COMMAND_D(back, "show trace", 't', NULL, 0), + PHPDBG_COMMAND_D(frame, "switch to a frame", 'f', NULL, 1), + PHPDBG_COMMAND_D(list, "lists some code", 'l', phpdbg_list_commands, 2), + PHPDBG_COMMAND_D(info, "displays some informations", 'i', phpdbg_info_commands, 1), + PHPDBG_COMMAND_D(clean, "clean the execution environment", 'X', NULL, 0), + PHPDBG_COMMAND_D(clear, "clear breakpoints", 'C', NULL, 0), + PHPDBG_COMMAND_D(help, "show help menu", 'h', phpdbg_help_commands, 2), + PHPDBG_COMMAND_D(quiet, "silence some output", 'Q', NULL, 1), + PHPDBG_COMMAND_D(aliases, "show alias list", 'a', NULL, 0), + PHPDBG_COMMAND_D(set, "set phpdbg configuration", 'S', phpdbg_set_commands, 1), + PHPDBG_COMMAND_D(register,"register a function", 'R', NULL, 1), + PHPDBG_COMMAND_D(source, "execute a phpdbginit", '.', NULL, 1), + PHPDBG_COMMAND_D(shell, "shell a command", '-', NULL, 1), + PHPDBG_COMMAND_D(quit, "exit phpdbg", 'q', NULL, 0), + PHPDBG_END_COMMAND +}; /* }}} */ + +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); + +static inline int phpdbg_call_register(phpdbg_input_t *input TSRMLS_DC) /* {{{ */ +{ + phpdbg_input_t *function = input->argv[0]; + + if (zend_hash_exists( + &PHPDBG_G(registered), function->string, function->length+1)) { + + zval fname, *fretval; + zend_fcall_info fci; + + ZVAL_STRINGL(&fname, function->string, function->length, 1); + + memset(&fci, 0, sizeof(zend_fcall_info)); + + fci.size = sizeof(zend_fcall_info); + fci.function_table = &PHPDBG_G(registered); + fci.function_name = &fname; + fci.symbol_table = EG(active_symbol_table); + fci.object_ptr = NULL; + fci.retval_ptr_ptr = &fretval; + fci.no_separation = 1; + + if (input->argc > 1) { + int param; + zval params; + + array_init(¶ms); + + for (param = 0; param < (input->argc-1); param++) { + add_next_index_stringl( + ¶ms, + input->argv[param+1]->string, + input->argv[param+1]->length, 1); + + phpdbg_debug( + "created param[%d] from argv[%d]: %s", + param, param+1, input->argv[param+1]->string); + } + + zend_fcall_info_args(&fci, ¶ms TSRMLS_CC); + } else { + fci.params = NULL; + fci.param_count = 0; + } + + phpdbg_debug( + "created %d params from %d arguments", + fci.param_count, input->argc); + + zend_call_function(&fci, NULL TSRMLS_CC); + + if (fretval) { + zend_print_zval_r( + fretval, 0 TSRMLS_CC); + phpdbg_writeln(EMPTY); + } + + zval_dtor(&fname); + + return SUCCESS; + } + + return FAILURE; +} /* }}} */ + +void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_init TSRMLS_DC) /* {{{ */ +{ + struct stat sb; + + if (init_file && VCWD_STAT(init_file, &sb) != -1) { + FILE *fp = fopen(init_file, "r"); + if (fp) { + int line = 1; + + char cmd[PHPDBG_MAX_CMD]; + size_t cmd_len = 0L; + char *code = NULL; + size_t code_len = 0L; + zend_bool in_code = 0; + + while (fgets(cmd, PHPDBG_MAX_CMD, fp) != NULL) { + cmd_len = strlen(cmd)-1; + + while (cmd_len > 0L && isspace(cmd[cmd_len-1])) + cmd_len--; + + cmd[cmd_len] = '\0'; + + if (*cmd && cmd_len > 0L && cmd[0] != '#') { + if (cmd_len == 2) { + if (memcmp(cmd, "<:", sizeof("<:")-1) == SUCCESS) { + in_code = 1; + goto next_line; + } else { + if (memcmp(cmd, ":>", sizeof(":>")-1) == SUCCESS) { + in_code = 0; + code[code_len] = '\0'; + { + zend_eval_stringl( + code, code_len, NULL, "phpdbginit code" TSRMLS_CC); + } + free(code); + code = NULL; + goto next_line; + } + } + } + + if (in_code) { + if (code == NULL) { + code = malloc(cmd_len + 1); + } else code = realloc(code, code_len + cmd_len + 1); + + if (code) { + memcpy( + &code[code_len], cmd, cmd_len); + code_len += cmd_len; + } + goto next_line; + } + + { + phpdbg_input_t *input = phpdbg_read_input(cmd TSRMLS_CC); + switch (phpdbg_do_cmd(phpdbg_prompt_commands, input TSRMLS_CC)) { + case FAILURE: + if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { + if (phpdbg_call_register(input TSRMLS_CC) == FAILURE) { + phpdbg_error("Unrecognized command in %s:%d: %s!", init_file, line, input->string); + } + } + break; + } + phpdbg_destroy_input(&input TSRMLS_CC); + } + + } +next_line: + line++; + } + + if (code) { + free(code); + } + + fclose(fp); + } else { + phpdbg_error( + "Failed to open %s for initialization", init_file); + } + + if (free_init) { + free(init_file); + } + } +} /* }}} */ + +void phpdbg_init(char *init_file, size_t init_file_len, zend_bool use_default TSRMLS_DC) /* {{{ */ +{ + if (!init_file && use_default) { + char *scan_dir = getenv("PHP_INI_SCAN_DIR"); + int i; + + phpdbg_try_file_init(PHPDBG_STRL(PHP_CONFIG_FILE_PATH "/" PHPDBG_INIT_FILENAME), 0 TSRMLS_CC); + + if (!scan_dir) { + scan_dir = PHP_CONFIG_FILE_SCAN_DIR; + } + while (*scan_dir != 0) { + i = 0; + while (scan_dir[i] != ':') { + if (scan_dir[i++] == 0) { + i = -1; + break; + } + } + if (i != -1) { + scan_dir[i] = 0; + } + + asprintf( + &init_file, "%s/%s", scan_dir, PHPDBG_INIT_FILENAME); + phpdbg_try_file_init(init_file, strlen(init_file), 1 TSRMLS_CC); + if (i == -1) { + break; + } + scan_dir += i + 1; + } + + phpdbg_try_file_init(PHPDBG_STRL(PHPDBG_INIT_FILENAME), 0 TSRMLS_CC); + } else { + phpdbg_try_file_init(init_file, init_file_len, 1 TSRMLS_CC); + } +} + +PHPDBG_COMMAND(exec) /* {{{ */ +{ + switch (param->type) { + case STR_PARAM: { + struct stat sb; + + if (VCWD_STAT(param->str, &sb) != FAILURE) { + if (sb.st_mode & (S_IFREG|S_IFLNK)) { + char *res = phpdbg_resolve_path(param->str TSRMLS_CC); + size_t res_len = strlen(res); + + if ((res_len != PHPDBG_G(exec_len)) || (memcmp(res, PHPDBG_G(exec), res_len) != SUCCESS)) { + + if (PHPDBG_G(exec)) { + phpdbg_notice("Unsetting old execution context: %s", PHPDBG_G(exec)); + efree(PHPDBG_G(exec)); + PHPDBG_G(exec) = NULL; + PHPDBG_G(exec_len) = 0L; + } + + if (PHPDBG_G(ops)) { + phpdbg_notice("Destroying compiled opcodes"); + phpdbg_clean(0 TSRMLS_CC); + } + + PHPDBG_G(exec) = res; + PHPDBG_G(exec_len) = res_len; + + phpdbg_notice("Set execution context: %s", PHPDBG_G(exec)); + } else { + phpdbg_notice("Execution context not changed"); + } + } else { + phpdbg_error("Cannot use %s as execution context, not a valid file or symlink", param->str); + } + } else { + phpdbg_error("Cannot stat %s, ensure the file exists", param->str); + } + } break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +int phpdbg_compile(TSRMLS_D) /* {{{ */ +{ + zend_file_handle fh; + + if (EG(in_execution)) { + phpdbg_error("Cannot compile while in execution"); + return FAILURE; + } + + phpdbg_notice("Attempting compilation of %s", PHPDBG_G(exec)); + + if (php_stream_open_for_zend_ex(PHPDBG_G(exec), &fh, + USE_PATH|STREAM_OPEN_FOR_INCLUDE TSRMLS_CC) == SUCCESS) { + + PHPDBG_G(ops) = zend_compile_file(&fh, ZEND_INCLUDE TSRMLS_CC); + zend_destroy_file_handle(&fh TSRMLS_CC); + + phpdbg_notice("Success"); + return SUCCESS; + } else { + phpdbg_error("Could not open file %s", PHPDBG_G(exec)); + } + + return FAILURE; +} /* }}} */ + +PHPDBG_COMMAND(compile) /* {{{ */ +{ + if (!PHPDBG_G(exec)) { + phpdbg_error("No execution context"); + return SUCCESS; + } + + if (!EG(in_execution)) { + if (PHPDBG_G(ops)) { + phpdbg_error("Destroying previously compiled opcodes"); + phpdbg_clean(0 TSRMLS_CC); + } + } + + phpdbg_compile(TSRMLS_C); + + return SUCCESS; +} /* }}} */ + +PHPDBG_COMMAND(step) /* {{{ */ +{ + switch (param->type) { + case EMPTY_PARAM: + case NUMERIC_PARAM: { + if (param->type == NUMERIC_PARAM && param->num) { + PHPDBG_G(flags) |= PHPDBG_IS_STEPPING; + } else { + PHPDBG_G(flags) &= ~PHPDBG_IS_STEPPING; + } + + phpdbg_notice("Stepping %s", + (PHPDBG_G(flags) & PHPDBG_IS_STEPPING) ? "on" : "off"); + } break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_COMMAND(next) /* {{{ */ +{ + return PHPDBG_NEXT; +} /* }}} */ + +PHPDBG_COMMAND(until) /* {{{ */ +{ + if (!EG(in_execution)) { + phpdbg_error("Not executing"); + return SUCCESS; + } + + PHPDBG_G(flags) |= PHPDBG_IN_UNTIL; + { + zend_uint next = 0, + self = (EG(current_execute_data)->opline - EG(active_op_array)->opcodes); + zend_op *opline = &EG(active_op_array)->opcodes[self]; + + for (next = self; next < EG(active_op_array)->last; next++) { + if (EG(active_op_array)->opcodes[next].lineno != opline->lineno) { + zend_hash_index_update( + &PHPDBG_G(seek), + (zend_ulong) &EG(active_op_array)->opcodes[next], + &EG(active_op_array)->opcodes[next], + sizeof(zend_op), NULL); + break; + } + } + } + + return PHPDBG_UNTIL; +} /* }}} */ + +PHPDBG_COMMAND(finish) /* {{{ */ +{ + if (!EG(in_execution)) { + phpdbg_error("Not executing"); + return SUCCESS; + } + + PHPDBG_G(flags) |= PHPDBG_IN_FINISH; + { + zend_uint next = 0, + self = (EG(current_execute_data)->opline - EG(active_op_array)->opcodes); + + for (next = self; next < EG(active_op_array)->last; next++) { + switch (EG(active_op_array)->opcodes[next].opcode) { + case ZEND_RETURN: + case ZEND_THROW: + case ZEND_EXIT: +#ifdef ZEND_YIELD + case ZEND_YIELD: +#endif + zend_hash_index_update( + &PHPDBG_G(seek), + (zend_ulong) &EG(active_op_array)->opcodes[next], + &EG(active_op_array)->opcodes[next], + sizeof(zend_op), NULL); + break; + } + } + } + + return PHPDBG_FINISH; +} /* }}} */ + +PHPDBG_COMMAND(leave) /* {{{ */ +{ + if (!EG(in_execution)) { + phpdbg_error("Not executing"); + return SUCCESS; + } + + PHPDBG_G(flags) |= PHPDBG_IN_LEAVE; + { + zend_uint next = 0, + self = (EG(current_execute_data)->opline - EG(active_op_array)->opcodes); + + for (next = self; next < EG(active_op_array)->last; next++) { + switch (EG(active_op_array)->opcodes[next].opcode) { + case ZEND_RETURN: + case ZEND_THROW: + case ZEND_EXIT: +#ifdef ZEND_YIELD + case ZEND_YIELD: +#endif + zend_hash_index_update( + &PHPDBG_G(seek), + (zend_ulong) &EG(active_op_array)->opcodes[next], + &EG(active_op_array)->opcodes[next], + sizeof(zend_op), NULL); + break; + } + } + } + + return PHPDBG_LEAVE; +} /* }}} */ + +PHPDBG_COMMAND(frame) /* {{{ */ +{ + switch (param->type) { + case NUMERIC_PARAM: + phpdbg_switch_frame(param->num TSRMLS_CC); + break; + + case EMPTY_PARAM: + phpdbg_notice("Currently in frame #%d", PHPDBG_G(frame).num); + break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +static inline void phpdbg_handle_exception(TSRMLS_D) /* }}} */ +{ + zend_fcall_info fci; + + zval fname, + *trace, + exception; + + /* get filename and linenumber before unsetting exception */ + const char *filename = zend_get_executed_filename(TSRMLS_C); + zend_uint lineno = zend_get_executed_lineno(TSRMLS_C); + + /* copy exception */ + exception = *EG(exception); + zval_copy_ctor(&exception); + EG(exception) = NULL; + + phpdbg_error( + "Uncaught %s!", + Z_OBJCE(exception)->name); + + /* call __toString */ + ZVAL_STRINGL(&fname, "__tostring", sizeof("__tostring")-1, 1); + fci.size = sizeof(fci); + fci.function_table = &Z_OBJCE(exception)->function_table; + fci.function_name = &fname; + fci.symbol_table = NULL; + fci.object_ptr = &exception; + fci.retval_ptr_ptr = &trace; + fci.param_count = 0; + fci.params = NULL; + fci.no_separation = 1; + zend_call_function(&fci, NULL TSRMLS_CC); + + if (trace) { + phpdbg_writeln( + "Uncaught %s", Z_STRVAL_P(trace)); + /* remember to dtor trace */ + zval_ptr_dtor(&trace); + } + + /* output useful information about address */ + phpdbg_writeln( + "Stacked entered at %p in %s on line %u", + EG(active_op_array)->opcodes, filename, lineno); + + zval_dtor(&fname); + zval_dtor(&exception); +} /* }}} */ + +PHPDBG_COMMAND(run) /* {{{ */ +{ + if (EG(in_execution)) { + phpdbg_error("Cannot start another execution while one is in progress"); + return SUCCESS; + } + + if (PHPDBG_G(ops) || PHPDBG_G(exec)) { + 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); + + if (!PHPDBG_G(ops)) { + if (phpdbg_compile(TSRMLS_C) == FAILURE) { + phpdbg_error("Failed to compile %s, cannot run", PHPDBG_G(exec)); + goto out; + } + } + + EG(active_op_array) = PHPDBG_G(ops); + EG(return_value_ptr_ptr) = &PHPDBG_G(retval); + if (!EG(active_symbol_table)) { + zend_rebuild_symbol_table(TSRMLS_C); + } + + /* clean seek state */ + PHPDBG_G(flags) &= ~PHPDBG_SEEK_MASK; + zend_hash_clean( + &PHPDBG_G(seek)); + + /* reset hit counters */ + phpdbg_reset_breakpoints(TSRMLS_C); + + zend_try { + php_output_activate(TSRMLS_C); + PHPDBG_G(flags) ^= PHPDBG_IS_INTERACTIVE; + zend_execute(EG(active_op_array) TSRMLS_CC); + PHPDBG_G(flags) ^= PHPDBG_IS_INTERACTIVE; + php_output_deactivate(TSRMLS_C); + } zend_catch { + EG(active_op_array) = orig_op_array; + EG(opline_ptr) = orig_opline; + EG(return_value_ptr_ptr) = orig_retval_ptr; + + if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { + phpdbg_error("Caught exit/error from VM"); + goto out; + } + } zend_end_try(); + + if (EG(exception)) { + phpdbg_handle_exception(TSRMLS_C); + } + + EG(active_op_array) = orig_op_array; + EG(opline_ptr) = orig_opline; + EG(return_value_ptr_ptr) = orig_retval_ptr; + + } else { + phpdbg_error("Nothing to execute!"); + } + +out: + PHPDBG_FRAME(num) = 0; + return SUCCESS; +} /* }}} */ + +PHPDBG_COMMAND(eval) /* {{{ */ +{ + switch (param->type) { + case STR_PARAM: { + zend_bool stepping = ((PHPDBG_G(flags) & PHPDBG_IS_STEPPING)==PHPDBG_IS_STEPPING); + zval retval; + + if (!(PHPDBG_G(flags) & PHPDBG_IS_STEPONEVAL)) { + PHPDBG_G(flags) &= ~ PHPDBG_IS_STEPPING; + } + + /* disable stepping while eval() in progress */ + PHPDBG_G(flags) |= PHPDBG_IN_EVAL; + zend_try { + if (zend_eval_stringl(param->str, param->len, + &retval, "eval()'d code" TSRMLS_CC) == SUCCESS) { + zend_print_zval_r( + &retval, 0 TSRMLS_CC); + phpdbg_writeln(EMPTY); + zval_dtor(&retval); + } + } zend_end_try(); + PHPDBG_G(flags) &= ~PHPDBG_IN_EVAL; + + /* switch stepping back on */ + if (stepping && + !(PHPDBG_G(flags) & PHPDBG_IS_STEPONEVAL)) { + PHPDBG_G(flags) |= PHPDBG_IS_STEPPING; + } + + CG(unclean_shutdown) = 0; + } break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_COMMAND(back) /* {{{ */ +{ + if (!EG(in_execution)) { + phpdbg_error("Not executing!"); + return SUCCESS; + } + + switch (param->type) { + case EMPTY_PARAM: + case NUMERIC_PARAM: + phpdbg_dump_backtrace( + (param->type == NUMERIC_PARAM) ? param->num : 0 TSRMLS_CC); + break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_COMMAND(print) /* {{{ */ +{ + switch (param->type) { + case EMPTY_PARAM: { + phpdbg_writeln(SEPARATE); + phpdbg_notice("Execution Context Information"); +#ifdef HAVE_LIBREADLINE + phpdbg_writeln("Readline\tyes"); +#else + phpdbg_writeln("Readline\tno"); +#endif + + phpdbg_writeln("Exec\t\t%s", PHPDBG_G(exec) ? PHPDBG_G(exec) : "none"); + phpdbg_writeln("Compiled\t%s", PHPDBG_G(ops) ? "yes" : "no"); + phpdbg_writeln("Stepping\t%s", (PHPDBG_G(flags) & PHPDBG_IS_STEPPING) ? "on" : "off"); + phpdbg_writeln("Quietness\t%s", (PHPDBG_G(flags) & PHPDBG_IS_QUIET) ? "on" : "off"); + phpdbg_writeln("Oplog\t\t%s", PHPDBG_G(oplog) ? "on" : "off"); + + if (PHPDBG_G(ops)) { + phpdbg_writeln("Opcodes\t\t%d", PHPDBG_G(ops)->last); + + if (PHPDBG_G(ops)->last_var) { + phpdbg_writeln("Variables\t%d", PHPDBG_G(ops)->last_var-1); + } else { + phpdbg_writeln("Variables\tNone"); + } + } + + phpdbg_writeln("Executing\t%s", EG(in_execution) ? "yes" : "no"); + if (EG(in_execution)) { + phpdbg_writeln("VM Return\t%d", PHPDBG_G(vmret)); + } + + phpdbg_writeln("Classes\t\t%d", zend_hash_num_elements(EG(class_table))); + phpdbg_writeln("Functions\t%d", zend_hash_num_elements(EG(function_table))); + phpdbg_writeln("Constants\t%d", zend_hash_num_elements(EG(zend_constants))); + phpdbg_writeln("Included\t%d", zend_hash_num_elements(&EG(included_files))); + + phpdbg_writeln(SEPARATE); + } break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_COMMAND(info) /* {{{ */ +{ + phpdbg_error( + "No information command selected!"); + + return SUCCESS; +} /* }}} */ + +PHPDBG_COMMAND(set) /* {{{ */ +{ + phpdbg_error( + "No information command selected!"); + + return SUCCESS; +} /* }}} */ + +PHPDBG_COMMAND(break) /* {{{ */ +{ + switch (param->type) { + case EMPTY_PARAM: + phpdbg_set_breakpoint_file( + zend_get_executed_filename(TSRMLS_C), + zend_get_executed_lineno(TSRMLS_C) TSRMLS_CC); + break; + case ADDR_PARAM: + phpdbg_set_breakpoint_opline(param->addr TSRMLS_CC); + break; + case NUMERIC_PARAM: + if (PHPDBG_G(exec)) { + phpdbg_set_breakpoint_file(phpdbg_current_file(TSRMLS_C), param->num TSRMLS_CC); + } else { + phpdbg_error("Execution context not set!"); + } + break; + case METHOD_PARAM: + phpdbg_set_breakpoint_method(param->method.class, param->method.name TSRMLS_CC); + break; + case NUMERIC_METHOD_PARAM: + phpdbg_set_breakpoint_method_opline(param->method.class, param->method.name, param->num TSRMLS_CC); + break; + case NUMERIC_FUNCTION_PARAM: + phpdbg_set_breakpoint_function_opline(param->str, param->num TSRMLS_CC); + break; + case FILE_PARAM: + phpdbg_set_breakpoint_file(param->file.name, param->file.line TSRMLS_CC); + break; + case STR_PARAM: + phpdbg_set_breakpoint_symbol(param->str, param->len TSRMLS_CC); + break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_COMMAND(shell) /* {{{ */ +{ + /* don't allow this to loop, ever ... */ + switch (param->type) { + case STR_PARAM: { + FILE *fd = NULL; + if ((fd=VCWD_POPEN((char*)param->str, "w"))) { + /* do something perhaps ?? do we want input ?? */ + fclose(fd); + } else { + phpdbg_error( + "Failed to execute %s", param->str); + } + } break; + + phpdbg_default_switch_case(); + } + return SUCCESS; +} /* }}} */ + +PHPDBG_COMMAND(source) /* {{{ */ +{ + switch (param->type) { + case STR_PARAM: { + if (input->argc > 2) { + if (phpdbg_argv_is(1, "export")) { + FILE *h = VCWD_FOPEN(input->argv[2]->string, "w+"); + if (h) { + phpdbg_export_breakpoints(h TSRMLS_CC); + fclose(h); + } else phpdbg_error("Failed to open %s", input->argv[1]->string); + } else { + phpdbg_error( + "Incorrect usage of source command, see help"); + } + } else { + struct stat sb; + if (VCWD_STAT(param->str, &sb) != -1) { + phpdbg_try_file_init(param->str, param->len, 0 TSRMLS_CC); + } else phpdbg_error("Cannot stat %s", param->str); + } + } break; + + phpdbg_default_switch_case(); + } + return SUCCESS; +} /* }}} */ + +PHPDBG_COMMAND(register) /* {{{ */ +{ + switch (param->type) { + case STR_PARAM: { + zend_function *function; + char *lcname = zend_str_tolower_dup(param->str, param->len); + size_t lcname_len = strlen(lcname); + + if (!zend_hash_exists(&PHPDBG_G(registered), lcname, lcname_len+1)) { + if (zend_hash_find(EG(function_table), lcname, lcname_len+1, (void**) &function) == SUCCESS) { + zend_hash_update( + &PHPDBG_G(registered), lcname, lcname_len+1, (void*)&function, sizeof(zend_function), NULL); + function_add_ref(function); + + phpdbg_notice( + "Registered %s", lcname); + } else { + phpdbg_error("The requested function (%s) could not be found", param->str); + } + } else { + phpdbg_error( + "The requested name (%s) is already in use", lcname); + } + + efree(lcname); + } break; + + phpdbg_default_switch_case(); + } + return SUCCESS; +} /* }}} */ + +PHPDBG_COMMAND(quit) /* {{{ */ +{ + /* don't allow this to loop, ever ... */ + if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { + + phpdbg_destroy_input((phpdbg_input_t**)&input TSRMLS_CC); + + PHPDBG_G(flags) |= PHPDBG_IS_QUITTING; + zend_bailout(); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_COMMAND(clean) /* {{{ */ +{ + if (EG(in_execution)) { + phpdbg_error("Cannot clean environment while executing"); + return SUCCESS; + } + + phpdbg_notice("Cleaning Execution Environment"); + + phpdbg_writeln("Classes\t\t\t%d", zend_hash_num_elements(EG(class_table))); + phpdbg_writeln("Functions\t\t%d", zend_hash_num_elements(EG(function_table))); + phpdbg_writeln("Constants\t\t%d", zend_hash_num_elements(EG(zend_constants))); + phpdbg_writeln("Includes\t\t%d", zend_hash_num_elements(&EG(included_files))); + + phpdbg_clean(1 TSRMLS_CC); + + return SUCCESS; +} /* }}} */ + +PHPDBG_COMMAND(clear) /* {{{ */ +{ + phpdbg_notice("Clearing Breakpoints"); + + phpdbg_writeln("File\t\t\t%d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE])); + phpdbg_writeln("Functions\t\t%d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM])); + phpdbg_writeln("Methods\t\t\t%d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD])); + phpdbg_writeln("Oplines\t\t\t%d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE])); + phpdbg_writeln("File oplines\t\t\t%d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE])); + phpdbg_writeln("Function oplines\t\t\t%d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE])); + phpdbg_writeln("Method oplines\t\t\t%d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE])); + phpdbg_writeln("Conditionals\t\t%d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_COND])); + + phpdbg_clear_breakpoints(TSRMLS_C); + + return SUCCESS; +} /* }}} */ + +PHPDBG_COMMAND(aliases) /* {{{ */ +{ + const phpdbg_command_t *prompt_command = phpdbg_prompt_commands; + + phpdbg_help_header(); + phpdbg_writeln("Below are the aliased, short versions of all supported commands"); + while (prompt_command && prompt_command->name) { + if (prompt_command->alias) { + if (prompt_command->subs) { + const phpdbg_command_t *sub_command = prompt_command->subs; + phpdbg_writeln(EMPTY); + phpdbg_writeln(" %c -> %9s", prompt_command->alias, prompt_command->name); + while (sub_command && sub_command->name) { + if (sub_command->alias) { + phpdbg_writeln(" |-------- %c -> %15s\t%s", sub_command->alias, + sub_command->name, sub_command->tip); + } + ++sub_command; + } + phpdbg_writeln(EMPTY); + } else { + phpdbg_writeln(" %c -> %9s\t\t\t%s", prompt_command->alias, + prompt_command->name, prompt_command->tip); + } + } + + ++prompt_command; + } + phpdbg_help_footer(); + + return SUCCESS; +} /* }}} */ + +PHPDBG_COMMAND(help) /* {{{ */ +{ + switch (param->type) { + case EMPTY_PARAM: { + const phpdbg_command_t *prompt_command = phpdbg_prompt_commands; + const phpdbg_command_t *help_command = phpdbg_help_commands; + + phpdbg_help_header(); + phpdbg_writeln("To get help regarding a specific command type \"help command\""); + + phpdbg_notice("Commands"); + + while (prompt_command && prompt_command->name) { + phpdbg_writeln( + " %10s\t%s", prompt_command->name, prompt_command->tip); + ++prompt_command; + } + + phpdbg_notice("Help Commands"); + + while (help_command && help_command->name) { + phpdbg_writeln(" %10s\t%s", help_command->name, help_command->tip); + ++help_command; + } + + phpdbg_help_footer(); + } break; + + default: { + phpdbg_error( + "No help can be found for the subject \"%s\"", param->str); + } + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_COMMAND(quiet) /* {{{ */ +{ + switch (param->type) { + case NUMERIC_PARAM: { + if (param->num) { + PHPDBG_G(flags) |= PHPDBG_IS_QUIET; + } else { + PHPDBG_G(flags) &= ~PHPDBG_IS_QUIET; + } + phpdbg_notice("Quietness %s", + (PHPDBG_G(flags) & PHPDBG_IS_QUIET) ? "enabled" : "disabled"); + } break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_COMMAND(list) /* {{{ */ +{ + switch (param->type) { + case NUMERIC_PARAM: + case EMPTY_PARAM: + return PHPDBG_LIST_HANDLER(lines)(PHPDBG_COMMAND_ARGS); + + case FILE_PARAM: + return PHPDBG_LIST_HANDLER(lines)(PHPDBG_COMMAND_ARGS); + + case STR_PARAM: + phpdbg_list_function_byname(param->str, param->len TSRMLS_CC); + break; + + case METHOD_PARAM: + return PHPDBG_LIST_HANDLER(method)(PHPDBG_COMMAND_ARGS); + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +int phpdbg_interactive(TSRMLS_D) /* {{{ */ +{ + int ret = SUCCESS; + phpdbg_input_t *input; + + PHPDBG_G(flags) |= PHPDBG_IS_INTERACTIVE; + + input = phpdbg_read_input(NULL TSRMLS_CC); + + if (input && input->length > 0L) { + do { + switch (ret = phpdbg_do_cmd(phpdbg_prompt_commands, input TSRMLS_CC)) { + case FAILURE: + if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { + if (phpdbg_call_register(input TSRMLS_CC) == FAILURE) { + phpdbg_error("Failed to execute %s!", input->string); + } + } + break; + + case PHPDBG_LEAVE: + case PHPDBG_FINISH: + case PHPDBG_UNTIL: + case PHPDBG_NEXT: { + if (!EG(in_execution)) { + phpdbg_error("Not running"); + } + goto out; + } + } + + phpdbg_destroy_input(&input TSRMLS_CC); + } while ((input = phpdbg_read_input(NULL TSRMLS_CC)) && (input->length > 0L)); + + if (input && !input->length) + goto last; + + } else { +last: + if (PHPDBG_G(lcmd)) { + ret = PHPDBG_G(lcmd)->handler( + &PHPDBG_G(lparam), input TSRMLS_CC); + goto out; + } + } + +out: + phpdbg_destroy_input(&input TSRMLS_CC); + + if (EG(in_execution)) { + phpdbg_restore_frame(TSRMLS_C); + } + + PHPDBG_G(flags) &= ~PHPDBG_IS_INTERACTIVE; + + return ret; +} /* }}} */ + +void phpdbg_clean(zend_bool full TSRMLS_DC) /* {{{ */ +{ + /* this is implicitly required */ + if (PHPDBG_G(ops)) { + destroy_op_array(PHPDBG_G(ops) TSRMLS_CC); + efree(PHPDBG_G(ops)); + PHPDBG_G(ops) = NULL; + } + + if (full) { + PHPDBG_G(flags) |= PHPDBG_IS_CLEANING; + + zend_bailout(); + } +} /* }}} */ + +static inline zend_execute_data *phpdbg_create_execute_data(zend_op_array *op_array, zend_bool nested TSRMLS_DC) /* {{{ */ +{ +#if PHP_VERSION_ID >= 50500 + return zend_create_execute_data_from_op_array(op_array, nested TSRMLS_CC); +#else + +#undef EX +#define EX(element) execute_data->element +#undef EX_CV +#define EX_CV(var) EX(CVs)[var] +#undef EX_CVs +#define EX_CVs() EX(CVs) +#undef EX_T +#define EX_T(offset) (*(temp_variable *)((char *) EX(Ts) + offset)) +#undef EX_Ts +#define EX_Ts() EX(Ts) + + zend_execute_data *execute_data = (zend_execute_data *)zend_vm_stack_alloc( + ZEND_MM_ALIGNED_SIZE(sizeof(zend_execute_data)) + + ZEND_MM_ALIGNED_SIZE(sizeof(zval**) * op_array->last_var * (EG(active_symbol_table) ? 1 : 2)) + + ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)) * op_array->T TSRMLS_CC); + + EX(CVs) = (zval***)((char*)execute_data + ZEND_MM_ALIGNED_SIZE(sizeof(zend_execute_data))); + memset(EX(CVs), 0, sizeof(zval**) * op_array->last_var); + EX(Ts) = (temp_variable *)(((char*)EX(CVs)) + ZEND_MM_ALIGNED_SIZE(sizeof(zval**) * op_array->last_var * (EG(active_symbol_table) ? 1 : 2))); + EX(fbc) = NULL; + EX(called_scope) = NULL; + EX(object) = NULL; + EX(old_error_reporting) = NULL; + EX(op_array) = op_array; + EX(symbol_table) = EG(active_symbol_table); + EX(prev_execute_data) = EG(current_execute_data); + EG(current_execute_data) = execute_data; + EX(nested) = nested; + + if (!op_array->run_time_cache && op_array->last_cache_slot) { + op_array->run_time_cache = ecalloc(op_array->last_cache_slot, sizeof(void*)); + } + + if (op_array->this_var != -1 && EG(This)) { + Z_ADDREF_P(EG(This)); /* For $this pointer */ + if (!EG(active_symbol_table)) { + EX_CV(op_array->this_var) = (zval**)EX_CVs() + (op_array->last_var + op_array->this_var); + *EX_CV(op_array->this_var) = EG(This); + } else { + if (zend_hash_add(EG(active_symbol_table), "this", sizeof("this"), &EG(This), sizeof(zval *), (void**)&EX_CV(op_array->this_var))==FAILURE) { + Z_DELREF_P(EG(This)); + } + } + } + + EX(opline) = UNEXPECTED((op_array->fn_flags & ZEND_ACC_INTERACTIVE) != 0) && EG(start_op) ? EG(start_op) : op_array->opcodes; + EG(opline_ptr) = &EX(opline); + + EX(function_state).function = (zend_function *) op_array; + EX(function_state).arguments = NULL; + + return execute_data; +#endif +} /* }}} */ + +#if PHP_VERSION_ID >= 50500 +void phpdbg_execute_ex(zend_execute_data *execute_data TSRMLS_DC) /* {{{ */ +{ +#else +void phpdbg_execute_ex(zend_op_array *op_array TSRMLS_DC) /* {{{ */ +{ + long long flags = 0; + zend_ulong address = 0L; + zend_execute_data *execute_data; + zend_bool nested = 0; +#endif + zend_bool original_in_execution = EG(in_execution); + HashTable vars; + +#if PHP_VERSION_ID < 50500 + if (EG(exception)) { + return; + } +#endif + + EG(in_execution) = 1; + +#if PHP_VERSION_ID >= 50500 + if (0) { +zend_vm_enter: + execute_data = phpdbg_create_execute_data(EG(active_op_array), 1 TSRMLS_CC); + } + zend_hash_init(&vars, EG(active_op_array)->last, NULL, NULL, 0); +#else +zend_vm_enter: + execute_data = phpdbg_create_execute_data(op_array, nested TSRMLS_CC); + nested = 1; + zend_hash_init(&vars, EG(active_op_array)->last, NULL, NULL, 0); +#endif + + while (1) { + + if ((PHPDBG_G(flags) & PHPDBG_BP_RESOLVE_MASK)) { + /* resolve nth opline breakpoints */ + phpdbg_resolve_op_array_breaks(EG(active_op_array) TSRMLS_CC); + } + +#ifdef ZEND_WIN32 + if (EG(timed_out)) { + zend_timeout(0); + } +#endif + +#define DO_INTERACTIVE() do { \ + 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 \ + ); \ + } \ + \ + do { \ + switch (phpdbg_interactive(TSRMLS_C)) { \ + case PHPDBG_LEAVE: \ + case PHPDBG_FINISH: \ + case PHPDBG_UNTIL: \ + case PHPDBG_NEXT:{ \ + goto next; \ + } \ + } \ + } while (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)); \ +} while (0) + + /* allow conditional breakpoints and + initialization to access the vm uninterrupted */ + if ((PHPDBG_G(flags) & PHPDBG_IN_COND_BP) || + (PHPDBG_G(flags) & PHPDBG_IS_INITIALIZING)) { + /* skip possible breakpoints */ + goto next; + } + + /* perform seek operation */ + if (PHPDBG_G(flags) & PHPDBG_SEEK_MASK) { + /* current address */ + zend_ulong address = (zend_ulong) execute_data->opline; + + /* run to next line */ + if (PHPDBG_G(flags) & PHPDBG_IN_UNTIL) { + if (zend_hash_index_exists(&PHPDBG_G(seek), address)) { + PHPDBG_G(flags) &= ~PHPDBG_IN_UNTIL; + zend_hash_clean( + &PHPDBG_G(seek)); + } else { + /* skip possible breakpoints */ + goto next; + } + } + + /* run to finish */ + if (PHPDBG_G(flags) & PHPDBG_IN_FINISH) { + if (zend_hash_index_exists(&PHPDBG_G(seek), address)) { + PHPDBG_G(flags) &= ~PHPDBG_IN_FINISH; + zend_hash_clean( + &PHPDBG_G(seek)); + } + /* skip possible breakpoints */ + goto next; + } + + /* break for leave */ + if (PHPDBG_G(flags) & PHPDBG_IN_LEAVE) { + if (zend_hash_index_exists(&PHPDBG_G(seek), address)) { + PHPDBG_G(flags) &= ~PHPDBG_IN_LEAVE; + zend_hash_clean( + &PHPDBG_G(seek)); + phpdbg_notice( + "Breaking for leave at %s:%u", + zend_get_executed_filename(TSRMLS_C), + zend_get_executed_lineno(TSRMLS_C) + ); + DO_INTERACTIVE(); + } else { + /* skip possible breakpoints */ + goto next; + } + } + } + + /* not while in conditionals */ + phpdbg_print_opline_ex( + execute_data, &vars, 0 TSRMLS_CC); + + /* search for breakpoints */ + { + phpdbg_breakbase_t *brake; + + if ((PHPDBG_G(flags) & PHPDBG_BP_MASK) && + (brake = phpdbg_find_breakpoint(execute_data TSRMLS_CC))) { + phpdbg_hit_breakpoint( + brake, 1 TSRMLS_CC); + DO_INTERACTIVE(); + } + } + + if (PHPDBG_G(flags) & PHPDBG_IS_STEPPING) { + DO_INTERACTIVE(); + } + +next: + if (PHPDBG_G(flags) & PHPDBG_IS_SIGNALED) { + phpdbg_writeln(EMPTY); + phpdbg_notice("Program received signal SIGINT"); + PHPDBG_G(flags) &= ~PHPDBG_IS_SIGNALED; + DO_INTERACTIVE(); + } + + PHPDBG_G(vmret) = execute_data->opline->handler(execute_data TSRMLS_CC); + + if (PHPDBG_G(vmret) > 0) { + switch (PHPDBG_G(vmret)) { + case 1: + EG(in_execution) = original_in_execution; + zend_hash_destroy(&vars); + return; + case 2: +#if PHP_VERSION_ID < 50500 + op_array = EG(active_op_array); +#endif + zend_hash_destroy(&vars); + goto zend_vm_enter; + break; + case 3: + execute_data = EG(current_execute_data); + break; + default: + break; + } + } + } + zend_error_noreturn(E_ERROR, "Arrived at end of main loop which shouldn't happen"); +} /* }}} */ diff --git a/phpdbg_prompt.h b/phpdbg_prompt.h new file mode 100644 index 00000000000..e6706c7d5b1 --- /dev/null +++ b/phpdbg_prompt.h @@ -0,0 +1,68 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHPDBG_PROMPT_H +#define PHPDBG_PROMPT_H + +/* {{{ */ +void phpdbg_init(char *init_file, size_t init_file_len, zend_bool use_default TSRMLS_DC); +void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_init TSRMLS_DC); +int phpdbg_interactive(TSRMLS_D); +int phpdbg_compile(TSRMLS_D); +void phpdbg_clean(zend_bool full TSRMLS_DC); /* }}} */ + +/* {{{ phpdbg command handlers */ +PHPDBG_COMMAND(exec); +PHPDBG_COMMAND(compile); +PHPDBG_COMMAND(step); +PHPDBG_COMMAND(next); +PHPDBG_COMMAND(run); +PHPDBG_COMMAND(eval); +PHPDBG_COMMAND(until); +PHPDBG_COMMAND(finish); +PHPDBG_COMMAND(leave); +PHPDBG_COMMAND(frame); +PHPDBG_COMMAND(print); +PHPDBG_COMMAND(break); +PHPDBG_COMMAND(back); +PHPDBG_COMMAND(list); +PHPDBG_COMMAND(info); +PHPDBG_COMMAND(clean); +PHPDBG_COMMAND(clear); +PHPDBG_COMMAND(help); +PHPDBG_COMMAND(quiet); +PHPDBG_COMMAND(aliases); +PHPDBG_COMMAND(shell); +PHPDBG_COMMAND(set); +PHPDBG_COMMAND(source); +PHPDBG_COMMAND(register); +PHPDBG_COMMAND(quit); /* }}} */ + +/* {{{ prompt commands */ +extern const phpdbg_command_t phpdbg_prompt_commands[]; /* }}} */ + +/* {{{ */ +#if PHP_VERSION_ID >= 50500 +void phpdbg_execute_ex(zend_execute_data *execute_data TSRMLS_DC); +#else +void phpdbg_execute_ex(zend_op_array *op_array TSRMLS_DC); +#endif /* }}} */ + +#endif /* PHPDBG_PROMPT_H */ diff --git a/phpdbg_set.c b/phpdbg_set.c new file mode 100644 index 00000000000..2472e1868c0 --- /dev/null +++ b/phpdbg_set.c @@ -0,0 +1,208 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#include "phpdbg.h" +#include "phpdbg_cmd.h" +#include "phpdbg_set.h" +#include "phpdbg_utils.h" +#include "phpdbg_bp.h" + +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); + +PHPDBG_SET(prompt) /* {{{ */ +{ + switch (param->type) { + case EMPTY_PARAM: + phpdbg_writeln("%s", phpdbg_get_prompt(TSRMLS_C)); + break; + + case STR_PARAM: + phpdbg_set_prompt(param->str TSRMLS_CC); + break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_SET(break) /* {{{ */ +{ + switch (param->type) { + case EMPTY_PARAM: + phpdbg_writeln("%s", + PHPDBG_G(flags) & PHPDBG_IS_BP_ENABLED ? "on" : "off"); + break; + + case STR_PARAM: + if (strncasecmp(param->str, PHPDBG_STRL("on")) == 0) { + phpdbg_enable_breakpoints(TSRMLS_C); + } else if (strncasecmp(param->str, PHPDBG_STRL("off")) == 0) { + phpdbg_disable_breakpoints(TSRMLS_C); + } + break; + + case NUMERIC_PARAM: { + if (input->argc > 2) { + if (phpdbg_argv_is(2, "on")) { + phpdbg_enable_breakpoint(param->num TSRMLS_CC); + } else if (phpdbg_argv_is(2, "off")) { + phpdbg_disable_breakpoint(param->num TSRMLS_CC); + } + } else { + phpdbg_breakbase_t *brake = phpdbg_find_breakbase(param->num TSRMLS_CC); + if (brake) { + phpdbg_writeln( + "%s", brake->disabled ? "off" : "on"); + } else { + phpdbg_error("Failed to find breakpoint #%lx", param->num); + } + } + } break; + + default: + phpdbg_error( + "set break used incorrectly: set break [id] "); + } + + return SUCCESS; +} /* }}} */ + +#ifndef _WIN32 +PHPDBG_SET(color) /* {{{ */ +{ + if ((param->type == STR_PARAM) && (input->argc == 3)) { + const phpdbg_color_t *color = phpdbg_get_color( + input->argv[2]->string, input->argv[2]->length TSRMLS_CC); + int element = PHPDBG_COLOR_INVALID; + + /* @TODO(anyone) make this consistent with other set commands */ + if (color) { + if (phpdbg_argv_is(1, "prompt")) { + phpdbg_notice( + "setting prompt color to %s (%s)", color->name, color->code); + element = PHPDBG_COLOR_PROMPT; + if (PHPDBG_G(prompt)[1]) { + free(PHPDBG_G(prompt)[1]); + PHPDBG_G(prompt)[1]=NULL; + } + } else if (phpdbg_argv_is(1, "error")) { + phpdbg_notice( + "setting error color to %s (%s)", color->name, color->code); + element = PHPDBG_COLOR_ERROR; + + } else if (phpdbg_argv_is(1, "notice")) { + phpdbg_notice( + "setting notice color to %s (%s)", color->name, color->code); + element = PHPDBG_COLOR_NOTICE; + + } else goto usage; + + /* set color for element */ + phpdbg_set_color(element, color TSRMLS_CC); + } else { + phpdbg_error( + "Failed to find the requested color (%s)", input->argv[2]->string); + } + } else { +usage: + phpdbg_error( + "set color used incorrectly: set color "); + } + return SUCCESS; +} /* }}} */ + +PHPDBG_SET(colors) /* {{{ */ +{ + switch (param->type) { + case EMPTY_PARAM: { + phpdbg_writeln( + "%s", PHPDBG_G(flags) & PHPDBG_IS_COLOURED ? "on" : "off"); + goto done; + } + + case STR_PARAM: { + if (strncasecmp(param->str, PHPDBG_STRL("on")) == 0) { + PHPDBG_G(flags) |= PHPDBG_IS_COLOURED; + goto done; + } else if (strncasecmp(param->str, PHPDBG_STRL("off")) == 0) { + PHPDBG_G(flags) &= ~PHPDBG_IS_COLOURED; + goto done; + } + } + + default: + phpdbg_error( + "set colors used incorrectly: set colors "); + } + +done: + return SUCCESS; +} /* }}} */ +#endif + +PHPDBG_SET(oplog) /* {{{ */ +{ + switch (param->type) { + case EMPTY_PARAM: + phpdbg_notice( + "Oplog %s", PHPDBG_G(oplog) ? "enabled" : "disabled"); + break; + + case NUMERIC_PARAM: switch (param->num) { + case 1: + phpdbg_error( + "An output file must be provided to enable oplog"); + break; + + case 0: { + if (PHPDBG_G(oplog)) { + phpdbg_notice("Disabling oplog"); + fclose( + PHPDBG_G(oplog)); + } else { + phpdbg_error("Oplog is not enabled!"); + } + } break; + } break; + + case STR_PARAM: { + /* open oplog */ + FILE *old = PHPDBG_G(oplog); + + PHPDBG_G(oplog) = fopen(param->str, "w+"); + if (!PHPDBG_G(oplog)) { + phpdbg_error("Failed to open %s for oplog", param->str); + PHPDBG_G(oplog) = old; + } else { + if (old) { + phpdbg_notice("Closing previously open oplog"); + fclose(old); + } + phpdbg_notice("Successfully opened oplog %s", param->str); + } + } break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + diff --git a/phpdbg_set.h b/phpdbg_set.h new file mode 100644 index 00000000000..1c48786c66c --- /dev/null +++ b/phpdbg_set.h @@ -0,0 +1,47 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHPDBG_SET_H +#define PHPDBG_SET_H + +#include "phpdbg_cmd.h" + +#define PHPDBG_SET(name) PHPDBG_COMMAND(set_##name) + +PHPDBG_SET(prompt); +#ifndef _WIN32 +PHPDBG_SET(color); +PHPDBG_SET(colors); +#endif +PHPDBG_SET(oplog); +PHPDBG_SET(break); + +static const phpdbg_command_t phpdbg_set_commands[] = { + PHPDBG_COMMAND_D_EX(prompt, "usage: set prompt ", 'p', set_prompt, NULL, 0), +#ifndef _WIN32 + PHPDBG_COMMAND_D_EX(color, "usage: set color ", 'c', set_color, NULL, 1), + PHPDBG_COMMAND_D_EX(colors, "usage: set colors ", 'C', set_colors, NULL, 1), +#endif + PHPDBG_COMMAND_D_EX(oplog, "usage: set oplog ", 'O', set_oplog, NULL, 0), + PHPDBG_COMMAND_D_EX(break, "usage: set break [id] ", 'b', set_break, NULL, 0), + PHPDBG_END_COMMAND +}; + +#endif /* PHPDBG_SET_H */ diff --git a/phpdbg_utils.c b/phpdbg_utils.c new file mode 100644 index 00000000000..86c17a71bee --- /dev/null +++ b/phpdbg_utils.c @@ -0,0 +1,386 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#include +#include +#include +#include "zend.h" +#include "php.h" +#include "spprintf.h" +#include "phpdbg.h" +#include "phpdbg_opcode.h" +#include "phpdbg_utils.h" + +#ifdef _WIN32 +# include "win32/time.h" +#endif + +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); + +/* {{{ color structures */ +const static phpdbg_color_t colors[] = { + PHPDBG_COLOR_D("none", "0;0"), + + PHPDBG_COLOR_D("white", "0;64"), + PHPDBG_COLOR_D("white-bold", "1;64"), + PHPDBG_COLOR_D("white-underline", "4;64"), + PHPDBG_COLOR_D("red", "0;31"), + PHPDBG_COLOR_D("red-bold", "1;31"), + PHPDBG_COLOR_D("red-underline", "4;31"), + PHPDBG_COLOR_D("green", "0;32"), + PHPDBG_COLOR_D("green-bold", "1;32"), + PHPDBG_COLOR_D("green-underline", "4;32"), + PHPDBG_COLOR_D("yellow", "0;33"), + PHPDBG_COLOR_D("yellow-bold", "1;33"), + PHPDBG_COLOR_D("yellow-underline", "4;33"), + PHPDBG_COLOR_D("blue", "0;34"), + PHPDBG_COLOR_D("blue-bold", "1;34"), + PHPDBG_COLOR_D("blue-underline", "4;34"), + PHPDBG_COLOR_D("purple", "0;35"), + PHPDBG_COLOR_D("purple-bold", "1;35"), + PHPDBG_COLOR_D("purple-underline", "4;35"), + PHPDBG_COLOR_D("cyan", "0;36"), + PHPDBG_COLOR_D("cyan-bold", "1;36"), + PHPDBG_COLOR_D("cyan-underline", "4;36"), + PHPDBG_COLOR_D("black", "0;30"), + PHPDBG_COLOR_D("black-bold", "1;30"), + PHPDBG_COLOR_D("black-underline", "4;30"), + PHPDBG_COLOR_END +}; /* }}} */ + +PHPDBG_API int phpdbg_is_numeric(const char *str) /* {{{ */ +{ + if (!str) + return 0; + + for (; *str; str++) { + if (isspace(*str) || *str == '-') { + continue; + } + return isdigit(*str); + } + return 0; +} /* }}} */ + +PHPDBG_API int phpdbg_is_empty(const char *str) /* {{{ */ +{ + if (!str) + return 1; + + for (; *str; str++) { + if (isspace(*str)) { + continue; + } + return 0; + } + return 1; +} /* }}} */ + +PHPDBG_API int phpdbg_is_addr(const char *str) /* {{{ */ +{ + return str[0] && str[1] && memcmp(str, "0x", 2) == 0; +} /* }}} */ + +PHPDBG_API int phpdbg_is_class_method(const char *str, size_t len, char **class, char **method) /* {{{ */ +{ + char *sep = NULL; + + if (strstr(str, "#") != NULL) + return 0; + + if (strstr(str, " ") != NULL) + return 0; + + sep = strstr(str, "::"); + + if (!sep || sep == str || sep+2 == str+len-1) { + return 0; + } + + if (class != NULL) { + + if (str[0] == '\\') { + str++; + len--; + } + + *class = estrndup(str, sep - str); + (*class)[sep - str] = 0; + } + + if (method != NULL) { + *method = estrndup(sep+2, str + len - (sep + 2)); + } + + return 1; +} /* }}} */ + +PHPDBG_API char *phpdbg_resolve_path(const char *path TSRMLS_DC) /* {{{ */ +{ + char resolved_name[MAXPATHLEN]; + + if (expand_filepath(path, resolved_name TSRMLS_CC) == NULL) { + return NULL; + } + + return estrdup(resolved_name); +} /* }}} */ + +PHPDBG_API const char *phpdbg_current_file(TSRMLS_D) /* {{{ */ +{ + const char *file = zend_get_executed_filename(TSRMLS_C); + + if (memcmp(file, "[no active file]", sizeof("[no active file]")) == 0) { + return PHPDBG_G(exec); + } + + return file; +} /* }}} */ + +PHPDBG_API const zend_function *phpdbg_get_function(const char *fname, const char *cname TSRMLS_DC) /* {{{ */ +{ + zend_function *func = NULL; + size_t fname_len = strlen(fname); + char *lcname = zend_str_tolower_dup(fname, fname_len); + + if (cname) { + zend_class_entry **ce; + size_t cname_len = strlen(cname); + char *lc_cname = zend_str_tolower_dup(cname, cname_len); + int ret = zend_lookup_class(lc_cname, cname_len, &ce TSRMLS_CC); + + efree(lc_cname); + + if (ret == SUCCESS) { + zend_hash_find(&(*ce)->function_table, lcname, fname_len+1, + (void**)&func); + } + } else { + zend_hash_find(EG(function_table), lcname, fname_len+1, + (void**)&func); + } + + efree(lcname); + return func; +} /* }}} */ + +PHPDBG_API char *phpdbg_trim(const char *str, size_t len, size_t *new_len) /* {{{ */ +{ + const char *p = str; + char *new = NULL; + + while (p && isspace(*p)) { + ++p; + --len; + } + + while (*p && isspace(*(p + len -1))) { + --len; + } + + if (len == 0) { + new = estrndup("", sizeof("")); + *new_len = 0; + } else { + new = estrndup(p, len); + *(new + len) = '\0'; + + if (new_len) { + *new_len = len; + } + } + + return new; + +} /* }}} */ + +PHPDBG_API int phpdbg_print(int type TSRMLS_DC, FILE *fp, const char *format, ...) /* {{{ */ +{ + int rc = 0; + char *buffer = NULL; + va_list args; + + if (format != NULL && strlen(format) > 0L) { + va_start(args, format); + vspprintf(&buffer, 0, format, args); + va_end(args); + } + + /* TODO(anyone) colours */ + + switch (type) { + case P_ERROR: + if (PHPDBG_G(flags) & PHPDBG_IS_COLOURED) { + rc = fprintf(fp, + "\033[%sm[%s]\033[0m\n", + PHPDBG_G(colors)[PHPDBG_COLOR_ERROR]->code, buffer); + } else { + rc = fprintf(fp, "[%s]\n", buffer); + } + break; + + case P_NOTICE: + if (PHPDBG_G(flags) & PHPDBG_IS_COLOURED) { + rc = fprintf(fp, + "\033[%sm[%s]\033[0m\n", + PHPDBG_G(colors)[PHPDBG_COLOR_NOTICE]->code, buffer); + } else { + rc = fprintf(fp, "[%s]\n", buffer); + } + break; + + case P_WRITELN: { + if (buffer) { + rc = fprintf(fp, "%s\n", buffer); + } else { + rc = fprintf(fp, "\n"); + } + } break; + + case P_WRITE: + if (buffer) { + rc = fprintf(fp, "%s", buffer); + } + break; + + /* no formatting on logging output */ + case P_LOG: + if (buffer) { + struct timeval tp; + if (gettimeofday(&tp, NULL) == SUCCESS) { + rc = fprintf(fp, "[%ld %.8F]: %s\n", tp.tv_sec, tp.tv_usec / 1000000.00, buffer); + } else { + rc = FAILURE; + } + } + break; + } + + if (buffer) { + efree(buffer); + } + + return rc; +} /* }}} */ + +PHPDBG_API int phpdbg_rlog(FILE *fp, const char *fmt, ...) { /* {{{ */ + int rc = 0; + + va_list args; + struct timeval tp; + + va_start(args, fmt); + if (gettimeofday(&tp, NULL) == SUCCESS) { + char friendly[100]; + char *format = NULL, *buffer = NULL; + + strftime(friendly, 100, "%a %b %d %T.%%04d %Y", localtime(&tp.tv_sec)); + asprintf( + &buffer, friendly, tp.tv_usec/1000); + asprintf( + &format, "[%s]: %s\n", buffer, fmt); + rc = vfprintf( + fp, format, args); + + free(format); + free(buffer); + } + va_end(args); + + return rc; +} /* }}} */ + +PHPDBG_API const phpdbg_color_t *phpdbg_get_color(const char *name, size_t name_length TSRMLS_DC) /* {{{ */ +{ + const phpdbg_color_t *color = colors; + + while (color && color->name) { + if (name_length == color->name_length && + memcmp(name, color->name, name_length) == SUCCESS) { + phpdbg_debug( + "phpdbg_get_color(%s, %lu): %s", name, name_length, color->code); + return color; + } + ++color; + } + + phpdbg_debug( + "phpdbg_get_color(%s, %lu): failed", name, name_length); + + return NULL; +} /* }}} */ + +PHPDBG_API void phpdbg_set_color(int element, const phpdbg_color_t *color TSRMLS_DC) /* {{{ */ +{ + PHPDBG_G(colors)[element] = color; +} /* }}} */ + +PHPDBG_API void phpdbg_set_color_ex(int element, const char *name, size_t name_length TSRMLS_DC) /* {{{ */ +{ + const phpdbg_color_t *color = phpdbg_get_color(name, name_length TSRMLS_CC); + + if (color) { + phpdbg_set_color(element, color TSRMLS_CC); + } else PHPDBG_G(colors)[element] = colors; +} /* }}} */ + +PHPDBG_API const phpdbg_color_t* phpdbg_get_colors(TSRMLS_D) /* {{{ */ +{ + return colors; +} /* }}} */ + +PHPDBG_API void phpdbg_set_prompt(const char *prompt TSRMLS_DC) /* {{{ */ +{ + /* free formatted prompt */ + if (PHPDBG_G(prompt)[1]) { + free(PHPDBG_G(prompt)[1]); + PHPDBG_G(prompt)[1] = NULL; + } + /* free old prompt */ + if (PHPDBG_G(prompt)[0]) { + free(PHPDBG_G(prompt)[0]); + PHPDBG_G(prompt)[0] = NULL; + } + + /* copy new prompt */ + PHPDBG_G(prompt)[0] = strdup(prompt); +} /* }}} */ + +PHPDBG_API const char *phpdbg_get_prompt(TSRMLS_D) /* {{{ */ +{ + /* find cached prompt */ + if (PHPDBG_G(prompt)[1]) { + return PHPDBG_G(prompt)[1]; + } + + /* create cached prompt */ + if ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED)) { + asprintf( + &PHPDBG_G(prompt)[1], "\033[%sm%s\033[0m ", + PHPDBG_G(colors)[PHPDBG_COLOR_PROMPT]->code, + PHPDBG_G(prompt)[0]); + } else { + asprintf( + &PHPDBG_G(prompt)[1], "%s ", + PHPDBG_G(prompt)[0]); + } + + return PHPDBG_G(prompt)[1]; +} /* }}} */ diff --git a/phpdbg_utils.h b/phpdbg_utils.h new file mode 100644 index 00000000000..fbc17b78dd3 --- /dev/null +++ b/phpdbg_utils.h @@ -0,0 +1,110 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHPDBG_UTILS_H +#define PHPDBG_UTILS_H + +/** + * Input scan functions + */ +PHPDBG_API int phpdbg_is_numeric(const char*); +PHPDBG_API int phpdbg_is_empty(const char*); +PHPDBG_API int phpdbg_is_addr(const char*); +PHPDBG_API int phpdbg_is_class_method(const char*, size_t, char**, char**); +PHPDBG_API const char *phpdbg_current_file(TSRMLS_D); +PHPDBG_API char *phpdbg_resolve_path(const char* TSRMLS_DC); +PHPDBG_API char *phpdbg_trim(const char*, size_t, size_t*); +PHPDBG_API const zend_function *phpdbg_get_function(const char*, const char* TSRMLS_DC); + +/** + * Error/notice/formatting helpers + */ +enum { + P_ERROR = 1, + P_NOTICE, + P_WRITELN, + P_WRITE, + P_LOG +}; + +#ifdef ZTS +PHPDBG_API int phpdbg_print(int TSRMLS_DC, FILE*, const char*, ...) PHP_ATTRIBUTE_FORMAT(printf, 4, 5); +#else +PHPDBG_API int phpdbg_print(int TSRMLS_DC, FILE*, const char*, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4); +#endif + +PHPDBG_API int phpdbg_rlog(FILE *stream, const char *fmt, ...); + +#define phpdbg_error(fmt, ...) phpdbg_print(P_ERROR TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT], fmt, ##__VA_ARGS__) +#define phpdbg_notice(fmt, ...) phpdbg_print(P_NOTICE TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT], fmt, ##__VA_ARGS__) +#define phpdbg_writeln(fmt, ...) phpdbg_print(P_WRITELN TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT], fmt, ##__VA_ARGS__) +#define phpdbg_write(fmt, ...) phpdbg_print(P_WRITE TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT], fmt, ##__VA_ARGS__) +#define phpdbg_log(fmt, ...) phpdbg_print(P_LOG TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT], fmt, ##__VA_ARGS__) + +#define phpdbg_error_ex(out, fmt, ...) phpdbg_print(P_ERROR TSRMLS_CC, out, fmt, ##__VA_ARGS__) +#define phpdbg_notice_ex(out, fmt, ...) phpdbg_print(P_NOTICE TSRMLS_CC, out, fmt, ##__VA_ARGS__) +#define phpdbg_writeln_ex(out, fmt, ...) phpdbg_print(P_WRITELN TSRMLS_CC, out, fmt, ##__VA_ARGS__) +#define phpdbg_write_ex(out, fmt, ...) phpdbg_print(P_WRITE TSRMLS_CC, out, fmt, ##__VA_ARGS__) +#define phpdbg_log_ex(out, fmt, ...) phpdbg_print(P_LOG TSRMLS_CC, out, fmt, ##__VA_ARGS__) + +#if PHPDBG_DEBUG +# define phpdbg_debug(fmt, ...) phpdbg_print(P_LOG TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDERR], fmt, ##__VA_ARGS__) +#else +# define phpdbg_debug(fmt, ...) +#endif + +/* {{{ For writing blank lines */ +#define EMPTY NULL /* }}} */ + +/* {{{ For prompt lines */ +#define PROMPT "phpdbg>" /* }}} */ + +/* {{{ For separation */ +#define SEPARATE "------------------------------------------------" /* }}} */ + +/* {{{ Color Management */ +#define PHPDBG_COLOR_LEN 12 +#define PHPDBG_COLOR_D(color, code) \ + {color, sizeof(color)-1, code} +#define PHPDBG_COLOR_END \ + {NULL, 0L, {0}} + +#define PHPDBG_COLOR_INVALID -1 +#define PHPDBG_COLOR_PROMPT 0 +#define PHPDBG_COLOR_ERROR 1 +#define PHPDBG_COLOR_NOTICE 2 +#define PHPDBG_COLORS 3 + +typedef struct _phpdbg_color_t { + char *name; + size_t name_length; + const char code[PHPDBG_COLOR_LEN]; +} phpdbg_color_t; + +PHPDBG_API const phpdbg_color_t *phpdbg_get_color(const char *name, size_t name_length TSRMLS_DC); +PHPDBG_API void phpdbg_set_color(int element, const phpdbg_color_t *color TSRMLS_DC); +PHPDBG_API void phpdbg_set_color_ex(int element, const char *name, size_t name_length TSRMLS_DC); +PHPDBG_API const phpdbg_color_t* phpdbg_get_colors(TSRMLS_D); /* }}} */ + +/* {{{ Prompt Management */ +PHPDBG_API void phpdbg_set_prompt(const char* TSRMLS_DC); +PHPDBG_API const char *phpdbg_get_prompt(TSRMLS_D); /* }}} */ + +#endif /* PHPDBG_UTILS_H */ diff --git a/test.php b/test.php new file mode 100644 index 00000000000..5fdbcbe1a45 --- /dev/null +++ b/test.php @@ -0,0 +1,51 @@ +isGreat("PHP Rocks!!")); + +foreach (test(1,2) as $gen) + continue; + +echo "it works!\n"; + +if (isset($dump)) + var_dump($_SERVER); + +function phpdbg_test_ob() +{ + echo 'Start'; + ob_start(); + echo 'Hello'; + $b = ob_get_clean(); + echo 'End'; + echo $b; +} diff --git a/tests/commands/0001_basic.test b/tests/commands/0001_basic.test new file mode 100644 index 00000000000..08aa9ab6644 --- /dev/null +++ b/tests/commands/0001_basic.test @@ -0,0 +1,8 @@ +####################################################### +# name: basic +# purpose: check basic functionality of phpdbg console +# expect: TEST::EXACT +# options: -rr +####################################################### +# [Nothing to execute!] +####################################################### diff --git a/tests/commands/0002_set.test b/tests/commands/0002_set.test new file mode 100644 index 00000000000..7720f94fff6 --- /dev/null +++ b/tests/commands/0002_set.test @@ -0,0 +1,23 @@ +################################################# +# name: set +# purpose: tests for set commands +# expect: TEST::CISTRING +# options: -rr +################################################# +# setting prompt color +# setting error color +# setting notice color +# Failed to find breakpoint #0 +# oplog disabled +# not enabled +# opened oplog test.log +# nothing +################################################# +set color prompt none +set color error none +set color notice none +set prompt promot> +set break 0 +set oplog +set oplog 0 +set oplog test.log diff --git a/tests/commands/0101_info.test b/tests/commands/0101_info.test new file mode 100644 index 00000000000..397a45c9927 --- /dev/null +++ b/tests/commands/0101_info.test @@ -0,0 +1,19 @@ +################################################# +# name: info +# purpose: test info commands +# expect: TEST::FORMAT +# options: -rr +################################################# +#[User Classes (%d)] +#User Class test (3) +#|---- in phpdbginit code on line %d +################################################# +<: +class test { + public function testMethod(){} + private function testPrivateMethod(){} + protected function testProtectedMethod(){} +} +:> +info classes +q diff --git a/tests/commands/0102_print.test b/tests/commands/0102_print.test new file mode 100644 index 00000000000..de4acb7651b --- /dev/null +++ b/tests/commands/0102_print.test @@ -0,0 +1,28 @@ +################################################# +# name: print +# purpose: test print commands +# expect: TEST::FORMAT +# options: -rr +################################################# +#[User Class: test] +#Methods (3): +#L%d-%d test::testMethod() %s +# L%d %s ZEND_RETURN C%d +# L%d-%d test::testPrivateMethod() %s +# L%d %s ZEND_RETURN C%d +# L%d-%d test::testProtectedMethod() %s +# L%d %s ZEND_RETURN C%d +#[User Method testMethod] +# L%d-%d test::testMethod() %s +# L%d %s ZEND_RETURN C%d +################################################# +<: +class test { + public function testMethod(){} + private function testPrivateMethod(){} + protected function testProtectedMethod(){} +} +:> +print class test +print method test::testMethod +q diff --git a/tests/commands/0103_register.test b/tests/commands/0103_register.test new file mode 100644 index 00000000000..38841591caf --- /dev/null +++ b/tests/commands/0103_register.test @@ -0,0 +1,28 @@ +################################################# +# name: register +# purpose: test registration functions +# expect: TEST::FORMAT +# options: -rr +################################################# +#[Registered test_function] +#array(5) { +# [0]=> +# string(1) "1" +# [1]=> +# string(1) "2" +# [2]=> +# string(1) "3" +# [3]=> +# string(1) "4" +# [4]=> +# string(1) "5" +#} +################################################# +<: +function test_function() { + var_dump(func_get_args()); +} +:> +R test_function +test_function 1 2 3 4 5 +q diff --git a/tests/commands/0104_clean.test b/tests/commands/0104_clean.test new file mode 100644 index 00000000000..c7a579be179 --- /dev/null +++ b/tests/commands/0104_clean.test @@ -0,0 +1,15 @@ +################################################# +# name: clean +# purpose: test cleaning environment +# expect: TEST::FORMAT +# options: -rr +################################################# +#[Cleaning Execution Environment] +#Classes %d +#Functions %d +#Constants %d +#Includes %d +#[Nothing to execute!] +################################################# +clean +quit diff --git a/tests/commands/0105_clear.test b/tests/commands/0105_clear.test new file mode 100644 index 00000000000..b547b0d6ba1 --- /dev/null +++ b/tests/commands/0105_clear.test @@ -0,0 +1,18 @@ +################################################# +# name: clear +# purpose: test clearing breakpoints +# expect: TEST::FORMAT +# options: -rr +################################################# +#[Clearing Breakpoints] +#File%w%d +#Functions%w%d +#Methods%w%d +#Oplines%w%d +#File oplines%w%d +#Function oplines%w%d +#Method oplines%w%d +#Conditionals%w%d +################################################# +clear +quit diff --git a/tests/commands/0106_compile.test b/tests/commands/0106_compile.test new file mode 100644 index 00000000000..d79211ddf75 --- /dev/null +++ b/tests/commands/0106_compile.test @@ -0,0 +1,19 @@ +################################################# +# name: compile +# purpose: test compiling code +# expect: TEST::FORMAT +# options: -rr +################################################# +#[Attempting compilation of %s] +#[Success] +#Hello World +################################################# +<: +define('OUT', + tempnam(null, "phpdbg")); +file_put_contents(OUT, ""); +phpdbg_exec(OUT); +:> +compile +run +quit diff --git a/tests/run-tests.php b/tests/run-tests.php new file mode 100644 index 00000000000..1fb6fa12242 --- /dev/null +++ b/tests/run-tests.php @@ -0,0 +1,583 @@ +config = array_shift($argv); + $this->message = vsprintf( + array_shift($argv), $argv); + } + } + } + + /** + * + * @package phpdbg + * @subpackage testing + */ + class TestsConfiguration implements \ArrayAccess { + + /** + * + * @param array basic configuration + * @param array argv + */ + public function __construct($config, $cmd) { + $this->options = $config; + while (($key = array_shift($cmd))) { + switch (substr($key, 0, 1)) { + case '-': switch(substr($key, 1, 1)) { + case '-': { + $arg = substr($key, 2); + if (($e=strpos($arg, '=')) !== false) { + $key = substr($arg, 0, $e); + $value = substr($arg, $e+1); + } else { + $key = $arg; + $value = array_shift($cmd); + } + + if (isset($key) && isset($value)) { + switch ($key) { + case 'phpdbg': + case 'width': + $this->options[$key] = $value; + break; + + default: { + if (isset($config[$key])) { + if (is_array($config[$key])) { + $this->options[$key][] = $value; + } else { + $this->options[$key] = array($config[$key], $value); + } + } else { + $this->options[$key] = $value; + } + } + } + + } + } break; + + default: + $this->flags[] = substr($key, 1); + } break; + } + } + + if (!is_executable($this->options['phpdbg'])) { + throw new TestConfigurationException( + $this->options, 'phpdbg could not be found at the specified path (%s)', $this->options['phpdbg']); + } else $this->options['phpdbg'] = realpath($this->options['phpdbg']); + + $this->options['width'] = (integer) $this->options['width']; + + /* display properly, all the time */ + if ($this->options['width'] < 50) { + $this->options['width'] = 50; + } + + /* calculate column widths */ + $this->options['lwidth'] = ceil($this->options['width'] / 3); + $this->options['rwidth'] = ceil($this->options['width'] - $this->options['lwidth']) - 5; + } + + public function hasFlag($flag) { + return in_array( + $flag, $this->flags); + } + + public function offsetExists($offset) { return isset($this->options[$offset]); } + public function offsetGet($offset) { return $this->options[$offset]; } + public function offsetUnset($offset) { unset($this->options[$offset]); } + public function offsetSet($offset, $data) { $this->options[$offset] = $data; } + + protected $options = array(); + protected $flags = array(); + } + + /** + * Tests is the console programming API for the test suite + * + * @package phpdbg + * @subpackage testing + */ + class Tests { + + /** + * Construct the console object + * + * @param array basic configuration + * @param array command line + */ + public function __construct(TestsConfiguration &$config) { + $this->config = &$config; + + if ($this->config->hasFlag('help') || + $this->config->hasFlag('h')) { + $this->showUsage(); + exit; + } + } + + /** + * Find valid paths as specified by configuration + * + */ + public function findPaths($in = null) { + $paths = array(); + $where = ($in != null) ? array($in) : $this->config['path']; + + foreach ($where as &$path) { + if ($path) { + if (is_dir($path)) { + $paths[] = $path; + foreach (scandir($path) as $child) { + if ($child != '.' && $child != '..') { + $paths = array_merge( + $paths, $this->findPaths("$path/$child")); + } + } + } + } + } + + return $paths; + } + + /** + * + * @param string the path to log + */ + public function logPath($path) { + printf( + '%s [%s]%s', + str_repeat( + '-', $this->config['width'] - strlen($path)), + $path, PHP_EOL); + } + + /** + * + * @param string the path to log + */ + public function logPathStats($path) { + if (!isset($this->stats[$path])) { + return; + } + + $total = array_sum($this->stats[$path]); + + if ($total) { + @$this->totals[true] += $this->stats[$path][true]; + @$this->totals[false] += $this->stats[$path][false]; + + $stats = @sprintf( + "%d/%d %%%d", + $this->stats[$path][true], + $this->stats[$path][false], + (100 / $total) * $this->stats[$path][true]); + + printf( + '%s [%s]%s', + str_repeat( + ' ', $this->config['width'] - strlen($stats)), + $stats, PHP_EOL); + + printf("%s%s", str_repeat('-', $this->config['width']+3), PHP_EOL); + printf("%s", PHP_EOL); + } + } + + /** + * + */ + public function logStats() { + $total = array_sum($this->totals); + $stats = @sprintf( + "%d/%d %%%d", + $this->totals[true], + $this->totals[false], + (100 / $total) * $this->totals[true]); + printf( + '%s [%s]%s', + str_repeat( + ' ', $this->config['width'] - strlen($stats)), + $stats, PHP_EOL); + + } + + /** + * + */ + protected function showUsage() { + printf('usage: php %s [flags] [options]%s', $this->config['exec'], PHP_EOL); + printf('[options]:%s', PHP_EOL); + printf("\t--path\t\tadd a path to scan outside of tests directory%s", PHP_EOL); + printf("\t--width\t\tset line width%s", PHP_EOL); + printf("\t--options\toptions to pass to phpdbg%s", PHP_EOL); + printf("\t--phpdbg\tpath to phpdbg binary%s", PHP_EOL); + printf('[flags]:%s', PHP_EOL); + printf("\t-nodiff\t\tdo not write diffs on failure%s", PHP_EOL); + printf("\t-nolog\t\tdo not write logs on failure%s", PHP_EOL); + printf('[examples]:%s', PHP_EOL); + printf("\tphp %s --phpdbg=/usr/local/bin/phpdbg --path=/usr/src/phpdbg/tests --options -n%s", + $this->config['exec'], PHP_EOL); + + } + + /** + * Find valid tests at the specified path (assumed valid) + * + * @param string a valid path + */ + public function findTests($path) { + $tests = array(); + + foreach (scandir($path) as $file) { + if ($file == '.' || $file == '..') + continue; + + $test = sprintf('%s/%s', $path, $file); + + if (preg_match('~\.test$~', $test)) { + yield new Test($this->config, $test); + } + } + } + + /** + * + * @param Test the test to log + */ + public function logTest($path, Test $test) { + @$this->stats[$path][($result=$test->getResult())]++; + + printf( + "%-{$this->config['lwidth']}s %-{$this->config['rwidth']}s [%s]%s", + $test->name, + $test->purpose, + $result ? "PASS" : "FAIL", + PHP_EOL); + } + + protected $config; + } + + class Test { + /* + * Expect exact line for line match + */ + const EXACT = 0x00000001; + + /* + * Expect strpos() !== false + */ + const STRING = 0x00000010; + + /* + * Expect stripos() !== false + */ + const CISTRING = 0x00000100; + + /* + * Formatted output + */ + const FORMAT = 0x00001000; + + /** + * Format specifiers + */ + private static $format = array( + 'search' => array( + '%e', + '%s', + '%S', + '%a', + '%A', + '%w', + '%i', + '%d', + '%x', + '%f', + '%c', + '%t', + '%T' + ), + 'replace' => array( + DIR_SEP, + '[^\r\n]+', + '[^\r\n]*', + '.+', + '.*', + '\s*', + '[+-]?\d+', + '\d+', + '[0-9a-fA-F]+', + '[+-]?\.?\d+\.?\d*(?:[Ee][+-]?\d+)?', + '.', + '\t', + '\t+' + ) + ); + + /** + * Constructs a new Test object given a specilized phpdbginit file + * + * @param array configuration + * @param string file + */ + public function __construct(TestsConfiguration &$config, &$file) { + if (($handle = fopen($file, 'r'))) { + while (($line = fgets($handle))) { + $trim = trim($line); + + switch (substr($trim, 0, 1)) { + case '#': if (($chunks = array_map('trim', preg_split('~:~', substr($trim, 1), 2)))) { + if (property_exists($this, $chunks[0])) { + switch ($chunks[0]) { + case 'expect': { + if ($chunks[1]) { + switch (strtoupper($chunks[1])) { + case 'TEST::EXACT': + case 'EXACT': { $this->expect = TEST::EXACT; } break; + + case 'TEST::STRING': + case 'STRING': { $this->expect = TEST::STRING; } break; + + case 'TEST::CISTRING': + case 'CISTRING': { $this->expect = TEST::CISTRING; } break; + + case 'TEST::FORMAT': + case 'FORMAT': { $this->expect = TEST::FORMAT; } break; + + default: + throw new TestConfigurationException( + $this->config, "unknown type of expectation (%s)", $chunks[1]); + } + } + } break; + + default: { + $this->$chunks[0] = $chunks[1]; + } + } + } else switch(substr($trim, 1, 1)) { + case '#': { /* do nothing */ } break; + + default: { + $line = preg_replace( + "~(\r\n)~", "\n", substr($trim, 1)); + + $line = trim($line); + + switch ($this->expect) { + case TEST::FORMAT: + $this->match[] = str_replace( + self::$format['search'], + self::$format['replace'], preg_quote($line)); + break; + + default: $this->match[] = $line; + } + } + } + } break; + + default: + break 2; + } + } + fclose($handle); + + $this->config = &$config; + $this->file = &$file; + } + } + + /** + * Obvious!! + * + */ + public function getResult() { + $options = sprintf( + '-i%s -qb', $this->file); + + if ($this->options) { + $options = sprintf( + '%s %s %s', + $options, + $this->config['options'], + $this->options + ); + } else { + $options = sprintf( + '%s %s', $options, $this->config['options'] + ); + } + + $result = `{$this->config['phpdbg']} {$options}`; + + if ($result) { + foreach (preg_split('~(\r|\n)~', $result) as $num => $line) { + if (!$line && !isset($this->match[$num])) + continue; + + switch ($this->expect) { + case TEST::EXACT: { + if (strcmp($line, $this->match[$num]) !== 0) { + $this->diff['wants'][$num] = &$this->match[$num]; + $this->diff['gets'][$num] = $line; + } + } continue 2; + + case TEST::STRING: { + if (strpos($line, $this->match[$num]) === false) { + $this->diff['wants'][$num] = &$this->match[$num]; + $this->diff['gets'][$num] = $line; + } + } continue 2; + + case TEST::CISTRING: { + if (stripos($line, $this->match[$num]) === false) { + $this->diff['wants'][$num] = &$this->match[$num]; + $this->diff['gets'][$num] = $line; + } + } continue 2; + + case TEST::FORMAT: { + $line = trim($line); + if (!preg_match("/^{$this->match[$num]}\$/s", $line)) { + $this->diff['wants'][$num] = &$this->match[$num]; + $this->diff['gets'][$num] = $line; + } + } continue 2; + } + } + } + + $this->writeLog($result); + $this->writeDiff(); + + return (count($this->diff) == 0); + } + + /** + * Write diff to disk if configuration allows it + * + */ + protected function writeDiff() { + $diff = sprintf( + '%s/%s.diff', + dirname($this->file), basename($this->file)); + + if (count($this->diff['wants'])) { + if (!in_array('nodiff', $this->config['flags'])) { + if (($diff = fopen($diff, 'w+'))) { + + foreach ($this->diff['wants'] as $line => $want) { + $got = $this->diff['gets'][$line]; + + fprintf( + $diff, '(%d) -%s%s', $line+1, $want, PHP_EOL); + fprintf( + $diff, '(%d) +%s%s', $line+1, $got, PHP_EOL); + } + + fclose($diff); + } + } + } else unlink($diff); + } + + /** + * Write log to disk if configuration allows it + * + */ + protected function writeLog(&$result = null) { + $log = sprintf( + '%s/%s.log', + dirname($this->file), basename($this->file)); + + if (count($this->diff) && $result) { + if (!in_array('nolog', $this->config['flags'])) { + @file_put_contents( + $log, $result); + } + } else unlink($log); + } + + public $name; + public $purpose; + public $file; + public $options; + public $expect; + + protected $match; + protected $diff; + protected $stats; + protected $totals; + } +} + +namespace { + use \phpdbg\Testing\Test; + use \phpdbg\Testing\Tests; + use \phpdbg\Testing\TestsConfiguration; + + $cwd = dirname(__FILE__); + $cmd = $_SERVER['argv']; + { + $config = new TestsConfiguration(array( + 'exec' => realpath(array_shift($cmd)), + 'phpdbg' => realpath(sprintf( + '%s/../phpdbg', $cwd + )), + 'path' => array( + realpath(dirname(__FILE__)) + ), + 'flags' => array(), + 'width' => 75 + ), $cmd); + + $tests = new Tests($config); + + foreach ($tests->findPaths() as $path) { + $tests->logPath($path); + + foreach ($tests->findTests($path) as $test) { + $tests->logTest($path, $test); + } + + $tests->logPathStats($path); + } + + $tests->logStats(); + } +} +?> diff --git a/travis/ci.sh b/travis/ci.sh new file mode 100755 index 00000000000..44d56a01ffe --- /dev/null +++ b/travis/ci.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env sh +git clone https://github.com/php/php-src +cd php-src/sapi +git clone https://github.com/krakjoe/phpdbg.git +cd ../ +./buildconf --force +./configure --disable-all --enable-phpdbg --enable-maintainer-zts +make +make test-phpdbg diff --git a/web-bootstrap.php b/web-bootstrap.php new file mode 100644 index 00000000000..7b8c5d30de8 --- /dev/null +++ b/web-bootstrap.php @@ -0,0 +1,64 @@ + 'localhost', + 'HTTP_CONNECTION' => 'keep-alive', + 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', + 'HTTP_USER_AGENT' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.65 Safari/537.36', + 'HTTP_ACCEPT_ENCODING' => 'gzip,deflate,sdch', + 'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.8', + 'HTTP_COOKIE' => 'tz=Europe%2FLondon; __utma=1.347100075.1384196523.1384196523.1384196523.1; __utmc=1; __utmz=1.1384196523.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)', + 'PATH' => '/usr/local/bin:/usr/bin:/bin', + 'SERVER_SIGNATURE' => '
Apache/2.4.6 (Ubuntu) Server at phpdbg.com Port 80
', + 'SERVER_SOFTWARE' => 'Apache/2.4.6 (Ubuntu)', + 'SERVER_NAME' => 'localhost', + 'SERVER_ADDR' => '127.0.0.1', + 'SERVER_PORT' => '80', + 'REMOTE_ADDR' => '127.0.0.1', + 'DOCUMENT_ROOT' => PHPDBG_BOOTPATH, + 'REQUEST_SCHEME' => 'http', + 'CONTEXT_PREFIX' => '', + 'CONTEXT_DOCUMENT_ROOT' => PHPDBG_BOOTPATH, + 'SERVER_ADMIN' => '[no address given]', + 'SCRIPT_FILENAME' => sprintf( + '%s/%s', PHPDBG_BOOTPATH, PHPDBG_BOOTSTRAP + ), + 'REMOTE_PORT' => '47931', + 'GATEWAY_INTERFACE' => 'CGI/1.1', + 'SERVER_PROTOCOL' => 'HTTP/1.1', + 'REQUEST_METHOD' => 'GET', + 'QUERY_STRING' => '', + 'REQUEST_URI' => PHPDBG_BOOTSTRAPPED, + 'SCRIPT_NAME' => PHPDBG_BOOTSTRAPPED, + 'PHP_SELF' => PHPDBG_BOOTSTRAPPED, + 'REQUEST_TIME' => time(), +); + +$_GET = array(); +$_REQUEST = array(); +$_POST = array(); +$_COOKIE = array(); +$_FILES = array(); + +chdir(PHPDBG_BOOTPATH); From a1387ae0883d0d4295d9d747d684e9e8055f1f39 Mon Sep 17 00:00:00 2001 From: Joe Watkins Date: Mon, 23 Dec 2013 22:36:30 +0000 Subject: [PATCH 002/398] credits file for phpdbg --- CREDITS | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 CREDITS diff --git a/CREDITS b/CREDITS new file mode 100644 index 00000000000..036bafe1db2 --- /dev/null +++ b/CREDITS @@ -0,0 +1,2 @@ +phpdbg +Felipe Pena, Joe Watkins, Bob Weinand From 02352bee6055dc7e250cc4464f002f9e61c0586b Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sat, 21 Dec 2013 22:42:11 +0100 Subject: [PATCH 003/398] Added breaking upon fatal-ish error --- phpdbg.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/phpdbg.c b/phpdbg.c index 17193ed244c..4b75ce26ca1 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -438,6 +438,35 @@ static void php_sapi_phpdbg_log_message(char *message TSRMLS_DC) /* {{{ */ */ if (phpdbg_booted) { phpdbg_error("%s", message); + + switch (PG(last_error_type)) { + case E_ERROR: + case E_CORE_ERROR: + case E_COMPILE_ERROR: + 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 + ); + } + + do { + switch (phpdbg_interactive(TSRMLS_C)) { + case PHPDBG_LEAVE: + case PHPDBG_FINISH: + case PHPDBG_UNTIL: + case PHPDBG_NEXT: + return; + } + } while (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)); + + } } else fprintf(stdout, "%s\n", message); } /* }}} */ From 31c15f0d177e503f47df22b9348796bddb08eb3b Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Mon, 23 Dec 2013 23:55:07 +0100 Subject: [PATCH 004/398] Fixed credits in phpdbg.* files --- phpdbg.c | 1 + phpdbg.h | 1 + 2 files changed, 2 insertions(+) diff --git a/phpdbg.c b/phpdbg.c index 4b75ce26ca1..a0665a7ee58 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -14,6 +14,7 @@ +----------------------------------------------------------------------+ | Authors: Felipe Pena | | Authors: Joe Watkins | + | Authors: Bob Weinand | +----------------------------------------------------------------------+ */ diff --git a/phpdbg.h b/phpdbg.h index f0a59ce4731..3a3da7636ac 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -14,6 +14,7 @@ +----------------------------------------------------------------------+ | Authors: Felipe Pena | | Authors: Joe Watkins | + | Authors: Bob Weinand | +----------------------------------------------------------------------+ */ From 36f487a32cb8b9d61bbcbc37c43b7a973dbcc7f8 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 24 Dec 2013 13:11:57 +0100 Subject: [PATCH 005/398] Fixed #18 Errors not displaying in some configurations --- phpdbg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/phpdbg.c b/phpdbg.c index a0665a7ee58..d025294f1fe 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -25,6 +25,7 @@ #include "phpdbg_prompt.h" #include "phpdbg_bp.h" #include "phpdbg_break.h" +#include "phpdbg_list.h" #include "phpdbg_utils.h" #include "phpdbg_set.h" @@ -609,7 +610,8 @@ const char phpdbg_ini_hardcoded[] = "display_errors=Off\n" "log_errors=On\n" "max_execution_time=0\n" -"max_input_time=-1\n\0"; +"max_input_time=-1\n" +"error_log=\n\0"; /* overwriteable ini defaults must be set in phpdbg_ini_defaults() */ #define INI_DEFAULT(name, value) \ From 868dbe7baffc20f964f2bc005f90e0d262e97730 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 24 Dec 2013 21:08:33 +0100 Subject: [PATCH 006/398] fixed incompatible pointer in phpdbg on win64 --- phpdbg_utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpdbg_utils.c b/phpdbg_utils.c index 86c17a71bee..7b2000da0ea 100644 --- a/phpdbg_utils.c +++ b/phpdbg_utils.c @@ -290,8 +290,9 @@ PHPDBG_API int phpdbg_rlog(FILE *fp, const char *fmt, ...) { /* {{{ */ if (gettimeofday(&tp, NULL) == SUCCESS) { char friendly[100]; char *format = NULL, *buffer = NULL; + const time_t tt = tp.tv_sec; - strftime(friendly, 100, "%a %b %d %T.%%04d %Y", localtime(&tp.tv_sec)); + strftime(friendly, 100, "%a %b %d %T.%%04d %Y", localtime(&tt)); asprintf( &buffer, friendly, tp.tv_usec/1000); asprintf( From b36bae023e5e4ef190bc67d8d49f7038589233d6 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 25 Dec 2013 23:43:20 +0100 Subject: [PATCH 007/398] fix c89 compat --- phpdbg.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index d025294f1fe..fd15f809848 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -137,9 +137,8 @@ static void php_phpdbg_destroy_bp_condition(void *data) /* {{{ */ static void php_phpdbg_destroy_registered(void *data) /* {{{ */ { - TSRMLS_FETCH(); - zend_function *function = (zend_function*) data; + TSRMLS_FETCH(); destroy_zend_function( function TSRMLS_CC); From 2b111a3b14feaae1fb557a3bd675448859bcf293 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Fri, 27 Dec 2013 18:03:11 +0000 Subject: [PATCH 008/398] update version output --- phpdbg.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index fd15f809848..fb3a67747cb 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -1037,11 +1037,10 @@ phpdbg_main: sapi_startup(phpdbg); phpdbg->startup(phpdbg); printf( - "phpdbg %s (built: %s %s)\nCopyright (c) 2013 %s\nPHP %s, Copyright (c) 1997-2013 The PHP Group\n%s", + "phpdbg %s (built: %s %s)\nPHP %s, Copyright (c) 1997-2013 The PHP Group\n%s", PHPDBG_VERSION, __DATE__, __TIME__, - PHPDBG_AUTHORS, PHP_VERSION, get_zend_version() ); From 75bad44801d1dd66fc785ed31ffa14a6cf98f3d6 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Fri, 3 Jan 2014 11:08:10 +0800 Subject: [PATCH 009/398] Bump year --- phpdbg.c | 4 ++-- phpdbg.h | 2 +- phpdbg_bp.c | 2 +- phpdbg_bp.h | 2 +- phpdbg_break.c | 2 +- phpdbg_break.h | 2 +- phpdbg_cmd.c | 2 +- phpdbg_cmd.h | 2 +- phpdbg_frame.c | 2 +- phpdbg_frame.h | 2 +- phpdbg_help.c | 2 +- phpdbg_help.h | 2 +- phpdbg_info.c | 2 +- phpdbg_info.h | 2 +- phpdbg_list.c | 2 +- phpdbg_list.h | 2 +- phpdbg_opcode.c | 2 +- phpdbg_opcode.h | 2 +- phpdbg_print.c | 2 +- phpdbg_print.h | 2 +- phpdbg_prompt.c | 2 +- phpdbg_prompt.h | 2 +- phpdbg_set.c | 2 +- phpdbg_set.h | 2 +- phpdbg_utils.c | 2 +- phpdbg_utils.h | 2 +- 26 files changed, 27 insertions(+), 27 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index fb3a67747cb..deb7be6e2bd 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -1037,7 +1037,7 @@ phpdbg_main: sapi_startup(phpdbg); phpdbg->startup(phpdbg); printf( - "phpdbg %s (built: %s %s)\nPHP %s, Copyright (c) 1997-2013 The PHP Group\n%s", + "phpdbg %s (built: %s %s)\nPHP %s, Copyright (c) 1997-2014 The PHP Group\n%s", PHPDBG_VERSION, __DATE__, __TIME__, diff --git a/phpdbg.h b/phpdbg.h index 3a3da7636ac..66b4f699575 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/phpdbg_bp.c b/phpdbg_bp.c index 69e0fa7086d..511d1db57d7 100644 --- a/phpdbg_bp.c +++ b/phpdbg_bp.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/phpdbg_bp.h b/phpdbg_bp.h index ed1b413f6d3..b1a9ddf4749 100644 --- a/phpdbg_bp.h +++ b/phpdbg_bp.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/phpdbg_break.c b/phpdbg_break.c index 1423b960e66..f56f76facd9 100644 --- a/phpdbg_break.c +++ b/phpdbg_break.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/phpdbg_break.h b/phpdbg_break.h index 04abeb6805f..f90e351d6de 100644 --- a/phpdbg_break.h +++ b/phpdbg_break.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index 9f052d6f6f3..36a9d26dc21 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/phpdbg_cmd.h b/phpdbg_cmd.h index e779fd4b55d..c86f92bb478 100644 --- a/phpdbg_cmd.h +++ b/phpdbg_cmd.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/phpdbg_frame.c b/phpdbg_frame.c index 24aff59dd92..de02addc1b9 100644 --- a/phpdbg_frame.c +++ b/phpdbg_frame.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/phpdbg_frame.h b/phpdbg_frame.h index fbccd5404f5..7c4574ed280 100644 --- a/phpdbg_frame.h +++ b/phpdbg_frame.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/phpdbg_help.c b/phpdbg_help.c index edb12659554..a02cb41c143 100644 --- a/phpdbg_help.c +++ b/phpdbg_help.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/phpdbg_help.h b/phpdbg_help.h index 012a1b49e73..319142cb5b2 100644 --- a/phpdbg_help.h +++ b/phpdbg_help.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/phpdbg_info.c b/phpdbg_info.c index 1744f59215b..0f4233bf30c 100644 --- a/phpdbg_info.c +++ b/phpdbg_info.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/phpdbg_info.h b/phpdbg_info.h index 5d538123707..a6b4e3719fe 100644 --- a/phpdbg_info.h +++ b/phpdbg_info.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/phpdbg_list.c b/phpdbg_list.c index b49be857efa..eb1091550b0 100644 --- a/phpdbg_list.c +++ b/phpdbg_list.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/phpdbg_list.h b/phpdbg_list.h index d6180271585..f9d1885eaf2 100644 --- a/phpdbg_list.h +++ b/phpdbg_list.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/phpdbg_opcode.c b/phpdbg_opcode.c index 025d57a08dc..7e64d16d92a 100644 --- a/phpdbg_opcode.c +++ b/phpdbg_opcode.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/phpdbg_opcode.h b/phpdbg_opcode.h index 5771488e707..144442981dd 100644 --- a/phpdbg_opcode.h +++ b/phpdbg_opcode.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/phpdbg_print.c b/phpdbg_print.c index 51edcfbf8da..c4925fe5fd7 100644 --- a/phpdbg_print.c +++ b/phpdbg_print.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/phpdbg_print.h b/phpdbg_print.h index 1232f544d29..80010d5e7cc 100644 --- a/phpdbg_print.h +++ b/phpdbg_print.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index f2f482b7ece..bb26556f5ce 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/phpdbg_prompt.h b/phpdbg_prompt.h index e6706c7d5b1..6807d88f41d 100644 --- a/phpdbg_prompt.h +++ b/phpdbg_prompt.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/phpdbg_set.c b/phpdbg_set.c index 2472e1868c0..7c4da12a46e 100644 --- a/phpdbg_set.c +++ b/phpdbg_set.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/phpdbg_set.h b/phpdbg_set.h index 1c48786c66c..120aeb34f4e 100644 --- a/phpdbg_set.h +++ b/phpdbg_set.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/phpdbg_utils.c b/phpdbg_utils.c index 7b2000da0ea..1effcfccaf9 100644 --- a/phpdbg_utils.c +++ b/phpdbg_utils.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/phpdbg_utils.h b/phpdbg_utils.h index fbc17b78dd3..c5164c3ac31 100644 --- a/phpdbg_utils.h +++ b/phpdbg_utils.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | From 2dd38009ca2c60123a94aaecbd3e0ad4ceb4040e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Schl=C3=BCter?= Date: Sat, 18 Jan 2014 13:52:27 +0100 Subject: [PATCH 010/398] Merge branch 'phpdbg' into PHP-5.6 --- phpdbg.c | 66 ++++++++++++++++++++++++++++--------------------- phpdbg.h | 2 +- phpdbg_cmd.c | 35 +++++++++++++++++--------- phpdbg_opcode.c | 16 ++++++------ phpdbg_prompt.c | 20 ++++++++------- 5 files changed, 82 insertions(+), 57 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index deb7be6e2bd..e7f841c0bca 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -653,8 +653,11 @@ static inline void phpdbg_sigint_handler(int signo) /* {{{ */ PHPDBG_G(flags) |= PHPDBG_IS_SIGNALED; } } else { - PHPDBG_G(flags) |= PHPDBG_IS_QUITTING; - zend_bailout(); + /* we quit remote consoles on recv SIGINT */ + if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) { + PHPDBG_G(flags) |= PHPDBG_IS_QUITTING; + zend_bailout(); + } } } /* }}} */ @@ -1198,17 +1201,17 @@ phpdbg_main: } zend_end_try(); /* initialize from file */ + PHPDBG_G(flags) |= PHPDBG_IS_INITIALIZING; zend_try { - PHPDBG_G(flags) |= PHPDBG_IS_INITIALIZING; phpdbg_init(init_file, init_file_len, init_file_default TSRMLS_CC); phpdbg_try_file_init(bp_tmp_file, strlen(bp_tmp_file), 0 TSRMLS_CC); - PHPDBG_G(flags) &= ~PHPDBG_IS_INITIALIZING; - } zend_catch { - PHPDBG_G(flags) &= ~PHPDBG_IS_INITIALIZING; - if (PHPDBG_G(flags) & PHPDBG_IS_QUITTING) { - goto phpdbg_out; - } } zend_end_try(); + PHPDBG_G(flags) &= ~PHPDBG_IS_INITIALIZING; + + /* quit if init says so */ + if (PHPDBG_G(flags) & PHPDBG_IS_QUITTING) { + goto phpdbg_out; + } /* step from here, not through init */ if (step) { @@ -1235,39 +1238,46 @@ phpdbg_interact: phpdbg_export_breakpoints(bp_tmp_fp TSRMLS_CC); fclose(bp_tmp_fp); cleaning = 1; - goto phpdbg_out; } else { cleaning = 0; } -#ifndef _WIN32 - /* remote client disconnected */ - if ((PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED)) { - /* renegociate connections */ - phpdbg_open_sockets( - address, listen, &server, &socket, streams); +#ifndef _WIN32 + if (!cleaning) { + /* remote client disconnected */ + if ((PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED)) { - /* set streams */ - if (streams[0] && streams[1]) { - PHPDBG_G(flags) &= ~PHPDBG_IS_QUITTING; + if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) { + /* renegociate connections */ + phpdbg_open_sockets( + address, listen, &server, &socket, streams); + + /* set streams */ + if (streams[0] && streams[1]) { + PHPDBG_G(flags) &= ~PHPDBG_IS_QUITTING; + } + + /* this must be forced */ + CG(unclean_shutdown) = 0; + } else { + /* local consoles cannot disconnect, ignore EOF */ + PHPDBG_G(flags) &= ~PHPDBG_IS_DISCONNECTED; + } } - - /* this must be forced */ - CG(unclean_shutdown) = 0; } #endif - if (PHPDBG_G(flags) & PHPDBG_IS_QUITTING) { - goto phpdbg_out; - } } zend_end_try(); - } while(!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)); + } 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) { + if ((PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED)) { PHPDBG_G(flags) &= ~PHPDBG_IS_DISCONNECTED; goto phpdbg_interact; } @@ -1316,7 +1326,7 @@ phpdbg_out: if (cleaning || remote) { goto phpdbg_main; } - + #ifdef ZTS /* bugggy */ /* tsrm_shutdown(); */ diff --git a/phpdbg.h b/phpdbg.h index 66b4f699575..6b7afb23704 100644 --- a/phpdbg.h +++ b/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.0" +#define PHPDBG_VERSION "0.3.1" #define PHPDBG_INIT_FILENAME ".phpdbginit" /* }}} */ diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index 36a9d26dc21..29424d00fe7 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -467,32 +467,43 @@ PHPDBG_API phpdbg_input_t *phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */ } if (buffered == NULL) { -#ifndef HAVE_LIBREADLINE - char buf[PHPDBG_MAX_CMD]; - if ((!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && !phpdbg_write(phpdbg_get_prompt(TSRMLS_C))) || - !fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) { - /* the user has gone away */ - phpdbg_error("Failed to read console!"); +disconnect: + if (0) { PHPDBG_G(flags) |= (PHPDBG_IS_QUITTING|PHPDBG_IS_DISCONNECTED); zend_bailout(); return NULL; } +#ifndef HAVE_LIBREADLINE + char buf[PHPDBG_MAX_CMD]; + if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { + if (!phpdbg_write(phpdbg_get_prompt(TSRMLS_C))) { + goto disconnect; + } + } + + /* note: EOF is ignored */ +readline: + if (!fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) { + /* the user has gone away */ + if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { + goto disconnect; + } else goto readline; + } + cmd = buf; #else + /* note: EOF makes readline write prompt again in local console mode */ +readline: if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { char buf[PHPDBG_MAX_CMD]; if (fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) { cmd = buf; - } else cmd = NULL; + } else goto disconnect; } else cmd = readline(phpdbg_get_prompt(TSRMLS_C)); if (!cmd) { - /* the user has gone away */ - phpdbg_error("Failed to read console!"); - PHPDBG_G(flags) |= (PHPDBG_IS_QUITTING|PHPDBG_IS_DISCONNECTED); - zend_bailout(); - return NULL; + goto readline; } if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { diff --git a/phpdbg_opcode.c b/phpdbg_opcode.c index 7e64d16d92a..50073eb22bb 100644 --- a/phpdbg_opcode.c +++ b/phpdbg_opcode.c @@ -52,13 +52,15 @@ static inline char *phpdbg_decode_op(zend_op_array *ops, znode_op *op, zend_uint case IS_VAR: case IS_TMP_VAR: { zend_ulong id = 0, *pid = NULL; - if (zend_hash_index_find(vars, (zend_ulong) ops->vars - op->var, (void**) &pid) != SUCCESS) { - id = zend_hash_num_elements(vars); - zend_hash_index_update( - vars, (zend_ulong) ops->vars - op->var, - (void**) &id, - sizeof(zend_ulong), NULL); - } else id = *pid; + if (vars != NULL) { + if (zend_hash_index_find(vars, (zend_ulong) ops->vars - op->var, (void**) &pid) != SUCCESS) { + id = zend_hash_num_elements(vars); + zend_hash_index_update( + vars, (zend_ulong) ops->vars - op->var, + (void**) &id, + sizeof(zend_ulong), NULL); + } else id = *pid; + } asprintf(&decode, "@%lu", id); } break; diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index bb26556f5ce..cb46407957c 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -551,7 +551,8 @@ PHPDBG_COMMAND(run) /* {{{ */ 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_bool restore = 1; + if (!PHPDBG_G(ops)) { if (phpdbg_compile(TSRMLS_C) == FAILURE) { phpdbg_error("Failed to compile %s, cannot run", PHPDBG_G(exec)); @@ -586,18 +587,19 @@ PHPDBG_COMMAND(run) /* {{{ */ if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { phpdbg_error("Caught exit/error from VM"); - goto out; + restore = 0; } } zend_end_try(); - if (EG(exception)) { - phpdbg_handle_exception(TSRMLS_C); + if (restore) { + if (EG(exception)) { + phpdbg_handle_exception(TSRMLS_C); + } + + EG(active_op_array) = orig_op_array; + EG(opline_ptr) = orig_opline; + EG(return_value_ptr_ptr) = orig_retval_ptr; } - - EG(active_op_array) = orig_op_array; - EG(opline_ptr) = orig_opline; - EG(return_value_ptr_ptr) = orig_retval_ptr; - } else { phpdbg_error("Nothing to execute!"); } From 137feda86a96caa368453acba9befb6c15c69d12 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sun, 19 Jan 2014 02:05:10 +0100 Subject: [PATCH 011/398] fix C89 compat --- phpdbg_cmd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index 29424d00fe7..c7008512436 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -459,6 +459,9 @@ PHPDBG_API phpdbg_input_t *phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */ { phpdbg_input_t *buffer = NULL; char *cmd = NULL; +#ifndef HAVE_LIBREADLINE + char buf[PHPDBG_MAX_CMD]; +#endif if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && @@ -475,7 +478,6 @@ disconnect: } #ifndef HAVE_LIBREADLINE - char buf[PHPDBG_MAX_CMD]; if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { if (!phpdbg_write(phpdbg_get_prompt(TSRMLS_C))) { goto disconnect; From 270e487d4170b7dd36cb9fa4945532995fbe6883 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Sun, 2 Feb 2014 13:43:43 +0000 Subject: [PATCH 012/398] remove use of zend directly, avoid leaks/bugs in modules etc --- phpdbg.c | 43 +++++++++---------------------------------- 1 file changed, 9 insertions(+), 34 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index e7f841c0bca..7c94ac19ddc 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -872,6 +872,7 @@ int main(int argc, char **argv) /* {{{ */ phpdbg_main: if (!cleaning) { bp_tmp_file = malloc(L_tmpnam); + tmpnam(bp_tmp_file); if (bp_tmp_file == NULL) { phpdbg_error("Unable to create temporary file"); @@ -1117,8 +1118,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 +1186,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 +1260,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 +1282,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); From 591e64ff5898dfcb6dcd49729546f823a6b0e775 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Sun, 2 Feb 2014 14:04:47 +0000 Subject: [PATCH 013/398] update version --- phpdbg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpdbg.h b/phpdbg.h index 6b7afb23704..68c505ca636 100644 --- a/phpdbg.h +++ b/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" /* }}} */ From 1deeec0ba870b94d10f4a909193b4c47bc7a028d Mon Sep 17 00:00:00 2001 From: krakjoe Date: Sun, 2 Feb 2014 14:42:31 +0000 Subject: [PATCH 014/398] better use of tmpnam/mkstemp --- phpdbg.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index 7c94ac19ddc..9341ad35a50 100644 --- a/phpdbg.c +++ b/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,23 @@ 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) { + 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"); } } @@ -1317,7 +1336,11 @@ phpdbg_out: free(sapi_name); } +#ifdef _WIN32 free(bp_tmp_file); +#else + unlink(bp_tmp_file); +#endif return 0; } /* }}} */ From 395a936397992ea3ad70f3a4832be0a18716fb1f Mon Sep 17 00:00:00 2001 From: krakjoe Date: Sun, 2 Feb 2014 14:50:32 +0000 Subject: [PATCH 015/398] woops --- phpdbg.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index 9341ad35a50..6cb1645e65a 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -892,9 +892,11 @@ phpdbg_main: memset(bp_tmp_file, 0, sizeof(bp_tmp_file)); } #endif - + if (!bp_tmp_file) { - phpdbg_error("Unable to create temporary file"); + phpdbg_error( + "Unable to create temporary file"); + return 1; } } ini_entries = NULL; From d260b5d2401a84c591ff0ded4e9d85afe06919c3 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Sun, 2 Feb 2014 14:58:39 +0000 Subject: [PATCH 016/398] another patch from upstream --- phpdbg_cmd.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index c7008512436..1d78c533216 100644 --- a/phpdbg_cmd.c +++ b/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(¶m, 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(¶m TSRMLS_CC); } break; } From f1a6ca29fb6f2577b3d6a5202c7d5f5ec3b596ba Mon Sep 17 00:00:00 2001 From: krakjoe Date: Sun, 2 Feb 2014 15:10:17 +0000 Subject: [PATCH 017/398] clean symbols --- phpdbg_prompt.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index cb46407957c..529ab04194d 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -566,6 +566,12 @@ PHPDBG_COMMAND(run) /* {{{ */ zend_rebuild_symbol_table(TSRMLS_C); } + /* clean up from last execution */ + zend_execute_data *ex = EG(current_execute_data); + if (ex && ex->symbol_table) { + zend_hash_clean(ex->symbol_table); + } + /* clean seek state */ PHPDBG_G(flags) &= ~PHPDBG_SEEK_MASK; zend_hash_clean( From 2462d2764a88c34cd5a34f09c7aa68d7ea5b6899 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Sun, 2 Feb 2014 15:14:25 +0000 Subject: [PATCH 018/398] windows --- phpdbg_prompt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 529ab04194d..f586bb5a84f 100644 --- a/phpdbg_prompt.c +++ b/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) { @@ -567,7 +568,6 @@ PHPDBG_COMMAND(run) /* {{{ */ } /* clean up from last execution */ - zend_execute_data *ex = EG(current_execute_data); if (ex && ex->symbol_table) { zend_hash_clean(ex->symbol_table); } From 57294d68241589d2b4d1dec790200b21f26f3e7f Mon Sep 17 00:00:00 2001 From: Veres Lajos Date: Fri, 14 Feb 2014 17:16:17 +0200 Subject: [PATCH 019/398] a few typofixes --- phpdbg_help.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpdbg_help.c b/phpdbg_help.c index a02cb41c143..d2fea8d7c7a 100644 --- a/phpdbg_help.c +++ b/phpdbg_help.c @@ -268,7 +268,7 @@ PHPDBG_HELP(break) /* {{{ */ phpdbg_writeln(EMPTY); phpdbg_writeln("\t%sbreak op ZEND_ADD", phpdbg_get_prompt(TSRMLS_C)); phpdbg_writeln("\t%sb O ZEND_ADD", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill break on every occurence of the opcode provided"); + phpdbg_writeln("\tWill break on every occurrence of the opcode provided"); phpdbg_writeln(EMPTY); phpdbg_writeln("\t%sbreak del 1", phpdbg_get_prompt(TSRMLS_C)); phpdbg_writeln("\t%sb d 1", phpdbg_get_prompt(TSRMLS_C)); @@ -574,7 +574,7 @@ PHPDBG_HELP(options) /* {{{ */ phpdbg_writeln(" -c\t-c/my/php.ini\t\tSet php.ini file to load"); phpdbg_writeln(" -d\t-dmemory_limit=4G\tSet a php.ini directive"); phpdbg_writeln(" -n\tN/A\t\t\tDisable default php.ini"); - phpdbg_writeln(" -q\tN/A\t\t\tSupress welcome banner"); + phpdbg_writeln(" -q\tN/A\t\t\tSuppress welcome banner"); phpdbg_writeln(" -e\t-emytest.php\t\tSet execution context"); phpdbg_writeln(" -v\tN/A\t\t\tEnable oplog output"); phpdbg_writeln(" -s\tN/A\t\t\tEnable stepping"); From b20abadf90bb3948b26a37e2554441ef8e6bf38d Mon Sep 17 00:00:00 2001 From: Mateusz Kocielski Date: Tue, 18 Mar 2014 09:51:39 +0100 Subject: [PATCH 020/398] Fix phpdbg build on FreeBSD Added missing netinet/in.h header. --- phpdbg.c | 1 + 1 file changed, 1 insertion(+) diff --git a/phpdbg.c b/phpdbg.c index 6cb1645e65a..7e0e2bafcd5 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -35,6 +35,7 @@ # include # include # include +# include # include # include #endif /* }}} */ From ea12799eff485479813a7b4a5c4c706e1f7bf415 Mon Sep 17 00:00:00 2001 From: Mateusz Kocielski Date: Tue, 18 Mar 2014 10:49:28 +0100 Subject: [PATCH 021/398] Fixed wrong indentation --- phpdbg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpdbg.c b/phpdbg.c index 7e0e2bafcd5..51a328d0b53 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -35,7 +35,7 @@ # include # include # include -# include +# include # include # include #endif /* }}} */ From 3e3dcde8d7337b981354e69216a0cbf3950e2703 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Mon, 21 Apr 2014 23:29:25 +0200 Subject: [PATCH 022/398] Merge sapi/phpdbg into PHP-5.6 --- .gitignore | 4 +- Makefile.frag | 10 +- config.m4 | 15 +- config.w32 | 9 +- phpdbg.c | 312 ++++--- phpdbg.h | 72 +- phpdbg_bp.c | 102 +-- phpdbg_bp.h | 2 +- phpdbg_break.c | 126 +-- phpdbg_break.h | 23 +- phpdbg_btree.c | 221 +++++ phpdbg_btree.h | 65 ++ phpdbg_cmd.c | 698 +++++++++------ phpdbg_cmd.h | 112 +-- phpdbg_frame.c | 4 +- phpdbg_help.c | 1427 +++++++++++++++++------------ phpdbg_help.h | 60 +- phpdbg_info.c | 16 + phpdbg_info.h | 12 +- phpdbg_lexer.c | 2271 +++++++++++++++++++++++++++++++++++++++++++++++ phpdbg_lexer.h | 348 ++++++++ phpdbg_lexer.l | 131 +++ phpdbg_list.c | 185 ++-- phpdbg_list.h | 8 +- phpdbg_opcode.c | 5 + phpdbg_parser.y | 168 ++++ phpdbg_print.c | 175 ++-- phpdbg_print.h | 13 +- phpdbg_prompt.c | 875 +++++++++--------- phpdbg_prompt.h | 13 +- phpdbg_set.c | 260 +++--- phpdbg_set.h | 15 +- phpdbg_utils.c | 61 ++ phpdbg_utils.h | 27 +- phpdbg_watch.c | 789 ++++++++++++++++ phpdbg_watch.h | 112 +++ phpdbg_win.c | 42 + phpdbg_win.h | 37 + test.php | 46 +- 39 files changed, 6825 insertions(+), 2046 deletions(-) create mode 100644 phpdbg_btree.c create mode 100644 phpdbg_btree.h create mode 100644 phpdbg_lexer.c create mode 100644 phpdbg_lexer.h create mode 100644 phpdbg_lexer.l create mode 100644 phpdbg_parser.y create mode 100644 phpdbg_watch.c create mode 100644 phpdbg_watch.h create mode 100644 phpdbg_win.c create mode 100644 phpdbg_win.h diff --git a/.gitignore b/.gitignore index 297efcbc420..af445861acd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ .libs/ -./phpdbg +phpdbg *.lo *.o build +phpdbg_parser.c +phpdbg_parser.h diff --git a/Makefile.frag b/Makefile.frag index 5be6d5b00f4..45768de2eff 100644 --- a/Makefile.frag +++ b/Makefile.frag @@ -8,6 +8,15 @@ $(BUILD_SHARED): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_PHPDBG_OBJS) $(BUILD_BINARY): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_PHPDBG_OBJS) $(BUILD_PHPDBG) +$(builddir)/sapi/phpdbg/phpdbg_lexer.lo: $(srcdir)/sapi/phpdbg/phpdbg_parser.h + +$(srcdir)/sapi/phpdbg/phpdbg_lexer.c: $(srcdir)/sapi/phpdbg/phpdbg_lexer.l + @(cd $(top_srcdir); $(RE2C) $(RE2C_FLAGS) --no-generation-date -cbdFo sapi/phpdbg/phpdbg_lexer.c sapi/phpdbg/phpdbg_lexer.l) + +$(srcdir)/sapi/phpdbg/phpdbg_parser.h: $(srcdir)/sapi/phpdbg/phpdbg_parser.c +$(srcdir)/sapi/phpdbg/phpdbg_parser.c: $(srcdir)/sapi/phpdbg/phpdbg_parser.y + @$(YACC) -p phpdbg_ -v -d $(srcdir)/sapi/phpdbg/phpdbg_parser.y -o $@ + install-phpdbg: $(BUILD_BINARY) @echo "Installing phpdbg binary: $(INSTALL_ROOT)$(bindir)/" @$(mkinstalldirs) $(INSTALL_ROOT)$(bindir) @@ -25,4 +34,3 @@ test-phpdbg: .PHONY: clean-phpdbg test-phpdbg - diff --git a/config.m4 b/config.m4 index 274e6409d04..3534d90124d 100644 --- a/config.m4 +++ b/config.m4 @@ -3,10 +3,10 @@ dnl $Id$ dnl PHP_ARG_ENABLE(phpdbg, for phpdbg support, -[ --enable-phpdbg Build phpdbg], yes, yes) +[ --enable-phpdbg Build phpdbg], no, no) PHP_ARG_ENABLE(phpdbg-debug, for phpdbg debug build, -[ --enable-phpdbg-debug Build phpdbg in debug mode], no, no) +[ --enable-phpdbg-debug Build phpdbg in debug mode], no, no) if test "$PHP_PHPDBG" != "no"; then AC_DEFINE(HAVE_PHPDBG, 1, [ ]) @@ -18,17 +18,22 @@ if test "$PHP_PHPDBG" != "no"; then fi PHP_PHPDBG_CFLAGS="-D_GNU_SOURCE" - PHP_PHPDBG_FILES="phpdbg.c phpdbg_prompt.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_info.c phpdbg_cmd.c phpdbg_set.c phpdbg_frame.c" + PHP_PHPDBG_FILES="phpdbg.c phpdbg_parser.c phpdbg_lexer.c phpdbg_prompt.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_info.c phpdbg_cmd.c phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_btree.c" + if test "$PHP_READLINE" != "no"; then + PHPDBG_EXTRA_LIBS="-lreadline" + fi + PHP_SUBST(PHP_PHPDBG_CFLAGS) PHP_SUBST(PHP_PHPDBG_FILES) - + PHP_SUBST(PHPDBG_EXTRA_LIBS) + PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/sapi/phpdbg/Makefile.frag]) PHP_SELECT_SAPI(phpdbg, program, $PHP_PHPDBG_FILES, $PHP_PHPDBG_CFLAGS, [$(SAPI_PHPDBG_PATH)]) BUILD_BINARY="sapi/phpdbg/phpdbg" BUILD_SHARED="sapi/phpdbg/libphpdbg.la" - + BUILD_PHPDBG="\$(LIBTOOL) --mode=link \ \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \ \$(PHP_GLOBAL_OBJS) \ diff --git a/config.w32 b/config.w32 index 29031507b31..fcc2b61a87e 100644 --- a/config.w32 +++ b/config.w32 @@ -1,19 +1,18 @@ -ARG_ENABLE('phpdbg', 'Build phpdbg', 'yes'); +ARG_ENABLE('phpdbg', 'Build phpdbg', 'no'); ARG_ENABLE('phpdbgs', 'Build phpdbg shared', 'no'); -PHPDBG_SOURCES='phpdbg.c phpdbg_prompt.c phpdbg_cmd.c phpdbg_info.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_set.c phpdbg_frame.c'; +PHPDBG_SOURCES='phpdbg.c phpdbg_prompt.c phpdbg_cmd.c phpdbg_info.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_win.c phpdbg_btree.c'; PHPDBG_DLL='php' + PHP_VERSION + 'phpdbg.dll'; PHPDBG_EXE='phpdbg.exe'; if (PHP_PHPDBG == "yes") { - /* build phpdbg binary */ SAPI('phpdbg', PHPDBG_SOURCES, PHPDBG_EXE); ADD_FLAG("LIBS_PHPDBG", "ws2_32.lib user32.lib"); + DEFINE("CFLAGS", configure_subst.item("CFLAGS") + " /EHa"); } if (PHP_PHPDBGS == "yes") { SAPI('phpdbgs', PHPDBG_SOURCES, PHPDBG_DLL, '/D PHP_PHPDBG_EXPORTS /I win32'); ADD_FLAG("LIBS_PHPDBGS", "ws2_32.lib user32.lib"); + DEFINE("CFLAGS", configure_subst.item("CFLAGS") + " /EHa"); } - - diff --git a/phpdbg.c b/phpdbg.c index 51a328d0b53..064e266082e 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -#ifndef ZEND_SIGNALS +#if !defined(ZEND_SIGNALS) || defined(_WIN32) # include #endif #include "phpdbg.h" @@ -28,6 +28,7 @@ #include "phpdbg_list.h" #include "phpdbg_utils.h" #include "phpdbg_set.h" +#include "zend_alloc.h" /* {{{ remote console headers */ #ifndef _WIN32 @@ -61,16 +62,15 @@ static inline void php_phpdbg_globals_ctor(zend_phpdbg_globals *pg) /* {{{ */ pg->exec = NULL; pg->exec_len = 0; + pg->buffer = NULL; pg->ops = NULL; pg->vmret = 0; pg->bp_count = 0; - pg->lcmd = NULL; pg->flags = PHPDBG_DEFAULT_FLAGS; pg->oplog = NULL; pg->io[PHPDBG_STDIN] = NULL; pg->io[PHPDBG_STDOUT] = NULL; pg->io[PHPDBG_STDERR] = NULL; - memset(&pg->lparam, 0, sizeof(phpdbg_param_t)); pg->frame.num = 0; } /* }}} */ @@ -145,6 +145,7 @@ static void php_phpdbg_destroy_registered(void *data) /* {{{ */ function TSRMLS_CC); } /* }}} */ + static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */ { zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], 8, NULL, php_phpdbg_destroy_bp_file, 0); @@ -157,7 +158,9 @@ static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */ zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], 8, NULL, php_phpdbg_destroy_bp_methods, 0); zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], 8, NULL, php_phpdbg_destroy_bp_condition, 0); zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], 8, NULL, NULL, 0); - + + phpdbg_setup_watchpoints(TSRMLS_C); + zend_hash_init(&PHPDBG_G(seek), 8, NULL, NULL, 0); zend_hash_init(&PHPDBG_G(registered), 8, NULL, php_phpdbg_destroy_registered, 0); @@ -178,7 +181,14 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */ zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP]); zend_hash_destroy(&PHPDBG_G(seek)); zend_hash_destroy(&PHPDBG_G(registered)); + zend_hash_destroy(&PHPDBG_G(watchpoints)); + zend_llist_destroy(&PHPDBG_G(watchlist_mem)); + if (PHPDBG_G(buffer)) { + efree(PHPDBG_G(buffer)); + PHPDBG_G(buffer) = NULL; + } + if (PHPDBG_G(exec)) { efree(PHPDBG_G(exec)); PHPDBG_G(exec) = NULL; @@ -209,24 +219,24 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */ return SUCCESS; } /* }}} */ -/* {{{ proto mixed phpdbg_exec(string context) +/* {{{ proto mixed phpdbg_exec(string context) Attempt to set the execution context for phpdbg If the execution context was set previously it is returned - If the execution context was not set previously boolean true is returned + If the execution context was not set previously boolean true is returned If the request to set the context fails, boolean false is returned, and an E_WARNING raised */ -static PHP_FUNCTION(phpdbg_exec) +static PHP_FUNCTION(phpdbg_exec) { char *exec = NULL; - zend_ulong exec_len = 0L; + int exec_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &exec, &exec_len) == FAILURE) { return; } - + { struct stat sb; zend_bool result = 1; - + if (VCWD_STAT(exec, &sb) != FAILURE) { if (sb.st_mode & (S_IFREG|S_IFLNK)) { if (PHPDBG_G(exec)) { @@ -234,11 +244,11 @@ static PHP_FUNCTION(phpdbg_exec) efree(PHPDBG_G(exec)); result = 0; } - + PHPDBG_G(exec) = estrndup(exec, exec_len); PHPDBG_G(exec_len) = exec_len; - - if (result) + + if (result) ZVAL_BOOL(return_value, 1); } else { zend_error( @@ -259,9 +269,9 @@ static PHP_FUNCTION(phpdbg_exec) static PHP_FUNCTION(phpdbg_break) { if (ZEND_NUM_ARGS() > 0) { - long type; + long type = 0; char *expr = NULL; - zend_uint expr_len = 0; + int expr_len = 0; phpdbg_param_t param; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &type, &expr, &expr_len) == FAILURE) { @@ -269,28 +279,7 @@ static PHP_FUNCTION(phpdbg_break) } phpdbg_parse_param(expr, expr_len, ¶m TSRMLS_CC); - - switch (type) { - case METHOD_PARAM: - phpdbg_do_break_method(¶m, NULL TSRMLS_CC); - break; - - case FILE_PARAM: - phpdbg_do_break_file(¶m, NULL TSRMLS_CC); - break; - - case NUMERIC_PARAM: - phpdbg_do_break_lineno(¶m, NULL TSRMLS_CC); - break; - - case STR_PARAM: - phpdbg_do_break_func(¶m, NULL TSRMLS_CC); - break; - - default: zend_error( - E_WARNING, "unrecognized parameter type %ld", type); - } - + phpdbg_do_break(¶m TSRMLS_CC); phpdbg_clear_param(¶m TSRMLS_CC); } else if (EG(current_execute_data) && EG(active_op_array)) { @@ -319,9 +308,9 @@ static PHP_FUNCTION(phpdbg_clear) /* {{{ proto void phpdbg_color(integer element, string color) */ static PHP_FUNCTION(phpdbg_color) { - long element; - char *color; - zend_uint color_len; + long element = 0L; + char *color = NULL; + int color_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &element, &color, &color_len) == FAILURE) { return; @@ -341,8 +330,8 @@ static PHP_FUNCTION(phpdbg_color) /* {{{ proto void phpdbg_prompt(string prompt) */ static PHP_FUNCTION(phpdbg_prompt) { - char *prompt; - zend_uint prompt_len; + char *prompt = NULL; + int prompt_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &prompt, &prompt_len) == FAILURE) { return; @@ -403,9 +392,9 @@ static inline int php_sapi_phpdbg_module_startup(sapi_module_struct *module) /* if (php_module_startup(module, &sapi_phpdbg_module_entry, 1) == FAILURE) { return FAILURE; } - + phpdbg_booted=1; - + return SUCCESS; } /* }}} */ @@ -585,7 +574,6 @@ const opt_struct OPTIONS[] = { /* {{{ */ {'z', 1, "load zend_extension"}, /* phpdbg options */ {'q', 0, "no banner"}, - {'e', 1, "exec"}, {'v', 0, "disable quietness"}, {'s', 0, "enable stepping"}, {'b', 0, "boring colours"}, @@ -615,10 +603,10 @@ const char phpdbg_ini_hardcoded[] = /* overwriteable ini defaults must be set in phpdbg_ini_defaults() */ #define INI_DEFAULT(name, value) \ - Z_SET_REFCOUNT(tmp, 0); \ - Z_UNSET_ISREF(tmp); \ - ZVAL_STRINGL(&tmp, zend_strndup(value, sizeof(value)-1), sizeof(value)-1, 0); \ - zend_hash_update(configuration_hash, name, sizeof(name), &tmp, sizeof(zval), NULL); + Z_SET_REFCOUNT(tmp, 0); \ + Z_UNSET_ISREF(tmp); \ + ZVAL_STRINGL(&tmp, zend_strndup(value, sizeof(value)-1), sizeof(value)-1, 0); \ + zend_hash_update(configuration_hash, name, sizeof(name), &tmp, sizeof(zval), NULL); void phpdbg_ini_defaults(HashTable *configuration_hash) /* {{{ */ { @@ -666,11 +654,11 @@ static inline void phpdbg_sigint_handler(int signo) /* {{{ */ int phpdbg_open_socket(const char *interface, short port) /* {{{ */ { int fd = socket(AF_INET, SOCK_STREAM, 0); - + switch (fd) { case -1: return -1; - + default: { int reuse = 1; @@ -678,27 +666,27 @@ int phpdbg_open_socket(const char *interface, short port) /* {{{ */ case -1: close(fd); return -2; - + default: { struct sockaddr_in address; - + memset(&address, 0, sizeof(address)); - + address.sin_port = htons(port); address.sin_family = AF_INET; - + if ((*interface == '*')) { - address.sin_addr.s_addr = htonl(INADDR_ANY); + address.sin_addr.s_addr = htonl(INADDR_ANY); } else if (!inet_pton(AF_INET, interface, &address.sin_addr)) { close(fd); return -3; } - + switch (bind(fd, (struct sockaddr *)&address, sizeof(address))) { case -1: close(fd); return -4; - + default: { listen(fd, 5); } @@ -707,28 +695,28 @@ int phpdbg_open_socket(const char *interface, short port) /* {{{ */ } } } - + return fd; } /* }}} */ static inline void phpdbg_close_sockets(int (*socket)[2], FILE *streams[2]) /* {{{ */ -{ +{ if ((*socket)[0] >= 0) { shutdown( (*socket)[0], SHUT_RDWR); close((*socket)[0]); } - + if (streams[0]) { fclose(streams[0]); } - + if ((*socket)[1] >= 0) { shutdown( (*socket)[1], SHUT_RDWR); close((*socket)[1]); } - + if (streams[1]) { fclose(streams[1]); } @@ -798,14 +786,34 @@ int phpdbg_open_sockets(char *address, int port[2], int (*listen)[2], int (*sock dup2((*socket)[0], fileno(stdin)); dup2((*socket)[1], fileno(stdout)); - + setbuf(stdout, NULL); streams[0] = fdopen((*socket)[0], "r"); streams[1] = fdopen((*socket)[1], "w"); - + return SUCCESS; } /* }}} */ + +void phpdbg_signal_handler(int sig, siginfo_t *info, void *context) { + int is_handled = FAILURE; + TSRMLS_FETCH(); + + switch (sig) { + case SIGBUS: + case SIGSEGV: + is_handled = phpdbg_watchpoint_segfault_handler(info, context TSRMLS_CC); + if (is_handled == FAILURE) { +#ifdef ZEND_SIGNALS + zend_sigaction(sig, &PHPDBG_G(old_sigsegv_signal), NULL TSRMLS_CC); +#else + sigaction(sig, &PHPDBG_G(old_sigsegv_signal), NULL); +#endif + } + break; + } + +} #endif int main(int argc, char **argv) /* {{{ */ @@ -852,6 +860,10 @@ int main(int argc, char **argv) /* {{{ */ #endif #ifndef _WIN32 + struct sigaction signal_struct; + signal_struct.sa_sigaction = phpdbg_signal_handler; + signal_struct.sa_flags = SA_SIGINFO | SA_NODEFER; + address = strdup("127.0.0.1"); socket[0] = -1; socket[1] = -1; @@ -888,17 +900,17 @@ phpdbg_main: bp_tmp_file = NULL; } } + + if (!bp_tmp_file) { + phpdbg_error("Unable to create temporary file"); + return 1; + } #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; ini_entries_len = 0; @@ -920,8 +932,7 @@ phpdbg_main: run = 0; step = 0; sapi_name = NULL; - - + while ((opt = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) { switch (opt) { case 'r': @@ -965,7 +976,7 @@ phpdbg_main: ini_entries_len += len + sizeof("=1\n\0") - 2; } } break; - + case 'z': zend_extensions_len++; if (zend_extensions) { @@ -976,16 +987,6 @@ phpdbg_main: /* begin phpdbg options */ - case 'e': { /* set execution context */ - exec_len = strlen(php_optarg); - if (exec_len) { - if (exec) { - free(exec); - } - exec = strdup(php_optarg); - } - } break; - case 'S': { /* set SAPI name */ if (sapi_name) { free(sapi_name); @@ -1001,7 +1002,7 @@ phpdbg_main: if (init_file) { free(init_file); } - + init_file_len = strlen(php_optarg); if (init_file_len) { init_file = strdup(php_optarg); @@ -1038,7 +1039,7 @@ phpdbg_main: #ifndef _WIN32 /* if you pass a listen port, we will accept input on listen port */ /* and write output to listen port * 2 */ - + case 'l': { /* set listen ports */ if (sscanf(php_optarg, "%d/%d", &listen[0], &listen[1]) != 2) { if (sscanf(php_optarg, "%d", &listen[0]) != 1) { @@ -1050,7 +1051,7 @@ phpdbg_main: } } } break; - + case 'a': { /* set bind address */ free(address); if (!php_optarg) { @@ -1076,6 +1077,19 @@ phpdbg_main: } break; } } + + /* set exec if present on command line */ + if ((argc > php_optind) && (strcmp(argv[php_optind-1],"--") != SUCCESS)) + { + exec_len = strlen(argv[php_optind]); + if (exec_len) { + if (exec) { + free(exec); + } + exec = strdup(argv[php_optind]); + } + php_optind++; + } #ifndef _WIN32 /* setup remote server if necessary */ @@ -1093,7 +1107,7 @@ phpdbg_main: if (sapi_name) { phpdbg->name = sapi_name; } - + phpdbg->ini_defaults = phpdbg_ini_defaults; phpdbg->phpinfo_as_text = 1; phpdbg->php_ini_ignore_cwd = 1; @@ -1114,14 +1128,14 @@ phpdbg_main: memcpy(ini_entries, phpdbg_ini_hardcoded, sizeof(phpdbg_ini_hardcoded)); } ini_entries_len += sizeof(phpdbg_ini_hardcoded) - 2; - + if (zend_extensions_len) { zend_ulong zend_extension = 0L; - + while (zend_extension < zend_extensions_len) { const char *ze = zend_extensions[zend_extension]; size_t ze_len = strlen(ze); - + ini_entries = realloc( ini_entries, ini_entries_len + (ze_len + (sizeof("zend_extension=\n")))); memcpy(&ini_entries[ini_entries_len], "zend_extension=", (sizeof("zend_extension=\n")-1)); @@ -1133,40 +1147,81 @@ phpdbg_main: free(zend_extensions[zend_extension]); zend_extension++; } - + free(zend_extensions); } phpdbg->ini_entries = ini_entries; - + if (phpdbg->startup(phpdbg) == SUCCESS) { - php_request_startup(TSRMLS_C); +#ifdef _WIN32 + EXCEPTION_POINTERS *xp; + __try { +#endif + zend_mm_heap *mm_heap = zend_mm_set_heap(NULL TSRMLS_CC); +#if ZEND_DEBUG + if (!mm_heap->use_zend_alloc) { + mm_heap->_malloc = malloc; + mm_heap->_realloc = realloc; + mm_heap->_free = free; +#endif + PHPDBG_G(original_free_function) = mm_heap->_free; + mm_heap->_free = phpdbg_watch_efree; + mm_heap->use_zend_alloc = 0; +#if ZEND_DEBUG + } +#endif + zend_mm_set_heap(mm_heap TSRMLS_CC); + + zend_activate(TSRMLS_C); + +#if defined(ZEND_SIGNALS) && !defined(_WIN32) + zend_try { + zend_signal_activate(TSRMLS_C); + } zend_end_try(); +#endif + +#if defined(ZEND_SIGNALS) && !defined(_WIN32) + zend_try { zend_sigaction(SIGSEGV, &signal_struct, &PHPDBG_G(old_sigsegv_signal) TSRMLS_CC); } zend_end_try(); + zend_try { zend_sigaction(SIGBUS, &signal_struct, &PHPDBG_G(old_sigsegv_signal) TSRMLS_CC); } zend_end_try(); +#elif !defined(_WIN32) + sigaction(SIGSEGV, &signal_struct, &PHPDBG_G(old_sigsegv_signal)); + sigaction(SIGBUS, &signal_struct, &PHPDBG_G(old_sigsegv_signal)); +#endif + + if (php_request_startup(TSRMLS_C) == SUCCESS) { + int i; + + SG(request_info).argc = argc - php_optind + 1; + SG(request_info).argv = emalloc(SG(request_info).argc * sizeof(char *)); + for (i = SG(request_info).argc; --i;) { + SG(request_info).argv[i] = estrdup(argv[php_optind - 1 + i]); + } + SG(request_info).argv[i] = exec ? estrndup(exec, exec_len) : estrdup(""); + + php_hash_environment(TSRMLS_C); + } + + /* make sure to turn off buffer for ev command */ + php_output_activate(TSRMLS_C); + php_output_deactivate(TSRMLS_C); /* do not install sigint handlers for remote consoles */ /* sending SIGINT then provides a decent way of shutting down the server */ -#ifdef ZEND_SIGNALS -# ifndef _WIN32 +#if defined(ZEND_SIGNALS) && !defined(_WIN32) if (listen[0] < 0) { -# endif - zend_try { - zend_signal_activate(TSRMLS_C); - zend_signal(SIGINT, phpdbg_sigint_handler TSRMLS_CC); - } zend_end_try(); -# ifndef _WIN32 + zend_try { zend_signal(SIGINT, phpdbg_sigint_handler TSRMLS_CC); } zend_end_try(); } -# endif -#else -# ifndef _WIN32 +#elif !defined(_WIN32) if (listen[0] < 0) { -# endif +#endif signal(SIGINT, phpdbg_sigint_handler); #ifndef _WIN32 } -#endif #endif PG(modules_activated) = 0; - + /* set flags from command line */ PHPDBG_G(flags) = flags; @@ -1182,10 +1237,9 @@ phpdbg_main: PHPDBG_G(io)[PHPDBG_STDIN] = stdin; PHPDBG_G(io)[PHPDBG_STDOUT] = stdout; PHPDBG_G(io)[PHPDBG_STDERR] = stderr; - + if (exec) { /* set execution context */ - PHPDBG_G(exec) = phpdbg_resolve_path( - exec TSRMLS_CC); + PHPDBG_G(exec) = phpdbg_resolve_path(exec TSRMLS_CC); PHPDBG_G(exec_len) = strlen(PHPDBG_G(exec)); free(exec); @@ -1213,6 +1267,11 @@ phpdbg_main: phpdbg_welcome((cleaning > 0) TSRMLS_CC); } + /* auto compile */ + if (PHPDBG_G(exec)) { + phpdbg_compile(TSRMLS_C); + } + /* initialize from file */ PHPDBG_G(flags) |= PHPDBG_IS_INITIALIZING; zend_try { @@ -1233,14 +1292,17 @@ phpdbg_main: if (run) { /* no need to try{}, run does it ... */ - PHPDBG_COMMAND_HANDLER(run)(NULL, NULL TSRMLS_CC); + PHPDBG_COMMAND_HANDLER(run)(NULL TSRMLS_CC); if (run > 1) { /* if -r is on the command line more than once just quit */ goto phpdbg_out; } } +/* #ifndef for making compiler shutting up */ +#ifndef _WIN32 phpdbg_interact: +#endif /* phpdbg main() */ do { zend_try { @@ -1282,21 +1344,42 @@ phpdbg_interact: } zend_end_try(); } while(!cleaning && !(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)); -phpdbg_out: + /* this must be forced */ + CG(unclean_shutdown) = 0; + + /* this is just helpful */ + PG(report_memleaks) = 0; + #ifndef _WIN32 +phpdbg_out: if ((PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED)) { PHPDBG_G(flags) &= ~PHPDBG_IS_DISCONNECTED; goto phpdbg_interact; } #endif +#ifdef _WIN32 + } __except(phpdbg_exception_handler_win32(xp = GetExceptionInformation())) { + phpdbg_error("Access violation (Segementation fault) encountered\ntrying to abort cleanly..."); + } +phpdbg_out: +#endif + + { + int i; + /* free argv */ + for (i = SG(request_info).argc; --i;) { + efree(SG(request_info).argv[i]); + } + efree(SG(request_info).argv); + } + #ifndef ZTS /* force cleanup of auto and core globals */ zend_hash_clean(CG(auto_globals)); memset( &core_globals, 0, sizeof(php_core_globals)); #endif - if (ini_entries) { free(ini_entries); } @@ -1318,6 +1401,7 @@ phpdbg_out: } zend_end_try(); sapi_shutdown(); + } if (cleaning || remote) { @@ -1331,7 +1415,7 @@ phpdbg_out: #ifndef _WIN32 if (address) { - free(address); + free(address); } #endif diff --git a/phpdbg.h b/phpdbg.h index 68c505ca636..be009e40d04 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -39,6 +39,9 @@ #include "zend_globals.h" #include "zend_ini_scanner.h" #include "zend_stream.h" +#ifndef _WIN32 +# include "zend_signal.h" +#endif #include "SAPI.h" #include #include @@ -68,6 +71,8 @@ #include "phpdbg_cmd.h" #include "phpdbg_utils.h" +#include "phpdbg_btree.h" +#include "phpdbg_watch.h" #ifdef ZTS # define PHPDBG_G(v) TSRMG(phpdbg_globals_id, zend_phpdbg_globals *, v) @@ -116,23 +121,26 @@ #define PHPDBG_IN_EVAL (1<<11) #define PHPDBG_IS_STEPPING (1<<12) -#define PHPDBG_IS_QUIET (1<<13) -#define PHPDBG_IS_QUITTING (1<<14) -#define PHPDBG_IS_COLOURED (1<<15) -#define PHPDBG_IS_CLEANING (1<<16) +#define PHPDBG_STEP_OPCODE (1<<13) +#define PHPDBG_IS_QUIET (1<<14) +#define PHPDBG_IS_QUITTING (1<<15) +#define PHPDBG_IS_COLOURED (1<<16) +#define PHPDBG_IS_CLEANING (1<<17) -#define PHPDBG_IN_UNTIL (1<<17) -#define PHPDBG_IN_FINISH (1<<18) -#define PHPDBG_IN_LEAVE (1<<19) +#define PHPDBG_IN_UNTIL (1<<18) +#define PHPDBG_IN_FINISH (1<<19) +#define PHPDBG_IN_LEAVE (1<<20) -#define PHPDBG_IS_REGISTERED (1<<20) -#define PHPDBG_IS_STEPONEVAL (1<<21) -#define PHPDBG_IS_INITIALIZING (1<<22) -#define PHPDBG_IS_SIGNALED (1<<23) -#define PHPDBG_IS_INTERACTIVE (1<<24) -#define PHPDBG_IS_BP_ENABLED (1<<25) -#define PHPDBG_IS_REMOTE (1<<26) -#define PHPDBG_IS_DISCONNECTED (1<<27) +#define PHPDBG_IS_REGISTERED (1<<21) +#define PHPDBG_IS_STEPONEVAL (1<<22) +#define PHPDBG_IS_INITIALIZING (1<<23) +#define PHPDBG_IS_SIGNALED (1<<24) +#define PHPDBG_IS_INTERACTIVE (1<<25) +#define PHPDBG_IS_BP_ENABLED (1<<26) +#define PHPDBG_IS_REMOTE (1<<27) +#define PHPDBG_IS_DISCONNECTED (1<<28) + +#define PHPDBG_SHOW_REFCOUNTS (1<<29) #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) @@ -149,7 +157,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.2" +#define PHPDBG_VERSION "0.4.0" #define PHPDBG_INIT_FILENAME ".phpdbginit" /* }}} */ @@ -159,12 +167,25 @@ #define PHPDBG_STDERR 2 #define PHPDBG_IO_FDS 3 /* }}} */ + /* {{{ structs */ ZEND_BEGIN_MODULE_GLOBALS(phpdbg) HashTable bp[PHPDBG_BREAK_TABLES]; /* break points */ HashTable registered; /* registered */ HashTable seek; /* seek oplines */ phpdbg_frame_t frame; /* frame */ + zend_uint last_line; /* last executed line */ + +#ifndef _WIN32 + struct sigaction old_sigsegv_signal; /* segv signal handler */ +#endif + + phpdbg_btree watchpoint_tree; /* tree with watchpoints */ + phpdbg_btree watch_HashTables; /* tree with original dtors of watchpoints */ + HashTable watchpoints; /* watchpoints */ + zend_llist watchlist_mem; /* triggered watchpoints */ + zend_bool watchpoint_hit; /* a watchpoint was hit */ + void (*original_free_function)(void *); /* the original AG(mm_heap)->_free function */ char *exec; /* file to execute */ size_t exec_len; /* size of exec */ @@ -178,11 +199,24 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg) char *prompt[2]; /* prompt */ const phpdbg_color_t *colors[PHPDBG_COLORS]; /* colors */ - - phpdbg_command_t *lcmd; /* last command */ - phpdbg_param_t lparam; /* last param */ + char *buffer; /* buffer */ zend_ulong flags; /* phpdbg flags */ ZEND_END_MODULE_GLOBALS(phpdbg) /* }}} */ +/* the beginning (= the important part) of the _zend_mm_heap struct defined in Zend/zend_alloc.c + Needed for realizing watchpoints */ +struct _zend_mm_heap { + int use_zend_alloc; + void *(*_malloc)(size_t); + void (*_free)(void *); + void *(*_realloc)(void *, size_t); + size_t free_bitmap; + size_t large_free_bitmap; + size_t block_size; + size_t compact_size; + zend_mm_segment *segments_list; + zend_mm_storage *storage; +}; + #endif /* PHPDBG_H */ diff --git a/phpdbg_bp.c b/phpdbg_bp.c index 511d1db57d7..a18316a2285 100644 --- a/phpdbg_bp.c +++ b/phpdbg_bp.c @@ -135,27 +135,27 @@ PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */ switch (brake->type) { case PHPDBG_BREAK_FILE: { fprintf(handle, - "break file %s:%lu\n", + "break %s:%lu\n", ((phpdbg_breakfile_t*)brake)->filename, ((phpdbg_breakfile_t*)brake)->line); } break; case PHPDBG_BREAK_SYM: { fprintf(handle, - "break func %s\n", + "break %s\n", ((phpdbg_breaksymbol_t*)brake)->symbol); } break; case PHPDBG_BREAK_METHOD: { fprintf(handle, - "break method %s::%s\n", + "break %s::%s\n", ((phpdbg_breakmethod_t*)brake)->class_name, ((phpdbg_breakmethod_t*)brake)->func_name); } break; case PHPDBG_BREAK_METHOD_OPLINE: { fprintf(handle, - "break address %s::%s#%ld\n", + "break %s::%s#%ld\n", ((phpdbg_breakopline_t*)brake)->class_name, ((phpdbg_breakopline_t*)brake)->func_name, ((phpdbg_breakopline_t*)brake)->opline_num); @@ -163,21 +163,21 @@ PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */ case PHPDBG_BREAK_FUNCTION_OPLINE: { fprintf(handle, - "break address %s#%ld\n", + "break %s#%ld\n", ((phpdbg_breakopline_t*)brake)->func_name, ((phpdbg_breakopline_t*)brake)->opline_num); } break; case PHPDBG_BREAK_FILE_OPLINE: { fprintf(handle, - "break address %s:%ld\n", + "break %s:#%ld\n", ((phpdbg_breakopline_t*)brake)->class_name, ((phpdbg_breakopline_t*)brake)->opline_num); } break; case PHPDBG_BREAK_OPCODE: { fprintf(handle, - "break op %s\n", + "break %s\n", ((phpdbg_breakop_t*)brake)->name); } break; @@ -209,7 +209,7 @@ PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */ } } else { fprintf( - handle, "break on %s\n", conditional->code); + handle, "break if %s\n", conditional->code); } } break; } @@ -221,14 +221,20 @@ PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRMLS_DC) /* {{{ */ { - struct stat sb; - - if (VCWD_STAT(path, &sb) != FAILURE) { - if (sb.st_mode & (S_IFREG|S_IFLNK)) { + php_stream_statbuf ssb; + char realpath[MAXPATHLEN]; + + if (php_stream_stat_path(path, &ssb) != FAILURE) { + if (ssb.sb.st_mode & (S_IFREG|S_IFLNK)) { HashTable *broken; phpdbg_breakfile_t new_break; - size_t path_len = strlen(path); - + size_t path_len = 0L; + + if (VCWD_REALPATH(path, realpath)) { + path = realpath; + } + path_len = strlen(path); + if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], path, path_len, (void**)&broken) == FAILURE) { HashTable breaks; @@ -324,9 +330,9 @@ PHPDBG_API void phpdbg_set_breakpoint_method(const char *class_name, const char PHPDBG_BREAK_MAPPING(new_break.id, class_table); } else { phpdbg_notice("Breakpoint exists at %s::%s", class_name, func_name); - } + } - efree(lcname); + efree(lcname); } /* }}} */ PHPDBG_API void phpdbg_set_breakpoint_opline(zend_ulong opline TSRMLS_DC) /* {{{ */ @@ -355,7 +361,7 @@ PHPDBG_API void phpdbg_set_breakpoint_opline(zend_ulong opline TSRMLS_DC) /* {{{ PHPDBG_API int phpdbg_resolve_op_array_break(phpdbg_breakopline_t *brake, zend_op_array *op_array TSRMLS_DC) /* {{{ */ { phpdbg_breakline_t opline_break; - if (op_array->last < brake->opline_num) { + if (op_array->last <= brake->opline_num) { if (brake->class_name == NULL) { phpdbg_error("There are only %d oplines in function %s (breaking at opline %ld impossible)", op_array->last, brake->func_name, brake->opline_num); } else if (brake->func_name == NULL) { @@ -760,56 +766,26 @@ PHPDBG_API void phpdbg_set_breakpoint_expression(const char *expr, size_t expr_l } } /* }}} */ -PHPDBG_API void phpdbg_set_breakpoint_at(const phpdbg_param_t *param, const phpdbg_input_t *input TSRMLS_DC) /* {{{ */ +PHPDBG_API void phpdbg_set_breakpoint_at(const phpdbg_param_t *param TSRMLS_DC) /* {{{ */ { - if (input->argc > 3 && phpdbg_argv_is(2, "if")) { - phpdbg_breakcond_t new_break; - phpdbg_param_t new_param; - - zend_ulong expr_hash = 0L; - size_t expr_len; - const char *join = strstr(input->string, "if"); - const char *expr = (join) + sizeof("if"); - - expr_len = strlen(expr); - expr = phpdbg_trim(expr, expr_len, &expr_len); - expr_hash = zend_inline_hash_func(expr, expr_len); - - { - /* get a clean parameter from input string */ - size_t sparam_len = 0L; - char *sparam = input->string; - - sparam[ - strstr(input->string, " ") - input->string] = 0; - sparam_len = strlen(sparam); - - switch (phpdbg_parse_param(sparam, sparam_len, &new_param TSRMLS_CC)) { - case EMPTY_PARAM: - case NUMERIC_PARAM: - phpdbg_clear_param( - &new_param TSRMLS_CC); - goto usage; - - default: { /* do nothing */ } break; - } - - expr_hash += phpdbg_hash_param(&new_param TSRMLS_CC); - } - - if (!zend_hash_index_exists(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], expr_hash)) { + phpdbg_breakcond_t new_break; + phpdbg_param_t *condition; + zend_ulong hash = 0L; + + if (param->next) { + condition = param->next; + hash = zend_inline_hash_func(condition->str, condition->len); + + if (!zend_hash_index_exists(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], hash)) { phpdbg_create_conditional_break( - &new_break, &new_param, expr, expr_len, expr_hash TSRMLS_CC); + &new_break, param, + condition->str, condition->len, hash TSRMLS_CC); } else { phpdbg_notice( - "Conditional break %s exists at the specified location", expr); - } - - phpdbg_clear_param(&new_param TSRMLS_CC); - } else { -usage: - phpdbg_error("usage: break at if "); + "Conditional break %s exists at the specified location", condition->str); + } } + } /* }}} */ static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_file(zend_op_array *op_array TSRMLS_DC) /* {{{ */ @@ -992,7 +968,7 @@ static inline phpdbg_breakbase_t *phpdbg_find_conditional_breakpoint(zend_execut for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], &position); zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], (void*)&bp, &position) == SUCCESS; - zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], &position)) { + zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], &position)) { zval *retval = NULL; int orig_interactive = CG(interactive); zval **orig_retval = EG(return_value_ptr_ptr); diff --git a/phpdbg_bp.h b/phpdbg_bp.h index b1a9ddf4749..97980e7ed78 100644 --- a/phpdbg_bp.h +++ b/phpdbg_bp.h @@ -119,7 +119,7 @@ PHPDBG_API void phpdbg_set_breakpoint_method_opline(const char *class, const cha PHPDBG_API void phpdbg_set_breakpoint_function_opline(const char *function, zend_ulong opline TSRMLS_DC); PHPDBG_API void phpdbg_set_breakpoint_file_opline(const char *file, zend_ulong opline TSRMLS_DC); PHPDBG_API void phpdbg_set_breakpoint_expression(const char* expression, size_t expression_len TSRMLS_DC); -PHPDBG_API void phpdbg_set_breakpoint_at(const phpdbg_param_t *param, const phpdbg_input_t *input TSRMLS_DC); /* }}} */ +PHPDBG_API void phpdbg_set_breakpoint_at(const phpdbg_param_t *param TSRMLS_DC); /* }}} */ /* {{{ Breakpoint Detection API */ PHPDBG_API phpdbg_breakbase_t* phpdbg_find_breakpoint(zend_execute_data* TSRMLS_DC); /* }}} */ diff --git a/phpdbg_break.c b/phpdbg_break.c index f56f76facd9..be76b22b059 100644 --- a/phpdbg_break.c +++ b/phpdbg_break.c @@ -24,132 +24,32 @@ #include "phpdbg_opcode.h" #include "phpdbg_break.h" #include "phpdbg_bp.h" +#include "phpdbg_prompt.h" ZEND_EXTERN_MODULE_GLOBALS(phpdbg); -PHPDBG_BREAK(file) /* {{{ */ -{ - switch (param->type) { - case FILE_PARAM: - phpdbg_set_breakpoint_file(param->file.name, param->file.line TSRMLS_CC); - break; +#define PHPDBG_BREAK_COMMAND_D(f, h, a, m, l, s) \ + PHPDBG_COMMAND_D_EXP(f, h, a, m, l, s, &phpdbg_prompt_commands[10]) - phpdbg_default_switch_case(); - } - - return SUCCESS; -} /* }}} */ - -PHPDBG_BREAK(method) /* {{{ */ -{ - switch (param->type) { - case METHOD_PARAM: - phpdbg_set_breakpoint_method(param->method.class, param->method.name TSRMLS_CC); - break; - - phpdbg_default_switch_case(); - } - - return SUCCESS; -} /* }}} */ - -PHPDBG_BREAK(address) /* {{{ */ -{ - switch (param->type) { - case ADDR_PARAM: - phpdbg_set_breakpoint_opline(param->addr TSRMLS_CC); - break; - - case NUMERIC_METHOD_PARAM: - phpdbg_set_breakpoint_method_opline(param->method.class, param->method.name, param->num TSRMLS_CC); - break; - - case NUMERIC_FUNCTION_PARAM: - phpdbg_set_breakpoint_function_opline(param->str, param->num TSRMLS_CC); - break; - - case FILE_PARAM: - phpdbg_set_breakpoint_file_opline(param->file.name, param->file.line TSRMLS_CC); - break; - - phpdbg_default_switch_case(); - } - - return SUCCESS; -} /* }}} */ - -PHPDBG_BREAK(on) /* {{{ */ -{ - switch (param->type) { - case STR_PARAM: - phpdbg_set_breakpoint_expression(param->str, param->len TSRMLS_CC); - break; - - phpdbg_default_switch_case(); - } - - return SUCCESS; -} /* }}} */ +/** + * Commands + */ +const phpdbg_command_t phpdbg_break_commands[] = { + PHPDBG_BREAK_COMMAND_D(at, "specify breakpoint by location and condition", '@', break_at, NULL, "*c"), + PHPDBG_BREAK_COMMAND_D(del, "delete breakpoint by identifier number", '~', break_del, NULL, "n"), + PHPDBG_END_COMMAND +}; PHPDBG_BREAK(at) /* {{{ */ { - phpdbg_set_breakpoint_at(param, input TSRMLS_CC); - - return SUCCESS; -} /* }}} */ - -PHPDBG_BREAK(lineno) /* {{{ */ -{ - switch (param->type) { - case NUMERIC_PARAM: { - if (PHPDBG_G(exec)) { - phpdbg_set_breakpoint_file(phpdbg_current_file(TSRMLS_C), param->num TSRMLS_CC); - } else { - phpdbg_error("Execution context not set!"); - } - } break; - - phpdbg_default_switch_case(); - } - - return SUCCESS; -} /* }}} */ - -PHPDBG_BREAK(func) /* {{{ */ -{ - switch (param->type) { - case STR_PARAM: - phpdbg_set_breakpoint_symbol(param->str, param->len TSRMLS_CC); - break; - - phpdbg_default_switch_case(); - } - - return SUCCESS; -} /* }}} */ - -PHPDBG_BREAK(op) /* {{{ */ -{ - switch (param->type) { - case STR_PARAM: - phpdbg_set_breakpoint_opcode(param->str, param->len TSRMLS_CC); - break; - - phpdbg_default_switch_case(); - } + phpdbg_set_breakpoint_at(param TSRMLS_CC); return SUCCESS; } /* }}} */ PHPDBG_BREAK(del) /* {{{ */ { - switch (param->type) { - case NUMERIC_PARAM: { - phpdbg_delete_breakpoint(param->num TSRMLS_CC); - } break; - - phpdbg_default_switch_case(); - } + phpdbg_delete_breakpoint(param->num TSRMLS_CC); return SUCCESS; } /* }}} */ diff --git a/phpdbg_break.h b/phpdbg_break.h index f90e351d6de..dc06da62b79 100644 --- a/phpdbg_break.h +++ b/phpdbg_break.h @@ -29,30 +29,9 @@ /** * Printer Forward Declarations */ -PHPDBG_BREAK(file); -PHPDBG_BREAK(func); -PHPDBG_BREAK(method); -PHPDBG_BREAK(address); PHPDBG_BREAK(at); -PHPDBG_BREAK(op); -PHPDBG_BREAK(on); -PHPDBG_BREAK(lineno); PHPDBG_BREAK(del); -/** - * Commands - */ -static const phpdbg_command_t phpdbg_break_commands[] = { - PHPDBG_COMMAND_D_EX(file, "specify breakpoint by file:line", 'F', break_file, NULL, 1), - PHPDBG_COMMAND_D_EX(func, "specify breakpoint by global function name", 'f', break_func, NULL, 1), - PHPDBG_COMMAND_D_EX(method, "specify breakpoint by class::method", 'm', break_method, NULL, 1), - PHPDBG_COMMAND_D_EX(address, "specify breakpoint by address", 'a', break_address, NULL, 1), - PHPDBG_COMMAND_D_EX(op, "specify breakpoint by opcode", 'O', break_op, NULL, 1), - PHPDBG_COMMAND_D_EX(on, "specify breakpoint by condition", 'o', break_on, NULL, 1), - PHPDBG_COMMAND_D_EX(at, "specify breakpoint by location and condition", 'A', break_at, NULL, 1), - PHPDBG_COMMAND_D_EX(lineno, "specify breakpoint by line of currently executing file", 'l', break_lineno, NULL, 1), - PHPDBG_COMMAND_D_EX(del, "delete breakpoint by identifier number", 'd', break_del, NULL, 1), - PHPDBG_END_COMMAND -}; +extern const phpdbg_command_t phpdbg_break_commands[]; #endif /* PHPDBG_BREAK_H */ diff --git a/phpdbg_btree.c b/phpdbg_btree.c new file mode 100644 index 00000000000..8fc2561e047 --- /dev/null +++ b/phpdbg_btree.c @@ -0,0 +1,221 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#include "phpdbg_btree.h" +#include "phpdbg.h" + +#define CHOOSE_BRANCH(n) \ + branch = branch->branches[!!(n)]; + +#ifdef _Win32 +# define emalloc malloc +# define efree free +#endif + +/* depth in bits */ +void phpdbg_btree_init(phpdbg_btree *tree, zend_ulong depth) { + tree->depth = depth; + tree->branch = NULL; + tree->count = 0; +} + +phpdbg_btree_result *phpdbg_btree_find(phpdbg_btree *tree, zend_ulong idx) { + phpdbg_btree_branch *branch = tree->branch; + int i = tree->depth - 1; + + if (branch == NULL) { + return NULL; + } + + do { + if ((idx >> i) % 2 == 1) { + if (branch->branches[1]) { + CHOOSE_BRANCH(1); + } else { + return NULL; + } + } else { + if (branch->branches[0]) { + CHOOSE_BRANCH(0); + } else { + return NULL; + } + } + } while (i--); + + return &branch->result; +} + +phpdbg_btree_result *phpdbg_btree_find_closest(phpdbg_btree *tree, zend_ulong idx) { + phpdbg_btree_branch *branch = tree->branch; + int i = tree->depth - 1, last_superior_i = -1; + zend_bool had_alternative_branch = 0; + + if (branch == NULL) { + return NULL; + } + + /* find nearest watchpoint */ + do { + /* an impossible branch was found if: */ + if (!had_alternative_branch && (idx >> i) % 2 == 0 && !branch->branches[0]) { + /* there's no lower branch than idx */ + if (last_superior_i == -1) { + /* failure */ + return NULL; + } + /* reset state */ + branch = tree->branch; + i = tree->depth - 1; + /* follow branch according to bits in idx until the last lower branch before the impossible branch */ + do { + CHOOSE_BRANCH((idx >> i) % 2 == 1 && branch->branches[1]); + } while (--i > last_superior_i); + /* use now the lower branch of which we can be sure that it contains only branches lower than idx */ + CHOOSE_BRANCH(0); + /* and choose the highest possible branch in the branch containing only branches lower than idx */ + while (i--) { + CHOOSE_BRANCH(branch->branches[1]); + } + break; + } + /* follow branch according to bits in idx until having found an impossible branch */ + if (had_alternative_branch || (idx >> i) % 2 == 1) { + if (branch->branches[1]) { + if (branch->branches[0]) { + last_superior_i = i; + } + CHOOSE_BRANCH(1); + } else { + CHOOSE_BRANCH(0); + had_alternative_branch = 1; + } + } else { + CHOOSE_BRANCH(0); + } + } while (i--); + + return &branch->result; +} + +phpdbg_btree_position phpdbg_btree_find_between(phpdbg_btree *tree, zend_ulong lower_idx, zend_ulong higher_idx) { + phpdbg_btree_position pos; + + pos.tree = tree; + pos.end = lower_idx; + pos.cur = higher_idx; + + return pos; +} + +phpdbg_btree_result *phpdbg_btree_next(phpdbg_btree_position *pos) { + phpdbg_btree_result *result = phpdbg_btree_find_closest(pos->tree, pos->cur); + + if (result == NULL || result->idx < pos->end) { + return NULL; + } + + pos->cur = result->idx - 1; + + return result; +} + +int phpdbg_btree_insert_or_update(phpdbg_btree *tree, zend_ulong idx, void *ptr, int flags) { + int i = tree->depth - 1; + phpdbg_btree_branch **branch = &tree->branch; + + do { + if (*branch == NULL) { + break; + } + branch = &(*branch)->branches[(idx >> i) % 2]; + } while (i--); + + if (*branch == NULL) { + if (!(flags & PHPDBG_BTREE_INSERT)) { + return FAILURE; + } + + { + phpdbg_btree_branch *memory = *branch = emalloc((i + 2) * sizeof(phpdbg_btree_branch)); + do { + (*branch)->branches[!((idx >> i) % 2)] = NULL; + branch = &(*branch)->branches[(idx >> i) % 2]; + *branch = ++memory; + } while (i--); + tree->count++; + } + } else if (!(flags & PHPDBG_BTREE_UPDATE)) { + return FAILURE; + } + + (*branch)->result.idx = idx; + (*branch)->result.ptr = ptr; + + return SUCCESS; +} + +int phpdbg_btree_delete(phpdbg_btree *tree, zend_ulong idx) { + int i = tree->depth; + phpdbg_btree_branch *branch = tree->branch; + int i_last_dual_branch = -1, last_dual_branch_branch; + phpdbg_btree_branch *last_dual_branch = NULL; + + goto check_branch_existence; + do { + if (branch->branches[0] && branch->branches[1]) { + last_dual_branch = branch; + i_last_dual_branch = i; + last_dual_branch_branch = (idx >> i) % 2; + } + branch = branch->branches[(idx >> i) % 2]; + +check_branch_existence: + if (branch == NULL) { + return FAILURE; + } + } while (i--); + + tree->count--; + + if (i_last_dual_branch == -1) { + efree(tree->branch); + tree->branch = NULL; + } else { + if (last_dual_branch->branches[last_dual_branch_branch] == last_dual_branch + 1) { + phpdbg_btree_branch *original_branch = last_dual_branch->branches[!last_dual_branch_branch]; + + memcpy(last_dual_branch + 1, last_dual_branch->branches[!last_dual_branch_branch], (i_last_dual_branch + 1) * sizeof(phpdbg_btree_branch)); + efree(last_dual_branch->branches[!last_dual_branch_branch]); + last_dual_branch->branches[!last_dual_branch_branch] = last_dual_branch + 1; + + branch = last_dual_branch->branches[!last_dual_branch_branch]; + for (i = i_last_dual_branch; i--;) { + branch = (branch->branches[branch->branches[1] == ++original_branch] = last_dual_branch + i_last_dual_branch - i + 1); + } + } else { + efree(last_dual_branch->branches[last_dual_branch_branch]); + } + + last_dual_branch->branches[last_dual_branch_branch] = NULL; + } + + return SUCCESS; +} diff --git a/phpdbg_btree.h b/phpdbg_btree.h new file mode 100644 index 00000000000..5fb217db35e --- /dev/null +++ b/phpdbg_btree.h @@ -0,0 +1,65 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHPDBG_BTREE_H +#define PHPDBG_BTREE_H + +#include "zend.h" + +typedef struct { + zend_ulong idx; + void *ptr; +} phpdbg_btree_result; + +typedef union _phpdbg_btree_branch phpdbg_btree_branch; +union _phpdbg_btree_branch { + phpdbg_btree_branch *branches[2]; + phpdbg_btree_result result; +}; + +typedef struct { + zend_ulong count; + zend_ulong depth; + phpdbg_btree_branch *branch; +} phpdbg_btree; + +typedef struct { + phpdbg_btree *tree; + zend_ulong cur; + zend_ulong end; +} phpdbg_btree_position; + +void phpdbg_btree_init(phpdbg_btree *tree, zend_ulong depth); +phpdbg_btree_result *phpdbg_btree_find(phpdbg_btree *tree, zend_ulong idx); +phpdbg_btree_result *phpdbg_btree_find_closest(phpdbg_btree *tree, zend_ulong idx); +phpdbg_btree_position phpdbg_btree_find_between(phpdbg_btree *tree, zend_ulong lower_idx, zend_ulong higher_idx); +phpdbg_btree_result *phpdbg_btree_next(phpdbg_btree_position *pos); +int phpdbg_btree_delete(phpdbg_btree *tree, zend_ulong idx); + +#define PHPDBG_BTREE_INSERT 1 +#define PHPDBG_BTREE_UPDATE 2 +#define PHPDBG_BTREE_OVERWRITE (PHPDBG_BTREE_INSERT | PHPDBG_BTREE_UPDATE) + +int phpdbg_btree_insert_or_update(phpdbg_btree *tree, zend_ulong idx, void *ptr, int flags); +#define phpdbg_btree_insert(tree, idx, ptr) phpdbg_btree_insert_or_update(tree, idx, ptr, PHPDBG_BTREE_INSERT) +#define phpdbg_btree_update(tree, idx, ptr) phpdbg_btree_insert_or_update(tree, idx, ptr, PHPDBG_BTREE_UPDATE) +#define phpdbg_btree_overwrite(tree, idx, ptr) phpdbg_btree_insert_or_update(tree, idx, ptr, PHPDBG_BTREE_OWERWRITE) + +#endif diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index 1d78c533216..d4ce8ebc55f 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -22,12 +22,32 @@ #include "phpdbg_cmd.h" #include "phpdbg_utils.h" #include "phpdbg_set.h" +#include "phpdbg_prompt.h" ZEND_EXTERN_MODULE_GLOBALS(phpdbg); +static inline const char *phpdbg_command_name(const phpdbg_command_t *command, char *buffer) { + size_t pos = 0; + + if (command->parent) { + memcpy(&buffer[pos], command->parent->name, command->parent->name_len); + pos += command->parent->name_len; + memcpy(&buffer[pos], " ", sizeof(" ")-1); + pos += (sizeof(" ")-1); + } + + memcpy(&buffer[pos], command->name, command->name_len); + pos += command->name_len; + buffer[pos] = 0; + + return buffer; +} + PHPDBG_API const char *phpdbg_get_param_type(const phpdbg_param_t *param TSRMLS_DC) /* {{{ */ { switch (param->type) { + case STACK_PARAM: + return "stack"; case EMPTY_PARAM: return "empty"; case ADDR_PARAM: @@ -208,10 +228,19 @@ PHPDBG_API char* phpdbg_param_tostring(const phpdbg_param_t *param, char **point PHPDBG_API void phpdbg_copy_param(const phpdbg_param_t* src, phpdbg_param_t* dest TSRMLS_DC) /* {{{ */ { switch ((dest->type = src->type)) { + case STACK_PARAM: + /* nope */ + break; + case STR_PARAM: dest->str = estrndup(src->str, src->len); dest->len = src->len; break; + + case OP_PARAM: + dest->str = estrndup(src->str, src->len); + dest->len = src->len; + break; case ADDR_PARAM: dest->addr = src->addr; @@ -226,6 +255,7 @@ PHPDBG_API void phpdbg_copy_param(const phpdbg_param_t* src, phpdbg_param_t* des dest->method.name = estrdup(src->method.name); break; + case NUMERIC_FILE_PARAM: case FILE_PARAM: dest->file.name = estrdup(src->file.name); dest->file.line = src->file.line; @@ -246,6 +276,10 @@ PHPDBG_API void phpdbg_copy_param(const phpdbg_param_t* src, phpdbg_param_t* des break; case EMPTY_PARAM: { /* do nothing */ } break; + + default: { + /* not yet */ + } } } /* }}} */ @@ -254,6 +288,10 @@ PHPDBG_API zend_ulong phpdbg_hash_param(const phpdbg_param_t *param TSRMLS_DC) / zend_ulong hash = param->type; switch (param->type) { + case STACK_PARAM: + /* nope */ + break; + case STR_PARAM: hash += zend_inline_hash_func(param->str, param->len); break; @@ -291,6 +329,10 @@ PHPDBG_API zend_ulong phpdbg_hash_param(const phpdbg_param_t *param TSRMLS_DC) / break; case EMPTY_PARAM: { /* do nothing */ } break; + + default: { + /* not yet */ + } } return hash; @@ -301,7 +343,11 @@ PHPDBG_API zend_bool phpdbg_match_param(const phpdbg_param_t *l, const phpdbg_pa if (l && r) { if (l->type == r->type) { switch (l->type) { - + case STACK_PARAM: + /* nope, or yep */ + return 1; + break; + case NUMERIC_FUNCTION_PARAM: if (l->num != r->num) { break; @@ -356,112 +402,400 @@ PHPDBG_API zend_bool phpdbg_match_param(const phpdbg_param_t *l, const phpdbg_pa case EMPTY_PARAM: return 1; + + default: { + /* not yet */ + } } } } return 0; } /* }}} */ -PHPDBG_API phpdbg_input_t **phpdbg_read_argv(char *buffer, int *argc TSRMLS_DC) /* {{{ */ -{ - char *p; - char b[PHPDBG_MAX_CMD]; - int l=0; - enum states { - IN_BETWEEN, - IN_WORD, - IN_STRING - } state = IN_BETWEEN; - phpdbg_input_t **argv = NULL; - - argv = (phpdbg_input_t**) emalloc(sizeof(phpdbg_input_t*)); - (*argc) = 0; - -#define RESET_STATE() do { \ - phpdbg_input_t *arg = emalloc(sizeof(phpdbg_input_t)); \ - if (arg) { \ - b[l]=0; \ - arg->length = l; \ - arg->string = estrndup(b, arg->length); \ - arg->argv = NULL; \ - arg->argc = 0; \ - argv = (phpdbg_input_t**) erealloc(argv, sizeof(phpdbg_input_t*) * ((*argc)+1)); \ - argv[(*argc)++] = arg; \ - l = 0; \ - } \ - state = IN_BETWEEN; \ -} while (0) - - for (p = buffer; *p != '\0'; p++) { - int c = (unsigned char) *p; - switch (state) { - case IN_BETWEEN: - if (isspace(c)) { - continue; - } - if (c == '"') { - state = IN_STRING; - continue; - } - state = IN_WORD; - b[l++]=c; - continue; - - case IN_STRING: - if (c == '"') { - if (buffer[(p - buffer)-1] == '\\') { - b[l-1]=c; - continue; - } - RESET_STATE(); - } else { - b[l++]=c; - } - continue; - - case IN_WORD: - if (isspace(c)) { - RESET_STATE(); - } else { - b[l++]=c; - } - continue; +/* {{{ */ +PHPDBG_API void phpdbg_param_debug(const phpdbg_param_t *param, const char *msg) { + if (param && param->type) { + switch (param->type) { + case STR_PARAM: + fprintf(stderr, "%s STR_PARAM(%s=%lu)\n", msg, param->str, param->len); + break; + + case ADDR_PARAM: + fprintf(stderr, "%s ADDR_PARAM(%lu)\n", msg, param->addr); + break; + + case NUMERIC_FILE_PARAM: + fprintf(stderr, "%s NUMERIC_FILE_PARAM(%s:#%lu)\n", msg, param->file.name, param->file.line); + break; + + case FILE_PARAM: + fprintf(stderr, "%s FILE_PARAM(%s:%lu)\n", msg, param->file.name, param->file.line); + break; + + case METHOD_PARAM: + fprintf(stderr, "%s METHOD_PARAM(%s::%s)\n", msg, param->method.class, param->method.name); + break; + + case NUMERIC_METHOD_PARAM: + fprintf(stderr, "%s NUMERIC_METHOD_PARAM(%s::%s)\n", msg, param->method.class, param->method.name); + break; + + case NUMERIC_FUNCTION_PARAM: + fprintf(stderr, "%s NUMERIC_FUNCTION_PARAM(%s::%ld)\n", msg, param->str, param->num); + break; + + case NUMERIC_PARAM: + fprintf(stderr, "%s NUMERIC_PARAM(%ld)\n", msg, param->num); + break; + + case COND_PARAM: + fprintf(stderr, "%s COND_PARAM(%s=%lu)\n", msg, param->str, param->len); + break; + + case OP_PARAM: + fprintf(stderr, "%s OP_PARAM(%s=%lu)\n", msg, param->str, param->len); + break; + + default: { + /* not yet */ + } } } - - switch (state) { - case IN_WORD: { - RESET_STATE(); - } break; - - case IN_STRING: - phpdbg_error( - "Malformed command line (unclosed quote) @ %ld: %s!", - (p - buffer)-1, &buffer[(p - buffer)-1]); - break; - - case IN_BETWEEN: - break; - } - - if ((*argc) == 0) { - /* not needed */ - efree(argv); - - /* to be sure */ - return NULL; - } - - return argv; } /* }}} */ -PHPDBG_API phpdbg_input_t *phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */ +/* {{{ */ +PHPDBG_API void phpdbg_stack_free(phpdbg_param_t *stack) { + if (stack && stack->next) { + phpdbg_param_t *remove = stack->next; + + while (remove) { + phpdbg_param_t *next = NULL; + + if (remove->next) + next = remove->next; + + switch (remove->type) { + case NUMERIC_METHOD_PARAM: + case METHOD_PARAM: + if (remove->method.class) + free(remove->method.class); + if (remove->method.name) + free(remove->method.name); + break; + + case NUMERIC_FUNCTION_PARAM: + case STR_PARAM: + case OP_PARAM: + if (remove->str) + free(remove->str); + break; + + case NUMERIC_FILE_PARAM: + case FILE_PARAM: + if (remove->file.name) + free(remove->file.name); + break; + + default: { + /* nothing */ + } + } + + free(remove); + remove = NULL; + + if (next) + remove = next; + else break; + } + } + + stack->next = NULL; +} /* }}} */ + +/* {{{ */ +PHPDBG_API void phpdbg_stack_push(phpdbg_param_t *stack, phpdbg_param_t *param) { + phpdbg_param_t *next = calloc(1, sizeof(phpdbg_param_t)); + + if (!next) + return; + + *(next) = *(param); + + next->next = NULL; + + if (stack->top == NULL) { + stack->top = next; + next->top = NULL; + stack->next = next; + } else { + stack->top->next = next; + next->top = stack->top; + stack->top = next; + } + + stack->len++; +} /* }}} */ + +PHPDBG_API int phpdbg_stack_verify(const phpdbg_command_t *command, phpdbg_param_t **stack, char **why TSRMLS_DC) { + if (command) { + char buffer[128] = {0,}; + const phpdbg_param_t *top = (stack != NULL) ? *stack : NULL; + const char *arg = command->args; + size_t least = 0L, + received = 0L, + current = 0L; + zend_bool optional = 0; + + /* check for arg spec */ + if (!(arg) || !(*arg)) { + if (!top) { + return SUCCESS; + } + + asprintf(why, + "The command \"%s\" expected no arguments", + phpdbg_command_name(command, buffer)); + return FAILURE; + } + + least = 0L; + + /* count least amount of arguments */ + while (arg && *arg) { + if (arg[0] == '|') { + break; + } + least++; + arg++; + } + + arg = command->args; + +#define verify_arg(e, a, t) if (!(a)) { \ + if (!optional) { \ + asprintf(why, \ + "The command \"%s\" expected %s and got nothing at parameter %lu", \ + phpdbg_command_name(command, buffer), \ + (e), \ + current); \ + return FAILURE;\ + } \ +} else if ((a)->type != (t)) { \ + asprintf(why, \ + "The command \"%s\" expected %s and got %s at parameter %lu", \ + phpdbg_command_name(command, buffer), \ + (e),\ + phpdbg_get_param_type((a) TSRMLS_CC), \ + current); \ + return FAILURE; \ +} + + while (arg && *arg) { + current++; + + switch (*arg) { + case '|': { + current--; + optional = 1; + arg++; + } continue; + + case 'i': verify_arg("raw input", top, STR_PARAM); break; + case 's': verify_arg("string", top, STR_PARAM); break; + case 'n': verify_arg("number", top, NUMERIC_PARAM); break; + case 'm': verify_arg("method", top, METHOD_PARAM); break; + case 'a': verify_arg("address", top, ADDR_PARAM); break; + case 'f': verify_arg("file:line", top, FILE_PARAM); break; + case 'c': verify_arg("condition", top, COND_PARAM); break; + case 'o': verify_arg("opcode", top, OP_PARAM); break; + case 'b': verify_arg("boolean", top, NUMERIC_PARAM); break; + + case '*': { /* do nothing */ } break; + } + + if (top ) { + top = top->next; + } else break; + + received++; + arg++; + } + +#undef verify_arg + + if ((received < least)) { + asprintf(why, + "The command \"%s\" expected at least %lu arguments (%s) and received %lu", + phpdbg_command_name(command, buffer), + least, + command->args, + received); + return FAILURE; + } + } + + return SUCCESS; +} + +/* {{{ */ +PHPDBG_API const phpdbg_command_t* phpdbg_stack_resolve(const phpdbg_command_t *commands, const phpdbg_command_t *parent, phpdbg_param_t **top, char **why) { + const phpdbg_command_t *command = commands; + phpdbg_param_t *name = *top; + const phpdbg_command_t *matched[3] = {NULL, NULL, NULL}; + ulong matches = 0L; + + while (command && command->name && command->handler) { + if ((name->len == 1) || (command->name_len >= name->len)) { + /* match single letter alias */ + if (command->alias && (name->len == 1)) { + if (command->alias == (*name->str)) { + matched[matches] = command; + matches++; + } + } else { + + /* match full, case insensitive, command name */ + if (strncasecmp(command->name, name->str, name->len) == SUCCESS) { + if (matches < 3) { + + /* only allow abbreviating commands that can be aliased */ + if (((name->len != command->name_len) && command->alias) || + (name->len == command->name_len)) { + matched[matches] = command; + matches++; + } + + + /* exact match */ + if (name->len == command->name_len) + break; + } else break; + } + } + } + + command++; + } + + switch (matches) { + case 0: { + if (parent) { + asprintf( + why, + "The command \"%s %s\" could not be found", + parent->name, name->str); + } else asprintf( + why, + "The command \"%s\" could not be found", + name->str); + } return parent; + + case 1: { + (*top) = (*top)->next; + + command = matched[0]; + } break; + + default: { + char *list = NULL; + zend_uint it = 0; + size_t pos = 0; + + while (it < matches) { + if (!list) { + list = malloc( + matched[it]->name_len + 1 + + ((it+1) < matches ? sizeof(", ")-1 : 0)); + } else { + list = realloc(list, + (pos + matched[it]->name_len) + 1 + + ((it+1) < matches ? sizeof(", ")-1 : 0)); + } + memcpy(&list[pos], matched[it]->name, matched[it]->name_len); + pos += matched[it]->name_len; + if ((it+1) < matches) { + memcpy(&list[pos], ", ", sizeof(", ")-1); + pos += (sizeof(", ") - 1); + } + + list[pos] = 0; + it++; + } + + asprintf( + why, + "The command \"%s\" is ambigious, matching %lu commands (%s)", + name->str, matches, list); + free(list); + } return NULL; + } + + if (command->subs && (*top) && ((*top)->type == STR_PARAM)) { + return phpdbg_stack_resolve(command->subs, command, top, why); + } else { + return command; + } + + return NULL; +} /* }}} */ + +/* {{{ */ +PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack, char **why TSRMLS_DC) { + phpdbg_param_t *top = NULL; + const phpdbg_command_t *handler = NULL; + + if (stack->type != STACK_PARAM) { + asprintf( + why, "The passed argument was not a stack !!"); + return FAILURE; + } + + if (!stack->len) { + asprintf( + why, "The stack contains nothing !!"); + return FAILURE; + } + + top = (phpdbg_param_t*) stack->next; + + switch (top->type) { + case EVAL_PARAM: + return PHPDBG_COMMAND_HANDLER(ev)(top TSRMLS_CC); + + case RUN_PARAM: + return PHPDBG_COMMAND_HANDLER(run)(top TSRMLS_CC); + + case SHELL_PARAM: + return PHPDBG_COMMAND_HANDLER(sh)(top TSRMLS_CC); + + case STR_PARAM: { + handler = phpdbg_stack_resolve( + phpdbg_prompt_commands, NULL, &top, why); + + if (handler) { + if (phpdbg_stack_verify(handler, &top, why TSRMLS_CC) == SUCCESS) { + return handler->handler(top TSRMLS_CC); + } + } + } return FAILURE; + + default: + asprintf( + why, "The first parameter makes no sense !!"); + return FAILURE; + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_API char* phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */ { - phpdbg_input_t *buffer = NULL; char *cmd = NULL; #ifndef HAVE_LIBREADLINE char buf[PHPDBG_MAX_CMD]; #endif + char *buffer = NULL; if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && @@ -513,32 +847,8 @@ readline: } #endif } else cmd = buffered; - - /* allocate and sanitize buffer */ - buffer = (phpdbg_input_t*) ecalloc(1, sizeof(phpdbg_input_t)); - if (!buffer) { - return NULL; - } - - buffer->string = phpdbg_trim(cmd, strlen(cmd), &buffer->length); - - /* store constant pointer to start of buffer */ - buffer->start = (char* const*) buffer->string; - - buffer->argv = phpdbg_read_argv( - buffer->string, &buffer->argc TSRMLS_CC); - -#ifdef PHPDBG_DEBUG - if (buffer->argc) { - int arg = 0; - - while (arg < buffer->argc) { - phpdbg_debug( - "argv %d=%s", arg, buffer->argv[arg]->string); - arg++; - } - } -#endif + + buffer = estrdup(cmd); #ifdef HAVE_LIBREADLINE if (!buffered && cmd && @@ -546,144 +856,34 @@ readline: free(cmd); } #endif - - return buffer; } - return NULL; -} /* }}} */ + if (buffer && isspace(*buffer)) { + char *trimmed = buffer; + while (isspace(*trimmed)) + trimmed++; -PHPDBG_API void phpdbg_destroy_argv(phpdbg_input_t **argv, int argc TSRMLS_DC) /* {{{ */ -{ - if (argv) { - if (argc) { - int arg; - for (arg=0; argstring) { - efree((*input)->string); - } - - phpdbg_destroy_argv( - (*input)->argv, (*input)->argc TSRMLS_CC); - - efree(*input); - } -} /* }}} */ - -PHPDBG_API int phpdbg_do_cmd(const phpdbg_command_t *command, phpdbg_input_t *input TSRMLS_DC) /* {{{ */ -{ - int rc = FAILURE; - - if (input->argc > 0) { - while (command && command->name && command->handler) { - if (((command->name_len == input->argv[0]->length) && - (memcmp(command->name, input->argv[0]->string, command->name_len) == SUCCESS)) || - (command->alias && - (input->argv[0]->length == 1) && - (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; - - if (input->argc > 1) { - if (command->subs) { - phpdbg_input_t sub = *input; - - sub.string += input->argv[0]->length; - sub.length -= input->argv[0]->length; - - sub.string = phpdbg_trim( - sub.string, sub.length, &sub.length); - - sub.argc--; - sub.argv++; - - phpdbg_debug( - "trying sub commands in \"%s\" for \"%s\" with %d arguments", - command->name, sub.argv[0]->string, sub.argc-1); - - if (phpdbg_do_cmd(command->subs, &sub TSRMLS_CC) == SUCCESS) { - efree(sub.string); - return SUCCESS; - } - - efree(sub.string); - } - - /* no sub command found */ - { - char *store = input->string; - - input->string += input->argv[0]->length; - input->length -= input->argv[0]->length; - - input->string = phpdbg_trim( - input->string, input->length, &input->length); - - efree(store); - } - - /* pass parameter on */ - phpdbg_parse_param( - input->string, - input->length, - ¶m TSRMLS_CC); - } - - phpdbg_debug( - "found command %s for %s with %d arguments", - command->name, input->argv[0]->string, input->argc-1); - { - int arg; - for (arg=1; argargc; arg++) { - phpdbg_debug( - "\t#%d: [%s=%zu]", - arg, - input->argv[arg]->string, - input->argv[arg]->length); - } - } - - 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(¶m, input TSRMLS_CC); - - /* only set last command when it is worth it! */ - 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(¶m TSRMLS_CC); - } - break; - } - command++; + if (buffer && strlen(buffer)) { + if (PHPDBG_G(buffer)) { + efree(PHPDBG_G(buffer)); } + PHPDBG_G(buffer) = estrdup(buffer); } else { - /* this should NEVER happen */ - phpdbg_error( - "No function executed!!"); + if (PHPDBG_G(buffer)) { + buffer = estrdup(PHPDBG_G(buffer)); + } } - - return rc; + + return buffer; +} /* }}} */ + +PHPDBG_API void phpdbg_destroy_input(char **input TSRMLS_DC) /*{{{ */ +{ + efree(*input); } /* }}} */ diff --git a/phpdbg_cmd.h b/phpdbg_cmd.h index c86f92bb478..571d065f59d 100644 --- a/phpdbg_cmd.h +++ b/phpdbg_cmd.h @@ -23,8 +23,6 @@ #include "TSRM.h" -typedef struct _phpdbg_command_t phpdbg_command_t; - /* {{{ Command and Parameter */ enum { NO_ARG = 0, @@ -36,24 +34,23 @@ typedef enum { EMPTY_PARAM = 0, ADDR_PARAM, FILE_PARAM, + NUMERIC_FILE_PARAM, METHOD_PARAM, STR_PARAM, NUMERIC_PARAM, NUMERIC_FUNCTION_PARAM, - NUMERIC_METHOD_PARAM + NUMERIC_METHOD_PARAM, + STACK_PARAM, + EVAL_PARAM, + SHELL_PARAM, + COND_PARAM, + OP_PARAM, + ORIG_PARAM, + RUN_PARAM } phpdbg_param_type; -typedef struct _phpdbg_input_t phpdbg_input_t; - -struct _phpdbg_input_t { - char * const *start; - char *string; - size_t length; - phpdbg_input_t **argv; - int argc; -}; - -typedef struct _phpdbg_param { +typedef struct _phpdbg_param phpdbg_param_t; +struct _phpdbg_param { phpdbg_param_type type; long num; zend_ulong addr; @@ -67,10 +64,31 @@ typedef struct _phpdbg_param { } method; char *str; size_t len; -} phpdbg_param_t; + phpdbg_param_t *next; + phpdbg_param_t *top; +}; -typedef int (*phpdbg_command_handler_t)(const phpdbg_param_t*, const phpdbg_input_t* TSRMLS_DC); +#define phpdbg_init_param(v, t) do{ \ + (v)->type = (t); \ + (v)->addr = 0; \ + (v)->num = 0; \ + (v)->file.name = NULL; \ + (v)->file.line = 0; \ + (v)->method.class = NULL; \ + (v)->method.name = NULL; \ + (v)->str = NULL; \ + (v)->len = 0; \ + (v)->next = NULL; \ + (v)->top = NULL; \ +} while(0) +#ifndef YYSTYPE +#define YYSTYPE phpdbg_param_t +#endif + +typedef int (*phpdbg_command_handler_t)(const phpdbg_param_t* TSRMLS_DC); + +typedef struct _phpdbg_command_t phpdbg_command_t; struct _phpdbg_command_t { const char *name; /* Command name */ size_t name_len; /* Command name length */ @@ -79,7 +97,8 @@ struct _phpdbg_command_t { char alias; /* Alias */ phpdbg_command_handler_t handler; /* Command handler */ const phpdbg_command_t *subs; /* Sub Commands */ - char arg_type; /* Accept args? */ + char *args; /* Argument Spec */ + const phpdbg_command_t *parent; /* Parent Command */ }; /* }}} */ @@ -95,35 +114,29 @@ typedef struct { } phpdbg_frame_t; /* }}} */ - - /* * Workflow: -* 1) read input -* input takes the line from console, creates argc/argv -* 2) parse parameters into suitable types based on arg_type -* takes input from 1) and arg_type and creates parameters -* 3) do command -* executes commands -* 4) destroy parameters -* cleans up what was allocated by creation of parameters -* 5) destroy input -* cleans up what was allocated by creation of input +* 1) the lexer/parser creates a stack of commands and arguments from input +* 2) the commands at the top of the stack are resolved sensibly using aliases, abbreviations and case insensitive matching +* 3) the remaining arguments in the stack are verified (optionally) against the handlers declared argument specification +* 4) the handler is called passing the top of the stack as the only parameter +* 5) the stack is destroyed upon return from the handler */ /* * Input Management */ -PHPDBG_API phpdbg_input_t* phpdbg_read_input(char *buffered TSRMLS_DC); -PHPDBG_API void phpdbg_destroy_input(phpdbg_input_t** TSRMLS_DC); +PHPDBG_API char* phpdbg_read_input(char *buffered TSRMLS_DC); +PHPDBG_API void phpdbg_destroy_input(char** TSRMLS_DC); -/* -* Argument Management -*/ -PHPDBG_API phpdbg_input_t** phpdbg_read_argv(char *buffer, int *argc TSRMLS_DC); -PHPDBG_API void phpdbg_destroy_argv(phpdbg_input_t **argv, int argc TSRMLS_DC); -#define phpdbg_argv_is(n, s) \ - (memcmp(input->argv[n]->string, s, input->argv[n]->length) == SUCCESS) +/** + * Stack Management + */ +PHPDBG_API void phpdbg_stack_push(phpdbg_param_t *stack, phpdbg_param_t *param); +PHPDBG_API const phpdbg_command_t* phpdbg_stack_resolve(const phpdbg_command_t *commands, const phpdbg_command_t *parent, phpdbg_param_t **top, char **why); +PHPDBG_API int phpdbg_stack_verify(const phpdbg_command_t *command, phpdbg_param_t **stack, char **why TSRMLS_DC); +PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack, char **why TSRMLS_DC); +PHPDBG_API void phpdbg_stack_free(phpdbg_param_t *stack); /* * Parameter Management @@ -135,28 +148,27 @@ PHPDBG_API zend_bool phpdbg_match_param(const phpdbg_param_t *, const phpdbg_par PHPDBG_API zend_ulong phpdbg_hash_param(const phpdbg_param_t * TSRMLS_DC); PHPDBG_API const char* phpdbg_get_param_type(const phpdbg_param_t* TSRMLS_DC); PHPDBG_API char* phpdbg_param_tostring(const phpdbg_param_t *param, char **pointer TSRMLS_DC); - -/* -* Command Executor -*/ -PHPDBG_API int phpdbg_do_cmd(const phpdbg_command_t*, phpdbg_input_t* TSRMLS_DC); +PHPDBG_API void phpdbg_param_debug(const phpdbg_param_t *param, const char *msg); /** * Command Declarators */ #define PHPDBG_COMMAND_HANDLER(name) phpdbg_do_##name -#define PHPDBG_COMMAND_D_EX(name, tip, alias, handler, children, has_args) \ - {PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##handler, children, has_args} +#define PHPDBG_COMMAND_D_EXP(name, tip, alias, handler, children, args, parent) \ + {PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##handler, children, args, parent} -#define PHPDBG_COMMAND_D(name, tip, alias, children, has_args) \ - {PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##name, children, has_args} +#define PHPDBG_COMMAND_D_EX(name, tip, alias, handler, children, args) \ + {PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##handler, children, args, NULL} -#define PHPDBG_COMMAND(name) int phpdbg_do_##name(const phpdbg_param_t *param, const phpdbg_input_t *input TSRMLS_DC) +#define PHPDBG_COMMAND_D(name, tip, alias, children, args) \ + {PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##name, children, args, NULL} -#define PHPDBG_COMMAND_ARGS param, input TSRMLS_CC +#define PHPDBG_COMMAND(name) int phpdbg_do_##name(const phpdbg_param_t *param TSRMLS_DC) -#define PHPDBG_END_COMMAND {NULL, 0, NULL, 0, '\0', NULL, NULL, '\0'} +#define PHPDBG_COMMAND_ARGS param TSRMLS_CC + +#define PHPDBG_END_COMMAND {NULL, 0, NULL, 0, '\0', NULL, NULL, '\0', NULL} /* * Default Switch Case diff --git a/phpdbg_frame.c b/phpdbg_frame.c index de02addc1b9..a235fe8cb04 100644 --- a/phpdbg_frame.c +++ b/phpdbg_frame.c @@ -167,7 +167,7 @@ void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */ zval **tmp; zval **file, **line; HashPosition position; - int i = 1, limit = num; + int i = 0, limit = num; int user_defined; if (limit < 0) { @@ -186,7 +186,7 @@ void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */ if (zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), (void**)&tmp, &position) == FAILURE) { - phpdbg_write("frame #0: {main} at %s:%ld", Z_STRVAL_PP(file), Z_LVAL_PP(line)); + phpdbg_write("frame #%d: {main} at %s:%ld", i, Z_STRVAL_PP(file), Z_LVAL_PP(line)); break; } diff --git a/phpdbg_help.c b/phpdbg_help.c index d2fea8d7c7a..f2d074ded60 100644 --- a/phpdbg_help.c +++ b/phpdbg_help.c @@ -15,589 +15,916 @@ | Authors: Felipe Pena | | Authors: Joe Watkins | | Authors: Bob Weinand | + | Authors: Terry Ellison | +----------------------------------------------------------------------+ */ #include "phpdbg.h" #include "phpdbg_help.h" -#include "phpdbg_print.h" -#include "phpdbg_utils.h" -#include "phpdbg_break.h" -#include "phpdbg_list.h" -#include "phpdbg_info.h" -#include "phpdbg_set.h" +#include "phpdbg_prompt.h" +#include "zend.h" ZEND_EXTERN_MODULE_GLOBALS(phpdbg); -PHPDBG_HELP(exec) /* {{{ */ -{ - phpdbg_help_header(); - phpdbg_writeln("\tWill attempt execution, if compilation has not yet taken place, it occurs now"); - phpdbg_writeln("The execution context must be set before execution can take place"); - phpdbg_help_footer(); - return SUCCESS; -} /* }}} */ +/* {{{ Commands Table */ +#define PHPDBG_COMMAND_HELP_D(name, tip, alias, action) \ + {PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, action, NULL, 0} -PHPDBG_HELP(step) /* {{{ */ -{ - phpdbg_help_header(); - phpdbg_writeln("You can enable and disable stepping at any phpdbg prompt during execution"); - phpdbg_writeln(EMPTY); - phpdbg_notice("Examples"); - phpdbg_writeln("\t%sstepping 1", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%ss 1", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill enable stepping"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("While stepping is enabled you are presented with a prompt after the execution of each opcode"); - phpdbg_help_footer(); - return SUCCESS; -} /* }}} */ +const phpdbg_command_t phpdbg_help_commands[] = { + PHPDBG_COMMAND_HELP_D(aliases, "show alias list", 'a', phpdbg_do_help_aliases), + PHPDBG_COMMAND_HELP_D(options, "command line options", 0, NULL), + PHPDBG_COMMAND_HELP_D(overview, "help overview", 0, NULL), + PHPDBG_COMMAND_HELP_D(phpdbginit, "phpdbginit file format", 0, NULL), + PHPDBG_COMMAND_HELP_D(syntax, "syntax overview", 0, NULL), + PHPDBG_END_COMMAND +}; /* }}} */ -PHPDBG_HELP(next) /* {{{ */ +/* {{{ pretty_print. Formatting escapes and wrapping text in a string before printing it. */ +void pretty_print(char *text TSRMLS_DC) { - phpdbg_help_header(); - phpdbg_write("Step back into the vm and execute the next opcode"); - phpdbg_writeln(EMPTY); - phpdbg_notice("Examples"); - phpdbg_writeln("\t%snext", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sn", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill cause control to be passed back to the vm, continuing execution"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("Note: is only useful while executing"); - phpdbg_help_footer(); - return SUCCESS; -} /* }}} */ + char *new, *p, *q; -PHPDBG_HELP(until) /* {{{ */ -{ - phpdbg_help_header(); - phpdbg_writeln("Step back into the vm, skipping breakpoints until the next source line"); - phpdbg_writeln(EMPTY); - phpdbg_notice("Examples"); - phpdbg_writeln("\t%suntil", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%su", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill cause control to be passed back to the vm, continuing execution"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("Note: is only useful while executing"); - phpdbg_help_footer(); - return SUCCESS; -} /* }}} */ + const char *prompt_escape = phpdbg_get_prompt(TSRMLS_C); + unsigned int prompt_escape_len = strlen(prompt_escape); + unsigned int prompt_len = strlen(PHPDBG_G(prompt)[0]); -PHPDBG_HELP(finish) /* {{{ */ -{ - phpdbg_help_header(); - phpdbg_writeln("Step back into the vm, skipping breakpoints until past the end of the current stack"); - phpdbg_writeln(EMPTY); - phpdbg_notice("Examples"); - phpdbg_writeln("\t%sfinish", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sF", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill cause control to be passed back to the vm, continuing execution"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("Note: this allows all breakpoints that would otherwise break execution in the current scope to be skipped"); - phpdbg_help_footer(); - return SUCCESS; -} /* }}} */ + const char *bold_on_escape = PHPDBG_G(flags) & PHPDBG_IS_COLOURED ? "\033[1m" : ""; + const char *bold_off_escape = PHPDBG_G(flags) & PHPDBG_IS_COLOURED ? "\033[0m" : ""; + unsigned int bold_escape_len = strlen(bold_on_escape); -PHPDBG_HELP(leave) /* {{{ */ -{ - phpdbg_help_header(); - phpdbg_writeln("Step back into the vm, skipping breakpoints until the current stack is returning"); - phpdbg_writeln(EMPTY); - phpdbg_notice("Examples"); - phpdbg_writeln("\t%sleave", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sL", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill cause a break when instructed to leave the current context"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("Note: this allows inspection of the return value before it is returned"); - phpdbg_help_footer(); - return SUCCESS; -} /* }}} */ + unsigned int term_width = phpdbg_get_terminal_width(TSRMLS_C); + unsigned int size = 0; -PHPDBG_HELP(compile) /* {{{ */ -{ - phpdbg_help_header(); - phpdbg_writeln("Pre-compilation of the execution context provides the opportunity to inspect opcodes before execution"); - phpdbg_writeln("The execution context must be set for compilation to succeed"); - phpdbg_writeln(EMPTY); - phpdbg_notice("Examples"); - phpdbg_writeln("\t%scompile", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sc", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill compile the current execution context, populating class/function/constant/etc tables"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("Note: It is a good idea to clean the environment between each compilation"); - phpdbg_help_footer(); - return SUCCESS; -} /* }}} */ + int in_bold = 0; -PHPDBG_HELP(print) /* {{{ */ -{ - phpdbg_help_header(); - phpdbg_writeln("By default, print will show information about the current execution context"); - phpdbg_writeln("Other printing commands give access to instruction information"); - phpdbg_writeln(EMPTY); - phpdbg_notice("Examples"); - phpdbg_writeln("\t%sprint class \\my\\class", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sp c \\my\\class", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill print the instructions for the methods in \\my\\class"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("\t%sprint method \\my\\class::method", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sp m \\my\\class::method", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill print the instructions for \\my\\class::method"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("\t%sprint func .getSomething", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sp f .getSomething", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill print the instructions for ::getSomething in the active scope"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("\t%sprint func my_function", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sp f my_function", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill print the instructions for the global function my_function"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("\t%sprint opline", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sp o", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill print the instruction for the current opline"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("\t%sprint exec", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sp e", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill print the instructions for the execution context"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("\t%sprint stack", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sp s", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill print the instructions for the current stack"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("Specific printers loaded are show below:"); - phpdbg_notice("Commands"); - { - const phpdbg_command_t *print_command = phpdbg_print_commands; + char *last_new_blank = NULL; /* position in new buffer of last blank char */ + unsigned int last_blank_count = 0; /* printable char offset of last blank char */ + unsigned int line_count = 0; /* number printable chars on current line */ - phpdbg_writeln("\tAlias\tCommand\t\tPurpose"); - while (print_command && print_command->name) { - if (print_command->alias) { - phpdbg_writeln("\t[%c]\t%s\t\t%s", print_command->alias, print_command->name, print_command->tip); - } else { - phpdbg_writeln("\t[ ]\t%s\t\t%s", print_command->name, print_command->tip); - } - ++print_command; + /* First pass calculates a safe size for the pretty print version */ + for (p = text; *p; p++) { + if (UNEXPECTED(p[0] == '*') && p[1] == '*') { + size += bold_escape_len - 2; + p++; + } else if (UNEXPECTED(p[0] == '$') && p[1] == 'P') { + size += prompt_escape_len - 2; + p++; + } else if (UNEXPECTED(p[0] == '\\')) { + p++; } } - phpdbg_help_footer(); - return SUCCESS; -} /* }}} */ + size += (p-text)+1; -PHPDBG_HELP(run) /* {{{ */ -{ - phpdbg_help_header(); - phpdbg_writeln("Execute the current context inside the phpdbg vm"); - phpdbg_writeln(EMPTY); - phpdbg_notice("Examples"); - phpdbg_writeln("\t%srun", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sr", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill cause execution of the context, if it is set."); - phpdbg_writeln(EMPTY); - phpdbg_writeln("Note: The execution context must be set, but not necessarily compiled before execution occurs"); - phpdbg_help_footer(); - return SUCCESS; -} /* }}} */ - -PHPDBG_HELP(eval) /* {{{ */ -{ - phpdbg_help_header(); - phpdbg_writeln("Access to eval() allows you to change the environment during execution, careful though!!"); - phpdbg_writeln(EMPTY); - phpdbg_notice("Examples"); - phpdbg_writeln("\t%seval $variable", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sE $variable", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill print_r($variable) on the console, if it is defined"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("\t%seval $variable = \"Hello phpdbg :)\"", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sE $variable = \"Hello phpdbg :)\"", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill set $variable in the current scope"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("Note: eval() will always show the result; do not prefix the code with \"return\""); - phpdbg_help_footer(); - return SUCCESS; -} /* }}} */ - -PHPDBG_HELP(break) /* {{{ */ -{ - phpdbg_help_header(); - phpdbg_writeln("Setting a breakpoint stops execution at a specific stage"); - phpdbg_writeln(EMPTY); - phpdbg_notice("Examples"); - phpdbg_writeln("\t%sbreak [file] test.php:1", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sb [F] test.php:1", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill break execution on line 1 of test.php"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("\t%sbreak [func] my_function", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sb [f] my_function", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill break execution on entry to my_function"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("\t%sbreak [method] \\my\\class::method", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sb [m] \\my\\class::method", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill break execution on entry to \\my\\class::method"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("\t%sbreak [address] 0x7ff68f570e08", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sb [a] 0x7ff68f570e08", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill break at the opline with the address provided"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("\t%sbreak [address] my_function#1", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sb [a] my_function#1", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill break at the opline number 1 of the function my_function"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("\t%sbreak [address] \\my\\class::method#2", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sb [a] \\my\\class::method#2", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill break at the opline number 2 of the method \\my\\class::method"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("\t%sbreak address test.php:3", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sb a test.php:3", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill break at the opline number 3 of test.php"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("\t%sbreak [lineno] 200", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sb [l] 200", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill break at line 200 of the currently executing file"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("\t%sbreak on ($expression == true)", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sb on ($expression == true)", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill break when the condition evaluates to true"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("\t%sbreak at phpdbg::isGreat if ($expression == true)", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill break at every opcode in phpdbg::isGreat when the condition evaluates to true"); - phpdbg_writeln("\t%sbreak at test.php:20 if ($expression == true)", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill break at every opcode on line 20 of test.php when the condition evaluates to true"); - phpdbg_write("\t"); - phpdbg_notice("The location can be anything accepted by file, func, method, or address break commands"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("\t%sbreak op ZEND_ADD", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sb O ZEND_ADD", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill break on every occurrence of the opcode provided"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("\t%sbreak del 1", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sb d 1", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill remove the breakpoint with the given identifier"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("Note: An address is only valid for the current compilation"); - phpdbg_writeln(EMPTY); - phpdbg_notice("The parameters enclosed by [] are usually optional, but help avoid ambigious commands"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("Specific breakers loaded are show below:"); - phpdbg_notice("Commands"); - { - const phpdbg_command_t *break_command = phpdbg_break_commands; - - phpdbg_writeln("\tAlias\tCommand\t\tPurpose"); - while (break_command && break_command->name) { - if (break_command->alias) { - phpdbg_writeln("\t[%c]\t%s\t\t%s", break_command->alias, break_command->name, break_command->tip); - } else { - phpdbg_writeln("\t[ ]\t%s\t\t%s", break_command->name, break_command->tip); + new = emalloc(size); + /* + * Second pass substitutes the bold and prompt escape sequences and line wrap + * + * ** toggles bold on and off if PHPDBG_IS_COLOURED flag is set + * $P substitutes the prompt sequence + * Lines are wrapped by replacing the last blank with a CR before + * characters. (This defaults to 100 if the width can't be detected). In the + * pathelogical case where no blanks are found, then the wrap occurs at the + * first blank. + */ + for (p = text, q = new; *p; p++) { + if (UNEXPECTED(*p == ' ')) { + last_new_blank = q; + last_blank_count = line_count++; + *q++ = ' '; + } else if (UNEXPECTED(*p == '\n')) { + last_new_blank = NULL; + *q++ = *p; + last_blank_count = 0; + line_count = 0; + } else if (UNEXPECTED(p[0] == '*') && p[1] == '*') { + if (bold_escape_len) { + in_bold = !in_bold; + memcpy (q, in_bold ? bold_on_escape : bold_off_escape, bold_escape_len); + q += bold_escape_len; + /* bold on/off has zero print width so line count is unchanged */ } - ++break_command; - } - } - phpdbg_writeln("Note: Conditional breaks are costly, use them sparingly!"); - phpdbg_help_footer(); - return SUCCESS; -} /* }}} */ - -PHPDBG_HELP(clean) /* {{{ */ -{ - phpdbg_help_header(); - phpdbg_writeln("While debugging you may experience errors because of attempts to redeclare classes, constants or functions"); - phpdbg_writeln("Cleaning the environment cleans these tables, so that files can be recompiled without exiting phpdbg"); - phpdbg_help_footer(); - return SUCCESS; -} /* }}} */ - -PHPDBG_HELP(clear) /* {{{ */ -{ - phpdbg_help_header(); - phpdbg_writeln("Clearing breakpoints means you can once again run code without interruption"); - phpdbg_writeln("Note: all breakpoints are lost; be sure debugging is complete before clearing"); - phpdbg_help_footer(); - return SUCCESS; -} /* }}} */ - -PHPDBG_HELP(info) /* {{{ */ -{ - phpdbg_help_header(); - phpdbg_writeln("info commands provide quick access to various types of information about the PHP environment"); - phpdbg_writeln("Specific info commands are show below:"); - phpdbg_notice("Commands"); - { - const phpdbg_command_t *info_command = phpdbg_info_commands; - - phpdbg_writeln("\tAlias\tCommand\t\tPurpose"); - while (info_command && info_command->name) { - if (info_command->alias) { - phpdbg_writeln("\t[%c]\t%s\t\t%s", info_command->alias, info_command->name, info_command->tip); - } else { - phpdbg_writeln("\t[ ]\t%s\t\t%s", info_command->name, info_command->tip); - } - ++info_command; - } - } - - phpdbg_help_footer(); - return SUCCESS; -} /* }}} */ - -PHPDBG_HELP(quiet) /* {{{ */ -{ - phpdbg_help_header(); - phpdbg_writeln("Setting quietness on will stop the OPLINE output during execution"); - phpdbg_writeln(EMPTY); - phpdbg_notice("Examples"); - phpdbg_writeln("\t%squiet 1", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sQ 1", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill silence OPLINE output, while"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("\t%squiet 0", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sQ 0", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill enable OPLINE output again"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("Note: Quietness is disabled automatically while stepping"); - phpdbg_help_footer(); - return SUCCESS; -} /* }}} */ - -PHPDBG_HELP(back) /* {{{ */ -{ - phpdbg_help_header(); - phpdbg_writeln("The backtrace is built with the default debug backtrace functionality"); - phpdbg_writeln(EMPTY); - phpdbg_notice("Examples"); - phpdbg_writeln("\t%sback 5", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%st 5", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill limit the number of frames to 5, the default is no limit"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("Note: it is not necessary for an exception to be thrown to show a backtrace"); - phpdbg_help_footer(); - return SUCCESS; -} /* }}} */ - -PHPDBG_HELP(frame) /* {{{ */ -{ - phpdbg_help_header(); - phpdbg_writeln("When viewing a backtrace, it is sometimes useful to jump to a frame in that trace"); - phpdbg_writeln(EMPTY); - phpdbg_notice("Examples"); - phpdbg_writeln("\t%sframe 2", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sf 2", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill go to frame 2, temporarily affecting scope and allowing access to the variables in that frame"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("Note: the current frame is restored when execution continues"); - phpdbg_help_footer(); - return SUCCESS; -} /* }}} */ - -PHPDBG_HELP(list) /* {{{ */ -{ - phpdbg_help_header(); - phpdbg_writeln("The list command displays source code for the given argument"); - phpdbg_writeln(EMPTY); - phpdbg_notice("Examples"); - phpdbg_writeln("\t%slist [lines] 2", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sl [l] 2", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill print next 2 lines from the current file"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("\t%slist [func] my_function", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sl [f] my_function", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill print the source of the global function \"my_function\""); - phpdbg_writeln(EMPTY); - phpdbg_writeln("\t%slist [func] .mine", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sl [f] .mine", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill print the source of the method \"mine\" from the active scope"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("\t%slist [method] my::method", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sl [m] my::method", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill print the source of \"my::method\""); - phpdbg_writeln(EMPTY); - phpdbg_writeln("\t%slist c myClass", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sl c myClass", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill print the source of \"myClass\""); - phpdbg_writeln(EMPTY); - phpdbg_writeln("Note: before listing functions you must have a populated function table, try compile!!"); - phpdbg_writeln(EMPTY); - phpdbg_notice("The parameters enclosed by [] are usually optional, but help avoid ambigious commands"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("Specific listers loaded are show below:"); - phpdbg_notice("Commands"); - { - const phpdbg_command_t *list_command = phpdbg_list_commands; - - phpdbg_writeln("\tAlias\tCommand\t\tPurpose"); - while (list_command && list_command->name) { - if (list_command->alias) { - phpdbg_writeln("\t[%c]\t%s\t\t%s", list_command->alias, list_command->name, list_command->tip); - } else { - phpdbg_writeln("\t[ ]\t%s\t\t%s", list_command->name, list_command->tip); - } - ++list_command; - } - } - phpdbg_help_footer(); - return SUCCESS; -} /* }}} */ - -PHPDBG_HELP(oplog) /* {{{ */ -{ - phpdbg_help_header(); - phpdbg_writeln("Even when quietness is enabled you may wish to save opline logs to a file"); - phpdbg_writeln("Setting a new oplog closes the previously open log"); - phpdbg_writeln("The log includes a high resolution timestamp on each entry"); - phpdbg_writeln(EMPTY); - phpdbg_notice("Examples"); - phpdbg_writeln("\t%soplog /path/to/my.oplog", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sO /path/to/my.oplog", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill open the file /path/to/my.oplog for writing, creating it if it does not exist"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("\t%soplog 0", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sO 0", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill close the currently open log file, disabling oplog"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("Note: upon failure to open a new oplog, the last oplog is held open"); - phpdbg_help_footer(); - return SUCCESS; -} /* }}} */ - -PHPDBG_HELP(set) /* {{{ */ -{ - phpdbg_help_header(); - phpdbg_writeln("Configure how phpdbg looks and behaves with the set command"); - phpdbg_writeln("Specific set commands are show below:"); - phpdbg_notice("Commands"); - { - const phpdbg_command_t *set_command = phpdbg_set_commands; - - phpdbg_writeln("\tAlias\tCommand\t\tPurpose"); - while (set_command && set_command->name) { - if (set_command->alias) { - phpdbg_writeln("\t[%c]\t%s\t\t%s", set_command->alias, set_command->name, set_command->tip); - } else { - phpdbg_writeln("\t[ ]\t%s\t\t%s", set_command->name, set_command->tip); - } - ++set_command; - } - } -#ifndef _WIN32 - phpdbg_notice("Colors"); - { - const phpdbg_color_t *color = phpdbg_get_colors(TSRMLS_C); - - if (PHPDBG_G(flags) & PHPDBG_IS_COLOURED) { - phpdbg_writeln("\t%-20s\t\tExample", "Name"); + p++; + } else if (UNEXPECTED(p[0] == '$') && p[1] == 'P') { + memcpy (q, prompt_escape, prompt_escape_len); + q += prompt_escape_len; + line_count += prompt_len; + p++; + } else if (UNEXPECTED(p[0] == '\\')) { + p++; + *q++ = *p; + line_count++; } else { - phpdbg_writeln("\tName"); + *q++ = *p; + line_count++; } - - while (color && color->name) { - if (PHPDBG_G(flags) & PHPDBG_IS_COLOURED) { - phpdbg_writeln( - "\t%-20s\t\t\033[%smphpdbg rocks :)\033[0m", color->name, color->code); - } else { - phpdbg_writeln("\t%s", color->name); + + if (UNEXPECTED(line_count>=term_width) && last_new_blank) { + *last_new_blank = '\n'; + last_new_blank = NULL; + line_count -= last_blank_count; + last_blank_count = 0; + } + } + *q++ = '\0'; + + if ((q-new)>size) { + phpdbg_error("Output overrun of %lu bytes", ((q-new) - size)); + } + + phpdbg_write("%s\n", new); + efree(new); +} /* }}} */ + +/* {{{ summary_print. Print a summary line giving, the command, its alias and tip */ +void summary_print(phpdbg_command_t const * const cmd TSRMLS_DC) +{ + char *summary; + spprintf(&summary, 0, "Command: **%s** Alias: **%c** **%s**\n", cmd->name, cmd->alias, cmd->tip); + pretty_print(summary TSRMLS_CC); + efree(summary); +} + +/* {{{ get_help. Retries and formats text from the phpdbg help text table */ +static char *get_help(const char * const key TSRMLS_DC) +{ + phpdbg_help_text_t *p; + + /* Note that phpdbg_help_text is not assumed to be collated in key order. This is an + inconvience that means that help can't be logically grouped Not worth + the savings */ + + for (p = phpdbg_help_text; p->key; p++) { + if (!strcmp(p->key, key)) { + return p->text; + } + } + return ""; /* return empty string to denote no match found */ +} /* }}} */ + +/* {{{ get_command. Return number of matching commands from a command table. + * Unlike the command parser, the help search is sloppy that is partial matches can occur + * * Any single character key is taken as an alias. + * * Other keys are matched again the table on the first len characters. + * * This means that non-unique keys can generate multiple matches. + * * The first matching command is returned as an OUT parameter. * + * The rationale here is to assist users in finding help on commands. So unique matches + * will be used to generate a help message but non-unique one will be used to list alternatives. + */ +static int get_command( + const char *key, size_t len, /* pointer and length of key */ + phpdbg_command_t const **command, /* address of first matching command */ + phpdbg_command_t const * commands /* command table to be scanned */ + TSRMLS_DC) +{ + const phpdbg_command_t *c; + unsigned int num_matches = 0; + + if (len == 1) { + for (c=commands; c->name; c++) { + if (c->alias == key[0]) { + num_matches++; + if ( num_matches == 1 && command) { + *command = c; + } + } + } + } else { + for (c=commands; c->name; c++) { + if (!strncmp(c->name, key, len)) { + ++num_matches; + if ( num_matches == 1 && command) { + *command = c; + } } - ++color; } } - phpdbg_writeln("The for set color can be \"prompt\", \"notice\", or \"error\""); -#endif - phpdbg_help_footer(); - return SUCCESS; -} /* }}} */ -PHPDBG_HELP(register) /* {{{ */ + return num_matches; + +} /* }}} */ + +PHPDBG_COMMAND(help) /* {{{ */ { - phpdbg_help_header(); - phpdbg_writeln("Register any global function for use as a command in phpdbg console"); - phpdbg_writeln(EMPTY); - phpdbg_notice("Examples"); - phpdbg_writeln("\t%sregister scandir", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%sR scandir", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill register the scandir function for use in phpdbg"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("Note: arguments passed as strings, return (if present) print_r'd on console"); - if (zend_hash_num_elements(&PHPDBG_G(registered))) { - HashPosition position; - char *name = NULL; - zend_uint name_len = 0; + phpdbg_command_t const *cmd; + int n; - phpdbg_notice("Registered Functions (%d)", zend_hash_num_elements(&PHPDBG_G(registered))); - for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(registered), &position); - zend_hash_get_current_key_ex(&PHPDBG_G(registered), &name, &name_len, NULL, 1, &position) == HASH_KEY_IS_STRING; - zend_hash_move_forward_ex(&PHPDBG_G(registered), &position)) { - phpdbg_writeln("|-------> %s", name); - efree(name); - } + if (!param || param->type == EMPTY_PARAM) { + pretty_print(get_help("overview!" TSRMLS_CC) TSRMLS_CC); + return SUCCESS; } - phpdbg_help_footer(); + if (param && param->type == STR_PARAM) { + n = get_command(param->str, param->len, &cmd, phpdbg_prompt_commands TSRMLS_CC); + + if (n==1) { + summary_print(cmd TSRMLS_CC); + pretty_print(get_help(cmd->name TSRMLS_CC) TSRMLS_CC); + return SUCCESS; + + } else if (n>1) { + if (param->len > 1) { + for (cmd=phpdbg_prompt_commands; cmd->name; cmd++) { + if (!strncmp(cmd->name, param->str, param->len)) { + summary_print(cmd TSRMLS_CC); + } + } + pretty_print(get_help("duplicate!" TSRMLS_CC) TSRMLS_CC); + return SUCCESS; + } else { + phpdbg_error("Internal help error, non-unique alias \"%c\"", param->str[0]); + return FAILURE; + } + + } else { /* no prompt command found so try help topic */ + n = get_command( param->str, param->len, &cmd, phpdbg_help_commands TSRMLS_CC); + + if (n>0) { + if (cmd->alias == 'a') { /* help aliases executes a canned routine */ + return cmd->handler(param TSRMLS_CC); + } else { + pretty_print(get_help(cmd->name TSRMLS_CC) TSRMLS_CC); + return SUCCESS; + } + } + } + } + + return FAILURE; + +} /* }}} */ + +PHPDBG_HELP(aliases) /* {{{ */ +{ + const phpdbg_command_t *c, *c_sub; + int len; + + /* Print out aliases for all commands except help as this one comes last */ + phpdbg_writeln("Below are the aliased, short versions of all supported commands"); + for(c = phpdbg_prompt_commands; c->name; c++) { + if (c->alias && c->alias != 'h') { + phpdbg_writeln(" %c %-20s %s", c->alias, c->name, c->tip); + if (c->subs) { + len = 20 - 1 - c->name_len; + for(c_sub = c->subs; c_sub->alias; c_sub++) { + if (c_sub->alias) { + phpdbg_writeln(" %c %c %s %-*s %s", + c->alias, c_sub->alias, (char *)c->name, len, c_sub->name, c_sub->tip); + } + } + } + } + } + + /* Print out aliases for help as this one comes last, with the added text on how aliases are used */ + get_command("h", 1, &c, phpdbg_prompt_commands TSRMLS_CC); + phpdbg_writeln(" %c %-20s %s\n", c->alias, c->name, c->tip); + + len = 20 - 1 - c->name_len; + for(c_sub = c->subs; c_sub->alias; c_sub++) { + if (c_sub->alias) { + phpdbg_writeln(" %c %c %s %-*s %s", + c->alias, c_sub->alias, c->name, len, c_sub->name, c_sub->tip); + } + } + + pretty_print(get_help("aliases!" TSRMLS_CC) TSRMLS_CC); return SUCCESS; } /* }}} */ -PHPDBG_HELP(source) /* {{{ */ -{ - phpdbg_help_header(); - phpdbg_writeln("Sourcing a phpdbginit during your debugging session might save some time"); - phpdbg_writeln("The source command can also be used to export breakpoints to a phpdbginit file"); - phpdbg_writeln(EMPTY); - phpdbg_notice("Examples"); - phpdbg_writeln("\t%ssource /my/init", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%s. /my/init", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill execute the phpdbginit file at /my/init"); - phpdbg_writeln("\t%ssource export /my/init", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%s. export /my/init", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill export breakpoints to /my/init in phpdbginit file format"); - phpdbg_help_footer(); - return SUCCESS; -} /* }}} */ -PHPDBG_HELP(shell) /* {{{ */ -{ - phpdbg_help_header(); - phpdbg_writeln("Direct access to shell commands saves having to switch windows/consoles"); - phpdbg_writeln(EMPTY); - phpdbg_notice("Examples"); - phpdbg_writeln("\t%sshell ls /usr/src/php-src", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\t%s- ls /usr/src/php-src", phpdbg_get_prompt(TSRMLS_C)); - phpdbg_writeln("\tWill execute ls /usr/src/php-src, displaying the output in the console"); - phpdbg_writeln(EMPTY); - phpdbg_writeln("Note: read only commands please!"); - phpdbg_help_footer(); - return SUCCESS; -} /* }}} */ +/* {{{ Help Text Table + * Contains help text entries keyed by a lowercase ascii key. + * Text is in ascii and enriched by a simple markup: + * ** toggles bold font emphasis. + * $P insert an bold phpdbg> prompt. + * \ escapes the following character. Note that this is itself escaped inside string + * constants so \\\\ is required to output a single \ e.g. as in namespace names. + * + * Text will be wrapped according to the STDOUT terminal width, so paragraphs are + * flowed using the C stringizing and the CR definition. Also note that entries + * are collated in alphabetic order on key. + * + * Also note the convention that help text not directly referenceable as a help param + * has a key ending in ! + */ +#define CR "\n" +phpdbg_help_text_t phpdbg_help_text[] = { -PHPDBG_HELP(options) /* {{{ */ -{ - phpdbg_help_header(); - phpdbg_writeln("Below are the command line options supported by phpdbg"); - phpdbg_notice("Command Line Options and Flags"); - phpdbg_writeln(" -c\t-c/my/php.ini\t\tSet php.ini file to load"); - phpdbg_writeln(" -d\t-dmemory_limit=4G\tSet a php.ini directive"); - phpdbg_writeln(" -n\tN/A\t\t\tDisable default php.ini"); - phpdbg_writeln(" -q\tN/A\t\t\tSuppress welcome banner"); - phpdbg_writeln(" -e\t-emytest.php\t\tSet execution context"); - phpdbg_writeln(" -v\tN/A\t\t\tEnable oplog output"); - phpdbg_writeln(" -s\tN/A\t\t\tEnable stepping"); - phpdbg_writeln(" -b\tN/A\t\t\tDisable colour"); - phpdbg_writeln(" -i\t-imy.init\t\tSet .phpdbginit file"); - phpdbg_writeln(" -I\tN/A\t\t\tIgnore default .phpdbginit"); - phpdbg_writeln(" -O\t-Omy.oplog\t\tSets oplog output file"); - phpdbg_writeln(" -r\tN/A\t\t\tRun execution context"); - phpdbg_writeln(" -E\tN/A\t\t\tEnable step through eval, careful!"); - phpdbg_writeln(" -S\t-Scli\t\t\tOverride SAPI name, careful!"); -#ifndef _WIN32 - phpdbg_writeln(" -l\t-l4000\t\t\tSetup remote console ports"); - phpdbg_writeln(" -a\t-a192.168.0.3\t\tSetup remote console bind address"); -#endif - phpdbg_writeln(" -V\tN/A\t\t\tVersion number"); - phpdbg_notice("Passing -rr will quit automatically after execution"); -#ifndef _WIN32 - phpdbg_writeln("Remote Console Mode"); - phpdbg_notice("For security, phpdbg will bind only to the loopback interface by default"); - phpdbg_writeln("-a without an argument implies all; phpdbg will bind to all available interfaces."); - phpdbg_writeln("specify both stdin and stdout with -lstdin/stdout; by default stdout is stdin * 2."); - phpdbg_notice("Steps should be taken to secure this service if bound to a public interface/port"); -#endif - phpdbg_help_footer(); - return SUCCESS; -} /* }}} */ +/******************************** General Help Topics ********************************/ +{"overview!", CR +"**phpdbg** is a lightweight, powerful and easy to use debugging platform for PHP5.4+" CR +"It supports the following commands:" CR CR + +"**Information**" CR +" **list** list PHP source" CR +" **info** displays information on the debug session" CR +" **print** show opcodes " CR +" **frame** select a stack frame and print a stack frame summary" CR +" **help** provide help on a topic" CR CR + +"**Starting and Stopping Execution**" CR +" **exec** set execution context" CR +" **run** attempt execution" CR +" **step** continue execution until other line is reached" CR +" **continue** continue execution" CR +" **until** continue execution up to the given location" CR +" **finish** continue up to end of the current execution frame" CR +" **leave** continue up to end of the current execution frame and halt after the calling instruction" CR +" **break** set a breakpoint at the specified target" CR +" **watch** set a watchpoint on $variable" CR +" **clear** clear one or all breakpoints" CR +" **clean** clean the execution environment" CR CR + +"**Miscellaneous**" CR +" **set** set the phpdbg configuration" CR +" **source** execute a phpdbginit script" CR +" **register** register a phpdbginit function as a command alias" CR +" **sh** shell a command" CR +" **ev** evaluate some code" CR +" **quit** exit phpdbg" CR CR + +"Type **help ** or (**help alias**) to get detailed help on any of the above commands, " +"for example **help list** or **h l**. Note that help will also match partial commands if unique " +"(and list out options if not unique), so **help clea** will give help on the **clean** command, " +"but **help cl** will list the summary for **clean** and **clear**." CR CR + +"Type **help aliases** to show a full alias list, including any registered phpdginit functions" CR +"Type **help syntax** for a general introduction to the command syntax." CR +"Type **help options** for a list of phpdbg command line options." CR +"Type **help phpdbginit** to show how to customise the debugger environment." +}, +{"options", CR +"Below are the command line options supported by phpdbg" CR CR + /* note the extra 4 space index in because of the extra **** */ +"**Command Line Options and Flags**" CR +" **Option** **Example Argument** **Description**" CR +" **-c** **-c**/my/php.ini Set php.ini file to load" CR +" **-d** **-d**memory_limit=4G Set a php.ini directive" CR +" **-n** Disable default php.ini" CR +" **-q** Supress welcome banner" CR +" **-v** Enable oplog output" CR +" **-s** Enable stepping" CR +" **-b** Disable colour" CR +" **-i** **-i**my.init Set .phpdbginit file" CR +" **-I** Ignore default .phpdbginit" CR +" **-O** **-O**my.oplog Sets oplog output file" CR +" **-r** Run execution context" CR +" **-rr** Run execution context and quit after execution" CR +" **-E** Enable step through eval, careful!" CR +" **-S** **-S**cli Override SAPI name, careful!" CR +" **-l** **-l**4000 Setup remote console ports" CR +" **-a** **-a**192.168.0.3 Setup remote console bind address" CR +" **-V** Print version number" CR +" **--** **--** arg1 arg2 Use to delimit phpdbg arguments and php $argv; append any $argv " +"argument after it" CR CR + +"**Remote Console Mode**" CR CR + +"This mode is enabled by specifying the **-a** option. Phpdbg will bind only to the loopback " +"interface by default, and this can only be overridden by explicitly setting the remote console " +"bind address using the **-a** option. If **-a** is specied without an argument, then phpdbg " +"will bind to all available interfaces. You should be aware of the security implications of " +"doing this, so measures should be taken to secure this service if bound to a publicly accessible " +"interface/port." CR CR + +"Specify both stdin and stdout with -lstdin/stdout; by default stdout is stdin * 2." +}, + +{"phpdbginit", CR +"Phpdgb uses an debugger script file to initialize the debugger context. By default, phpdbg looks " +"for the file named **.phpdbginit** in the current working directory. This location can be " +"overridden on the command line using the **-i** switch (see **help options** for a more " +"details)." CR CR + +"Debugger scripts can also be executed using the **source** command." CR CR + +"A script file can contain a sequence of valid debugger commands, comments and embedded PHP " +"code. " CR CR + +"Comment lines are prefixed by the **#** character. Note that comments are only allowed in script " +"files and not in interactive sessions." CR CR + +"PHP code is delimited by the start and end escape tags **<:** and **:>**. PHP code can be used " +"to define application context for a debugging session and also to extend the debugger by defining " +"and **register** PHP functions as new commands." CR CR + +"Also note that executing a **clear** command will cause the current **phpdbginit** to be reparsed " +"/ reloaded." +}, + +{"syntax", CR +"Commands start with a keyword, and some (**break**, " +"**info**, **set**, **print** and **list**) may include a subcommand keyword. All keywords are " +"lower case but also have a single letter alias that may be used as an alternative to typing in the" +"keyword in full. Note some aliases are uppercase, and that keywords cannot be abbreviated other " +"than by substitution by the alias." CR CR + +"Some commands take an argument. Arguments are typed according to their format:" CR +" * **omitted**" CR +" * **address** **0x** followed by a hex string" CR +" * **number** an optionally signed number" CR +" * **method** a valid **Class::methodName** expression" CR +" * **func#op** a valid **Function name** follow by # and an integer" CR +" * **method#op** a valid **Class::methodName** follow by # and an integer" CR +" * **string** a general string" CR +" * **function** a valid **Function name**" CR +" * **file:line** a valid **filename** follow by : and an integer" CR CR + +"In some cases the type of the argument enables the second keyword to be omitted." CR CR + +"Type **help** for an overview of all commands and type **help ** to get detailed help " +"on any specific command." CR CR + +"**Valid Examples**" CR CR + +" $P quit" CR +" $P q" CR +" Quit the debugger" CR CR + +" $P ev $total[2]" CR +" Evaluate and print the variable $total[2] in the current stack frame" CR +" " CR +" $P break 200" CR +" $P b my_source.php:200" CR +" Break at line 200 in the current source and in file **my_source.php**. " CR CR + +" $P b @ ClassX::get_args if $arg[0] == \"fred\"" CR +" $P b ~ 3" CR +" Break at ClassX::get_args() if $arg[0] == \"fred\" and delete breakpoint 3" CR CR + +"**Examples of invalid commands**" CR + +" $P #This is a comment" CR +" Comments introduced by the **#** character are only allowed in **phpdbginit** script files." +}, + +/******************************** Help Codicils ********************************/ +{"aliases!", CR +"Note that aliases can be used for either command or sub-command keywords or both, so **info b** " +"is a synomyn for **info break** and **l func** for **list func**, etc." CR CR + +"Note that help will also accept any alias as a parameter and provide help on that command, for example **h p** will provide help on the print command." +}, + +{"duplicate!", CR +"Parameter is not unique. For detailed help select help on one of the above commands." +}, + +/******************************** Help on Commands ********************************/ +{"back", +"Provide a formatted backtrace using the standard debug_backtrace() functionality. An optional " +"unsigned integer argument specifying the maximum number of frames to be traced; if omitted then " +"a complete backtrace is given." CR CR + +"**Examples**" CR CR +" $P back 5" CR +" $P t " CR +" " CR +"A backtrace can be executed at any time during execution." +}, + +{"break", +"Breakpoints can be set at a range of targets within the execution environment. Execution will " +"be paused if the program flow hits a breakpoint. The break target can be one of the following " +"types:" CR CR + +" **Target** **Alias** **Purpose**" CR +" **at** **A** specify breakpoint by location and condition" CR +" **del** **d** delete breakpoint by breakpoint identifier number" CR CR + +"**Break at** takes two arguments. The first is any valid target. The second " +"is a valid PHP expression which will trigger the break in " +"execution, if evaluated as true in a boolean context at the specified target." CR CR + +"Note that breakpoints can also be disabled and re-enabled by the **set break** command." CR CR + +"**Examples**" CR CR +" $P break test.php:100" CR +" $P b test.php:100" CR +" Break execution at line 100 of test.php" CR CR + +" $P break 200" CR +" $P b 200" CR +" Break execution at line 200 of the currently PHP script file" CR CR + +" $P break \\\\mynamespace\\\\my_function" CR +" $P b \\\\mynamespace\\\\my_function" CR +" Break execution on entry to \\\\mynamespace\\\\my_function" CR CR + +" $P break classX::method" CR +" $P b classX::method" CR +" Break execution on entry to classX::method" CR CR + +" $P break 0x7ff68f570e08" CR +" $P b 0x7ff68f570e08" CR +" Break at the opline at the address 0x7ff68f570e08" CR CR + +" $P break my_function#14" CR +" $P b my_function#14" CR +" Break at the opline #14 of the function my_function" CR CR + +" $P break \\\\my\\\\class::method#2" CR +" $P b \\\\my\\\\class::method#2" CR +" Break at the opline #2 of the method \\\\my\\\\class::method" CR CR + +" $P break test.php:#3" CR +" $P b test.php:#3" CR +" Break at opline #3 in test.php" CR CR + +" $P break if $cnt > 10" CR +" $P b if $cnt > 10" CR +" Break when the condition ($cnt > 10) evaluates to true" CR CR + +" $P break at phpdbg::isGreat if $opt == 'S'" CR +" $P break @ phpdbg::isGreat if $opt == 'S'" CR +" Break at any opcode in phpdbg::isGreat when the condition ($opt == 'S') is true" CR CR + +" $P break at test.php:20 if !isset($x)" CR +" Break at every opcode on line 20 of test.php when the condition evaluates to true" CR CR + +" $P break ZEND_ADD" CR +" $P b ZEND_ADD" CR +" Break on any occurence of the opcode ZEND_ADD" CR CR + +" $P break del 2" CR +" $P b ~ 2" CR +" Remove breakpoint 2" CR CR + +"Note: Conditional breaks are costly in terms of runtime overhead. Use them only when required " +"as they significantly slow execution." CR CR + +"Note: An address is only valid for the current compilation." +}, + +{"clean", +"Classes, constants or functions can only be declared once in PHP. You may experience errors " +"during a debug session if you attempt to recompile a PHP source. The clean command clears " +"the Zend runtime tables which holds the sets of compiled classes, constants and functions, " +"releasing any associated storage back into the storage pool. This enables recompilation to " +"take place." CR CR + +"Note that you cannot selectively trim any of these resource pools. You can only do a complete " +"clean." +}, + +{"clear", +"Clearing breakpoints means you can once again run code without interruption." CR CR + +"Note: use break delete N to clear a specific breakpoint." CR CR + +"Note: if all breakpoints are cleared, then the PHP script will run until normal completion." +}, + +{"ev", +"The **ev** command takes a string expression which it evaluates and then displays. It " +"evaluates in the context of the lowest (that is the executing) frame, unless this has first " +"been explicitly changed by issuing a **frame** command. " CR CR + +"**Examples**" CR CR +" $P ev $variable" CR +" Will print_r($variable) on the console, if it is defined" CR CR + +" $P ev $variable = \"Hello phpdbg :)\"" CR +" Will set $variable in the current scope" CR CR + +"Note that **ev** allows any valid PHP expression including assignments, function calls and " +"other write statements. This enables you to change the environment during execution, so care " +"is needed here. You can even call PHP functions which have breakpoints defined. " CR CR + +"Note: **ev** will always show the result, so do not prefix the code with **return**" +}, + +{"exec", +"The **exec** command sets the execution context, that is the script to be executed. The " +"execution context must be defined either by executing the **exec** command or by using the " +"**-e** command line option." CR CR + +"Note that the **exec** command also can be used to replace a previously defined execution " +"context." CR CR + +"**Examples**" CR CR + +" $P exec /tmp/script.php" CR +" $P e /tmp/script.php" CR +" Set the execution context to **/tmp/script.php**" +}, + +//*********** Does F skip any breakpoints lower stack frames or only the current?? +{"finish", +"The **finish** command causes control to be passed back to the vm, continuing execution. Any " +"breakpoints that are encountered within the current stack frame will be skipped. Execution " +"will then continue until the next breakpoint after leaving the stack frame or unitil " +"completion of the script" CR CR + +"Note when **step**ping is enabled, any opcode steps within the current stack frame are also " +"skipped. "CR CR + +"Note **finish** will trigger a \"not executing\" error if not executing." +}, + +{"frame", +"The **frame** takes an optional integer argument. If omitted, then the current frame is displayed " +"If specified then the current scope is set to the corresponding frame listed in a **back** trace. " "This can be used to allowing access to the variables in a higher stack frame than that currently " +"being executed." CR CR + +"**Examples**" CR CR +" $P frame 2" CR +" $P E $count" CR +" Go to frame 2 and print out variable **$count** in that frame" CR CR + +"Note that this frame scope is discarded when execution continues, with the execution frame " +"then reset to the lowest executiong frame." +}, + +{"info", +"**info** commands provide quick access to various types of information about the PHP environment" CR +"Specific info commands are show below:" CR CR + +" **Target** **Alias** **Purpose**" CR +" **break** **b** show current breakpoints" CR +" **files** **F** show included files" CR +" **classes** **c** show loaded classes" CR +" **funcs** **f** show loaded classes" CR +" **error** **e** show last error" CR +" **vars** **v** show active variables" CR +" **literal** **l** show active literal constants" CR +" **memory** **m** show memory manager stats" +}, + +// ******** same issue about breakpoints in called frames +{"leave", +"The **leave** command causes control to be passed back to the vm, continuing execution. Any " +"breakpoints that are encountered within the current stack frame will be skipped. In effect a " +"temporary breakpoint is associated with any return opcode, so that a break in execution occurs " +"before leaving the current stack frame. This allows inspection / modification of any frame " +"variables including the return value before it is returned" CR CR + +"**Examples**" CR CR + +" $P leave" CR +" $P L" CR CR + +"Note when **step**ping is enabled, any opcode steps within the current stack frame are also " +"skipped. "CR CR + +"Note **leave** will trigger a \"not executing\" error if not executing." +}, + +{"list", +"The list command displays source code for the given argument. The target type is specficied by " +"a second subcommand keyword:" CR CR + +" **Type** **Alias** **Purpose**" CR +" **lines** **l** List N lines from the current execution point" CR +" **func** **f** List the complete source for a specified function" CR +" **method** **m** List the complete source for a specified class::method" CR +" **class** **c** List the complete source for a specified class" CR CR + +"Note that the context of **lines**, **func** and **method** can be determined by parsing the " +"argument, so these subcommands are optional. However, you must specify the **class** keyword " +"to list off a class." CR CR + +"**Examples**" CR CR +" $P list 2" CR +" $P l l 2" CR +" List the next 2 lines from the current file" CR CR + +" $P list my_function" CR +" $P l f my_function" CR +" List the source of the function **my_function**" CR CR + +//************ ???? +" $P list func .mine" CR +" $P l f .mine" CR +" List the source of the method **mine** from the active class in scope" CR CR + +" $P list m my::method" CR +" $P l my::method" CR +" List the source of **my::method**" CR CR + +" $P list c myClass" CR +" $P l c myClass" CR +" List the source of **myClass**" CR CR + +"Note that functions and classes can only be listed if the corresponding classes and functions " +"table in the Zend executor has a corresponding entry. You can use the compile command to " +"populate these tables for a given execution context." +}, + +{"continue", +"Continue with execution after hitting a break or watchpoint" CR CR + +"**Examples**" CR CR +" $P continue" CR +" $P c" CR +" Continue executing until the next break or watchpoint" CR CR + +"Note **continue** will trigger a \"not running\" error if not executing." +}, + +{"print", +"By default, print will show information about the current execution context." CR +"Other printing commands give access to instruction information." CR +"Specific printers loaded are show below:" CR CR + +" **Type** **Alias** **Purpose**" CR +" **exec** **e** print out the instructions in the execution context" CR +" **opline** **o** print out the instruction in the current opline" CR +" **class** **c** print out the instructions in the specified class" CR +" **method** **m** print out the instructions in the specified method" CR +" **func** **f** print out the instructions in the specified function" CR +" **stack** **s** print out the instructions in the current stack" CR CR + +"**Examples**" CR CR +" $P print class \\\\my\\\\class" CR +" $P p c \\\\my\\\\class" CR +" Print the instructions for the methods in \\\\my\\\\class" CR CR + +" $P print method \\\\my\\\\class::method" CR +" $P p m \\\\my\\\\class::method" CR +" Print the instructions for \\\\my\\\\class::method" CR CR + +" $P print func .getSomething" CR +" $P p f .getSomething" CR +//************* Check this local method scope +" Print the instructions for ::getSomething in the active scope" CR CR + +" $P print func my_function" CR +" $P p f my_function" CR +" Print the instructions for the global function my_function" CR CR + +" $P print opline" CR +" $P p o" CR +" Print the instruction for the current opline" CR CR + +" $P print exec" CR +" $P p e" CR +" Print the instructions for the execution context" CR CR + +" $P print stack" CR +" $P p s" CR +" Print the instructions for the current stack" +}, + +{"register", +//******* Needs a general explanation of the how registered functions work +"Register any global function for use as a command in phpdbg console" CR CR + +"**Examples**" CR CR +" $P register scandir" CR +" $P R scandir" CR +" Will register the scandir function for use in phpdbg" CR CR + +"Note: arguments passed as strings, return (if present) print_r'd on console" +}, + +{"run", +"Enter the vm, startinging execution. Execution will then continue until the next breakpoint " +"or completion of the script. Add parameters you want to use as $argv" +"**Examples**" CR CR +" $P run" CR +" $P r" CR +" Will cause execution of the context, if it is set" CR CR +" $P r test" CR +" Will execute with $argv[1] == \"test\"" CR CR + +"Note that the execution context must be set. If not previously compiled, then the script will " +"be compiled before execution." CR CR + +"Note that attempting to run a script that is already executing will result in an \"execution " +"in progress\" error." +}, + +{"set", +"The **set** command is used to configure how phpdbg looks and behaves. Specific set commands " +"are as follows:" CR CR + +" **Type** **Alias** **Purpose**" CR +" **prompt** **p** set the prompt" CR +" **color** **c** set color " CR +" **colors** **C** set colors []" CR +" **oplog** **O** set oplog [output]" CR +" **break** **b** set break **id** " CR +" **breaks** **B** set breaks []" CR +" **quiet** **q** set quiet []" CR +" **stepping** **s** set stepping []" CR +" **refcount** **r** set refcount [] " CR CR + +"Valid colors are **none**, **white**, **red**, **green**, **yellow**, **blue**, **purple**, " +"**cyan** and **black**. All colours except **none** can be followed by an optional " +"**-bold** or **-underline** qualifier." CR CR + +"Color elements can be one of **prompt**, **notice**, or **error**." CR CR + +"**Examples**" CR CR +" $P S C on" CR +" Set colors on" CR CR + +" $P set p >" CR +" $P set color prompt white-bold" CR +" Set the prompt to a bold >" CR CR + +" $P S c error red-bold" CR +" Use red bold for errors" CR CR + +" $P S refcount on" CR +" Enable refcount display when hitting watchpoints" CR CR + +" $P S b 4 off" CR +" Temporarily disable breakpoint 4. This can be subsequently reenabled by a **s b 4 on**." CR +//*********** check oplog syntax +}, + +{"sh", +"Direct access to shell commands saves having to switch windows/consoles" CR CR + +"**Examples**" CR CR +" $P sh ls /usr/src/php-src" CR +" Will execute ls /usr/src/php-src, displaying the output in the console" +//*********** what does this mean????Note: read only commands please! +}, + +{"source", +"Sourcing a **phpdbginit** script during your debugging session might save some time." CR CR + +"**Examples**" CR CR + +" $P source /my/init" CR +" $P < /my/init" CR +" Will execute the phpdbginit file at /my/init" CR CR +}, + +{"export", +"Exporting breakpoints allows you to share, and or save your current debugging session" CR CR + +"**Examples**" CR CR + +" $P export /my/exports" CR +" $P > /my/exports" CR +" Will export all breakpoints to /my/exports" CR CR +}, + +{"step", +"Execute opcodes until next line" CR CR + +"**Examples**" CR CR + +" $P s" CR +" Will continue and break again in the next encountered line" CR CR +}, + +{"until", +"The **until** command causes control to be passed back to the vm, continuing execution. Any " +"breakpoints that are encountered before the next source line will be skipped. Execution " +"will then continue until the next breakpoint or completion of the script" CR CR + +"Note when **step**ping is enabled, any opcode steps within the current line are also skipped. "CR CR + +"Note that if the next line is **not** executed then **all** subsequent breakpoints will be " +"skipped. " CR CR + +"Note **until** will trigger a \"not executing\" error if not executing." + +}, +{"watch", +"Sets watchpoints on variables as long as they are defined" CR +"Passing no parameter to **watch**, lists all actually active watchpoints" CR CR + +"**Format for $variable**" CR CR +" **$var** Variable $var" CR +" **$var[]** All array elements of $var" CR +" **$var->** All properties of $var" CR +" **$var->a** Property $var->a" CR +" **$var[b]** Array element with key b in array $var" CR CR + +"Subcommands of **watch**:" CR CR + +" **Type** **Alias** **Purpose**" CR +" **array** **a** Sets watchpoint on array/object to observe if an entry is added or removed" CR +" **recursive** **r** Watches variable recursively and automatically adds watchpoints if some entry is added to an array/object" CR +" **delete** **d** Removes watchpoint" CR CR + +"Note when **recursive** watchpoints are removed, watchpoints on all the children are removed too" CR CR + +"**Examples**" CR CR +" $P watch" CR +" List currently active watchpoints" CR CR + +" $P watch $array" CR +" $P w $array" CR +" Set watchpoint on $array" CR CR + +" $P watch recursive $obj->" CR +" $P w r $obj->" CR +" Set recursive watchpoint on $obj->" CR CR + +" $P watch delete $obj->a" CR +" $P w d $obj->a" CR +" Remove watchpoint $obj->a" CR CR + +"Technical note: If using this feature with a debugger, you will get many segmentation faults, each time when a memory page containing a watched address is hit." CR +" You then you can continue, phpdbg will remove the write protection, so that the program can continue." CR +" If phpdbg could not handle that segfault, the same segfault is triggered again and this time phpdbg will abort." +}, +{NULL, NULL /* end of table marker */} +}; /* }}} */ diff --git a/phpdbg_help.h b/phpdbg_help.h index 319142cb5b2..16a1e771e37 100644 --- a/phpdbg_help.h +++ b/phpdbg_help.h @@ -30,63 +30,19 @@ /** * Helper Forward Declarations */ -PHPDBG_HELP(exec); -PHPDBG_HELP(compile); -PHPDBG_HELP(step); -PHPDBG_HELP(next); -PHPDBG_HELP(run); -PHPDBG_HELP(eval); -PHPDBG_HELP(until); -PHPDBG_HELP(finish); -PHPDBG_HELP(leave); -PHPDBG_HELP(print); -PHPDBG_HELP(break); -PHPDBG_HELP(clean); -PHPDBG_HELP(clear); -PHPDBG_HELP(info); -PHPDBG_HELP(back); -PHPDBG_HELP(frame); -PHPDBG_HELP(quiet); -PHPDBG_HELP(list); -PHPDBG_HELP(set); -PHPDBG_HELP(register); -PHPDBG_HELP(options); -PHPDBG_HELP(source); -PHPDBG_HELP(shell); +PHPDBG_HELP(aliases); -/** - * Commands - */ -static const phpdbg_command_t phpdbg_help_commands[] = { - PHPDBG_COMMAND_D_EX(exec, "the execution context should be a valid path", 'e', help_exec, NULL, 0), - PHPDBG_COMMAND_D_EX(compile, "allow inspection of code before execution", 'c', help_compile, NULL, 0), - PHPDBG_COMMAND_D_EX(step, "step through execution to break at every opcode", 's', help_step, NULL, 0), - PHPDBG_COMMAND_D_EX(next, "continue executing while stepping or after breaking", 'n', help_next, NULL, 0), - PHPDBG_COMMAND_D_EX(run, "execute inside the phpdbg vm", 'r', help_run, NULL, 0), - PHPDBG_COMMAND_D_EX(eval, "access to eval() allows affecting the environment", 'E', help_eval, NULL, 0), - PHPDBG_COMMAND_D_EX(until, "continue until the current line is executed", 'u', help_until, NULL, 0), - PHPDBG_COMMAND_D_EX(finish, "continue until the current function has returned", 'F', help_finish, NULL, 0), - PHPDBG_COMMAND_D_EX(leave, "continue until the current function is returning", 'L', help_leave, NULL, 0), - PHPDBG_COMMAND_D_EX(print, "print context information or instructions", 'p', help_print, NULL, 0), - PHPDBG_COMMAND_D_EX(break, "breakpoints allow execution interruption", 'b', help_break, NULL, 0), - PHPDBG_COMMAND_D_EX(clean, "resetting the environment is useful while debugging", 'X', help_clean, NULL, 0), - PHPDBG_COMMAND_D_EX(clear, "reset breakpoints to execute without interruption", 'c', help_clear, NULL, 0), - PHPDBG_COMMAND_D_EX(info, "quick access to useful information on the console", 'i', help_info, NULL, 0), - PHPDBG_COMMAND_D_EX(back, "show debug backtrace information during execution", 't', help_back, NULL, 0), - PHPDBG_COMMAND_D_EX(frame, "switch to a frame in the current stack for inspection", 'f', help_frame, NULL, 0), - PHPDBG_COMMAND_D_EX(quiet, "be quiet during execution", 'Q', help_quiet, NULL, 0), - PHPDBG_COMMAND_D_EX(list, "list code gives you quick access to code", 'l', help_list, NULL, 0), - PHPDBG_COMMAND_D_EX(set, "configure how phpdbg looks and behaves", 'S', help_set, NULL, 0), - PHPDBG_COMMAND_D_EX(register, "register a function for use as a command", 'R', help_register,NULL, 0), - PHPDBG_COMMAND_D_EX(options, "show information about command line options", 'o', help_options, NULL, 0), - PHPDBG_COMMAND_D_EX(source, "load a phpdbginit file at the console", '.', help_source, NULL, 0), - PHPDBG_COMMAND_D_EX(shell, "execute system commands with direct shell access", '-', help_shell, NULL, 0), - PHPDBG_END_COMMAND -}; +extern const phpdbg_command_t phpdbg_help_commands[]; #define phpdbg_help_header() \ phpdbg_notice("Welcome to phpdbg, the interactive PHP debugger, v%s", PHPDBG_VERSION); #define phpdbg_help_footer() \ phpdbg_notice("Please report bugs to <%s>", PHPDBG_ISSUES); +typedef struct _phpdbg_help_text_t { + char *key; + char *text; +} phpdbg_help_text_t; + +extern phpdbg_help_text_t phpdbg_help_text[]; #endif /* PHPDBG_HELP_H */ diff --git a/phpdbg_info.c b/phpdbg_info.c index 0f4233bf30c..97f88bfa1ec 100644 --- a/phpdbg_info.c +++ b/phpdbg_info.c @@ -23,9 +23,25 @@ #include "phpdbg_utils.h" #include "phpdbg_info.h" #include "phpdbg_bp.h" +#include "phpdbg_prompt.h" ZEND_EXTERN_MODULE_GLOBALS(phpdbg); +#define PHPDBG_INFO_COMMAND_D(f, h, a, m, l, s) \ + PHPDBG_COMMAND_D_EXP(f, h, a, m, l, s, &phpdbg_prompt_commands[14]) + +const phpdbg_command_t phpdbg_info_commands[] = { + PHPDBG_INFO_COMMAND_D(break, "show breakpoints", 'b', info_break, NULL, 0), + PHPDBG_INFO_COMMAND_D(files, "show included files", 'F', info_files, NULL, 0), + PHPDBG_INFO_COMMAND_D(classes, "show loaded classes", 'c', info_classes, NULL, 0), + PHPDBG_INFO_COMMAND_D(funcs, "show loaded classes", 'f', info_funcs, NULL, 0), + PHPDBG_INFO_COMMAND_D(error, "show last error", 'e', info_error, NULL, 0), + PHPDBG_INFO_COMMAND_D(vars, "show active variables", 'v', info_vars, NULL, 0), + PHPDBG_INFO_COMMAND_D(literal, "show active literal constants", 'l', info_literal, NULL, 0), + PHPDBG_INFO_COMMAND_D(memory, "show memory manager stats", 'm', info_memory, NULL, 0), + PHPDBG_END_COMMAND +}; + PHPDBG_INFO(break) /* {{{ */ { phpdbg_print_breakpoints(PHPDBG_BREAK_FILE TSRMLS_CC); diff --git a/phpdbg_info.h b/phpdbg_info.h index a6b4e3719fe..c36e6bebd65 100644 --- a/phpdbg_info.h +++ b/phpdbg_info.h @@ -34,16 +34,6 @@ PHPDBG_INFO(vars); PHPDBG_INFO(literal); PHPDBG_INFO(memory); -static const phpdbg_command_t phpdbg_info_commands[] = { - PHPDBG_COMMAND_D_EX(break, "show breakpoints", 'b', info_break, NULL, 0), - PHPDBG_COMMAND_D_EX(files, "show included files", 'F', info_files, NULL, 0), - PHPDBG_COMMAND_D_EX(classes, "show loaded classes", 'c', info_classes, NULL, 0), - PHPDBG_COMMAND_D_EX(funcs, "show loaded classes", 'f', info_funcs, NULL, 0), - PHPDBG_COMMAND_D_EX(error, "show last error", 'e', info_error, NULL, 0), - PHPDBG_COMMAND_D_EX(vars, "show active variables", 'v', info_vars, NULL, 0), - PHPDBG_COMMAND_D_EX(literal, "show active literal constants", 'l', info_literal, NULL, 0), - PHPDBG_COMMAND_D_EX(memory, "show memory manager stats", 'm', info_memory, NULL, 0), - PHPDBG_END_COMMAND -}; +extern const phpdbg_command_t phpdbg_info_commands[]; #endif /* PHPDBG_INFO_H */ diff --git a/phpdbg_lexer.c b/phpdbg_lexer.c new file mode 100644 index 00000000000..c289004b981 --- /dev/null +++ b/phpdbg_lexer.c @@ -0,0 +1,2271 @@ +#line 2 "sapi/phpdbg/phpdbg_lexer.c" + +#line 4 "sapi/phpdbg/phpdbg_lexer.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 37 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart(yyin ,yyscanner ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void yyrestart (FILE *input_file ,yyscan_t yyscanner ); +void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); +void yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +void yypop_buffer_state (yyscan_t yyscanner ); + +static void yyensure_buffer_stack (yyscan_t yyscanner ); +static void yy_load_buffer_state (yyscan_t yyscanner ); +static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); + +#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner) + +YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner ); + +void *yyalloc (yy_size_t ,yyscan_t yyscanner ); +void *yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); +void yyfree (void * ,yyscan_t yyscanner ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define yywrap(yyscanner) 1 +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); +static int yy_get_next_buffer (yyscan_t yyscanner ); +static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 18 +#define YY_END_OF_BUFFER 19 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_acclist[229] = + { 0, + 19, 4, 15, 18, 4, 17, 18, 17, 18, 4, + 7, 18, 4, 12, 15, 18, 4, 12, 15, 18, + 4, 9, 18, 4, 15, 18, 4, 15, 18, 4, + 15, 18, 4, 15, 18, 4, 15, 18, 4, 15, + 18, 3, 4, 15, 18, 4, 15, 18, 4, 15, + 18, 4, 15, 18, 4, 15, 18, 16, 18, 16, + 17, 18, 15, 18, 7, 18, 12, 15, 18, 12, + 15, 18, 9, 18, 15, 18, 15, 18, 15, 18, + 15, 18, 15, 18, 15, 18, 15, 18, 15, 18, + 15, 18, 15, 18, 4, 15, 4, 4, 4, 17, + + 17, 4, 12, 15, 4, 15, 4, 8, 4, 15, + 4, 15, 4, 15, 1, 4, 15, 4, 15, 4, + 11, 15, 4, 15, 4, 10, 15, 4, 15, 2, + 4, 15, 4, 15, 4, 15, 4, 15, 16, 16, + 17, 15, 12, 15, 15, 8, 15, 15, 15, 15, + 5, 15, 11, 15, 15, 10, 15, 15, 15, 15, + 4, 4, 13, 15, 4, 15, 4, 15, 4, 15, + 4, 15, 3, 4, 15, 4, 15, 4, 15, 13, + 15, 15, 15, 15, 15, 15, 15, 4, 6, 4, + 15, 4, 15, 4, 15, 4, 15, 4, 15, 6, + + 15, 15, 15, 15, 15, 4, 15, 4, 15, 4, + 15, 15, 15, 15, 4, 14, 15, 4, 15, 4, + 15, 14, 15, 15, 15, 4, 15, 15 + } ; + +static yyconst flex_int16_t yy_accept[127] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 2, 5, 8, + 10, 13, 17, 21, 24, 27, 30, 33, 36, 39, + 42, 46, 49, 52, 55, 58, 60, 63, 65, 67, + 70, 73, 75, 77, 79, 81, 83, 85, 87, 89, + 91, 93, 95, 97, 98, 99, 101, 102, 105, 107, + 109, 111, 113, 115, 118, 120, 123, 125, 128, 130, + 133, 135, 137, 139, 140, 142, 143, 143, 145, 146, + 147, 148, 149, 150, 151, 153, 155, 156, 158, 159, + 160, 161, 162, 165, 167, 169, 171, 173, 176, 178, + 180, 180, 182, 183, 184, 185, 186, 187, 188, 190, + + 192, 194, 196, 198, 200, 201, 202, 203, 204, 205, + 206, 208, 210, 212, 213, 214, 215, 218, 220, 222, + 224, 225, 226, 228, 229, 229 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 1, 4, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 5, 6, 7, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 9, 1, 1, + 1, 1, 1, 1, 10, 10, 10, 11, 12, 10, + 13, 13, 13, 13, 13, 13, 13, 14, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 15, + 1, 1, 1, 1, 16, 1, 17, 18, 10, 19, + + 20, 21, 13, 22, 23, 13, 13, 24, 13, 25, + 26, 13, 13, 27, 28, 29, 30, 31, 13, 32, + 33, 34, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[35] = + { 0, + 1, 2, 3, 2, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1 + } ; + +static yyconst flex_int16_t yy_base[133] = + { 0, + 0, 0, 33, 35, 38, 0, 357, 71, 74, 76, + 352, 79, 87, 90, 96, 100, 108, 109, 112, 120, + 123, 126, 138, 142, 148, 0, 104, 316, 455, 151, + 162, 313, 73, 92, 65, 146, 122, 94, 152, 127, + 155, 163, 172, 318, 131, 176, 182, 288, 190, 314, + 178, 184, 187, 211, 212, 215, 221, 224, 225, 235, + 236, 239, 245, 0, 203, 260, 259, 248, 264, 455, + 237, 190, 243, 253, 255, 222, 259, 194, 249, 250, + 277, 229, 0, 285, 286, 289, 295, 304, 307, 310, + 184, 0, 252, 283, 292, 296, 306, 309, 163, 328, + + 329, 332, 341, 344, 455, 326, 331, 330, 342, 343, + 362, 370, 371, 394, 368, 356, 410, 384, 404, 426, + 376, 378, 420, 411, 455, 442, 445, 447, 450, 148, + 452, 96 + } ; + +static yyconst flex_int16_t yy_def[133] = + { 0, + 125, 1, 126, 126, 125, 5, 125, 127, 128, 125, + 128, 127, 127, 128, 127, 127, 127, 127, 127, 127, + 127, 127, 127, 127, 127, 129, 129, 130, 125, 130, + 130, 125, 130, 130, 130, 130, 130, 130, 130, 130, + 130, 130, 127, 128, 128, 128, 125, 13, 13, 128, + 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, + 127, 127, 127, 129, 129, 130, 125, 130, 130, 125, + 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, + 130, 128, 49, 127, 127, 127, 127, 127, 127, 127, + 125, 69, 130, 130, 130, 130, 130, 130, 128, 127, + + 127, 127, 127, 127, 125, 130, 130, 130, 130, 130, + 131, 127, 127, 132, 130, 130, 131, 127, 127, 132, + 130, 130, 127, 130, 0, 125, 125, 125, 125, 125, + 125, 125 + } ; + +static yyconst flex_int16_t yy_nxt[490] = + { 0, + 8, 9, 10, 11, 12, 8, 13, 12, 14, 8, + 8, 8, 8, 8, 15, 8, 8, 8, 16, 17, + 18, 8, 8, 8, 19, 20, 21, 22, 23, 8, + 8, 8, 24, 25, 27, 10, 27, 10, 28, 10, + 10, 29, 30, 28, 31, 30, 32, 28, 28, 28, + 28, 28, 33, 28, 28, 28, 34, 35, 36, 28, + 37, 28, 38, 39, 28, 28, 40, 28, 28, 28, + 41, 42, 44, 67, 44, 46, 47, 47, 47, 45, + 44, 67, 44, 48, 71, 48, 48, 45, 44, 73, + 44, 48, 125, 48, 48, 45, 120, 44, 50, 44, + + 67, 44, 67, 44, 45, 65, 47, 51, 45, 44, + 44, 44, 44, 44, 72, 44, 45, 45, 49, 76, + 45, 44, 52, 44, 44, 55, 44, 44, 45, 44, + 67, 45, 53, 125, 45, 67, 82, 56, 54, 44, + 57, 44, 75, 44, 58, 44, 45, 60, 66, 44, + 45, 44, 59, 79, 67, 68, 45, 68, 68, 67, + 67, 62, 74, 67, 61, 125, 68, 63, 68, 68, + 67, 67, 77, 44, 80, 44, 78, 46, 47, 44, + 45, 44, 81, 47, 47, 44, 45, 44, 44, 105, + 44, 84, 45, 69, 43, 45, 83, 83, 67, 83, + + 83, 83, 67, 86, 65, 47, 83, 83, 83, 83, + 83, 85, 44, 44, 44, 44, 44, 94, 44, 45, + 45, 43, 44, 45, 44, 44, 44, 44, 44, 45, + 67, 125, 45, 45, 99, 87, 44, 44, 44, 44, + 44, 56, 44, 45, 45, 67, 44, 45, 44, 88, + 93, 67, 68, 45, 68, 68, 67, 67, 67, 95, + 67, 67, 106, 67, 91, 89, 58, 67, 67, 90, + 92, 92, 67, 92, 92, 92, 96, 78, 97, 76, + 92, 92, 92, 92, 92, 67, 44, 44, 44, 44, + 44, 67, 44, 45, 45, 100, 44, 45, 44, 107, + + 67, 98, 101, 45, 67, 44, 102, 44, 44, 108, + 44, 44, 45, 44, 67, 45, 125, 67, 45, 43, + 125, 70, 103, 109, 67, 78, 58, 110, 104, 44, + 44, 44, 44, 44, 67, 44, 45, 45, 67, 67, + 45, 114, 44, 111, 44, 44, 112, 44, 115, 45, + 67, 67, 45, 116, 125, 113, 125, 125, 114, 111, + 56, 76, 43, 44, 67, 44, 43, 43, 43, 43, + 45, 44, 44, 44, 44, 122, 67, 43, 45, 45, + 125, 125, 125, 125, 67, 44, 67, 44, 125, 125, + 119, 121, 45, 118, 66, 124, 78, 125, 66, 66, + + 66, 66, 67, 123, 125, 44, 125, 44, 125, 66, + 43, 44, 45, 44, 43, 43, 43, 43, 45, 67, + 125, 44, 58, 44, 125, 43, 66, 125, 45, 76, + 66, 66, 66, 66, 67, 125, 125, 125, 56, 125, + 125, 66, 26, 26, 26, 43, 43, 44, 44, 44, + 64, 64, 117, 117, 7, 125, 125, 125, 125, 125, + 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, + 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, + 125, 125, 125, 125, 125, 125, 125, 125, 125 + } ; + +static yyconst flex_int16_t yy_chk[490] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 3, 3, 4, 4, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 8, 35, 8, 9, 9, 10, 10, 8, + 12, 33, 12, 12, 33, 12, 12, 12, 13, 35, + 13, 13, 14, 13, 13, 13, 132, 15, 14, 15, + + 34, 16, 38, 16, 15, 27, 27, 15, 16, 17, + 18, 17, 18, 19, 34, 19, 17, 18, 13, 38, + 19, 20, 16, 20, 21, 18, 21, 22, 20, 22, + 37, 21, 17, 45, 22, 40, 45, 19, 17, 23, + 20, 23, 37, 24, 20, 24, 23, 22, 130, 25, + 24, 25, 21, 40, 36, 30, 25, 30, 30, 30, + 39, 24, 36, 41, 23, 99, 31, 25, 31, 31, + 31, 42, 39, 43, 41, 43, 39, 46, 46, 51, + 43, 51, 42, 47, 47, 52, 51, 52, 53, 91, + 53, 51, 52, 31, 49, 53, 49, 49, 72, 49, + + 49, 49, 78, 53, 65, 65, 49, 49, 49, 49, + 49, 52, 54, 55, 54, 55, 56, 72, 56, 54, + 55, 49, 57, 56, 57, 58, 59, 58, 59, 57, + 76, 82, 58, 59, 82, 55, 60, 61, 60, 61, + 62, 57, 62, 60, 61, 71, 63, 62, 63, 59, + 71, 73, 68, 63, 68, 68, 68, 79, 80, 73, + 93, 74, 93, 75, 67, 61, 62, 77, 66, 63, + 69, 69, 69, 69, 69, 69, 74, 80, 79, 77, + 69, 69, 69, 69, 69, 81, 84, 85, 84, 85, + 86, 94, 86, 84, 85, 84, 87, 86, 87, 94, + + 95, 81, 85, 87, 96, 88, 86, 88, 89, 95, + 89, 90, 88, 90, 97, 89, 50, 98, 90, 48, + 44, 32, 87, 96, 28, 97, 89, 98, 90, 100, + 101, 100, 101, 102, 106, 102, 100, 101, 108, 107, + 102, 106, 103, 100, 103, 104, 101, 104, 107, 103, + 109, 110, 104, 108, 11, 102, 7, 0, 110, 104, + 103, 109, 111, 111, 116, 111, 111, 111, 111, 111, + 111, 112, 113, 112, 113, 116, 115, 111, 112, 113, + 0, 0, 0, 0, 121, 118, 122, 118, 0, 0, + 113, 115, 118, 112, 114, 121, 122, 0, 114, 114, + + 114, 114, 114, 118, 0, 119, 0, 119, 0, 114, + 117, 117, 119, 117, 117, 117, 117, 117, 117, 124, + 0, 123, 119, 123, 0, 117, 120, 0, 123, 124, + 120, 120, 120, 120, 120, 0, 0, 0, 123, 0, + 0, 120, 126, 126, 126, 127, 127, 128, 128, 128, + 129, 129, 131, 131, 125, 125, 125, 125, 125, 125, + 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, + 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, + 125, 125, 125, 125, 125, 125, 125, 125, 125 + } ; + +#define REJECT \ +{ \ +*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ \ +yy_cp = yyg->yy_full_match; /* restore poss. backed-over text */ \ +++yyg->yy_lp; \ +goto find_rule; \ +} + +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" +#line 2 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" + +/* + * phpdbg_lexer.l + */ + +#include "phpdbg.h" +#include "phpdbg_cmd.h" +#define YYSTYPE phpdbg_param_t + +#include "phpdbg_parser.h" + + + +#define YY_NO_UNISTD_H 1 +#line 629 "sapi/phpdbg/phpdbg_lexer.c" + +#define INITIAL 0 +#define RAW 1 +#define NORMAL 2 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + yy_size_t yy_n_chars; + yy_size_t yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + yy_state_type *yy_state_buf; + yy_state_type *yy_state_ptr; + char *yy_full_match; + int yy_lp; + + /* These are only needed for trailing context rules, + * but there's no conditional variable for that yet. */ + int yy_looking_for_trail_begin; + int yy_full_lp; + int *yy_full_state; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals (yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + +int yylex_init (yyscan_t* scanner); + +int yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy (yyscan_t yyscanner ); + +int yyget_debug (yyscan_t yyscanner ); + +void yyset_debug (int debug_flag ,yyscan_t yyscanner ); + +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner ); + +void yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); + +FILE *yyget_in (yyscan_t yyscanner ); + +void yyset_in (FILE * in_str ,yyscan_t yyscanner ); + +FILE *yyget_out (yyscan_t yyscanner ); + +void yyset_out (FILE * out_str ,yyscan_t yyscanner ); + +yy_size_t yyget_leng (yyscan_t yyscanner ); + +char *yyget_text (yyscan_t yyscanner ); + +int yyget_lineno (yyscan_t yyscanner ); + +void yyset_lineno (int line_number ,yyscan_t yyscanner ); + +int yyget_column (yyscan_t yyscanner ); + +void yyset_column (int column_no ,yyscan_t yyscanner ); + +YYSTYPE * yyget_lval (yyscan_t yyscanner ); + +void yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap (yyscan_t yyscanner ); +#else +extern int yywrap (yyscan_t yyscanner ); +#endif +#endif + + static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner); + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (yyscan_t yyscanner ); +#else +static int input (yyscan_t yyscanner ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex \ + (YYSTYPE * yylval_param ,yyscan_t yyscanner); + +#define YY_DECL int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + +#line 44 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" + + +#line 882 "sapi/phpdbg/phpdbg_lexer.c" + + yylval = yylval_param; + + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + /* Create the reject buffer large enough to save one state per allowed character. */ + if ( ! yyg->yy_state_buf ) + yyg->yy_state_buf = (yy_state_type *)yyalloc(YY_STATE_BUF_SIZE ,yyscanner); + if ( ! yyg->yy_state_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yylex()" ); + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + } + + yy_load_buffer_state(yyscanner ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yyg->yy_start; + + yyg->yy_state_ptr = yyg->yy_state_buf; + *yyg->yy_state_ptr++ = yy_current_state; + +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 126 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + *yyg->yy_state_ptr++ = yy_current_state; + ++yy_cp; + } + while ( yy_current_state != 125 ); + +yy_find_action: + yy_current_state = *--yyg->yy_state_ptr; + yyg->yy_lp = yy_accept[yy_current_state]; +find_rule: /* we branch to this label when backing up */ + for ( ; ; ) /* until we find what rule we matched */ + { + if ( yyg->yy_lp && yyg->yy_lp < yy_accept[yy_current_state + 1] ) + { + yy_act = yy_acclist[yyg->yy_lp]; + { + yyg->yy_full_match = yy_cp; + break; + } + } + --yy_cp; + yy_current_state = *--yyg->yy_state_ptr; + yyg->yy_lp = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + +case 1: +YY_RULE_SETUP +#line 47 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" +{ + BEGIN(RAW); + phpdbg_init_param(yylval, EMPTY_PARAM); + return T_EVAL; + } + YY_BREAK +case 2: +YY_RULE_SETUP +#line 52 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" +{ + BEGIN(RAW); + phpdbg_init_param(yylval, EMPTY_PARAM); + return T_SHELL; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 57 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" +{ + BEGIN(RAW); + phpdbg_init_param(yylval, EMPTY_PARAM); + return T_RUN; + } + YY_BREAK +case 4: +YY_RULE_SETUP +#line 63 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" +{ + BEGIN(NORMAL); + REJECT; + } + YY_BREAK + + +case 5: +YY_RULE_SETUP +#line 70 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" +{ + BEGIN(RAW); + phpdbg_init_param(yylval, EMPTY_PARAM); + return T_IF; + } + YY_BREAK + + +case 6: +YY_RULE_SETUP +#line 78 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" +{ + phpdbg_init_param(yylval, STR_PARAM); + yylval->str = strndup(yytext, yyleng); + yylval->len = yyleng; + return T_PROTO; + } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 84 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" +{ return T_POUND; } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 85 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" +{ return T_DCOLON; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 86 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" +{ return T_COLON; } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 88 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" +{ + phpdbg_init_param(yylval, NUMERIC_PARAM); + yylval->num = 1; + return T_TRUTHY; + } + YY_BREAK +case 11: +YY_RULE_SETUP +#line 93 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" +{ + phpdbg_init_param(yylval, NUMERIC_PARAM); + yylval->num = 0; + return T_FALSY; + } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 98 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" +{ + phpdbg_init_param(yylval, NUMERIC_PARAM); + yylval->num = atoi(yytext); + return T_DIGITS; + } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 103 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" +{ + phpdbg_init_param(yylval, ADDR_PARAM); + yylval->addr = strtoul(yytext, 0, 16); + return T_ADDR; + } + YY_BREAK +case 14: +YY_RULE_SETUP +#line 108 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" +{ + phpdbg_init_param(yylval, OP_PARAM); + yylval->str = strndup(yytext, yyleng); + yylval->len = yyleng; + return T_OPCODE; + } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 114 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" +{ + phpdbg_init_param(yylval, STR_PARAM); + yylval->str = strndup(yytext, yyleng); + yylval->len = yyleng; + return T_ID; + } + YY_BREAK + +case 16: +YY_RULE_SETUP +#line 122 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" +{ + phpdbg_init_param(yylval, STR_PARAM); + yylval->str = strndup(yytext, yyleng); + yylval->len = yyleng; + BEGIN(INITIAL); + return T_INPUT; +} + YY_BREAK +case 17: +/* rule 17 can match eol */ +YY_RULE_SETUP +#line 130 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" +{ /* ignore whitespace */ } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 131 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" +YY_FATAL_ERROR( "flex scanner jammed" ); + YY_BREAK +#line 1129 "sapi/phpdbg/phpdbg_lexer.c" + case YY_STATE_EOF(INITIAL): + case YY_STATE_EOF(RAW): + case YY_STATE_EOF(NORMAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( yywrap(yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = yyg->yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart(yyin ,yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +{ + register yy_state_type yy_current_state; + register char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_current_state = yyg->yy_start; + + yyg->yy_state_ptr = yyg->yy_state_buf; + *yyg->yy_state_ptr++ = yy_current_state; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 126 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + *yyg->yy_state_ptr++ = yy_current_state; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +{ + register int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + + register YY_CHAR yy_c = 1; + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 126 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 125); + if ( ! yy_is_jam ) + *yyg->yy_state_ptr++ = yy_current_state; + + (void)yyg; + return yy_is_jam ? 0 : yy_current_state; +} + + static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner) +{ + register char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_cp = yyg->yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yyg->yy_hold_char; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register yy_size_t number_to_move = yyg->yy_n_chars + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + yyg->yytext_ptr = yy_bp; + yyg->yy_hold_char = *yy_cp; + yyg->yy_c_buf_p = yy_cp; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart(yyin ,yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap(yyscanner ) ) + return EOF; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + } + + yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); + yy_load_buffer_state(yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state(yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +static void yy_load_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ,yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer(b,file ,yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * @param yyscanner The scanner object. + */ + void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree((void *) b->yy_ch_buf ,yyscanner ); + + yyfree((void *) b ,yyscanner ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_flush_buffer(b ,yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ + void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state(yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(yyscanner); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void yypop_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (yyscan_t yyscanner) +{ + yy_size_t num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer(b ,yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (yyconst char * yystr , yyscan_t yyscanner) +{ + + return yy_scan_bytes(yystr,strlen(yystr) ,yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + yy_size_t i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = _yybytes_len + 2; + buf = (char *) yyalloc(n ,yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer(buf,n ,yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int yyget_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int yyget_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +yy_size_t yyget_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *yyget_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/** Set the current line number. + * @param line_number + * @param yyscanner The scanner object. + */ +void yyset_lineno (int line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); + + yylineno = line_number; +} + +/** Set the current column. + * @param line_number + * @param yyscanner The scanner object. + */ +void yyset_column (int column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_column called with no buffer" ); + + yycolumn = column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * @param yyscanner The scanner object. + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = in_str ; +} + +void yyset_out (FILE * out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = out_str ; +} + +int yyget_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void yyset_debug (int bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = bdebug ; +} + +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * yyget_lval (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +/* User-visible API */ + +/* yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ + +int yylex_init(yyscan_t* ptr_yy_globals) + +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* yylex_init_extra has the same functionality as yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to yyalloc in + * the yyextra field. + */ + +int yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) + +{ + struct yyguts_t dummy_yyguts; + + yyset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + yyset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = 0; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = (char *) 0; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + + yyg->yy_state_buf = 0; + yyg->yy_state_ptr = 0; + yyg->yy_full_match = 0; + yyg->yy_lp = 0; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = (FILE *) 0; + yyout = (FILE *) 0; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + yyfree(yyg->yy_buffer_stack ,yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + yyfree(yyg->yy_start_stack ,yyscanner ); + yyg->yy_start_stack = NULL; + + yyfree ( yyg->yy_state_buf , yyscanner); + yyg->yy_state_buf = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + + /* Destroy the main struct (reentrant only). */ + yyfree ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size , yyscan_t yyscanner) +{ + return (void *) malloc( size ); +} + +void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void yyfree (void * ptr , yyscan_t yyscanner) +{ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 131 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" + + + diff --git a/phpdbg_lexer.h b/phpdbg_lexer.h new file mode 100644 index 00000000000..1958cef9a26 --- /dev/null +++ b/phpdbg_lexer.h @@ -0,0 +1,348 @@ +#ifndef yyHEADER_H +#define yyHEADER_H 1 +#define yyIN_HEADER 1 + +#line 6 "sapi/phpdbg/phpdbg_lexer.h" + +#line 8 "sapi/phpdbg/phpdbg_lexer.h" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 37 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +void yyrestart (FILE *input_file ,yyscan_t yyscanner ); +void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); +void yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +void yypop_buffer_state (yyscan_t yyscanner ); + +YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner ); + +void *yyalloc (yy_size_t ,yyscan_t yyscanner ); +void *yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); +void yyfree (void * ,yyscan_t yyscanner ); + +/* Begin user sect3 */ + +#define yywrap(yyscanner) 1 +#define YY_SKIP_YYWRAP + +#define yytext_ptr yytext_r + +#ifdef YY_HEADER_EXPORT_START_CONDITIONS +#define INITIAL 0 +#define RAW 1 +#define NORMAL 2 + +#endif + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +int yylex_init (yyscan_t* scanner); + +int yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy (yyscan_t yyscanner ); + +int yyget_debug (yyscan_t yyscanner ); + +void yyset_debug (int debug_flag ,yyscan_t yyscanner ); + +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner ); + +void yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); + +FILE *yyget_in (yyscan_t yyscanner ); + +void yyset_in (FILE * in_str ,yyscan_t yyscanner ); + +FILE *yyget_out (yyscan_t yyscanner ); + +void yyset_out (FILE * out_str ,yyscan_t yyscanner ); + +yy_size_t yyget_leng (yyscan_t yyscanner ); + +char *yyget_text (yyscan_t yyscanner ); + +int yyget_lineno (yyscan_t yyscanner ); + +void yyset_lineno (int line_number ,yyscan_t yyscanner ); + +int yyget_column (yyscan_t yyscanner ); + +void yyset_column (int column_no ,yyscan_t yyscanner ); + +YYSTYPE * yyget_lval (yyscan_t yyscanner ); + +void yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap (yyscan_t yyscanner ); +#else +extern int yywrap (yyscan_t yyscanner ); +#endif +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex \ + (YYSTYPE * yylval_param ,yyscan_t yyscanner); + +#define YY_DECL int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +#undef YY_NEW_FILE +#undef YY_FLUSH_BUFFER +#undef yy_set_bol +#undef yy_new_buffer +#undef yy_set_interactive +#undef YY_DO_BEFORE_ACTION + +#ifdef YY_DECL_IS_OURS +#undef YY_DECL_IS_OURS +#undef YY_DECL +#endif + +#line 131 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" + + +#line 347 "sapi/phpdbg/phpdbg_lexer.h" +#undef yyIN_HEADER +#endif /* yyHEADER_H */ diff --git a/phpdbg_lexer.l b/phpdbg_lexer.l new file mode 100644 index 00000000000..ad5edd9f8f9 --- /dev/null +++ b/phpdbg_lexer.l @@ -0,0 +1,131 @@ +%{ + +/* + * phpdbg_lexer.l + */ + +#include "phpdbg.h" +#include "phpdbg_cmd.h" +#define YYSTYPE phpdbg_param_t + +#include "phpdbg_parser.h" + +%} + +%s RAW +%s NORMAL + +%option outfile="sapi/phpdbg/phpdbg_lexer.c" header-file="sapi/phpdbg/phpdbg_lexer.h" +%option warn nodefault + +%option reentrant noyywrap never-interactive nounistd +%option bison-bridge + +T_TRUE "true" +T_YES "yes" +T_ON "on" +T_ENABLED "enabled" +T_FALSE "false" +T_NO "no" +T_OFF "off" +T_DISABLED "disabled" +T_EVAL "ev" +T_SHELL "sh" +T_IF "if" +T_RUN "run" +T_RUN_SHORT "r" + +WS [ \r\n\t]+ +DIGITS [0-9\.]+ +ID [^ \r\n\t:#]+ +ADDR 0x[a-fA-F0-9]+ +OPCODE (ZEND_|zend_)([A-Za-z])+ +INPUT [^\n]+ +%% + +{ + {T_EVAL} { + BEGIN(RAW); + phpdbg_init_param(yylval, EMPTY_PARAM); + return T_EVAL; + } + {T_SHELL} { + BEGIN(RAW); + phpdbg_init_param(yylval, EMPTY_PARAM); + return T_SHELL; + } + {T_RUN}|{T_RUN_SHORT} { + BEGIN(RAW); + phpdbg_init_param(yylval, EMPTY_PARAM); + return T_RUN; + } + + .+ { + BEGIN(NORMAL); + REJECT; + } +} + +{ + {T_IF} { + BEGIN(RAW); + phpdbg_init_param(yylval, EMPTY_PARAM); + return T_IF; + } +} + +{ + {ID}[:]{1}[//]{2} { + phpdbg_init_param(yylval, STR_PARAM); + yylval->str = strndup(yytext, yyleng); + yylval->len = yyleng; + return T_PROTO; + } + [#]{1} { return T_POUND; } + [:]{2} { return T_DCOLON; } + [:]{1} { return T_COLON; } + + {T_YES}|{T_ON}|{T_ENABLED}|{T_TRUE} { + phpdbg_init_param(yylval, NUMERIC_PARAM); + yylval->num = 1; + return T_TRUTHY; + } + {T_NO}|{T_OFF}|{T_DISABLED}|{T_FALSE} { + phpdbg_init_param(yylval, NUMERIC_PARAM); + yylval->num = 0; + return T_FALSY; + } + {DIGITS} { + phpdbg_init_param(yylval, NUMERIC_PARAM); + yylval->num = atoi(yytext); + return T_DIGITS; + } + {ADDR} { + phpdbg_init_param(yylval, ADDR_PARAM); + yylval->addr = strtoul(yytext, 0, 16); + return T_ADDR; + } + {OPCODE} { + phpdbg_init_param(yylval, OP_PARAM); + yylval->str = strndup(yytext, yyleng); + yylval->len = yyleng; + return T_OPCODE; + } + {ID} { + phpdbg_init_param(yylval, STR_PARAM); + yylval->str = strndup(yytext, yyleng); + yylval->len = yyleng; + return T_ID; + } +} + +{INPUT} { + phpdbg_init_param(yylval, STR_PARAM); + yylval->str = strndup(yytext, yyleng); + yylval->len = yyleng; + BEGIN(INITIAL); + return T_INPUT; +} + +{WS} { /* ignore whitespace */ } +%% diff --git a/phpdbg_list.c b/phpdbg_list.c index eb1091550b0..037c6c38b2a 100644 --- a/phpdbg_list.c +++ b/phpdbg_list.c @@ -29,9 +29,22 @@ #include "phpdbg.h" #include "phpdbg_list.h" #include "phpdbg_utils.h" +#include "phpdbg_prompt.h" +#include "php_streams.h" ZEND_EXTERN_MODULE_GLOBALS(phpdbg); +#define PHPDBG_LIST_COMMAND_D(f, h, a, m, l, s) \ + PHPDBG_COMMAND_D_EXP(f, h, a, m, l, s, &phpdbg_prompt_commands[13]) + +const phpdbg_command_t phpdbg_list_commands[] = { + PHPDBG_LIST_COMMAND_D(lines, "lists the specified lines", 'l', list_lines, NULL, "l"), + PHPDBG_LIST_COMMAND_D(class, "lists the specified class", 'c', list_class, NULL, "s"), + PHPDBG_LIST_COMMAND_D(method, "lists the specified method", 'm', list_method, NULL, "m"), + PHPDBG_LIST_COMMAND_D(func, "lists the specified function", 'f', list_func, NULL, "s"), + PHPDBG_END_COMMAND +}; + PHPDBG_LIST(lines) /* {{{ */ { if (!PHPDBG_G(exec) && !zend_is_executing(TSRMLS_C)) { @@ -41,12 +54,12 @@ PHPDBG_LIST(lines) /* {{{ */ switch (param->type) { case NUMERIC_PARAM: - case EMPTY_PARAM: phpdbg_list_file(phpdbg_current_file(TSRMLS_C), - param->type == EMPTY_PARAM ? 0 : (param->num < 0 ? 1 - param->num : param->num), - (param->type != EMPTY_PARAM && param->num < 0 ? param->num : 0) + zend_get_executed_lineno(TSRMLS_C), + (param->num < 0 ? 1 - param->num : param->num), + (param->num < 0 ? param->num : 0) + zend_get_executed_lineno(TSRMLS_C), 0 TSRMLS_CC); break; + case FILE_PARAM: phpdbg_list_file(param->file.name, param->file.line, 0, 0 TSRMLS_CC); break; @@ -59,41 +72,28 @@ PHPDBG_LIST(lines) /* {{{ */ PHPDBG_LIST(func) /* {{{ */ { - switch (param->type) { - case STR_PARAM: - phpdbg_list_function_byname( - param->str, param->len TSRMLS_CC); - break; - - phpdbg_default_switch_case(); - } + phpdbg_list_function_byname(param->str, param->len TSRMLS_CC); return SUCCESS; } /* }}} */ PHPDBG_LIST(method) /* {{{ */ { - switch (param->type) { - case METHOD_PARAM: { - zend_class_entry **ce; + zend_class_entry **ce; - if (zend_lookup_class(param->method.class, strlen(param->method.class), &ce TSRMLS_CC) == SUCCESS) { - zend_function *function; - char *lcname = zend_str_tolower_dup(param->method.name, strlen(param->method.name)); + if (zend_lookup_class(param->method.class, strlen(param->method.class), &ce TSRMLS_CC) == SUCCESS) { + zend_function *function; + char *lcname = zend_str_tolower_dup(param->method.name, strlen(param->method.name)); - if (zend_hash_find(&(*ce)->function_table, lcname, strlen(lcname)+1, (void**) &function) == SUCCESS) { - phpdbg_list_function(function TSRMLS_CC); - } else { - phpdbg_error("Could not find %s::%s", param->method.class, param->method.name); - } + if (zend_hash_find(&(*ce)->function_table, lcname, strlen(lcname)+1, (void**) &function) == SUCCESS) { + phpdbg_list_function(function TSRMLS_CC); + } else { + phpdbg_error("Could not find %s::%s", param->method.class, param->method.name); + } - efree(lcname); - } else { - phpdbg_error("Could not find the class %s", param->method.class); - } - } break; - - phpdbg_default_switch_case(); + efree(lcname); + } else { + phpdbg_error("Could not find the class %s", param->method.class); } return SUCCESS; @@ -101,30 +101,24 @@ PHPDBG_LIST(method) /* {{{ */ PHPDBG_LIST(class) /* {{{ */ { - switch (param->type) { - case STR_PARAM: { - zend_class_entry **ce; + zend_class_entry **ce; - if (zend_lookup_class(param->str, param->len, &ce TSRMLS_CC) == SUCCESS) { - if ((*ce)->type == ZEND_USER_CLASS) { - if ((*ce)->info.user.filename) { - phpdbg_list_file( - (*ce)->info.user.filename, - (*ce)->info.user.line_end - (*ce)->info.user.line_start + 1, - (*ce)->info.user.line_start, 0 TSRMLS_CC - ); - } else { - phpdbg_error("The source of the requested class (%s) cannot be found", (*ce)->name); - } - } else { - phpdbg_error("The class requested (%s) is not user defined", (*ce)->name); - } + if (zend_lookup_class(param->str, param->len, &ce TSRMLS_CC) == SUCCESS) { + if ((*ce)->type == ZEND_USER_CLASS) { + if ((*ce)->info.user.filename) { + phpdbg_list_file( + (*ce)->info.user.filename, + (*ce)->info.user.line_end - (*ce)->info.user.line_start + 1, + (*ce)->info.user.line_start, 0 TSRMLS_CC + ); } else { - phpdbg_error("The requested class (%s) could not be found", param->str); + phpdbg_error("The source of the requested class (%s) cannot be found", (*ce)->name); } - } break; - - phpdbg_default_switch_case(); + } else { + phpdbg_error("The class requested (%s) is not user defined", (*ce)->name); + } + } else { + phpdbg_error("The requested class (%s) could not be found", param->str); } return SUCCESS; @@ -132,97 +126,46 @@ PHPDBG_LIST(class) /* {{{ */ void phpdbg_list_file(const char *filename, long count, long offset, int highlight TSRMLS_DC) /* {{{ */ { - unsigned char *mem, *pos, *last_pos, *end_pos; struct stat st; -#ifndef _WIN32 - int fd; -#else - HANDLE fd, map; -#endif - int all_content = (count == 0); - int line = 0, displayed = 0; - + char *opened = NULL; + char buffer[8096] = {0,}; + long line = 0; + + php_stream *stream = NULL; + if (VCWD_STAT(filename, &st) == FAILURE) { phpdbg_error("Failed to stat file %s", filename); return; } - -#ifndef _WIN32 - if ((fd = VCWD_OPEN(filename, O_RDONLY)) == FAILURE) { + + stream = php_stream_open_wrapper(filename, "rb", USE_PATH, &opened); + + if (!stream) { phpdbg_error("Failed to open file %s to list", filename); return; } - - pos = last_pos = mem = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0); - end_pos = mem + st.st_size; -#else - - fd = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (fd == INVALID_HANDLE_VALUE) { - phpdbg_error("Failed to open file!"); - return; - } - - map = CreateFileMapping(fd, NULL, PAGE_READONLY, 0, 0, NULL); - if (map == NULL) { - phpdbg_error("Failed to map file!"); - CloseHandle(fd); - return; - } - - pos = last_pos = mem = (char*) MapViewOfFile(map, FILE_MAP_READ, 0, 0, 0); - if (mem == NULL) { - phpdbg_error("Failed to map file in memory"); - CloseHandle(map); - CloseHandle(fd); - return; - } - end_pos = mem + st.st_size; -#endif - while (1) { - if (pos == end_pos) { - break; - } - - pos = memchr(last_pos, '\n', end_pos - last_pos); - - if (!pos) { - /* No more line breaks */ - pos = end_pos; - } - + + while (php_stream_gets(stream, buffer, sizeof(buffer)) != NULL) { ++line; - + if (!offset || offset <= line) { /* Without offset, or offset reached */ if (!highlight) { - phpdbg_writeln("%05u: %.*s", line, (int)(pos - last_pos), last_pos); + phpdbg_write("%05ld: %s", line, buffer); } else { if (highlight != line) { - phpdbg_writeln(" %05u: %.*s", line, (int)(pos - last_pos), last_pos); + phpdbg_write(" %05ld: %s", line, buffer); } else { - phpdbg_writeln(">%05u: %.*s", line, (int)(pos - last_pos), last_pos); + phpdbg_write(">%05ld: %s", line, buffer); } } - ++displayed; } - - last_pos = pos + 1; - - if (!all_content && displayed == count) { - /* Reached max line to display */ + + if ((count + (offset-1)) == line) break; - } } - -#ifndef _WIN32 - munmap(mem, st.st_size); - close(fd); -#else - UnmapViewOfFile(mem); - CloseHandle(map); - CloseHandle(fd); -#endif + + php_stream_close(stream); } /* }}} */ void phpdbg_list_function(const zend_function *fbc TSRMLS_DC) /* {{{ */ diff --git a/phpdbg_list.h b/phpdbg_list.h index f9d1885eaf2..14905f65673 100644 --- a/phpdbg_list.h +++ b/phpdbg_list.h @@ -36,12 +36,6 @@ void phpdbg_list_function_byname(const char *, size_t TSRMLS_DC); void phpdbg_list_function(const zend_function* TSRMLS_DC); void phpdbg_list_file(const char*, long, long, int TSRMLS_DC); -static const phpdbg_command_t phpdbg_list_commands[] = { - PHPDBG_COMMAND_D_EX(lines, "lists the specified lines", 'l', list_lines, NULL, 1), - PHPDBG_COMMAND_D_EX(class, "lists the specified class", 'c', list_class, NULL, 1), - PHPDBG_COMMAND_D_EX(method, "lists the specified method", 'm', list_method, NULL, 1), - PHPDBG_COMMAND_D_EX(func, "lists the specified function", 'f', list_func, NULL, 1), - PHPDBG_END_COMMAND -}; +extern const phpdbg_command_t phpdbg_list_commands[]; #endif /* PHPDBG_LIST_H */ diff --git a/phpdbg_opcode.c b/phpdbg_opcode.c index 50073eb22bb..6b13625fc14 100644 --- a/phpdbg_opcode.c +++ b/phpdbg_opcode.c @@ -183,6 +183,7 @@ void phpdbg_print_opline(zend_execute_data *execute_data, zend_bool ignore_flags const char *phpdbg_decode_opcode(zend_uchar opcode) /* {{{ */ { +#if ZEND_EXTENSION_API_NO <= PHP_5_5_API_NO #define CASE(s) case s: return #s switch (opcode) { CASE(ZEND_NOP); @@ -360,4 +361,8 @@ const char *phpdbg_decode_opcode(zend_uchar opcode) /* {{{ */ default: return "UNKNOWN"; } +#else + const char *ret = zend_get_opcode_name(opcode); + return ret?ret:"UNKNOWN"; +#endif } /* }}} */ diff --git a/phpdbg_parser.y b/phpdbg_parser.y new file mode 100644 index 00000000000..4a84504e2e5 --- /dev/null +++ b/phpdbg_parser.y @@ -0,0 +1,168 @@ +%error-verbose +%{ + +/* + * phpdbg_parser.y + * (from php-src root) + * flex sapi/phpdbg/dev/phpdbg_lexer.l + * bison sapi/phpdbg/dev/phpdbg_parser.y + */ + +#include "phpdbg.h" +#include "phpdbg_cmd.h" +#include "phpdbg_utils.h" +#include "phpdbg_cmd.h" +#include "phpdbg_prompt.h" + +#define YYSTYPE phpdbg_param_t + +#include "phpdbg_parser.h" +#include "phpdbg_lexer.h" + +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); + +int yyerror(phpdbg_param_t *stack, yyscan_t scanner, const char *msg) { + TSRMLS_FETCH(); + phpdbg_error("Parse Error: %s", msg); + { + const phpdbg_param_t *top = stack; + + while (top) { + phpdbg_param_debug( + top, "--> "); + top = top->next; + } + } + return 0; +} +%} + +%code requires { +#include "phpdbg.h" +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif +} +%output "sapi/phpdbg/phpdbg_parser.c" +%defines "sapi/phpdbg/phpdbg_parser.h" + +%define api.pure +%lex-param { yyscan_t scanner } +%parse-param { phpdbg_param_t *stack } +%parse-param { yyscan_t scanner } + +%token T_EVAL "eval" +%token T_RUN "run" +%token T_SHELL "shell" +%token T_IF "if (condition)" +%token T_TRUTHY "truthy (true, on, yes or enabled)" +%token T_FALSY "falsy (false, off, no or disabled)" +%token T_STRING "string (some input, perhaps)" +%token T_COLON ": (colon)" +%token T_DCOLON ":: (double colon)" +%token T_POUND "# (pound sign)" +%token T_PROTO "protocol (file://)" +%token T_DIGITS "digits (numbers)" +%token T_LITERAL "literal (string)" +%token T_ADDR "address" +%token T_OPCODE "opcode" +%token T_ID "identifier (command or function name)" +%token T_INPUT "input (input string or data)" +%token T_UNEXPECTED "input" +%% + +input + : parameters + | /* nothing */ + ; + +parameters + : parameter { phpdbg_stack_push(stack, &$1); } + | parameters parameter { phpdbg_stack_push(stack, &$2); } + ; + +parameter + : T_ID T_COLON T_DIGITS { + $$.type = FILE_PARAM; + $$.file.name = $2.str; + $$.file.line = $3.num; + } + | T_ID T_COLON T_POUND T_DIGITS { + $$.type = NUMERIC_FILE_PARAM; + $$.file.name = $1.str; + $$.file.line = $4.num; + } + | T_PROTO T_ID T_COLON T_DIGITS { + $$.type = FILE_PARAM; + $$.file.name = malloc($1.len + + $2.len + 1); + if ($$.file.name) { + memcpy(&$$.file.name[0], $1.str, $1.len); + memcpy(&$$.file.name[$1.len], $2.str, $2.len); + $$.file.name[$1.len + $2.len] = '\0'; + } + $$.file.line = $4.num; + } + | T_PROTO T_ID T_COLON T_POUND T_DIGITS { + $$.type = NUMERIC_FILE_PARAM; + $$.file.name = malloc($1.len + + $2.len + 1); + if ($$.file.name) { + memcpy(&$$.file.name[0], $1.str, $1.len); + memcpy(&$$.file.name[$1.len], $2.str, $2.len); + $$.file.name[$1.len + $2.len] = '\0'; + } + $$.file.line = $5.num; + } + | T_ID T_DCOLON T_ID { + $$.type = METHOD_PARAM; + $$.method.class = $1.str; + $$.method.name = $3.str; + } + | T_ID T_DCOLON T_ID T_POUND T_DIGITS { + $$.type = NUMERIC_METHOD_PARAM; + $$.method.class = $1.str; + $$.method.name = $3.str; + $$.num = $5.num; + } + | T_ID T_POUND T_DIGITS { + $$.type = NUMERIC_FUNCTION_PARAM; + $$.str = $1.str; + $$.len = $1.len; + $$.num = $3.num; + } + | T_IF T_INPUT { + $$.type = COND_PARAM; + $$.str = $2.str; + $$.len = $2.len; + } + | T_EVAL T_INPUT { + $$.type = EVAL_PARAM; + $$.str = $2.str; + $$.len = $2.len; + } + | T_SHELL T_INPUT { + $$.type = SHELL_PARAM; + $$.str = $2.str; + $$.len = $2.len; + } + | T_RUN { + $$.type = RUN_PARAM; + $$.len = 0; + } + | T_RUN T_INPUT { + $$.type = RUN_PARAM; + $$.str = $2.str; + $$.len = $2.len; + } + | T_OPCODE { $$ = $1; } + | T_ADDR { $$ = $1; } + | T_LITERAL { $$ = $1; } + | T_TRUTHY { $$ = $1; } + | T_FALSY { $$ = $1; } + | T_DIGITS { $$ = $1; } + | T_ID { $$ = $1; } + ; + +%% diff --git a/phpdbg_print.c b/phpdbg_print.c index c4925fe5fd7..76321a5042d 100644 --- a/phpdbg_print.c +++ b/phpdbg_print.c @@ -26,6 +26,19 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg); +#define PHPDBG_PRINT_COMMAND_D(f, h, a, m, l, s) \ + PHPDBG_COMMAND_D_EXP(f, h, a, m, l, s, &phpdbg_prompt_commands[9]) + +const phpdbg_command_t phpdbg_print_commands[] = { + PHPDBG_PRINT_COMMAND_D(exec, "print out the instructions in the execution context", 'e', print_exec, NULL, 0), + PHPDBG_PRINT_COMMAND_D(opline, "print out the instruction in the current opline", 'o', print_opline, NULL, 0), + PHPDBG_PRINT_COMMAND_D(class, "print out the instructions in the specified class", 'c', print_class, NULL, "s"), + PHPDBG_PRINT_COMMAND_D(method, "print out the instructions in the specified method", 'm', print_method, NULL, "m"), + PHPDBG_PRINT_COMMAND_D(func, "print out the instructions in the specified function", 'f', print_func, NULL, "s"), + PHPDBG_PRINT_COMMAND_D(stack, "print out the instructions in the current stack", 's', print_stack, NULL, 0), + PHPDBG_END_COMMAND +}; + PHPDBG_PRINT(opline) /* {{{ */ { if (EG(in_execution) && EG(current_execute_data)) { @@ -77,7 +90,7 @@ static inline void phpdbg_print_function_helper(zend_function *method TSRMLS_DC) phpdbg_error("\tFailed to decode opline %16p", opline); } opline++; - } while (++opcode < end); + } while (opcode++ < end); zend_hash_destroy(&vars); } } break; @@ -141,36 +154,30 @@ PHPDBG_PRINT(class) /* {{{ */ { zend_class_entry **ce; - switch (param->type) { - case STR_PARAM: { - if (zend_lookup_class(param->str, param->len, &ce TSRMLS_CC) == SUCCESS) { - phpdbg_notice("%s %s: %s", - ((*ce)->type == ZEND_USER_CLASS) ? - "User" : "Internal", - ((*ce)->ce_flags & ZEND_ACC_INTERFACE) ? - "Interface" : - ((*ce)->ce_flags & ZEND_ACC_ABSTRACT) ? - "Abstract Class" : - "Class", - (*ce)->name); + if (zend_lookup_class(param->str, param->len, &ce TSRMLS_CC) == SUCCESS) { + phpdbg_notice("%s %s: %s", + ((*ce)->type == ZEND_USER_CLASS) ? + "User" : "Internal", + ((*ce)->ce_flags & ZEND_ACC_INTERFACE) ? + "Interface" : + ((*ce)->ce_flags & ZEND_ACC_ABSTRACT) ? + "Abstract Class" : + "Class", + (*ce)->name); - phpdbg_writeln("Methods (%d):", zend_hash_num_elements(&(*ce)->function_table)); - if (zend_hash_num_elements(&(*ce)->function_table)) { - HashPosition position; - zend_function *method; + phpdbg_writeln("Methods (%d):", zend_hash_num_elements(&(*ce)->function_table)); + if (zend_hash_num_elements(&(*ce)->function_table)) { + HashPosition position; + zend_function *method; - for (zend_hash_internal_pointer_reset_ex(&(*ce)->function_table, &position); - zend_hash_get_current_data_ex(&(*ce)->function_table, (void**) &method, &position) == SUCCESS; - zend_hash_move_forward_ex(&(*ce)->function_table, &position)) { - phpdbg_print_function_helper(method TSRMLS_CC); - } - } - } else { - phpdbg_error("The class %s could not be found", param->str); + for (zend_hash_internal_pointer_reset_ex(&(*ce)->function_table, &position); + zend_hash_get_current_data_ex(&(*ce)->function_table, (void**) &method, &position) == SUCCESS; + zend_hash_move_forward_ex(&(*ce)->function_table, &position)) { + phpdbg_print_function_helper(method TSRMLS_CC); } - } break; - - phpdbg_default_switch_case(); + } + } else { + phpdbg_error("The class %s could not be found", param->str); } return SUCCESS; @@ -178,31 +185,25 @@ PHPDBG_PRINT(class) /* {{{ */ PHPDBG_PRINT(method) /* {{{ */ { - switch (param->type) { - case METHOD_PARAM: { - zend_class_entry **ce; + zend_class_entry **ce; - if (zend_lookup_class(param->method.class, strlen(param->method.class), &ce TSRMLS_CC) == SUCCESS) { - zend_function *fbc; - char *lcname = zend_str_tolower_dup(param->method.name, strlen(param->method.name)); + if (zend_lookup_class(param->method.class, strlen(param->method.class), &ce TSRMLS_CC) == SUCCESS) { + zend_function *fbc; + char *lcname = zend_str_tolower_dup(param->method.name, strlen(param->method.name)); - if (zend_hash_find(&(*ce)->function_table, lcname, strlen(lcname)+1, (void**)&fbc) == SUCCESS) { - phpdbg_notice("%s Method %s", - (fbc->type == ZEND_USER_FUNCTION) ? "User" : "Internal", - fbc->common.function_name); + if (zend_hash_find(&(*ce)->function_table, lcname, strlen(lcname)+1, (void**)&fbc) == SUCCESS) { + phpdbg_notice("%s Method %s", + (fbc->type == ZEND_USER_FUNCTION) ? "User" : "Internal", + fbc->common.function_name); - phpdbg_print_function_helper(fbc TSRMLS_CC); - } else { - phpdbg_error("The method %s could not be found", param->method.name); - } + phpdbg_print_function_helper(fbc TSRMLS_CC); + } else { + phpdbg_error("The method %s could not be found", param->method.name); + } - efree(lcname); - } else { - phpdbg_error("The class %s could not be found", param->method.class); - } - } break; - - phpdbg_default_switch_case(); + efree(lcname); + } else { + phpdbg_error("The class %s could not be found", param->method.class); } return SUCCESS; @@ -210,49 +211,43 @@ PHPDBG_PRINT(method) /* {{{ */ PHPDBG_PRINT(func) /* {{{ */ { - switch (param->type) { - case STR_PARAM: { - HashTable *func_table = EG(function_table); - zend_function* fbc; - const char *func_name = param->str; - size_t func_name_len = param->len; - char *lcname; - /* search active scope if begins with period */ - if (func_name[0] == '.') { - if (EG(scope)) { - func_name++; - func_name_len--; + HashTable *func_table = EG(function_table); + zend_function* fbc; + const char *func_name = param->str; + size_t func_name_len = param->len; + char *lcname; + /* search active scope if begins with period */ + if (func_name[0] == '.') { + if (EG(scope)) { + func_name++; + func_name_len--; - func_table = &EG(scope)->function_table; - } else { - phpdbg_error("No active class"); - return SUCCESS; - } - } else if (!EG(function_table)) { - phpdbg_error("No function table loaded"); - return SUCCESS; - } else { - func_table = EG(function_table); - } - - lcname = zend_str_tolower_dup(func_name, func_name_len); - - if (zend_hash_find(func_table, lcname, strlen(lcname)+1, (void**)&fbc) == SUCCESS) { - phpdbg_notice("%s %s %s", - (fbc->type == ZEND_USER_FUNCTION) ? "User" : "Internal", - (fbc->common.scope) ? "Method" : "Function", - fbc->common.function_name); - - phpdbg_print_function_helper(fbc TSRMLS_CC); - } else { - phpdbg_error("The function %s could not be found", func_name); - } - - efree(lcname); - } break; - - phpdbg_default_switch_case(); + func_table = &EG(scope)->function_table; + } else { + phpdbg_error("No active class"); + return SUCCESS; + } + } else if (!EG(function_table)) { + phpdbg_error("No function table loaded"); + return SUCCESS; + } else { + func_table = EG(function_table); } + lcname = zend_str_tolower_dup(func_name, func_name_len); + + if (zend_hash_find(func_table, lcname, strlen(lcname)+1, (void**)&fbc) == SUCCESS) { + phpdbg_notice("%s %s %s", + (fbc->type == ZEND_USER_FUNCTION) ? "User" : "Internal", + (fbc->common.scope) ? "Method" : "Function", + fbc->common.function_name); + + phpdbg_print_function_helper(fbc TSRMLS_CC); + } else { + phpdbg_error("The function %s could not be found", func_name); + } + + efree(lcname); + return SUCCESS; } /* }}} */ diff --git a/phpdbg_print.h b/phpdbg_print.h index 80010d5e7cc..ed85e965c1b 100644 --- a/phpdbg_print.h +++ b/phpdbg_print.h @@ -35,17 +35,6 @@ PHPDBG_PRINT(method); PHPDBG_PRINT(func); PHPDBG_PRINT(stack); -/** - * Commands - */ -static const phpdbg_command_t phpdbg_print_commands[] = { - PHPDBG_COMMAND_D_EX(exec, "print out the instructions in the execution context", 'e', print_exec, NULL, 0), - PHPDBG_COMMAND_D_EX(opline, "print out the instruction in the current opline", 'o', print_opline, NULL, 0), - PHPDBG_COMMAND_D_EX(class, "print out the instructions in the specified class", 'c', print_class, NULL, 1), - PHPDBG_COMMAND_D_EX(method, "print out the instructions in the specified method", 'm', print_method, NULL, 1), - PHPDBG_COMMAND_D_EX(func, "print out the instructions in the specified function", 'f', print_func, NULL, 1), - PHPDBG_COMMAND_D_EX(stack, "print out the instructions in the current stack", 's', print_stack, NULL, 0), - PHPDBG_END_COMMAND -}; +extern const phpdbg_command_t phpdbg_print_commands[]; #endif /* PHPDBG_PRINT_H */ diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index f586bb5a84f..7a28a75129f 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -35,99 +35,154 @@ #include "phpdbg_cmd.h" #include "phpdbg_set.h" #include "phpdbg_frame.h" +#include "phpdbg_lexer.h" +#include "phpdbg_parser.h" + +int yyparse(phpdbg_param_t *stack, yyscan_t scanner); /* {{{ command declarations */ const phpdbg_command_t phpdbg_prompt_commands[] = { - PHPDBG_COMMAND_D(exec, "set execution context", 'e', NULL, 1), - PHPDBG_COMMAND_D(compile, "attempt compilation", 'c', NULL, 0), - PHPDBG_COMMAND_D(step, "step through execution", 's', NULL, 1), - PHPDBG_COMMAND_D(next, "continue execution", 'n', NULL, 0), - PHPDBG_COMMAND_D(run, "attempt execution", 'r', NULL, 0), - PHPDBG_COMMAND_D(eval, "evaluate some code", 'E', NULL, 1), + PHPDBG_COMMAND_D(exec, "set execution context", 'e', NULL, "s"), + PHPDBG_COMMAND_D(step, "step through execution", 's', NULL, 0), + PHPDBG_COMMAND_D(continue,"continue execution", 'c', NULL, 0), + PHPDBG_COMMAND_D(run, "attempt execution", 'r', NULL, "|s"), + PHPDBG_COMMAND_D(ev, "evaluate some code", 0, NULL, "i"), PHPDBG_COMMAND_D(until, "continue past the current line", 'u', NULL, 0), PHPDBG_COMMAND_D(finish, "continue past the end of the stack", 'F', NULL, 0), PHPDBG_COMMAND_D(leave, "continue until the end of the stack", 'L', NULL, 0), - PHPDBG_COMMAND_D(print, "print something", 'p', phpdbg_print_commands, 2), - PHPDBG_COMMAND_D(break, "set breakpoint", 'b', phpdbg_break_commands, 1), - PHPDBG_COMMAND_D(back, "show trace", 't', NULL, 0), - PHPDBG_COMMAND_D(frame, "switch to a frame", 'f', NULL, 1), - PHPDBG_COMMAND_D(list, "lists some code", 'l', phpdbg_list_commands, 2), - PHPDBG_COMMAND_D(info, "displays some informations", 'i', phpdbg_info_commands, 1), + PHPDBG_COMMAND_D(print, "print something", 'p', phpdbg_print_commands, 0), + PHPDBG_COMMAND_D(break, "set breakpoint", 'b', phpdbg_break_commands, "|*c"), + PHPDBG_COMMAND_D(back, "show trace", 't', NULL, "|n"), + PHPDBG_COMMAND_D(frame, "switch to a frame", 'f', NULL, "|n"), + PHPDBG_COMMAND_D(list, "lists some code", 'l', phpdbg_list_commands, "*"), + PHPDBG_COMMAND_D(info, "displays some informations", 'i', phpdbg_info_commands, "s"), PHPDBG_COMMAND_D(clean, "clean the execution environment", 'X', NULL, 0), PHPDBG_COMMAND_D(clear, "clear breakpoints", 'C', NULL, 0), - PHPDBG_COMMAND_D(help, "show help menu", 'h', phpdbg_help_commands, 2), - PHPDBG_COMMAND_D(quiet, "silence some output", 'Q', NULL, 1), - PHPDBG_COMMAND_D(aliases, "show alias list", 'a', NULL, 0), - PHPDBG_COMMAND_D(set, "set phpdbg configuration", 'S', phpdbg_set_commands, 1), - PHPDBG_COMMAND_D(register,"register a function", 'R', NULL, 1), - PHPDBG_COMMAND_D(source, "execute a phpdbginit", '.', NULL, 1), - PHPDBG_COMMAND_D(shell, "shell a command", '-', NULL, 1), + PHPDBG_COMMAND_D(help, "show help menu", 'h', phpdbg_help_commands, "|s"), + PHPDBG_COMMAND_D(set, "set phpdbg configuration", 'S', phpdbg_set_commands, "s"), + PHPDBG_COMMAND_D(register,"register a function", 'R', NULL, "s"), + PHPDBG_COMMAND_D(source, "execute a phpdbginit", '<', NULL, "s"), + PHPDBG_COMMAND_D(export, "export breaks to a .phpdbginit script", '>', NULL, "s"), + PHPDBG_COMMAND_D(sh, "shell a command", 0, NULL, "i"), PHPDBG_COMMAND_D(quit, "exit phpdbg", 'q', NULL, 0), + PHPDBG_COMMAND_D(watch, "set watchpoint", 'w', phpdbg_watch_commands, "|ss"), PHPDBG_END_COMMAND }; /* }}} */ ZEND_EXTERN_MODULE_GLOBALS(phpdbg); -static inline int phpdbg_call_register(phpdbg_input_t *input TSRMLS_DC) /* {{{ */ +static inline int phpdbg_call_register(phpdbg_param_t *stack TSRMLS_DC) /* {{{ */ { - phpdbg_input_t *function = input->argv[0]; + phpdbg_param_t *name = NULL; - if (zend_hash_exists( - &PHPDBG_G(registered), function->string, function->length+1)) { + if (stack->type == STACK_PARAM) { + name = stack->next; + + if (!name || name->type != STR_PARAM) { + return FAILURE; + } + + if (zend_hash_exists( + &PHPDBG_G(registered), name->str, name->len+1)) { - zval fname, *fretval; - zend_fcall_info fci; + zval fname, *fretval; + zend_fcall_info fci; - ZVAL_STRINGL(&fname, function->string, function->length, 1); + ZVAL_STRINGL(&fname, name->str, name->len, 1); - memset(&fci, 0, sizeof(zend_fcall_info)); + memset(&fci, 0, sizeof(zend_fcall_info)); - fci.size = sizeof(zend_fcall_info); - fci.function_table = &PHPDBG_G(registered); - fci.function_name = &fname; - fci.symbol_table = EG(active_symbol_table); - fci.object_ptr = NULL; - fci.retval_ptr_ptr = &fretval; - fci.no_separation = 1; + fci.size = sizeof(zend_fcall_info); + fci.function_table = &PHPDBG_G(registered); + fci.function_name = &fname; + fci.symbol_table = EG(active_symbol_table); + fci.object_ptr = NULL; + fci.retval_ptr_ptr = &fretval; + fci.no_separation = 1; - if (input->argc > 1) { - int param; - zval params; + if (name->next) { + zval params; + phpdbg_param_t *next = name->next; + + array_init(¶ms); - array_init(¶ms); + while (next) { + char *buffered = NULL; + + switch (next->type) { + case OP_PARAM: + case COND_PARAM: + case STR_PARAM: + add_next_index_stringl( + ¶ms, + next->str, + next->len, 1); + break; + + case NUMERIC_PARAM: + add_next_index_long(¶ms, next->num); + break; + + case METHOD_PARAM: + spprintf(&buffered, 0, "%s::%s", + next->method.class, next->method.name); + add_next_index_string(¶ms, buffered, 0); + break; + + case NUMERIC_METHOD_PARAM: + spprintf(&buffered, 0, "%s::%s#%ld", + next->method.class, next->method.name, next->num); + add_next_index_string(¶ms, buffered, 0); + break; + + case NUMERIC_FUNCTION_PARAM: + spprintf(&buffered, 0, "%s#%ld", + next->str, next->num); + add_next_index_string(¶ms, buffered, 0); + break; + + case FILE_PARAM: + spprintf(&buffered, 0, "%s:%ld", + next->file.name, next->file.line); + add_next_index_string(¶ms, buffered, 0); + break; + + case NUMERIC_FILE_PARAM: + spprintf(&buffered, 0, "%s:#%ld", + next->file.name, next->file.line); + add_next_index_string(¶ms, buffered, 0); + break; + + default: { + /* not yet */ + } + } + + next = next->next; + } - for (param = 0; param < (input->argc-1); param++) { - add_next_index_stringl( - ¶ms, - input->argv[param+1]->string, - input->argv[param+1]->length, 1); - - phpdbg_debug( - "created param[%d] from argv[%d]: %s", - param, param+1, input->argv[param+1]->string); + zend_fcall_info_args(&fci, ¶ms TSRMLS_CC); + } else { + fci.params = NULL; + fci.param_count = 0; } - zend_fcall_info_args(&fci, ¶ms TSRMLS_CC); - } else { - fci.params = NULL; - fci.param_count = 0; - } + phpdbg_debug( + "created %d params from arguments", + fci.param_count); - phpdbg_debug( - "created %d params from %d arguments", - fci.param_count, input->argc); + zend_call_function(&fci, NULL TSRMLS_CC); - zend_call_function(&fci, NULL TSRMLS_CC); + if (fretval) { + zend_print_zval_r( + fretval, 0 TSRMLS_CC); + phpdbg_writeln(EMPTY); + } - if (fretval) { - zend_print_zval_r( - fretval, 0 TSRMLS_CC); - phpdbg_writeln(EMPTY); - } + zval_dtor(&fname); - zval_dtor(&fname); - - return SUCCESS; + return SUCCESS; + } } return FAILURE; @@ -136,7 +191,7 @@ static inline int phpdbg_call_register(phpdbg_input_t *input TSRMLS_DC) /* {{{ * void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_init TSRMLS_DC) /* {{{ */ { struct stat sb; - + if (init_file && VCWD_STAT(init_file, &sb) != -1) { FILE *fp = fopen(init_file, "r"); if (fp) { @@ -190,19 +245,47 @@ void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_ } { - phpdbg_input_t *input = phpdbg_read_input(cmd TSRMLS_CC); - switch (phpdbg_do_cmd(phpdbg_prompt_commands, input TSRMLS_CC)) { - case FAILURE: - if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { - if (phpdbg_call_register(input TSRMLS_CC) == FAILURE) { - phpdbg_error("Unrecognized command in %s:%d: %s!", init_file, line, input->string); - } - } + char *why = NULL; + char *input = phpdbg_read_input(cmd TSRMLS_CC); + phpdbg_param_t stack; + yyscan_t scanner; + YY_BUFFER_STATE state; + + phpdbg_init_param(&stack, STACK_PARAM); + + if (yylex_init(&scanner)) { + phpdbg_error( + "could not initialize scanner"); break; } + + state = yy_scan_string(input, scanner); + + if (yyparse(&stack, scanner) <= 0) { + switch (phpdbg_stack_execute(&stack, &why TSRMLS_CC)) { + case FAILURE: +// if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { + if (phpdbg_call_register(&stack TSRMLS_CC) == FAILURE) { + phpdbg_error( + "Unrecognized command in %s:%d: %s, %s!", + init_file, line, input, why); + } +// } + break; + } + } + + if (why) { + free(why); + why = NULL; + } + + yy_delete_buffer(state, scanner); + yylex_destroy(scanner); + + phpdbg_stack_free(&stack); phpdbg_destroy_input(&input TSRMLS_CC); } - } next_line: line++; @@ -264,47 +347,47 @@ void phpdbg_init(char *init_file, size_t init_file_len, zend_bool use_default TS PHPDBG_COMMAND(exec) /* {{{ */ { - switch (param->type) { - case STR_PARAM: { - struct stat sb; + struct stat sb; - if (VCWD_STAT(param->str, &sb) != FAILURE) { - if (sb.st_mode & (S_IFREG|S_IFLNK)) { - char *res = phpdbg_resolve_path(param->str TSRMLS_CC); - size_t res_len = strlen(res); + if (VCWD_STAT(param->str, &sb) != FAILURE) { + if (sb.st_mode & (S_IFREG|S_IFLNK)) { + char *res = phpdbg_resolve_path(param->str TSRMLS_CC); + size_t res_len = strlen(res); - if ((res_len != PHPDBG_G(exec_len)) || (memcmp(res, PHPDBG_G(exec), res_len) != SUCCESS)) { + if ((res_len != PHPDBG_G(exec_len)) || (memcmp(res, PHPDBG_G(exec), res_len) != SUCCESS)) { - if (PHPDBG_G(exec)) { - phpdbg_notice("Unsetting old execution context: %s", PHPDBG_G(exec)); - efree(PHPDBG_G(exec)); - PHPDBG_G(exec) = NULL; - PHPDBG_G(exec_len) = 0L; - } + if (PHPDBG_G(exec)) { + phpdbg_notice("Unsetting old execution context: %s", PHPDBG_G(exec)); + efree(PHPDBG_G(exec)); + PHPDBG_G(exec) = NULL; + PHPDBG_G(exec_len) = 0L; + } - if (PHPDBG_G(ops)) { - phpdbg_notice("Destroying compiled opcodes"); - phpdbg_clean(0 TSRMLS_CC); - } + if (PHPDBG_G(ops)) { + phpdbg_notice("Destroying compiled opcodes"); + phpdbg_clean(0 TSRMLS_CC); + } - PHPDBG_G(exec) = res; - PHPDBG_G(exec_len) = res_len; + PHPDBG_G(exec) = res; + PHPDBG_G(exec_len) = res_len; + + *SG(request_info).argv = PHPDBG_G(exec); + php_hash_environment(TSRMLS_C); - phpdbg_notice("Set execution context: %s", PHPDBG_G(exec)); - } else { - phpdbg_notice("Execution context not changed"); - } - } else { - phpdbg_error("Cannot use %s as execution context, not a valid file or symlink", param->str); + phpdbg_notice("Set execution context: %s", PHPDBG_G(exec)); + + if (phpdbg_compile(TSRMLS_C) == FAILURE) { + phpdbg_error("Failed to compile %s", PHPDBG_G(exec)); } } else { - phpdbg_error("Cannot stat %s, ensure the file exists", param->str); + phpdbg_notice("Execution context not changed"); } - } break; - - phpdbg_default_switch_case(); + } else { + phpdbg_error("Cannot use %s as execution context, not a valid file or symlink", param->str); + } + } else { + phpdbg_error("Cannot stat %s, ensure the file exists", param->str); } - return SUCCESS; } /* }}} */ @@ -312,6 +395,11 @@ int phpdbg_compile(TSRMLS_D) /* {{{ */ { zend_file_handle fh; + if (!PHPDBG_G(exec)) { + phpdbg_error("No execution context"); + return SUCCESS; + } + if (EG(in_execution)) { phpdbg_error("Cannot compile while in execution"); return FAILURE; @@ -334,47 +422,16 @@ int phpdbg_compile(TSRMLS_D) /* {{{ */ return FAILURE; } /* }}} */ -PHPDBG_COMMAND(compile) /* {{{ */ -{ - if (!PHPDBG_G(exec)) { - phpdbg_error("No execution context"); - return SUCCESS; - } - - if (!EG(in_execution)) { - if (PHPDBG_G(ops)) { - phpdbg_error("Destroying previously compiled opcodes"); - phpdbg_clean(0 TSRMLS_CC); - } - } - - phpdbg_compile(TSRMLS_C); - - return SUCCESS; -} /* }}} */ - PHPDBG_COMMAND(step) /* {{{ */ { - switch (param->type) { - case EMPTY_PARAM: - case NUMERIC_PARAM: { - if (param->type == NUMERIC_PARAM && param->num) { - PHPDBG_G(flags) |= PHPDBG_IS_STEPPING; - } else { - PHPDBG_G(flags) &= ~PHPDBG_IS_STEPPING; - } - - phpdbg_notice("Stepping %s", - (PHPDBG_G(flags) & PHPDBG_IS_STEPPING) ? "on" : "off"); - } break; - - phpdbg_default_switch_case(); + if (EG(in_execution)) { + PHPDBG_G(flags) |= PHPDBG_IS_STEPPING; } - return SUCCESS; + return PHPDBG_NEXT; } /* }}} */ -PHPDBG_COMMAND(next) /* {{{ */ +PHPDBG_COMMAND(continue) /* {{{ */ { return PHPDBG_NEXT; } /* }}} */ @@ -475,17 +532,9 @@ PHPDBG_COMMAND(leave) /* {{{ */ PHPDBG_COMMAND(frame) /* {{{ */ { - switch (param->type) { - case NUMERIC_PARAM: - phpdbg_switch_frame(param->num TSRMLS_CC); - break; - - case EMPTY_PARAM: - phpdbg_notice("Currently in frame #%d", PHPDBG_G(frame).num); - break; - - phpdbg_default_switch_case(); - } + if (!param) { + phpdbg_notice("Currently in frame #%d", PHPDBG_G(frame).num); + } else phpdbg_switch_frame(param->num TSRMLS_CC); return SUCCESS; } /* }}} */ @@ -580,6 +629,31 @@ PHPDBG_COMMAND(run) /* {{{ */ /* reset hit counters */ phpdbg_reset_breakpoints(TSRMLS_C); + if (param && param->type != EMPTY_PARAM && param->len != 0) { + char **argv = emalloc(5 * sizeof(char *)); + int argc = 0; + int i; + char *argv_str = strtok(param->str, " "); + + while (argv_str) { + if (argc >= 4 && argc == (argc & -argc)) { + argv = erealloc(argv, (argc * 2 + 1) * sizeof(char *)); + } + argv[++argc] = argv_str; + argv_str = strtok(0, " "); + argv[argc] = estrdup(argv[argc]); + } + argv[0] = SG(request_info).argv[0]; + for (i = SG(request_info).argc; --i;) { + efree(SG(request_info).argv[i]); + } + efree(SG(request_info).argv); + SG(request_info).argv = erealloc(argv, ++argc * sizeof(char *)); + SG(request_info).argc = argc; + + php_hash_environment(TSRMLS_C); + } + zend_try { php_output_activate(TSRMLS_C); PHPDBG_G(flags) ^= PHPDBG_IS_INTERACTIVE; @@ -615,42 +689,36 @@ out: return SUCCESS; } /* }}} */ -PHPDBG_COMMAND(eval) /* {{{ */ +PHPDBG_COMMAND(ev) /* {{{ */ { - switch (param->type) { - case STR_PARAM: { - zend_bool stepping = ((PHPDBG_G(flags) & PHPDBG_IS_STEPPING)==PHPDBG_IS_STEPPING); - zval retval; + zend_bool stepping = ((PHPDBG_G(flags) & PHPDBG_IS_STEPPING)==PHPDBG_IS_STEPPING); + zval retval; - if (!(PHPDBG_G(flags) & PHPDBG_IS_STEPONEVAL)) { - PHPDBG_G(flags) &= ~ PHPDBG_IS_STEPPING; - } - - /* disable stepping while eval() in progress */ - PHPDBG_G(flags) |= PHPDBG_IN_EVAL; - zend_try { - if (zend_eval_stringl(param->str, param->len, - &retval, "eval()'d code" TSRMLS_CC) == SUCCESS) { - zend_print_zval_r( - &retval, 0 TSRMLS_CC); - phpdbg_writeln(EMPTY); - zval_dtor(&retval); - } - } zend_end_try(); - PHPDBG_G(flags) &= ~PHPDBG_IN_EVAL; - - /* switch stepping back on */ - if (stepping && - !(PHPDBG_G(flags) & PHPDBG_IS_STEPONEVAL)) { - PHPDBG_G(flags) |= PHPDBG_IS_STEPPING; - } - - CG(unclean_shutdown) = 0; - } break; - - phpdbg_default_switch_case(); + if (!(PHPDBG_G(flags) & PHPDBG_IS_STEPONEVAL)) { + PHPDBG_G(flags) &= ~ PHPDBG_IS_STEPPING; } + /* disable stepping while eval() in progress */ + PHPDBG_G(flags) |= PHPDBG_IN_EVAL; + zend_try { + if (zend_eval_stringl(param->str, param->len, + &retval, "eval()'d code" TSRMLS_CC) == SUCCESS) { + zend_print_zval_r( + &retval, 0 TSRMLS_CC); + phpdbg_writeln(EMPTY); + zval_dtor(&retval); + } + } zend_end_try(); + PHPDBG_G(flags) &= ~PHPDBG_IN_EVAL; + + /* switch stepping back on */ + if (stepping && + !(PHPDBG_G(flags) & PHPDBG_IS_STEPONEVAL)) { + PHPDBG_G(flags) |= PHPDBG_IS_STEPPING; + } + + CG(unclean_shutdown) = 0; + return SUCCESS; } /* }}} */ @@ -661,14 +729,10 @@ PHPDBG_COMMAND(back) /* {{{ */ return SUCCESS; } - switch (param->type) { - case EMPTY_PARAM: - case NUMERIC_PARAM: - phpdbg_dump_backtrace( - (param->type == NUMERIC_PARAM) ? param->num : 0 TSRMLS_CC); - break; - - phpdbg_default_switch_case(); + if (!param) { + phpdbg_dump_backtrace(0 TSRMLS_CC); + } else { + phpdbg_dump_backtrace(param->num TSRMLS_CC); } return SUCCESS; @@ -676,48 +740,42 @@ PHPDBG_COMMAND(back) /* {{{ */ PHPDBG_COMMAND(print) /* {{{ */ { - switch (param->type) { - case EMPTY_PARAM: { - phpdbg_writeln(SEPARATE); - phpdbg_notice("Execution Context Information"); + phpdbg_writeln(SEPARATE); + phpdbg_notice("Execution Context Information"); #ifdef HAVE_LIBREADLINE - phpdbg_writeln("Readline\tyes"); + phpdbg_writeln("Readline\tyes"); #else - phpdbg_writeln("Readline\tno"); + phpdbg_writeln("Readline\tno"); #endif - phpdbg_writeln("Exec\t\t%s", PHPDBG_G(exec) ? PHPDBG_G(exec) : "none"); - phpdbg_writeln("Compiled\t%s", PHPDBG_G(ops) ? "yes" : "no"); - phpdbg_writeln("Stepping\t%s", (PHPDBG_G(flags) & PHPDBG_IS_STEPPING) ? "on" : "off"); - phpdbg_writeln("Quietness\t%s", (PHPDBG_G(flags) & PHPDBG_IS_QUIET) ? "on" : "off"); - phpdbg_writeln("Oplog\t\t%s", PHPDBG_G(oplog) ? "on" : "off"); + phpdbg_writeln("Exec\t\t%s", PHPDBG_G(exec) ? PHPDBG_G(exec) : "none"); + phpdbg_writeln("Compiled\t%s", PHPDBG_G(ops) ? "yes" : "no"); + phpdbg_writeln("Stepping\t%s", (PHPDBG_G(flags) & PHPDBG_IS_STEPPING) ? "on" : "off"); + phpdbg_writeln("Quietness\t%s", (PHPDBG_G(flags) & PHPDBG_IS_QUIET) ? "on" : "off"); + phpdbg_writeln("Oplog\t\t%s", PHPDBG_G(oplog) ? "on" : "off"); - if (PHPDBG_G(ops)) { - phpdbg_writeln("Opcodes\t\t%d", PHPDBG_G(ops)->last); + if (PHPDBG_G(ops)) { + phpdbg_writeln("Opcodes\t\t%d", PHPDBG_G(ops)->last); - if (PHPDBG_G(ops)->last_var) { - phpdbg_writeln("Variables\t%d", PHPDBG_G(ops)->last_var-1); - } else { - phpdbg_writeln("Variables\tNone"); - } - } - - phpdbg_writeln("Executing\t%s", EG(in_execution) ? "yes" : "no"); - if (EG(in_execution)) { - phpdbg_writeln("VM Return\t%d", PHPDBG_G(vmret)); - } - - phpdbg_writeln("Classes\t\t%d", zend_hash_num_elements(EG(class_table))); - phpdbg_writeln("Functions\t%d", zend_hash_num_elements(EG(function_table))); - phpdbg_writeln("Constants\t%d", zend_hash_num_elements(EG(zend_constants))); - phpdbg_writeln("Included\t%d", zend_hash_num_elements(&EG(included_files))); - - phpdbg_writeln(SEPARATE); - } break; - - phpdbg_default_switch_case(); + if (PHPDBG_G(ops)->last_var) { + phpdbg_writeln("Variables\t%d", PHPDBG_G(ops)->last_var-1); + } else { + phpdbg_writeln("Variables\tNone"); + } } + phpdbg_writeln("Executing\t%s", EG(in_execution) ? "yes" : "no"); + if (EG(in_execution)) { + phpdbg_writeln("VM Return\t%d", PHPDBG_G(vmret)); + } + + phpdbg_writeln("Classes\t\t%d", zend_hash_num_elements(EG(class_table))); + phpdbg_writeln("Functions\t%d", zend_hash_num_elements(EG(function_table))); + phpdbg_writeln("Constants\t%d", zend_hash_num_elements(EG(zend_constants))); + phpdbg_writeln("Included\t%d", zend_hash_num_elements(&EG(included_files))); + + phpdbg_writeln(SEPARATE); + return SUCCESS; } /* }}} */ @@ -732,19 +790,18 @@ PHPDBG_COMMAND(info) /* {{{ */ PHPDBG_COMMAND(set) /* {{{ */ { phpdbg_error( - "No information command selected!"); + "No set command selected!"); return SUCCESS; } /* }}} */ PHPDBG_COMMAND(break) /* {{{ */ { - switch (param->type) { - case EMPTY_PARAM: - phpdbg_set_breakpoint_file( + if (!param) { + phpdbg_set_breakpoint_file( zend_get_executed_filename(TSRMLS_C), zend_get_executed_lineno(TSRMLS_C) TSRMLS_CC); - break; + } else switch (param->type) { case ADDR_PARAM: phpdbg_set_breakpoint_opline(param->addr TSRMLS_CC); break; @@ -767,9 +824,18 @@ PHPDBG_COMMAND(break) /* {{{ */ case FILE_PARAM: phpdbg_set_breakpoint_file(param->file.name, param->file.line TSRMLS_CC); break; + case NUMERIC_FILE_PARAM: + phpdbg_set_breakpoint_file_opline(param->file.name, param->file.line TSRMLS_CC); + break; + case COND_PARAM: + phpdbg_set_breakpoint_expression(param->str, param->len TSRMLS_CC); + break; case STR_PARAM: phpdbg_set_breakpoint_symbol(param->str, param->len TSRMLS_CC); break; + case OP_PARAM: + phpdbg_set_breakpoint_opcode(param->str, param->len TSRMLS_CC); + break; phpdbg_default_switch_case(); } @@ -777,83 +843,72 @@ PHPDBG_COMMAND(break) /* {{{ */ return SUCCESS; } /* }}} */ -PHPDBG_COMMAND(shell) /* {{{ */ +PHPDBG_COMMAND(sh) /* {{{ */ { - /* don't allow this to loop, ever ... */ - switch (param->type) { - case STR_PARAM: { - FILE *fd = NULL; - if ((fd=VCWD_POPEN((char*)param->str, "w"))) { - /* do something perhaps ?? do we want input ?? */ - fclose(fd); - } else { - phpdbg_error( - "Failed to execute %s", param->str); - } - } break; - - phpdbg_default_switch_case(); + FILE *fd = NULL; + if ((fd=VCWD_POPEN((char*)param->str, "w"))) { + /* do something perhaps ?? do we want input ?? */ + fclose(fd); + } else { + phpdbg_error( + "Failed to execute %s", param->str); } + return SUCCESS; } /* }}} */ PHPDBG_COMMAND(source) /* {{{ */ { - switch (param->type) { - case STR_PARAM: { - if (input->argc > 2) { - if (phpdbg_argv_is(1, "export")) { - FILE *h = VCWD_FOPEN(input->argv[2]->string, "w+"); - if (h) { - phpdbg_export_breakpoints(h TSRMLS_CC); - fclose(h); - } else phpdbg_error("Failed to open %s", input->argv[1]->string); - } else { - phpdbg_error( - "Incorrect usage of source command, see help"); - } - } else { - struct stat sb; - if (VCWD_STAT(param->str, &sb) != -1) { - phpdbg_try_file_init(param->str, param->len, 0 TSRMLS_CC); - } else phpdbg_error("Cannot stat %s", param->str); - } - } break; - - phpdbg_default_switch_case(); + struct stat sb; + + if (VCWD_STAT(param->str, &sb) != -1) { + phpdbg_try_file_init(param->str, param->len, 0 TSRMLS_CC); + } else { + phpdbg_error( + "Failed to stat %s, file does not exist", param->str); } + + return SUCCESS; +} /* }}} */ + +PHPDBG_COMMAND(export) /* {{{ */ +{ + FILE *handle = VCWD_FOPEN(param->str, "w+"); + + if (handle) { + phpdbg_export_breakpoints(handle TSRMLS_CC); + fclose(handle); + } else { + phpdbg_error( + "Failed to open or create %s, check path and permissions", param->str); + } + return SUCCESS; } /* }}} */ PHPDBG_COMMAND(register) /* {{{ */ { - switch (param->type) { - case STR_PARAM: { - zend_function *function; - char *lcname = zend_str_tolower_dup(param->str, param->len); - size_t lcname_len = strlen(lcname); + zend_function *function; + char *lcname = zend_str_tolower_dup(param->str, param->len); + size_t lcname_len = strlen(lcname); - if (!zend_hash_exists(&PHPDBG_G(registered), lcname, lcname_len+1)) { - if (zend_hash_find(EG(function_table), lcname, lcname_len+1, (void**) &function) == SUCCESS) { - zend_hash_update( - &PHPDBG_G(registered), lcname, lcname_len+1, (void*)&function, sizeof(zend_function), NULL); - function_add_ref(function); + if (!zend_hash_exists(&PHPDBG_G(registered), lcname, lcname_len+1)) { + if (zend_hash_find(EG(function_table), lcname, lcname_len+1, (void**) &function) == SUCCESS) { + zend_hash_update( + &PHPDBG_G(registered), lcname, lcname_len+1, (void*)&function, sizeof(zend_function), NULL); + function_add_ref(function); - phpdbg_notice( - "Registered %s", lcname); - } else { - phpdbg_error("The requested function (%s) could not be found", param->str); - } - } else { - phpdbg_error( - "The requested name (%s) is already in use", lcname); - } - - efree(lcname); - } break; - - phpdbg_default_switch_case(); + phpdbg_notice( + "Registered %s", lcname); + } else { + phpdbg_error("The requested function (%s) could not be found", param->str); + } + } else { + phpdbg_error( + "The requested name (%s) is already in use", lcname); } + + efree(lcname); return SUCCESS; } /* }}} */ @@ -861,14 +916,11 @@ PHPDBG_COMMAND(quit) /* {{{ */ { /* don't allow this to loop, ever ... */ if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { - - phpdbg_destroy_input((phpdbg_input_t**)&input TSRMLS_CC); - PHPDBG_G(flags) |= PHPDBG_IS_QUITTING; zend_bailout(); } - return SUCCESS; + return PHPDBG_NEXT; } /* }}} */ PHPDBG_COMMAND(clean) /* {{{ */ @@ -908,100 +960,12 @@ PHPDBG_COMMAND(clear) /* {{{ */ return SUCCESS; } /* }}} */ -PHPDBG_COMMAND(aliases) /* {{{ */ -{ - const phpdbg_command_t *prompt_command = phpdbg_prompt_commands; - - phpdbg_help_header(); - phpdbg_writeln("Below are the aliased, short versions of all supported commands"); - while (prompt_command && prompt_command->name) { - if (prompt_command->alias) { - if (prompt_command->subs) { - const phpdbg_command_t *sub_command = prompt_command->subs; - phpdbg_writeln(EMPTY); - phpdbg_writeln(" %c -> %9s", prompt_command->alias, prompt_command->name); - while (sub_command && sub_command->name) { - if (sub_command->alias) { - phpdbg_writeln(" |-------- %c -> %15s\t%s", sub_command->alias, - sub_command->name, sub_command->tip); - } - ++sub_command; - } - phpdbg_writeln(EMPTY); - } else { - phpdbg_writeln(" %c -> %9s\t\t\t%s", prompt_command->alias, - prompt_command->name, prompt_command->tip); - } - } - - ++prompt_command; - } - phpdbg_help_footer(); - - return SUCCESS; -} /* }}} */ - -PHPDBG_COMMAND(help) /* {{{ */ -{ - switch (param->type) { - case EMPTY_PARAM: { - const phpdbg_command_t *prompt_command = phpdbg_prompt_commands; - const phpdbg_command_t *help_command = phpdbg_help_commands; - - phpdbg_help_header(); - phpdbg_writeln("To get help regarding a specific command type \"help command\""); - - phpdbg_notice("Commands"); - - while (prompt_command && prompt_command->name) { - phpdbg_writeln( - " %10s\t%s", prompt_command->name, prompt_command->tip); - ++prompt_command; - } - - phpdbg_notice("Help Commands"); - - while (help_command && help_command->name) { - phpdbg_writeln(" %10s\t%s", help_command->name, help_command->tip); - ++help_command; - } - - phpdbg_help_footer(); - } break; - - default: { - phpdbg_error( - "No help can be found for the subject \"%s\"", param->str); - } - } - - return SUCCESS; -} /* }}} */ - -PHPDBG_COMMAND(quiet) /* {{{ */ -{ - switch (param->type) { - case NUMERIC_PARAM: { - if (param->num) { - PHPDBG_G(flags) |= PHPDBG_IS_QUIET; - } else { - PHPDBG_G(flags) &= ~PHPDBG_IS_QUIET; - } - phpdbg_notice("Quietness %s", - (PHPDBG_G(flags) & PHPDBG_IS_QUIET) ? "enabled" : "disabled"); - } break; - - phpdbg_default_switch_case(); - } - - return SUCCESS; -} /* }}} */ - PHPDBG_COMMAND(list) /* {{{ */ { - switch (param->type) { + if (!param) { + return PHPDBG_LIST_HANDLER(lines)(PHPDBG_COMMAND_ARGS); + } else switch (param->type) { case NUMERIC_PARAM: - case EMPTY_PARAM: return PHPDBG_LIST_HANDLER(lines)(PHPDBG_COMMAND_ARGS); case FILE_PARAM: @@ -1020,54 +984,101 @@ PHPDBG_COMMAND(list) /* {{{ */ return SUCCESS; } /* }}} */ +PHPDBG_COMMAND(watch) /* {{{ */ +{ + if (!param || param->type == EMPTY_PARAM) { + phpdbg_list_watchpoints(TSRMLS_C); + } else switch (param->type) { + case STR_PARAM: + if (phpdbg_create_var_watchpoint(param->str, param->len TSRMLS_CC) != FAILURE) { + phpdbg_notice("Set watchpoint on %.*s", (int)param->len, param->str); + } + break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + int phpdbg_interactive(TSRMLS_D) /* {{{ */ { int ret = SUCCESS; - phpdbg_input_t *input; + char *why = NULL; + char *input = NULL; + phpdbg_param_t stack; PHPDBG_G(flags) |= PHPDBG_IS_INTERACTIVE; input = phpdbg_read_input(NULL TSRMLS_CC); - if (input && input->length > 0L) { + if (input) { do { - switch (ret = phpdbg_do_cmd(phpdbg_prompt_commands, input TSRMLS_CC)) { - case FAILURE: - if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { - if (phpdbg_call_register(input TSRMLS_CC) == FAILURE) { - phpdbg_error("Failed to execute %s!", input->string); - } - } - break; + yyscan_t scanner; + YY_BUFFER_STATE state; - case PHPDBG_LEAVE: - case PHPDBG_FINISH: - case PHPDBG_UNTIL: - case PHPDBG_NEXT: { - if (!EG(in_execution)) { - phpdbg_error("Not running"); + phpdbg_init_param(&stack, STACK_PARAM); + + if (yylex_init(&scanner)) { + phpdbg_error( + "could not initialize scanner"); + return FAILURE; + } + + state = yy_scan_string(input, scanner); + + if (yyparse(&stack, scanner) <= 0) { + switch (ret = phpdbg_stack_execute(&stack, &why TSRMLS_CC)) { + case FAILURE: + if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { + if (phpdbg_call_register(&stack TSRMLS_CC) == FAILURE) { + if (why) { + phpdbg_error("%s", why); + } + } + } + + if (why) { + free(why); + why = NULL; + } + break; + + case PHPDBG_LEAVE: + case PHPDBG_FINISH: + case PHPDBG_UNTIL: + case PHPDBG_NEXT: { + if (!EG(in_execution) && !(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { + phpdbg_error("Not running"); + } + goto out; } - goto out; } } + if (why) { + free(why); + why = NULL; + } + + yy_delete_buffer(state, scanner); + yylex_destroy(scanner); + + phpdbg_stack_free(&stack); phpdbg_destroy_input(&input TSRMLS_CC); - } while ((input = phpdbg_read_input(NULL TSRMLS_CC)) && (input->length > 0L)); - if (input && !input->length) - goto last; - - } else { -last: - if (PHPDBG_G(lcmd)) { - ret = PHPDBG_G(lcmd)->handler( - &PHPDBG_G(lparam), input TSRMLS_CC); - goto out; - } + } while ((input = phpdbg_read_input(NULL TSRMLS_CC))); } out: - phpdbg_destroy_input(&input TSRMLS_CC); + if (input) { + phpdbg_stack_free(&stack); + phpdbg_destroy_input(&input TSRMLS_CC); + } + + if (why) { + free(why); + } if (EG(in_execution)) { phpdbg_restore_frame(TSRMLS_C); @@ -1075,6 +1086,8 @@ out: PHPDBG_G(flags) &= ~PHPDBG_IS_INTERACTIVE; + phpdbg_print_changed_zvals(TSRMLS_C); + return ret; } /* }}} */ @@ -1214,7 +1227,7 @@ zend_vm_enter: ); \ } \ \ - do { \ +/* do { */\ switch (phpdbg_interactive(TSRMLS_C)) { \ case PHPDBG_LEAVE: \ case PHPDBG_FINISH: \ @@ -1223,7 +1236,7 @@ zend_vm_enter: goto next; \ } \ } \ - } while (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)); \ +/* } while (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)); */\ } while (0) /* allow conditional breakpoints and @@ -1285,20 +1298,28 @@ zend_vm_enter: phpdbg_print_opline_ex( execute_data, &vars, 0 TSRMLS_CC); - /* search for breakpoints */ - { - phpdbg_breakbase_t *brake; + if (PHPDBG_G(flags) & PHPDBG_IS_STEPPING && (PHPDBG_G(flags) & PHPDBG_STEP_OPCODE || execute_data->opline->lineno != PHPDBG_G(last_line))) { + PHPDBG_G(flags) &= ~PHPDBG_IS_STEPPING; + DO_INTERACTIVE(); + } - if ((PHPDBG_G(flags) & PHPDBG_BP_MASK) && - (brake = phpdbg_find_breakpoint(execute_data TSRMLS_CC))) { - phpdbg_hit_breakpoint( - brake, 1 TSRMLS_CC); + /* check if some watchpoint was hit */ + { + if (phpdbg_print_changed_zvals(TSRMLS_C) == SUCCESS) { DO_INTERACTIVE(); } } - if (PHPDBG_G(flags) & PHPDBG_IS_STEPPING) { - DO_INTERACTIVE(); + /* search for breakpoints */ + { + phpdbg_breakbase_t *brake; + + if ((PHPDBG_G(flags) & PHPDBG_BP_MASK) + && (brake = phpdbg_find_breakpoint(execute_data TSRMLS_CC)) + && (brake->type != PHPDBG_BREAK_FILE || execute_data->opline->lineno != PHPDBG_G(last_line))) { + phpdbg_hit_breakpoint(brake, 1 TSRMLS_CC); + DO_INTERACTIVE(); + } } next: @@ -1309,6 +1330,8 @@ next: DO_INTERACTIVE(); } + PHPDBG_G(last_line) = execute_data->opline->lineno; + PHPDBG_G(vmret) = execute_data->opline->handler(execute_data TSRMLS_CC); if (PHPDBG_G(vmret) > 0) { diff --git a/phpdbg_prompt.h b/phpdbg_prompt.h index 6807d88f41d..ef648aabeb0 100644 --- a/phpdbg_prompt.h +++ b/phpdbg_prompt.h @@ -30,11 +30,10 @@ void phpdbg_clean(zend_bool full TSRMLS_DC); /* }}} */ /* {{{ phpdbg command handlers */ PHPDBG_COMMAND(exec); -PHPDBG_COMMAND(compile); PHPDBG_COMMAND(step); -PHPDBG_COMMAND(next); +PHPDBG_COMMAND(continue); PHPDBG_COMMAND(run); -PHPDBG_COMMAND(eval); +PHPDBG_COMMAND(ev); PHPDBG_COMMAND(until); PHPDBG_COMMAND(finish); PHPDBG_COMMAND(leave); @@ -47,13 +46,13 @@ PHPDBG_COMMAND(info); PHPDBG_COMMAND(clean); PHPDBG_COMMAND(clear); PHPDBG_COMMAND(help); -PHPDBG_COMMAND(quiet); -PHPDBG_COMMAND(aliases); -PHPDBG_COMMAND(shell); +PHPDBG_COMMAND(sh); PHPDBG_COMMAND(set); PHPDBG_COMMAND(source); +PHPDBG_COMMAND(export); PHPDBG_COMMAND(register); -PHPDBG_COMMAND(quit); /* }}} */ +PHPDBG_COMMAND(quit); +PHPDBG_COMMAND(watch); /* }}} */ /* {{{ prompt commands */ extern const phpdbg_command_t phpdbg_prompt_commands[]; /* }}} */ diff --git a/phpdbg_set.c b/phpdbg_set.c index 7c4da12a46e..54269a81931 100644 --- a/phpdbg_set.c +++ b/phpdbg_set.c @@ -23,56 +23,52 @@ #include "phpdbg_set.h" #include "phpdbg_utils.h" #include "phpdbg_bp.h" +#include "phpdbg_prompt.h" ZEND_EXTERN_MODULE_GLOBALS(phpdbg); +#define PHPDBG_SET_COMMAND_D(f, h, a, m, l, s) \ + PHPDBG_COMMAND_D_EXP(f, h, a, m, l, s, &phpdbg_prompt_commands[18]) + +const phpdbg_command_t phpdbg_set_commands[] = { + PHPDBG_SET_COMMAND_D(prompt, "usage: set prompt []", 'p', set_prompt, NULL, "|s"), +#ifndef _WIN32 + PHPDBG_SET_COMMAND_D(color, "usage: set color ", 'c', set_color, NULL, "ss"), + PHPDBG_SET_COMMAND_D(colors, "usage: set colors []", 'C', set_colors, NULL, "|b"), +#endif + PHPDBG_SET_COMMAND_D(oplog, "usage: set oplog []", 'O', set_oplog, NULL, "|s"), + PHPDBG_SET_COMMAND_D(break, "usage: set break id []", 'b', set_break, NULL, "l|b"), + PHPDBG_SET_COMMAND_D(breaks, "usage: set breaks []", 'B', set_breaks, NULL, "|b"), + PHPDBG_SET_COMMAND_D(quiet, "usage: set quiet []", 'q', set_quiet, NULL, "|b"), + PHPDBG_SET_COMMAND_D(stepping, "usage: set stepping []", 's', set_stepping, NULL, "|s"), + PHPDBG_SET_COMMAND_D(refcount, "usage: set refcount []", 'r', set_refcount, NULL, "|b"), + PHPDBG_END_COMMAND +}; + PHPDBG_SET(prompt) /* {{{ */ { - switch (param->type) { - case EMPTY_PARAM: - phpdbg_writeln("%s", phpdbg_get_prompt(TSRMLS_C)); - break; - - case STR_PARAM: - phpdbg_set_prompt(param->str TSRMLS_CC); - break; - - phpdbg_default_switch_case(); - } - + if (!param || param->type == EMPTY_PARAM) { + phpdbg_writeln("%s", phpdbg_get_prompt(TSRMLS_C)); + } else phpdbg_set_prompt(param->str TSRMLS_CC); + return SUCCESS; } /* }}} */ PHPDBG_SET(break) /* {{{ */ { switch (param->type) { - case EMPTY_PARAM: - phpdbg_writeln("%s", - PHPDBG_G(flags) & PHPDBG_IS_BP_ENABLED ? "on" : "off"); - break; - - case STR_PARAM: - if (strncasecmp(param->str, PHPDBG_STRL("on")) == 0) { - phpdbg_enable_breakpoints(TSRMLS_C); - } else if (strncasecmp(param->str, PHPDBG_STRL("off")) == 0) { - phpdbg_disable_breakpoints(TSRMLS_C); - } - break; - case NUMERIC_PARAM: { - if (input->argc > 2) { - if (phpdbg_argv_is(2, "on")) { - phpdbg_enable_breakpoint(param->num TSRMLS_CC); - } else if (phpdbg_argv_is(2, "off")) { - phpdbg_disable_breakpoint(param->num TSRMLS_CC); - } + if (param->next) { + if (param->next->num) { + phpdbg_enable_breakpoint(param->num TSRMLS_CC); + } else phpdbg_disable_breakpoint(param->num TSRMLS_CC); } else { phpdbg_breakbase_t *brake = phpdbg_find_breakbase(param->num TSRMLS_CC); if (brake) { phpdbg_writeln( "%s", brake->disabled ? "off" : "on"); } else { - phpdbg_error("Failed to find breakpoint #%lx", param->num); + phpdbg_error("Failed to find breakpoint #%ld", param->num); } } } break; @@ -85,104 +81,96 @@ PHPDBG_SET(break) /* {{{ */ return SUCCESS; } /* }}} */ +PHPDBG_SET(breaks) /* {{{ */ +{ + if (!param || param->type == EMPTY_PARAM) { + phpdbg_writeln("%s", + PHPDBG_G(flags) & PHPDBG_IS_BP_ENABLED ? "on" : "off"); + } else switch (param->type) { + case NUMERIC_PARAM: { + if (param->num) { + phpdbg_enable_breakpoints(TSRMLS_C); + } else phpdbg_disable_breakpoints(TSRMLS_C); + } break; + + default: + phpdbg_error( + "set break used incorrectly: set break [id] "); + } + + return SUCCESS; +} /* }}} */ + #ifndef _WIN32 PHPDBG_SET(color) /* {{{ */ { - if ((param->type == STR_PARAM) && (input->argc == 3)) { - const phpdbg_color_t *color = phpdbg_get_color( - input->argv[2]->string, input->argv[2]->length TSRMLS_CC); - int element = PHPDBG_COLOR_INVALID; - - /* @TODO(anyone) make this consistent with other set commands */ - if (color) { - if (phpdbg_argv_is(1, "prompt")) { - phpdbg_notice( - "setting prompt color to %s (%s)", color->name, color->code); - element = PHPDBG_COLOR_PROMPT; - if (PHPDBG_G(prompt)[1]) { - free(PHPDBG_G(prompt)[1]); - PHPDBG_G(prompt)[1]=NULL; - } - } else if (phpdbg_argv_is(1, "error")) { - phpdbg_notice( - "setting error color to %s (%s)", color->name, color->code); - element = PHPDBG_COLOR_ERROR; - - } else if (phpdbg_argv_is(1, "notice")) { - phpdbg_notice( - "setting notice color to %s (%s)", color->name, color->code); - element = PHPDBG_COLOR_NOTICE; - - } else goto usage; - - /* set color for element */ - phpdbg_set_color(element, color TSRMLS_CC); - } else { - phpdbg_error( - "Failed to find the requested color (%s)", input->argv[2]->string); - } - } else { -usage: + const phpdbg_color_t *color = phpdbg_get_color( + param->next->str, param->next->len TSRMLS_CC); + + if (!color) { phpdbg_error( - "set color used incorrectly: set color "); + "Failed to find the requested color (%s)", param->next->str); + return SUCCESS; } + + switch (phpdbg_get_element(param->str, param->len TSRMLS_CC)) { + case PHPDBG_COLOR_PROMPT: + phpdbg_notice( + "setting prompt color to %s (%s)", color->name, color->code); + if (PHPDBG_G(prompt)[1]) { + free(PHPDBG_G(prompt)[1]); + PHPDBG_G(prompt)[1]=NULL; + } + phpdbg_set_color(PHPDBG_COLOR_PROMPT, color TSRMLS_CC); + break; + + case PHPDBG_COLOR_ERROR: + phpdbg_notice( + "setting error color to %s (%s)", color->name, color->code); + phpdbg_set_color(PHPDBG_COLOR_ERROR, color TSRMLS_CC); + break; + + case PHPDBG_COLOR_NOTICE: + phpdbg_notice( + "setting notice color to %s (%s)", color->name, color->code); + phpdbg_set_color(PHPDBG_COLOR_NOTICE, color TSRMLS_CC); + break; + + default: + phpdbg_error( + "Failed to find the requested element (%s)", param->str); + } + return SUCCESS; } /* }}} */ PHPDBG_SET(colors) /* {{{ */ { - switch (param->type) { - case EMPTY_PARAM: { - phpdbg_writeln( - "%s", PHPDBG_G(flags) & PHPDBG_IS_COLOURED ? "on" : "off"); - goto done; - } - - case STR_PARAM: { - if (strncasecmp(param->str, PHPDBG_STRL("on")) == 0) { + if (!param || param->type == EMPTY_PARAM) { + phpdbg_writeln("%s", PHPDBG_G(flags) & PHPDBG_IS_COLOURED ? "on" : "off"); + } else switch (param->type) { + case NUMERIC_PARAM: { + if (param->num) { PHPDBG_G(flags) |= PHPDBG_IS_COLOURED; - goto done; - } else if (strncasecmp(param->str, PHPDBG_STRL("off")) == 0) { + } else { PHPDBG_G(flags) &= ~PHPDBG_IS_COLOURED; - goto done; } - } + } break; default: phpdbg_error( "set colors used incorrectly: set colors "); } -done: return SUCCESS; } /* }}} */ #endif PHPDBG_SET(oplog) /* {{{ */ { - switch (param->type) { - case EMPTY_PARAM: - phpdbg_notice( - "Oplog %s", PHPDBG_G(oplog) ? "enabled" : "disabled"); - break; - - case NUMERIC_PARAM: switch (param->num) { - case 1: - phpdbg_error( - "An output file must be provided to enable oplog"); - break; - - case 0: { - if (PHPDBG_G(oplog)) { - phpdbg_notice("Disabling oplog"); - fclose( - PHPDBG_G(oplog)); - } else { - phpdbg_error("Oplog is not enabled!"); - } - } break; - } break; - + if (!param || param->type == EMPTY_PARAM) { + phpdbg_notice("Oplog %s", PHPDBG_G(oplog) ? "enabled" : "disabled"); + } else switch (param->type) { case STR_PARAM: { /* open oplog */ FILE *old = PHPDBG_G(oplog); @@ -206,3 +194,65 @@ PHPDBG_SET(oplog) /* {{{ */ return SUCCESS; } /* }}} */ +PHPDBG_SET(quiet) /* {{{ */ +{ + if (!param || param->type == EMPTY_PARAM) { + phpdbg_writeln("Quietness %s", + PHPDBG_G(flags) & PHPDBG_IS_QUIET ? "on" : "off"); + } else switch (param->type) { + case NUMERIC_PARAM: { + if (param->num) { + PHPDBG_G(flags) |= PHPDBG_IS_QUIET; + } else { + PHPDBG_G(flags) &= ~PHPDBG_IS_QUIET; + } + } break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_SET(stepping) /* {{{ */ +{ + if (!param || param->type == EMPTY_PARAM) { + phpdbg_writeln("Stepping %s", + PHPDBG_G(flags) & PHPDBG_STEP_OPCODE ? "opcode" : "line"); + } else switch (param->type) { + case STR_PARAM: { + if ((param->len == sizeof("opcode")-1) && + (memcmp(param->str, "opcode", sizeof("opcode")) == SUCCESS)) { + PHPDBG_G(flags) |= PHPDBG_STEP_OPCODE; + } else if ((param->len == sizeof("line")-1) && + (memcmp(param->str, "line", sizeof("line")) == SUCCESS)) { + PHPDBG_G(flags) &= ~PHPDBG_STEP_OPCODE; + } else { + phpdbg_error("usage set stepping []"); + } + } break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_SET(refcount) /* {{{ */ +{ + if (!param || param->type == EMPTY_PARAM) { + phpdbg_writeln("Refcount %s", PHPDBG_G(flags) & PHPDBG_IS_QUIET ? "on" : "off"); + } else switch (param->type) { + case NUMERIC_PARAM: { + if (param->num) { + PHPDBG_G(flags) |= PHPDBG_SHOW_REFCOUNTS; + } else { + PHPDBG_G(flags) &= ~PHPDBG_SHOW_REFCOUNTS; + } + } break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ diff --git a/phpdbg_set.h b/phpdbg_set.h index 120aeb34f4e..dea61ed3825 100644 --- a/phpdbg_set.h +++ b/phpdbg_set.h @@ -32,16 +32,11 @@ PHPDBG_SET(colors); #endif PHPDBG_SET(oplog); PHPDBG_SET(break); +PHPDBG_SET(breaks); +PHPDBG_SET(quiet); +PHPDBG_SET(stepping); +PHPDBG_SET(refcount); -static const phpdbg_command_t phpdbg_set_commands[] = { - PHPDBG_COMMAND_D_EX(prompt, "usage: set prompt ", 'p', set_prompt, NULL, 0), -#ifndef _WIN32 - PHPDBG_COMMAND_D_EX(color, "usage: set color ", 'c', set_color, NULL, 1), - PHPDBG_COMMAND_D_EX(colors, "usage: set colors ", 'C', set_colors, NULL, 1), -#endif - PHPDBG_COMMAND_D_EX(oplog, "usage: set oplog ", 'O', set_oplog, NULL, 0), - PHPDBG_COMMAND_D_EX(break, "usage: set break [id] ", 'b', set_break, NULL, 0), - PHPDBG_END_COMMAND -}; +extern const phpdbg_command_t phpdbg_set_commands[]; #endif /* PHPDBG_SET_H */ diff --git a/phpdbg_utils.c b/phpdbg_utils.c index 1effcfccaf9..c9b22a20397 100644 --- a/phpdbg_utils.c +++ b/phpdbg_utils.c @@ -30,6 +30,8 @@ #ifdef _WIN32 # include "win32/time.h" +#elif defined(HAVE_SYS_IOCTL_H) +# include "sys/ioctl.h" #endif ZEND_EXTERN_MODULE_GLOBALS(phpdbg); @@ -65,6 +67,14 @@ const static phpdbg_color_t colors[] = { PHPDBG_COLOR_END }; /* }}} */ +/* {{{ */ +const static phpdbg_element_t elements[] = { + PHPDBG_ELEMENT_D("prompt", PHPDBG_COLOR_PROMPT), + PHPDBG_ELEMENT_D("error", PHPDBG_COLOR_ERROR), + PHPDBG_ELEMENT_D("notice", PHPDBG_COLOR_NOTICE), + PHPDBG_ELEMENT_END +}; /* }}} */ + PHPDBG_API int phpdbg_is_numeric(const char *str) /* {{{ */ { if (!str) @@ -347,6 +357,21 @@ PHPDBG_API const phpdbg_color_t* phpdbg_get_colors(TSRMLS_D) /* {{{ */ return colors; } /* }}} */ +PHPDBG_API int phpdbg_get_element(const char *name, size_t len TSRMLS_DC) { + const phpdbg_element_t *element = elements; + + while (element && element->name) { + if (len == element->name_length) { + if (strncasecmp(name, element->name, len) == SUCCESS) { + return element->id; + } + } + element++; + } + + return PHPDBG_COLOR_INVALID; +} + PHPDBG_API void phpdbg_set_prompt(const char *prompt TSRMLS_DC) /* {{{ */ { /* free formatted prompt */ @@ -385,3 +410,39 @@ PHPDBG_API const char *phpdbg_get_prompt(TSRMLS_D) /* {{{ */ return PHPDBG_G(prompt)[1]; } /* }}} */ + +int phpdbg_rebuild_symtable(TSRMLS_D) { + if (!EG(active_op_array)) { + phpdbg_error("No active op array!"); + return FAILURE; + } + + if (!EG(active_symbol_table)) { + zend_rebuild_symbol_table(TSRMLS_C); + + if (!EG(active_symbol_table)) { + phpdbg_error("No active symbol table!"); + return FAILURE; + } + } + + return SUCCESS; +} + +PHPDBG_API int phpdbg_get_terminal_width(TSRMLS_D) /* {{{ */ +{ + int columns; +#ifdef _WIN32 + CONSOLE_SCREEN_BUFFER_INFO csbi; + + GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); + columns = csbi.srWindow.Right - csbi.srWindow.Left + 1; +#elif defined(HAVE_SYS_IOCTL_H) + struct winsize w; + + columns = ioctl(fileno(stdout), TIOCGWINSZ, &w) == 0 ? w.ws_col : 100; +#else + columns = 100; +#endif + return columns; +} /* }}} */ diff --git a/phpdbg_utils.h b/phpdbg_utils.h index c5164c3ac31..68ae7e44a39 100644 --- a/phpdbg_utils.h +++ b/phpdbg_utils.h @@ -85,12 +85,17 @@ PHPDBG_API int phpdbg_rlog(FILE *stream, const char *fmt, ...); {color, sizeof(color)-1, code} #define PHPDBG_COLOR_END \ {NULL, 0L, {0}} +#define PHPDBG_ELEMENT_LEN 3 +#define PHPDBG_ELEMENT_D(name, id) \ + {name, sizeof(name)-1, id} +#define PHPDBG_ELEMENT_END \ + {NULL, 0L, 0} #define PHPDBG_COLOR_INVALID -1 -#define PHPDBG_COLOR_PROMPT 0 -#define PHPDBG_COLOR_ERROR 1 -#define PHPDBG_COLOR_NOTICE 2 -#define PHPDBG_COLORS 3 +#define PHPDBG_COLOR_PROMPT 0 +#define PHPDBG_COLOR_ERROR 1 +#define PHPDBG_COLOR_NOTICE 2 +#define PHPDBG_COLORS 3 typedef struct _phpdbg_color_t { char *name; @@ -98,13 +103,25 @@ typedef struct _phpdbg_color_t { const char code[PHPDBG_COLOR_LEN]; } phpdbg_color_t; +typedef struct _phpdbg_element_t { + char *name; + size_t name_length; + int id; +} phpdbg_element_t; + PHPDBG_API const phpdbg_color_t *phpdbg_get_color(const char *name, size_t name_length TSRMLS_DC); PHPDBG_API void phpdbg_set_color(int element, const phpdbg_color_t *color TSRMLS_DC); PHPDBG_API void phpdbg_set_color_ex(int element, const char *name, size_t name_length TSRMLS_DC); -PHPDBG_API const phpdbg_color_t* phpdbg_get_colors(TSRMLS_D); /* }}} */ +PHPDBG_API const phpdbg_color_t* phpdbg_get_colors(TSRMLS_D); +PHPDBG_API int phpdbg_get_element(const char *name, size_t len TSRMLS_DC); /* }}} */ /* {{{ Prompt Management */ PHPDBG_API void phpdbg_set_prompt(const char* TSRMLS_DC); PHPDBG_API const char *phpdbg_get_prompt(TSRMLS_D); /* }}} */ +/* {{{ Console Width */ +PHPDBG_API int phpdbg_get_terminal_width(TSRMLS_D); /* }}} */ + +int phpdbg_rebuild_symtable(TSRMLS_D); + #endif /* PHPDBG_UTILS_H */ diff --git a/phpdbg_watch.c b/phpdbg_watch.c new file mode 100644 index 00000000000..a6bf6289bf5 --- /dev/null +++ b/phpdbg_watch.c @@ -0,0 +1,789 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#include "zend.h" +#include "phpdbg.h" +#include "phpdbg_btree.h" +#include "phpdbg_watch.h" +#include "phpdbg_utils.h" +#ifndef _WIN32 +# include +# include +#endif + +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); + + +typedef struct { + void *page; + size_t size; + char reenable_writing; + /* data must be last element */ + void *data; +} phpdbg_watch_memdump; + +#define MEMDUMP_SIZE(size) (sizeof(phpdbg_watch_memdump) - sizeof(void *) + (size)) + + +static phpdbg_watchpoint_t *phpdbg_check_for_watchpoint(void *addr TSRMLS_DC) { + phpdbg_watchpoint_t *watch; + phpdbg_btree_result *result = phpdbg_btree_find_closest(&PHPDBG_G(watchpoint_tree), (zend_ulong)phpdbg_get_page_boundary(addr) + phpdbg_pagesize - 1); + + if (result == NULL) { + return NULL; + } + + watch = result->ptr; + + /* check if that addr is in a mprotect()'ed memory area */ + if ((char *)phpdbg_get_page_boundary(watch->addr.ptr) > (char *)addr || (char *)phpdbg_get_page_boundary(watch->addr.ptr) + phpdbg_get_total_page_size(watch->addr.ptr, watch->size) < (char *)addr) { + /* failure */ + return NULL; + } + + return watch; +} + +static void phpdbg_change_watchpoint_access(phpdbg_watchpoint_t *watch, int access TSRMLS_DC) { + int m; + + /* pagesize is assumed to be in the range of 2^x */ + m = mprotect(phpdbg_get_page_boundary(watch->addr.ptr), phpdbg_get_total_page_size(watch->addr.ptr, watch->size), access); +} + +static inline void phpdbg_activate_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_DC) { + phpdbg_change_watchpoint_access(watch, PROT_READ TSRMLS_CC); +} + +static inline void phpdbg_deactivate_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_DC) { + phpdbg_change_watchpoint_access(watch, PROT_READ | PROT_WRITE TSRMLS_CC); +} + +static inline void phpdbg_store_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_DC) { + phpdbg_btree_insert(&PHPDBG_G(watchpoint_tree), (zend_ulong)watch->addr.ptr, watch); +} + +static inline void phpdbg_remove_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_DC) { + phpdbg_btree_delete(&PHPDBG_G(watchpoint_tree), (zend_ulong)watch->addr.ptr); +} + +void phpdbg_create_addr_watchpoint(void *addr, size_t size, phpdbg_watchpoint_t *watch) { + watch->addr.ptr = addr; + watch->size = size; +} + +void phpdbg_create_zval_watchpoint(zval *zv, phpdbg_watchpoint_t *watch) { + phpdbg_create_addr_watchpoint(zv, sizeof(zval), watch); + watch->type = WATCH_ON_ZVAL; +} + +void phpdbg_create_ht_watchpoint(HashTable *ht, phpdbg_watchpoint_t *watch) { + phpdbg_create_addr_watchpoint(ht, sizeof(HashTable), watch); + watch->type = WATCH_ON_HASHTABLE; +} + +void phpdbg_watch_HashTable_dtor(zval **ptr); + +static int phpdbg_create_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_DC) { + watch->flags |= PHPDBG_WATCH_SIMPLE; + + phpdbg_store_watchpoint(watch TSRMLS_CC); + zend_hash_add(&PHPDBG_G(watchpoints), watch->str, watch->str_len, &watch, sizeof(phpdbg_watchpoint_t *), NULL); + + if (watch->type == WATCH_ON_ZVAL) { + phpdbg_btree_insert(&PHPDBG_G(watch_HashTables), (zend_ulong)watch->parent_container, watch->parent_container->pDestructor); + watch->parent_container->pDestructor = (dtor_func_t)phpdbg_watch_HashTable_dtor; + } + + phpdbg_activate_watchpoint(watch TSRMLS_CC); + + return SUCCESS; +} + +static int phpdbg_create_array_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_DC) { + HashTable *ht; + + switch (Z_TYPE_P(watch->addr.zv)) { + case IS_ARRAY: + ht = Z_ARRVAL_P(watch->addr.zv); + break; + case IS_OBJECT: + ht = Z_OBJPROP_P(watch->addr.zv); + break; + default: + return FAILURE; + } + + phpdbg_create_ht_watchpoint(ht, watch); + + phpdbg_create_watchpoint(watch TSRMLS_CC); + + return SUCCESS; +} + +static char *phpdbg_get_property_key(char *key) { + if (*key != 0) { + return key; + } + return strchr(key + 1, 0) + 1; +} + +static int phpdbg_create_recursive_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_DC) { + HashTable *ht; + + if (watch->type != WATCH_ON_ZVAL) { + return FAILURE; + } + + watch->flags |= PHPDBG_WATCH_RECURSIVE; + phpdbg_create_watchpoint(watch TSRMLS_CC); + + switch (Z_TYPE_P(watch->addr.zv)) { + case IS_ARRAY: + ht = Z_ARRVAL_P(watch->addr.zv); + break; + case IS_OBJECT: + ht = Z_OBJPROP_P(watch->addr.zv); + break; + default: + return SUCCESS; + } + + { + HashPosition position; + zval **zv; + zval key; + + for (zend_hash_internal_pointer_reset_ex(ht, &position); + zend_hash_get_current_data_ex(ht, (void **)&zv, &position) == SUCCESS; + zend_hash_move_forward_ex(ht, &position)) { + phpdbg_watchpoint_t *new_watch = emalloc(sizeof(phpdbg_watchpoint_t)); + + new_watch->flags = PHPDBG_WATCH_RECURSIVE; + new_watch->parent = watch; + new_watch->parent_container = ht; + + zend_hash_get_current_key_zval_ex(ht, &key, &position); + if (Z_TYPE(key) == IS_STRING) { + new_watch->name_in_parent = zend_strndup(Z_STRVAL(key), Z_STRLEN(key)); + new_watch->name_in_parent_len = Z_STRLEN(key); + } else { + new_watch->name_in_parent = NULL; + new_watch->name_in_parent_len = asprintf(&new_watch->name_in_parent, "%ld", Z_LVAL(key)); + } + + new_watch->str = NULL; + new_watch->str_len = asprintf(&new_watch->str, "%.*s%s%s%s", (int)watch->str_len, watch->str, Z_TYPE_P(watch->addr.zv) == IS_ARRAY?"[":"->", phpdbg_get_property_key(new_watch->name_in_parent), Z_TYPE_P(watch->addr.zv) == IS_ARRAY?"]":""); + + phpdbg_create_zval_watchpoint(*zv, new_watch); + phpdbg_create_recursive_watchpoint(new_watch TSRMLS_CC); + } + } + + { + phpdbg_watchpoint_t *new_watch = emalloc(sizeof(phpdbg_watchpoint_t)); + + new_watch->parent = watch; + new_watch->parent_container = watch->parent_container; + new_watch->name_in_parent = zend_strndup(watch->name_in_parent, watch->name_in_parent_len); + new_watch->name_in_parent_len = watch->name_in_parent_len; + new_watch->str = NULL; + new_watch->str_len = asprintf(&new_watch->str, "%.*s[]", (int)watch->str_len, watch->str); + new_watch->flags = PHPDBG_WATCH_RECURSIVE; + + phpdbg_create_ht_watchpoint(ht, new_watch); + phpdbg_create_watchpoint(new_watch TSRMLS_CC); + } + + return SUCCESS; +} + +static int phpdbg_delete_watchpoint_recursive(phpdbg_watchpoint_t *watch, zend_bool user_request TSRMLS_DC) { + if (watch->type == WATCH_ON_HASHTABLE || (watch->type == WATCH_ON_ZVAL && (Z_TYPE_P(watch->addr.zv) == IS_ARRAY || Z_TYPE_P(watch->addr.zv) == IS_OBJECT))) { + HashTable *ht; + phpdbg_btree_result *result; + + if (watch->type == WATCH_ON_HASHTABLE && user_request) { + HashPosition position; + zval **zv; + zval key; + char *str; + int str_len; + phpdbg_watchpoint_t **watchpoint; + + ht = watch->addr.ht; + + for (zend_hash_internal_pointer_reset_ex(ht, &position); + zend_hash_get_current_data_ex(ht, (void **)&zv, &position) == SUCCESS; + zend_hash_move_forward_ex(ht, &position)) { + zend_hash_get_current_key_zval_ex(ht, &key, &position); + str = NULL; + if (Z_TYPE(key) == IS_STRING) { + str_len = asprintf(&str, "%.*s%s%s%s", (int)watch->parent->str_len, watch->parent->str, Z_TYPE_P(watch->parent->addr.zv) == IS_ARRAY?"[":"->", phpdbg_get_property_key(Z_STRVAL(key)), Z_TYPE_P(watch->parent->addr.zv) == IS_ARRAY?"]":""); + } else { + str_len = asprintf(&str, "%.*s%s%li%s", (int)watch->parent->str_len, watch->parent->str, Z_TYPE_P(watch->parent->addr.zv) == IS_ARRAY?"[":"->", Z_LVAL(key), Z_TYPE_P(watch->parent->addr.zv) == IS_ARRAY?"]":""); + } + + if (zend_hash_find(&PHPDBG_G(watchpoints), str, str_len, (void **) &watchpoint) == SUCCESS) { + phpdbg_delete_watchpoint_recursive(*watchpoint, 1 TSRMLS_CC); + } + } + } else { + switch (Z_TYPE_P(watch->addr.zv)) { + case IS_ARRAY: + ht = Z_ARRVAL_P(watch->addr.zv); + break; + case IS_OBJECT: + ht = Z_OBJPROP_P(watch->addr.zv); + break; + } + + if ((result = phpdbg_btree_find(&PHPDBG_G(watchpoint_tree), (zend_ulong) ht))) { + phpdbg_delete_watchpoint_recursive((phpdbg_watchpoint_t *) result->ptr, user_request TSRMLS_CC); + } + } + } + + return zend_hash_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len); +} + +static int phpdbg_delete_watchpoint(phpdbg_watchpoint_t *tmp_watch TSRMLS_DC) { + int ret; + phpdbg_watchpoint_t *watch; + phpdbg_btree_result *result; + + if ((result = phpdbg_btree_find(&PHPDBG_G(watchpoint_tree), (zend_ulong)tmp_watch->addr.ptr)) == NULL) { + return FAILURE; + } + + watch = result->ptr; + + if (watch->flags & PHPDBG_WATCH_RECURSIVE) { + ret = phpdbg_delete_watchpoint_recursive(watch, 1 TSRMLS_CC); + } else { + ret = zend_hash_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len); + } + + free(tmp_watch->str); + efree(tmp_watch); + + return ret; +} + +static int phpdbg_watchpoint_parse_input(char *input, size_t len, HashTable *parent, size_t i, int (*callback)(phpdbg_watchpoint_t * TSRMLS_DC), zend_bool silent TSRMLS_DC) { + int ret = FAILURE; + zend_bool new_index = 1; + char *last_index; + int index_len = 0; + zval **zv; + + if (len < 2 || *input != '$') { + goto error; + } + + while (i++ < len) { + if (i == len) { + new_index = 1; + } else { + switch (input[i]) { + case '[': + new_index = 1; + break; + case ']': + break; + case '>': + if (last_index[index_len - 1] == '-') { + new_index = 1; + index_len--; + } + break; + + default: + if (new_index) { + last_index = input + i; + new_index = 0; + } + if (input[i - 1] == ']') { + goto error; + } + index_len++; + } + } + + if (new_index && index_len == 0) { + HashPosition position; + for (zend_hash_internal_pointer_reset_ex(parent, &position); + zend_hash_get_current_data_ex(parent, (void **)&zv, &position) == SUCCESS; + zend_hash_move_forward_ex(parent, &position)) { + if (i == len || (i == len - 1 && input[len - 1] == ']')) { + zval *key = emalloc(sizeof(zval)); + phpdbg_watchpoint_t *watch = emalloc(sizeof(phpdbg_watchpoint_t)); + watch->flags = 0; + zend_hash_get_current_key_zval_ex(parent, key, &position); + convert_to_string(key); + watch->str = malloc(i + Z_STRLEN_P(key) + 2); + watch->str_len = sprintf(watch->str, "%.*s%s%s", (int)i, input, phpdbg_get_property_key(Z_STRVAL_P(key)), input[len - 1] == ']'?"]":""); + efree(key); + watch->name_in_parent = zend_strndup(last_index, index_len); + watch->name_in_parent_len = index_len; + watch->parent_container = parent; + phpdbg_create_zval_watchpoint(*zv, watch); + + ret = callback(watch TSRMLS_CC) == SUCCESS || ret == SUCCESS?SUCCESS:FAILURE; + } else if (Z_TYPE_PP(zv) == IS_OBJECT) { + phpdbg_watchpoint_parse_input(input, len, Z_OBJPROP_PP(zv), i, callback, silent TSRMLS_CC); + } else if (Z_TYPE_PP(zv) == IS_ARRAY) { + phpdbg_watchpoint_parse_input(input, len, Z_ARRVAL_PP(zv), i, callback, silent TSRMLS_CC); + } else { + /* Ignore silently */ + } + } + return ret; + } else if (new_index) { + char last_chr = last_index[index_len]; + last_index[index_len] = 0; + if (zend_symtable_find(parent, last_index, index_len + 1, (void **)&zv) == FAILURE) { + if (!silent) { + phpdbg_error("%.*s is undefined", (int)i, input); + } + return FAILURE; + } + last_index[index_len] = last_chr; + if (i == len) { + phpdbg_watchpoint_t *watch = emalloc(sizeof(phpdbg_watchpoint_t)); + watch->flags = 0; + watch->str = zend_strndup(input, len); + watch->str_len = len; + watch->name_in_parent = zend_strndup(last_index, index_len); + watch->name_in_parent_len = index_len; + watch->parent_container = parent; + phpdbg_create_zval_watchpoint(*zv, watch); + + ret = callback(watch TSRMLS_CC) == SUCCESS || ret == SUCCESS?SUCCESS:FAILURE; + } else if (Z_TYPE_PP(zv) == IS_OBJECT) { + parent = Z_OBJPROP_PP(zv); + } else if (Z_TYPE_PP(zv) == IS_ARRAY) { + parent = Z_ARRVAL_PP(zv); + } else { + phpdbg_error("%.*s is nor an array nor an object", (int)i, input); + return FAILURE; + } + index_len = 0; + } + } + + return ret; + error: + phpdbg_error("Malformed input"); + return FAILURE; +} + +static int phpdbg_watchpoint_parse_symtables(char *input, size_t len, int (*callback)(phpdbg_watchpoint_t * TSRMLS_DC) TSRMLS_DC) { + if (EG(This) && len >= 5 && !memcmp("$this", input, 5)) { + zend_hash_add(EG(active_symbol_table), "this", sizeof("this"), &EG(This), sizeof(zval *), NULL); + } + + if (zend_is_auto_global(input, len TSRMLS_CC) && phpdbg_watchpoint_parse_input(input, len, &EG(symbol_table), 0, callback, 1 TSRMLS_CC) != FAILURE) { + return SUCCESS; + } + + return phpdbg_watchpoint_parse_input(input, len, EG(active_symbol_table), 0, callback, 0 TSRMLS_CC); +} + +PHPDBG_WATCH(delete) /* {{{ */ +{ + switch (param->type) { + case STR_PARAM: + if (phpdbg_delete_var_watchpoint(param->str, param->len TSRMLS_CC) == FAILURE) { + phpdbg_error("Nothing was deleted, no corresponding watchpoint found"); + } else { + phpdbg_notice("Removed watchpoint %.*s", (int)param->len, param->str); + } + break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_WATCH(recursive) /* {{{ */ +{ + if (phpdbg_rebuild_symtable(TSRMLS_C) == FAILURE) { + return SUCCESS; + } + + switch (param->type) { + case STR_PARAM: + if (phpdbg_watchpoint_parse_symtables(param->str, param->len, phpdbg_create_recursive_watchpoint TSRMLS_CC) != FAILURE) { + phpdbg_notice("Set recursive watchpoint on %.*s", (int)param->len, param->str); + } + break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +PHPDBG_WATCH(array) /* {{{ */ +{ + if (phpdbg_rebuild_symtable(TSRMLS_C) == FAILURE) { + return SUCCESS; + } + + switch (param->type) { + case STR_PARAM: + if (phpdbg_watchpoint_parse_symtables(param->str, param->len, phpdbg_create_array_watchpoint TSRMLS_CC) != FAILURE) { + phpdbg_notice("Set array watchpoint on %.*s", (int)param->len, param->str); + } + break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + +void phpdbg_watch_HashTable_dtor(zval **zv) { + TSRMLS_FETCH(); + + phpdbg_btree_result *result; + zval_ptr_dtor_wrapper(zv); + + + if ((result = phpdbg_btree_find(&PHPDBG_G(watchpoint_tree), (zend_ulong)*zv))) { + phpdbg_watchpoint_t *watch = result->ptr; + + PHPDBG_G(watchpoint_hit) = 1; + + phpdbg_notice("%.*s was removed, removing watchpoint%s", (int)watch->str_len, watch->str, (watch->flags & PHPDBG_WATCH_RECURSIVE)?" recursively":""); + + if (watch->flags & PHPDBG_WATCH_RECURSIVE) { + phpdbg_delete_watchpoint_recursive(watch, 0 TSRMLS_CC); + } else { + zend_hash_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len); + } + } +} + + +int phpdbg_create_var_watchpoint(char *input, size_t len TSRMLS_DC) { + if (phpdbg_rebuild_symtable(TSRMLS_C) == FAILURE) { + return FAILURE; + } + + return phpdbg_watchpoint_parse_symtables(input, len, phpdbg_create_watchpoint TSRMLS_CC); +} + +int phpdbg_delete_var_watchpoint(char *input, size_t len TSRMLS_DC) { + if (phpdbg_rebuild_symtable(TSRMLS_C) == FAILURE) { + return FAILURE; + } + + return phpdbg_watchpoint_parse_symtables(input, len, phpdbg_delete_watchpoint TSRMLS_CC); +} + +#ifdef _WIN32 +int phpdbg_watchpoint_segfault_handler(void *addr TSRMLS_DC) { +#else +int phpdbg_watchpoint_segfault_handler(siginfo_t *info, void *context TSRMLS_DC) { +#endif + void *page; + phpdbg_watch_memdump *dump; + phpdbg_watchpoint_t *watch; + size_t size; + + watch = phpdbg_check_for_watchpoint( +#ifdef _WIN32 + addr +#else + info->si_addr +#endif + TSRMLS_CC); + + if (watch == NULL) { + return FAILURE; + } + + page = phpdbg_get_page_boundary(watch->addr.ptr); + size = phpdbg_get_total_page_size(watch->addr.ptr, watch->size); + + /* re-enable writing */ + mprotect(page, size, PROT_READ | PROT_WRITE); + + dump = malloc(MEMDUMP_SIZE(size)); + dump->page = page; + dump->size = size; + + memcpy(&dump->data, page, size); + + zend_llist_add_element(&PHPDBG_G(watchlist_mem), &dump); + + return SUCCESS; +} + +void phpdbg_watchpoints_clean(TSRMLS_D) { + zend_hash_clean(&PHPDBG_G(watchpoints)); +} + +static void phpdbg_watch_dtor(void *pDest) { + TSRMLS_FETCH(); + + phpdbg_watchpoint_t *watch = *(phpdbg_watchpoint_t **)pDest; + + phpdbg_deactivate_watchpoint(watch TSRMLS_CC); + phpdbg_remove_watchpoint(watch TSRMLS_CC); + + free(watch->str); + free(watch->name_in_parent); + efree(watch); +} + +static void phpdbg_watch_mem_dtor(void *llist_data) { + phpdbg_watch_memdump *dump = *(phpdbg_watch_memdump **)llist_data; + + /* Disble writing again */ + if (dump->reenable_writing) { + mprotect(dump->page, dump->size, PROT_READ); + } + + free(*(void **)llist_data); +} + +void phpdbg_setup_watchpoints(TSRMLS_D) { +#if _SC_PAGE_SIZE + phpdbg_pagesize = sysconf(_SC_PAGE_SIZE); +#elif _SC_PAGESIZE + phpdbg_pagesize = sysconf(_SC_PAGESIZE); +#elif _SC_NUTC_OS_PAGESIZE + phpdbg_pagesize = sysconf(_SC_NUTC_OS_PAGESIZE); +#else + phpdbg_pagesize = 4096; /* common pagesize */ +#endif + + zend_llist_init(&PHPDBG_G(watchlist_mem), sizeof(void *), phpdbg_watch_mem_dtor, 1); + phpdbg_btree_init(&PHPDBG_G(watchpoint_tree), sizeof(void *) * 8); + phpdbg_btree_init(&PHPDBG_G(watch_HashTables), sizeof(void *) * 8); + _zend_hash_init(&PHPDBG_G(watchpoints), 8, phpdbg_watch_dtor, 0 ZEND_FILE_LINE_CC); +} + +static void phpdbg_print_changed_zval(phpdbg_watch_memdump *dump TSRMLS_DC) { + /* fetch all changes between dump->page and dump->page + dump->size */ + phpdbg_btree_position pos = phpdbg_btree_find_between(&PHPDBG_G(watchpoint_tree), (zend_ulong)dump->page, (zend_ulong)dump->page + dump->size); + phpdbg_btree_result *result, *htresult; + int elementDiff; + void *curTest; + + dump->reenable_writing = 0; + + while ((result = phpdbg_btree_next(&pos))) { + phpdbg_watchpoint_t *watch = result->ptr, *htwatch; + void *oldPtr = (char *)&dump->data + ((size_t)watch->addr.ptr - (size_t)dump->page); + char reenable = 1; + + if (watch->addr.ptr < dump->page || watch->addr.ptr + watch->size > dump->page + dump->size) { + continue; + } + + /* Test if the zval was separated and if necessary move the watchpoint */ + if (zend_hash_find(watch->parent_container, watch->name_in_parent, watch->name_in_parent_len + 1, &curTest) == SUCCESS) { + if (watch->type == WATCH_ON_HASHTABLE) { + switch (Z_TYPE_PP((zval **)curTest)) { + case IS_ARRAY: + curTest = (void *)Z_ARRVAL_PP((zval **)curTest); + break; + case IS_OBJECT: + curTest = (void *)Z_OBJPROP_PP((zval **)curTest); + break; + } + } else { + curTest = *(void **)curTest; + } + + if (curTest != watch->addr.ptr) { + phpdbg_deactivate_watchpoint(watch TSRMLS_CC); + phpdbg_remove_watchpoint(watch TSRMLS_CC); + watch->addr.ptr = curTest; + phpdbg_store_watchpoint(watch TSRMLS_CC); + phpdbg_activate_watchpoint(watch TSRMLS_CC); + + reenable = 0; + } + } + + /* Show to the user what changed and delete watchpoint upon removal */ + if (memcmp(oldPtr, watch->addr.ptr, watch->size) != SUCCESS) { + if (PHPDBG_G(flags) & PHPDBG_SHOW_REFCOUNTS || (watch->type == WATCH_ON_ZVAL && memcmp(oldPtr, watch->addr.zv, sizeof(zvalue_value))) || (watch->type == WATCH_ON_HASHTABLE +#if ZEND_DEBUG + && !watch->addr.ht->inconsistent +#endif + && zend_hash_num_elements((HashTable *)oldPtr) != zend_hash_num_elements(watch->addr.ht))) { + PHPDBG_G(watchpoint_hit) = 1; + + phpdbg_notice("Breaking on watchpoint %s", watch->str); + } + + switch (watch->type) { + case WATCH_ON_ZVAL: { + int removed = ((zval *)oldPtr)->refcount__gc != watch->addr.zv->refcount__gc && !zend_symtable_exists(watch->parent_container, watch->name_in_parent, watch->name_in_parent_len + 1); + int show_value = memcmp(oldPtr, watch->addr.zv, sizeof(zvalue_value)); + int show_ref = ((zval *)oldPtr)->refcount__gc != watch->addr.zv->refcount__gc || ((zval *)oldPtr)->is_ref__gc != watch->addr.zv->is_ref__gc; + + if (removed || show_value) { + phpdbg_write("Old value: "); + if ((Z_TYPE_P((zval *)oldPtr) == IS_ARRAY || Z_TYPE_P((zval *)oldPtr) == IS_OBJECT) && removed) { + phpdbg_writeln("Value inaccessible, HashTable already destroyed"); + } else { + zend_print_flat_zval_r((zval *)oldPtr TSRMLS_CC); + phpdbg_writeln(""); + } + } + if (PHPDBG_G(flags) & PHPDBG_SHOW_REFCOUNTS && (removed || show_ref)) { + phpdbg_writeln("Old refcount: %d; Old is_ref: %d", ((zval *)oldPtr)->refcount__gc, ((zval *)oldPtr)->is_ref__gc); + } + + /* check if zval was removed */ + if (removed) { + phpdbg_notice("Watchpoint %s was unset, removing watchpoint", watch->str); + zend_hash_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len); + + reenable = 0; + + if (Z_TYPE_P((zval *)oldPtr) == IS_ARRAY || Z_TYPE_P((zval *)oldPtr) == IS_OBJECT) { + goto remove_ht_watch; + } + + break; + } + + if (show_value) { + phpdbg_write("New value: "); + zend_print_flat_zval_r(watch->addr.zv TSRMLS_CC); + phpdbg_writeln(""); + } + if (PHPDBG_G(flags) & PHPDBG_SHOW_REFCOUNTS && show_ref) { + phpdbg_writeln("New refcount: %d; New is_ref: %d", watch->addr.zv->refcount__gc, watch->addr.zv->is_ref__gc); + } + + if ((Z_TYPE_P(watch->addr.zv) == IS_ARRAY && Z_ARRVAL_P(watch->addr.zv) != Z_ARRVAL_P((zval *)oldPtr)) || (Z_TYPE_P(watch->addr.zv) != IS_OBJECT && Z_OBJ_HANDLE_P(watch->addr.zv) == Z_OBJ_HANDLE_P((zval *)oldPtr))) { + /* add new watchpoints if necessary */ + if (watch->flags & PHPDBG_WATCH_RECURSIVE) { + phpdbg_create_recursive_watchpoint(watch TSRMLS_CC); + } + } + + if ((Z_TYPE_P((zval *)oldPtr) != IS_ARRAY || Z_ARRVAL_P(watch->addr.zv) == Z_ARRVAL_P((zval *)oldPtr)) && (Z_TYPE_P((zval *)oldPtr) != IS_OBJECT || Z_OBJ_HANDLE_P(watch->addr.zv) == Z_OBJ_HANDLE_P((zval *)oldPtr))) { + break; + } + +remove_ht_watch: + if ((htresult = phpdbg_btree_find(&PHPDBG_G(watchpoint_tree), (zend_ulong)Z_ARRVAL_P((zval *)oldPtr)))) { + htwatch = htresult->ptr; + zend_hash_del(&PHPDBG_G(watchpoints), htwatch->str, htwatch->str_len); + } + + break; + } + case WATCH_ON_HASHTABLE: + +#ifdef ZEND_DEBUG + if (watch->addr.ht->inconsistent) { + phpdbg_notice("Watchpoint %s was unset, removing watchpoint", watch->str); + zend_hash_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len); + + reenable = 0; + + break; + } +#endif + + elementDiff = zend_hash_num_elements((HashTable *)oldPtr) - zend_hash_num_elements(watch->addr.ht); + if (elementDiff) { + if (elementDiff > 0) { + phpdbg_writeln("%d elements were removed from the array", elementDiff); + } else { + phpdbg_writeln("%d elements were added to the array", -elementDiff); + + /* add new watchpoints if necessary */ + if (watch->flags & PHPDBG_WATCH_RECURSIVE) { + phpdbg_create_recursive_watchpoint(watch TSRMLS_CC); + } + } + } + if (((HashTable *)oldPtr)->pInternalPointer != watch->addr.ht->pInternalPointer) { + phpdbg_writeln("Internal pointer of array was changed"); + } + break; + } + } + + dump->reenable_writing = dump->reenable_writing | reenable; + } +} + +int phpdbg_print_changed_zvals(TSRMLS_D) { + zend_llist_position pos; + phpdbg_watch_memdump **dump; + int ret; + + if (zend_llist_count(&PHPDBG_G(watchlist_mem)) == 0) { + return FAILURE; + } + + dump = (phpdbg_watch_memdump **)zend_llist_get_last_ex(&PHPDBG_G(watchlist_mem), &pos); + + do { + phpdbg_print_changed_zval(*dump TSRMLS_CC); + } while ((dump = (phpdbg_watch_memdump **)zend_llist_get_prev_ex(&PHPDBG_G(watchlist_mem), &pos))); + + zend_llist_clean(&PHPDBG_G(watchlist_mem)); + + ret = PHPDBG_G(watchpoint_hit)?SUCCESS:FAILURE; + PHPDBG_G(watchpoint_hit) = 0; + + return ret; +} + +void phpdbg_list_watchpoints(TSRMLS_D) { + HashPosition position; + phpdbg_watchpoint_t **watch; + + for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(watchpoints), &position); + zend_hash_get_current_data_ex(&PHPDBG_G(watchpoints), (void**) &watch, &position) == SUCCESS; + zend_hash_move_forward_ex(&PHPDBG_G(watchpoints), &position)) { + phpdbg_writeln("%.*s", (int)(*watch)->str_len, (*watch)->str); + } +} + +void phpdbg_watch_efree(void *ptr) { + TSRMLS_FETCH(); + phpdbg_btree_result *result = phpdbg_btree_find_closest(&PHPDBG_G(watchpoint_tree), (zend_ulong)ptr); + + if (result) { + phpdbg_watchpoint_t *watch = result->ptr; + + if ((size_t)watch->addr.ptr + watch->size > (size_t)ptr) { + zend_hash_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len); + } + } + + PHPDBG_G(original_free_function)(ptr); +} diff --git a/phpdbg_watch.h b/phpdbg_watch.h new file mode 100644 index 00000000000..d00bcff77e5 --- /dev/null +++ b/phpdbg_watch.h @@ -0,0 +1,112 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHPDBG_WATCH_H +#define PHPDBG_WATCH_H + +#include "TSRM.h" +#include "phpdbg_cmd.h" + +#ifdef _WIN32 +# include "phpdbg_win.h" +#endif + +#define PHPDBG_WATCH(name) PHPDBG_COMMAND(watch_##name) + +/** + * Printer Forward Declarations + */ +PHPDBG_WATCH(array); +PHPDBG_WATCH(delete); +PHPDBG_WATCH(recursive); + +/** + * Commands + */ + +static const phpdbg_command_t phpdbg_watch_commands[] = { + PHPDBG_COMMAND_D_EX(array, "create watchpoint on an array", 'a', watch_array, NULL, "s"), + PHPDBG_COMMAND_D_EX(delete, "delete watchpoint", 'd', watch_delete, NULL, "s"), + PHPDBG_COMMAND_D_EX(recursive, "create recursive watchpoints", 'r', watch_recursive, NULL, "s"), + PHPDBG_END_COMMAND +}; + +/* Watchpoint functions/typedefs */ + +typedef enum { + WATCH_ON_ZVAL, + WATCH_ON_HASHTABLE, +} phpdbg_watchtype; + + +#define PHPDBG_WATCH_SIMPLE 0x0 +#define PHPDBG_WATCH_RECURSIVE 0x1 + +typedef struct _phpdbg_watchpoint_t phpdbg_watchpoint_t; + +struct _phpdbg_watchpoint_t { + phpdbg_watchpoint_t *parent; + HashTable *parent_container; + char *name_in_parent; + size_t name_in_parent_len; + char *str; + size_t str_len; + union { + zval *zv; + HashTable *ht; + void *ptr; + } addr; + size_t size; + phpdbg_watchtype type; + char flags; +}; + +void phpdbg_setup_watchpoints(TSRMLS_D); + +#ifndef _WIN32 +int phpdbg_watchpoint_segfault_handler(siginfo_t *info, void *context TSRMLS_DC); +#else +int phpdbg_watchpoint_segfault_handler(void *addr TSRMLS_DC); +#endif + +void phpdbg_create_addr_watchpoint(void *addr, size_t size, phpdbg_watchpoint_t *watch); +void phpdbg_create_zval_watchpoint(zval *zv, phpdbg_watchpoint_t *watch); + +int phpdbg_delete_var_watchpoint(char *input, size_t len TSRMLS_DC); +int phpdbg_create_var_watchpoint(char *input, size_t len TSRMLS_DC); + +int phpdbg_print_changed_zvals(TSRMLS_D); + +void phpdbg_list_watchpoints(TSRMLS_D); + +void phpdbg_watch_efree(void *ptr); + + +static long phpdbg_pagesize; + +static zend_always_inline void *phpdbg_get_page_boundary(void *addr) { + return (void *)((size_t)addr & ~(phpdbg_pagesize - 1)); +} + +static zend_always_inline size_t phpdbg_get_total_page_size(void *addr, size_t size) { + return (size_t)phpdbg_get_page_boundary((void *)((size_t)addr + size - 1)) - (size_t)phpdbg_get_page_boundary(addr) + phpdbg_pagesize; +} + +#endif diff --git a/phpdbg_win.c b/phpdbg_win.c new file mode 100644 index 00000000000..b0cbdf267a1 --- /dev/null +++ b/phpdbg_win.c @@ -0,0 +1,42 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#include "zend.h" +#include "phpdbg.h" + +int mprotect(void *addr, size_t size, int protection) { + int var; + return (int)VirtualProtect(addr, size, protection == (PROT_READ | PROT_WRITE) ? PAGE_READWRITE : PAGE_READONLY, &var); +} + +int phpdbg_exception_handler_win32(EXCEPTION_POINTERS *xp) { + EXCEPTION_RECORD *xr = xp->ExceptionRecord; + CONTEXT *xc = xp->ContextRecord; + + if(xr->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) { + TSRMLS_FETCH(); + + if (phpdbg_watchpoint_segfault_handler((void *)xr->ExceptionInformation[1] TSRMLS_CC) == SUCCESS) { + return EXCEPTION_CONTINUE_EXECUTION; + } + } + + return EXCEPTION_CONTINUE_SEARCH; +} diff --git a/phpdbg_win.h b/phpdbg_win.h new file mode 100644 index 00000000000..68c30527907 --- /dev/null +++ b/phpdbg_win.h @@ -0,0 +1,37 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHPDBG_WIN_H +#define PHPDBG_WIN_H + +#include "winbase.h" +#include "windows.h" +#include "excpt.h" + +#define PROT_READ 1 +#define PROT_WRITE 2 + +int mprotect(void *addr, size_t size, int protection); + +void phpdbg_win_set_mm_heap(zend_mm_heap *heap); + +int phpdbg_exception_handler_win32(EXCEPTION_POINTERS *xp); + +#endif \ No newline at end of file diff --git a/test.php b/test.php index 5fdbcbe1a45..d93c81a89a4 100644 --- a/test.php +++ b/test.php @@ -6,11 +6,16 @@ if (isset($include)) { $stdout = fopen("php://stdout", "w+"); class phpdbg { - public function isGreat($greeting = null) { - printf( - "%s: %s\n", __METHOD__, $greeting); - return $this; - } + private $sprintf = "%s: %s\n"; + + public function isGreat($greeting = null) { + printf($this->sprintf, __METHOD__, $greeting); + return $this; + } +} + +function mine() { + var_dump(func_get_args()); } function test($x, $y = 0) { @@ -49,3 +54,34 @@ function phpdbg_test_ob() echo 'End'; echo $b; } + +$array = [ + 1, + 2, + [3, 4], + [5, 6], +]; + +$array[] = 7; + +array_walk($array, function (&$item) { + if (is_array($item)) + $item[0] += 2; + else + $item -= 1; +}); + +class testClass { + public $a = 2; + protected $b = [1, 3]; + private $c = 7; +} + +$obj = new testClass; + +$test = $obj->a; + +$obj->a += 2; +$test -= 2; + +unset($obj); From 91b599f4a3d525ce75e43a630f150d11bfdde08e Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 24 Apr 2014 11:05:52 +0200 Subject: [PATCH 023/398] Merge remote-tracking branch 'phpdbg/master' into PHP-5.6 --- .gitignore | 2 - config.w32 | 4 +- phpdbg_lexer.c | 8 +- phpdbg_lexer.l | 8 +- phpdbg_parser.c | 1885 +++++++++++++++++++++++++++++++++++++++++++++++ phpdbg_parser.h | 126 ++++ phpdbg_watch.c | 10 +- 7 files changed, 2026 insertions(+), 17 deletions(-) create mode 100644 phpdbg_parser.c create mode 100644 phpdbg_parser.h diff --git a/.gitignore b/.gitignore index af445861acd..5506a2652d0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,3 @@ phpdbg *.lo *.o build -phpdbg_parser.c -phpdbg_parser.h diff --git a/config.w32 b/config.w32 index fcc2b61a87e..33a7b46d4f6 100644 --- a/config.w32 +++ b/config.w32 @@ -1,7 +1,7 @@ ARG_ENABLE('phpdbg', 'Build phpdbg', 'no'); ARG_ENABLE('phpdbgs', 'Build phpdbg shared', 'no'); -PHPDBG_SOURCES='phpdbg.c phpdbg_prompt.c phpdbg_cmd.c phpdbg_info.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_win.c phpdbg_btree.c'; +PHPDBG_SOURCES='phpdbg.c phpdbg_prompt.c phpdbg_cmd.c phpdbg_info.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_win.c phpdbg_btree.c phpdbg_parser.c phpdbg_lexer.c'; PHPDBG_DLL='php' + PHP_VERSION + 'phpdbg.dll'; PHPDBG_EXE='phpdbg.exe'; @@ -9,10 +9,12 @@ if (PHP_PHPDBG == "yes") { SAPI('phpdbg', PHPDBG_SOURCES, PHPDBG_EXE); ADD_FLAG("LIBS_PHPDBG", "ws2_32.lib user32.lib"); DEFINE("CFLAGS", configure_subst.item("CFLAGS") + " /EHa"); + ADD_FLAG("CFLAGS_PHPDBG", "/D YY_NO_UNISTD_H"); } if (PHP_PHPDBGS == "yes") { SAPI('phpdbgs', PHPDBG_SOURCES, PHPDBG_DLL, '/D PHP_PHPDBG_EXPORTS /I win32'); ADD_FLAG("LIBS_PHPDBGS", "ws2_32.lib user32.lib"); DEFINE("CFLAGS", configure_subst.item("CFLAGS") + " /EHa"); + ADD_FLAG("CFLAGS_PHPDBG", "/D YY_NO_UNISTD_H"); } diff --git a/phpdbg_lexer.c b/phpdbg_lexer.c index c289004b981..94a4ba9766a 100644 --- a/phpdbg_lexer.c +++ b/phpdbg_lexer.c @@ -1026,7 +1026,7 @@ YY_RULE_SETUP #line 78 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" { phpdbg_init_param(yylval, STR_PARAM); - yylval->str = strndup(yytext, yyleng); + yylval->str = zend_strndup(yytext, yyleng); yylval->len = yyleng; return T_PROTO; } @@ -1087,7 +1087,7 @@ YY_RULE_SETUP #line 108 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" { phpdbg_init_param(yylval, OP_PARAM); - yylval->str = strndup(yytext, yyleng); + yylval->str = zend_strndup(yytext, yyleng); yylval->len = yyleng; return T_OPCODE; } @@ -1097,7 +1097,7 @@ YY_RULE_SETUP #line 114 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" { phpdbg_init_param(yylval, STR_PARAM); - yylval->str = strndup(yytext, yyleng); + yylval->str = zend_strndup(yytext, yyleng); yylval->len = yyleng; return T_ID; } @@ -1108,7 +1108,7 @@ YY_RULE_SETUP #line 122 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" { phpdbg_init_param(yylval, STR_PARAM); - yylval->str = strndup(yytext, yyleng); + yylval->str = zend_strndup(yytext, yyleng); yylval->len = yyleng; BEGIN(INITIAL); return T_INPUT; diff --git a/phpdbg_lexer.l b/phpdbg_lexer.l index ad5edd9f8f9..b3536feab84 100644 --- a/phpdbg_lexer.l +++ b/phpdbg_lexer.l @@ -77,7 +77,7 @@ INPUT [^\n]+ { {ID}[:]{1}[//]{2} { phpdbg_init_param(yylval, STR_PARAM); - yylval->str = strndup(yytext, yyleng); + yylval->str = zend_strndup(yytext, yyleng); yylval->len = yyleng; return T_PROTO; } @@ -107,13 +107,13 @@ INPUT [^\n]+ } {OPCODE} { phpdbg_init_param(yylval, OP_PARAM); - yylval->str = strndup(yytext, yyleng); + yylval->str = zend_strndup(yytext, yyleng); yylval->len = yyleng; return T_OPCODE; } {ID} { phpdbg_init_param(yylval, STR_PARAM); - yylval->str = strndup(yytext, yyleng); + yylval->str = zend_strndup(yytext, yyleng); yylval->len = yyleng; return T_ID; } @@ -121,7 +121,7 @@ INPUT [^\n]+ {INPUT} { phpdbg_init_param(yylval, STR_PARAM); - yylval->str = strndup(yytext, yyleng); + yylval->str = zend_strndup(yytext, yyleng); yylval->len = yyleng; BEGIN(INITIAL); return T_INPUT; diff --git a/phpdbg_parser.c b/phpdbg_parser.c new file mode 100644 index 00000000000..79af58f8c9a --- /dev/null +++ b/phpdbg_parser.c @@ -0,0 +1,1885 @@ +/* A Bison parser, made by GNU Bison 2.7. */ + +/* Bison implementation for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.7" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + + + + +/* Copy the first part of user declarations. */ +/* Line 371 of yacc.c */ +#line 2 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + + +/* + * phpdbg_parser.y + * (from php-src root) + * flex sapi/phpdbg/dev/phpdbg_lexer.l + * bison sapi/phpdbg/dev/phpdbg_parser.y + */ + +#include "phpdbg.h" +#include "phpdbg_cmd.h" +#include "phpdbg_utils.h" +#include "phpdbg_cmd.h" +#include "phpdbg_prompt.h" + +#define YYSTYPE phpdbg_param_t + +#include "phpdbg_parser.h" +#include "phpdbg_lexer.h" + +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); + +int yyerror(phpdbg_param_t *stack, yyscan_t scanner, const char *msg) { + TSRMLS_FETCH(); + phpdbg_error("Parse Error: %s", msg); + { + const phpdbg_param_t *top = stack; + + while (top) { + phpdbg_param_debug( + top, "--> "); + top = top->next; + } + } + return 0; +} + +/* Line 371 of yacc.c */ +#line 106 "sapi/phpdbg/phpdbg_parser.c" + +# ifndef YY_NULL +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULL nullptr +# else +# define YY_NULL 0 +# endif +# endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 1 +#endif + +/* In a future release of Bison, this section will be replaced + by #include "phpdbg_parser.h". */ +#ifndef YY_YY_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED +# define YY_YY_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int yydebug; +#endif +/* "%code requires" blocks. */ +/* Line 387 of yacc.c */ +#line 40 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + +#include "phpdbg.h" +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + + +/* Line 387 of yacc.c */ +#line 147 "sapi/phpdbg/phpdbg_parser.c" + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + T_EVAL = 258, + T_RUN = 259, + T_SHELL = 260, + T_IF = 261, + T_TRUTHY = 262, + T_FALSY = 263, + T_STRING = 264, + T_COLON = 265, + T_DCOLON = 266, + T_POUND = 267, + T_PROTO = 268, + T_DIGITS = 269, + T_LITERAL = 270, + T_ADDR = 271, + T_OPCODE = 272, + T_ID = 273, + T_INPUT = 274, + T_UNEXPECTED = 275 + }; +#endif +/* Tokens. */ +#define T_EVAL 258 +#define T_RUN 259 +#define T_SHELL 260 +#define T_IF 261 +#define T_TRUTHY 262 +#define T_FALSY 263 +#define T_STRING 264 +#define T_COLON 265 +#define T_DCOLON 266 +#define T_POUND 267 +#define T_PROTO 268 +#define T_DIGITS 269 +#define T_LITERAL 270 +#define T_ADDR 271 +#define T_OPCODE 272 +#define T_ID 273 +#define T_INPUT 274 +#define T_UNEXPECTED 275 + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +#endif + + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (phpdbg_param_t *stack, yyscan_t scanner); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + +#endif /* !YY_YY_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED */ + +/* Copy the second part of user declarations. */ + +/* Line 390 of yacc.c */ +#line 224 "sapi/phpdbg/phpdbg_parser.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) +# endif +# endif +# ifndef YY_ +# define YY_(Msgid) Msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(E) ((void) (E)) +#else +# define YYUSE(E) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(N) (N) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int yyi) +#else +static int +YYID (yyi) + int yyi; +#endif +{ + return yyi; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ + /* Use EXIT_SUCCESS as a witness for stdlib.h. */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +# define YYCOPY_NEEDED 1 + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +#if defined YYCOPY_NEEDED && YYCOPY_NEEDED +/* Copy COUNT objects from SRC to DST. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(Dst, Src, Count) \ + __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) +# else +# define YYCOPY(Dst, Src, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (Dst)[yyi] = (Src)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif +#endif /* !YYCOPY_NEEDED */ + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 24 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 33 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 21 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 4 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 24 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 37 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 275 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 5, 6, 8, 11, 15, 20, 25, + 31, 35, 41, 45, 48, 51, 54, 56, 59, 61, + 63, 65, 67, 69, 71 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 22, 0, -1, 23, -1, -1, 24, -1, 23, 24, + -1, 18, 10, 14, -1, 18, 10, 12, 14, -1, + 13, 18, 10, 14, -1, 13, 18, 10, 12, 14, + -1, 18, 11, 18, -1, 18, 11, 18, 12, 14, + -1, 18, 12, 14, -1, 6, 19, -1, 3, 19, + -1, 5, 19, -1, 4, -1, 4, 19, -1, 17, + -1, 16, -1, 15, -1, 7, -1, 8, -1, 14, + -1, 18, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 76, 76, 77, 81, 82, 86, 91, 96, 107, + 118, 123, 129, 135, 140, 145, 150, 154, 159, 160, + 161, 162, 163, 164, 165 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || 1 +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "\"eval\"", "\"run\"", "\"shell\"", + "\"if (condition)\"", "\"truthy (true, on, yes or enabled)\"", + "\"falsy (false, off, no or disabled)\"", + "\"string (some input, perhaps)\"", "\": (colon)\"", + "\":: (double colon)\"", "\"# (pound sign)\"", "\"protocol (file://)\"", + "\"digits (numbers)\"", "\"literal (string)\"", "\"address\"", + "\"opcode\"", "\"identifier (command or function name)\"", + "\"input (input string or data)\"", "\"input\"", "$accept", "input", + "parameters", "parameter", YY_NULL +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 21, 22, 22, 23, 23, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 0, 1, 2, 3, 4, 4, 5, + 3, 5, 3, 2, 2, 2, 1, 2, 1, 1, + 1, 1, 1, 1, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 3, 0, 16, 0, 0, 21, 22, 0, 23, 20, + 19, 18, 24, 0, 2, 4, 14, 17, 15, 13, + 0, 0, 0, 0, 1, 5, 0, 0, 6, 10, + 12, 0, 8, 7, 0, 9, 11 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 13, 14, 15 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -11 +static const yytype_int8 yypact[] = +{ + -3, -10, 1, 2, 3, -11, -11, 6, -11, -11, + -11, -11, -4, 23, -3, -11, -11, -11, -11, -11, + 15, 4, 8, 13, -11, -11, 5, 14, -11, 17, + -11, 16, -11, -11, 18, -11, -11 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -11, -11, -11, 19 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_uint8 yytable[] = +{ + 1, 2, 3, 4, 5, 6, 21, 22, 23, 16, + 7, 8, 9, 10, 11, 12, 27, 31, 28, 32, + 17, 18, 19, 24, 20, 26, 29, 30, 33, 34, + 35, 0, 36, 25 +}; + +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-11))) + +#define yytable_value_is_error(Yytable_value) \ + YYID (0) + +static const yytype_int8 yycheck[] = +{ + 3, 4, 5, 6, 7, 8, 10, 11, 12, 19, + 13, 14, 15, 16, 17, 18, 12, 12, 14, 14, + 19, 19, 19, 0, 18, 10, 18, 14, 14, 12, + 14, -1, 14, 14 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 3, 4, 5, 6, 7, 8, 13, 14, 15, + 16, 17, 18, 22, 23, 24, 19, 19, 19, 19, + 18, 10, 11, 12, 0, 24, 10, 12, 14, 18, + 14, 12, 14, 14, 12, 14, 14 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. However, + YYFAIL appears to be in use. Nevertheless, it is formally deprecated + in Bison 2.4.2's NEWS entry, where a plan to phase it out is + discussed. */ + +#define YYFAIL goto yyerrlab +#if defined YYFAIL + /* This is here to suppress warnings from the GCC cpp's + -Wunused-macros. Normally we don't worry about that warning, but + some users do, and we want to make it easy for users to remove + YYFAIL uses, which will produce warnings from Bison 2.5. */ +#endif + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (stack, scanner, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + +/* Error token number */ +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* This macro is provided for backward compatibility. */ +#ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, scanner) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, stack, scanner); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, phpdbg_param_t *stack, yyscan_t scanner) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, stack, scanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + phpdbg_param_t *stack; + yyscan_t scanner; +#endif +{ + FILE *yyo = yyoutput; + YYUSE (yyo); + if (!yyvaluep) + return; + YYUSE (stack); + YYUSE (scanner); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, phpdbg_param_t *stack, yyscan_t scanner) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, stack, scanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + phpdbg_param_t *stack; + yyscan_t scanner; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, stack, scanner); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +#else +static void +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, phpdbg_param_t *stack, yyscan_t scanner) +#else +static void +yy_reduce_print (yyvsp, yyrule, stack, scanner) + YYSTYPE *yyvsp; + int yyrule; + phpdbg_param_t *stack; + yyscan_t scanner; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , stack, scanner); + YYFPRINTF (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, stack, scanner); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message + about the unexpected token YYTOKEN for the state stack whose top is + YYSSP. + + Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is + not large enough to hold the message. In that case, also set + *YYMSG_ALLOC to the required number of bytes. Return 2 if the + required number of bytes is too large to store. */ +static int +yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, + yytype_int16 *yyssp, int yytoken) +{ + YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); + YYSIZE_T yysize = yysize0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + /* Internationalized format string. */ + const char *yyformat = YY_NULL; + /* Arguments of yyformat. */ + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + /* Number of reported tokens (one for the "unexpected", one per + "expected"). */ + int yycount = 0; + + /* There are many possibilities here to consider: + - Assume YYFAIL is not used. It's too flawed to consider. See + + for details. YYERROR is fine as it does not invoke this + function. + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yychar) is if + this state is a consistent state with a default action. Thus, + detecting the absence of a lookahead is sufficient to determine + that there is no unexpected or expected token to report. In that + case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is a + consistent state with a default action. There might have been a + previous inconsistent state, consistent state with a non-default + action, or user semantic action that manipulated yychar. + - Of course, the expected token list depends on states to have + correct lookahead information, and it depends on the parser not + to perform extra reductions after fetching a lookahead from the + scanner and before detecting a syntax error. Thus, state merging + (from LALR or IELR) and default reductions corrupt the expected + token list. However, the list is correct for canonical LR with + one exception: it will still contain any token that will not be + accepted due to an error action in a later state. + */ + if (yytoken != YYEMPTY) + { + int yyn = yypact[*yyssp]; + yyarg[yycount++] = yytname[yytoken]; + if (!yypact_value_is_default (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yyx; + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR + && !yytable_value_is_error (yytable[yyx + yyn])) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + break; + } + yyarg[yycount++] = yytname[yyx]; + { + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + } + } + } + + switch (yycount) + { +# define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +# undef YYCASE_ + } + + { + YYSIZE_T yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + + if (*yymsg_alloc < yysize) + { + *yymsg_alloc = 2 * yysize; + if (! (yysize <= *yymsg_alloc + && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) + *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; + return 1; + } + + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + { + char *yyp = *yymsg; + int yyi = 0; + while ((*yyp = *yyformat) != '\0') + if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyformat += 2; + } + else + { + yyp++; + yyformat++; + } + } + return 0; +} +#endif /* YYERROR_VERBOSE */ + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, phpdbg_param_t *stack, yyscan_t scanner) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, stack, scanner) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + phpdbg_param_t *stack; + yyscan_t scanner; +#endif +{ + YYUSE (yyvaluep); + YYUSE (stack); + YYUSE (scanner); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (phpdbg_param_t *stack, yyscan_t scanner) +#else +int +yyparse (stack, scanner) + phpdbg_param_t *stack; + yyscan_t scanner; +#endif +#endif +{ +/* The lookahead symbol. */ +int yychar; + + +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") +#else +/* Default value used for initialization, for pacifying older GCCs + or non-GCC compilers. */ +static YYSTYPE yyval_default; +# define YY_INITIAL_VALUE(Value) = Value +#endif +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ +#endif + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); + + /* Number of syntax errors so far. */ + int yynerrs; + + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + + Refer to the stacks through separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYSIZE_T yystacksize; + + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + yyssp = yyss = yyssa; + yyvsp = yyvs = yyvsa; + yystacksize = YYINITDEPTH; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + if (yystate == YYFINAL) + YYACCEPT; + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to lookahead token. */ + yyn = yypact[yystate]; + if (yypact_value_is_default (yyn)) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yytable_value_is_error (yyn)) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + + yystate = yyn; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 4: +/* Line 1792 of yacc.c */ +#line 81 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + { phpdbg_stack_push(stack, &(yyvsp[(1) - (1)])); } + break; + + case 5: +/* Line 1792 of yacc.c */ +#line 82 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + { phpdbg_stack_push(stack, &(yyvsp[(2) - (2)])); } + break; + + case 6: +/* Line 1792 of yacc.c */ +#line 86 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + { + (yyval).type = FILE_PARAM; + (yyval).file.name = (yyvsp[(2) - (3)]).str; + (yyval).file.line = (yyvsp[(3) - (3)]).num; + } + break; + + case 7: +/* Line 1792 of yacc.c */ +#line 91 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + { + (yyval).type = NUMERIC_FILE_PARAM; + (yyval).file.name = (yyvsp[(1) - (4)]).str; + (yyval).file.line = (yyvsp[(4) - (4)]).num; + } + break; + + case 8: +/* Line 1792 of yacc.c */ +#line 96 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + { + (yyval).type = FILE_PARAM; + (yyval).file.name = malloc((yyvsp[(1) - (4)]).len + + (yyvsp[(2) - (4)]).len + 1); + if ((yyval).file.name) { + memcpy(&(yyval).file.name[0], (yyvsp[(1) - (4)]).str, (yyvsp[(1) - (4)]).len); + memcpy(&(yyval).file.name[(yyvsp[(1) - (4)]).len], (yyvsp[(2) - (4)]).str, (yyvsp[(2) - (4)]).len); + (yyval).file.name[(yyvsp[(1) - (4)]).len + (yyvsp[(2) - (4)]).len] = '\0'; + } + (yyval).file.line = (yyvsp[(4) - (4)]).num; + } + break; + + case 9: +/* Line 1792 of yacc.c */ +#line 107 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + { + (yyval).type = NUMERIC_FILE_PARAM; + (yyval).file.name = malloc((yyvsp[(1) - (5)]).len + + (yyvsp[(2) - (5)]).len + 1); + if ((yyval).file.name) { + memcpy(&(yyval).file.name[0], (yyvsp[(1) - (5)]).str, (yyvsp[(1) - (5)]).len); + memcpy(&(yyval).file.name[(yyvsp[(1) - (5)]).len], (yyvsp[(2) - (5)]).str, (yyvsp[(2) - (5)]).len); + (yyval).file.name[(yyvsp[(1) - (5)]).len + (yyvsp[(2) - (5)]).len] = '\0'; + } + (yyval).file.line = (yyvsp[(5) - (5)]).num; + } + break; + + case 10: +/* Line 1792 of yacc.c */ +#line 118 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + { + (yyval).type = METHOD_PARAM; + (yyval).method.class = (yyvsp[(1) - (3)]).str; + (yyval).method.name = (yyvsp[(3) - (3)]).str; + } + break; + + case 11: +/* Line 1792 of yacc.c */ +#line 123 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + { + (yyval).type = NUMERIC_METHOD_PARAM; + (yyval).method.class = (yyvsp[(1) - (5)]).str; + (yyval).method.name = (yyvsp[(3) - (5)]).str; + (yyval).num = (yyvsp[(5) - (5)]).num; + } + break; + + case 12: +/* Line 1792 of yacc.c */ +#line 129 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + { + (yyval).type = NUMERIC_FUNCTION_PARAM; + (yyval).str = (yyvsp[(1) - (3)]).str; + (yyval).len = (yyvsp[(1) - (3)]).len; + (yyval).num = (yyvsp[(3) - (3)]).num; + } + break; + + case 13: +/* Line 1792 of yacc.c */ +#line 135 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + { + (yyval).type = COND_PARAM; + (yyval).str = (yyvsp[(2) - (2)]).str; + (yyval).len = (yyvsp[(2) - (2)]).len; + } + break; + + case 14: +/* Line 1792 of yacc.c */ +#line 140 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + { + (yyval).type = EVAL_PARAM; + (yyval).str = (yyvsp[(2) - (2)]).str; + (yyval).len = (yyvsp[(2) - (2)]).len; + } + break; + + case 15: +/* Line 1792 of yacc.c */ +#line 145 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + { + (yyval).type = SHELL_PARAM; + (yyval).str = (yyvsp[(2) - (2)]).str; + (yyval).len = (yyvsp[(2) - (2)]).len; + } + break; + + case 16: +/* Line 1792 of yacc.c */ +#line 150 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + { + (yyval).type = RUN_PARAM; + (yyval).len = 0; + } + break; + + case 17: +/* Line 1792 of yacc.c */ +#line 154 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + { + (yyval).type = RUN_PARAM; + (yyval).str = (yyvsp[(2) - (2)]).str; + (yyval).len = (yyvsp[(2) - (2)]).len; + } + break; + + case 18: +/* Line 1792 of yacc.c */ +#line 159 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 19: +/* Line 1792 of yacc.c */ +#line 160 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 20: +/* Line 1792 of yacc.c */ +#line 161 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 21: +/* Line 1792 of yacc.c */ +#line 162 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 22: +/* Line 1792 of yacc.c */ +#line 163 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 23: +/* Line 1792 of yacc.c */ +#line 164 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 24: +/* Line 1792 of yacc.c */ +#line 165 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + +/* Line 1792 of yacc.c */ +#line 1653 "sapi/phpdbg/phpdbg_parser.c" + default: break; + } + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action invokes + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an + incorrect destructor might then be invoked immediately. In the + case of YYERROR or YYBACKUP, subsequent parser actions might lead + to an incorrect destructor call or verbose syntax error message + before the lookahead is translated. */ + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); + + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (stack, scanner, YY_("syntax error")); +#else +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ + yyssp, yytoken) + { + char const *yymsgp = YY_("syntax error"); + int yysyntax_error_status; + yysyntax_error_status = YYSYNTAX_ERROR; + if (yysyntax_error_status == 0) + yymsgp = yymsg; + else if (yysyntax_error_status == 1) + { + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + if (!yymsg) + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + yysyntax_error_status = 2; + } + else + { + yysyntax_error_status = YYSYNTAX_ERROR; + yymsgp = yymsg; + } + } + yyerror (stack, scanner, yymsgp); + if (yysyntax_error_status == 2) + goto yyexhaustedlab; + } +# undef YYSYNTAX_ERROR +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, stack, scanner); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (!yypact_value_is_default (yyn)) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, stack, scanner); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#if !defined yyoverflow || YYERROR_VERBOSE +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (stack, scanner, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEMPTY) + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, stack, scanner); + } + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, stack, scanner); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +/* Line 2055 of yacc.c */ +#line 168 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + diff --git a/phpdbg_parser.h b/phpdbg_parser.h new file mode 100644 index 00000000000..6acb8963c9e --- /dev/null +++ b/phpdbg_parser.h @@ -0,0 +1,126 @@ +/* A Bison parser, made by GNU Bison 2.7. */ + +/* Bison interface for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +#ifndef YY_YY_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED +# define YY_YY_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int yydebug; +#endif +/* "%code requires" blocks. */ +/* Line 2058 of yacc.c */ +#line 40 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + +#include "phpdbg.h" +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + + +/* Line 2058 of yacc.c */ +#line 55 "sapi/phpdbg/phpdbg_parser.h" + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + T_EVAL = 258, + T_RUN = 259, + T_SHELL = 260, + T_IF = 261, + T_TRUTHY = 262, + T_FALSY = 263, + T_STRING = 264, + T_COLON = 265, + T_DCOLON = 266, + T_POUND = 267, + T_PROTO = 268, + T_DIGITS = 269, + T_LITERAL = 270, + T_ADDR = 271, + T_OPCODE = 272, + T_ID = 273, + T_INPUT = 274, + T_UNEXPECTED = 275 + }; +#endif +/* Tokens. */ +#define T_EVAL 258 +#define T_RUN 259 +#define T_SHELL 260 +#define T_IF 261 +#define T_TRUTHY 262 +#define T_FALSY 263 +#define T_STRING 264 +#define T_COLON 265 +#define T_DCOLON 266 +#define T_POUND 267 +#define T_PROTO 268 +#define T_DIGITS 269 +#define T_LITERAL 270 +#define T_ADDR 271 +#define T_OPCODE 272 +#define T_ID 273 +#define T_INPUT 274 +#define T_UNEXPECTED 275 + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +#endif + + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (phpdbg_param_t *stack, yyscan_t scanner); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + +#endif /* !YY_YY_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED */ diff --git a/phpdbg_watch.c b/phpdbg_watch.c index a6bf6289bf5..9ee580ca0bd 100644 --- a/phpdbg_watch.c +++ b/phpdbg_watch.c @@ -463,10 +463,9 @@ PHPDBG_WATCH(array) /* {{{ */ } /* }}} */ void phpdbg_watch_HashTable_dtor(zval **zv) { - TSRMLS_FETCH(); - phpdbg_btree_result *result; zval_ptr_dtor_wrapper(zv); + TSRMLS_FETCH(); if ((result = phpdbg_btree_find(&PHPDBG_G(watchpoint_tree), (zend_ulong)*zv))) { @@ -545,9 +544,8 @@ void phpdbg_watchpoints_clean(TSRMLS_D) { } static void phpdbg_watch_dtor(void *pDest) { - TSRMLS_FETCH(); - phpdbg_watchpoint_t *watch = *(phpdbg_watchpoint_t **)pDest; + TSRMLS_FETCH(); phpdbg_deactivate_watchpoint(watch TSRMLS_CC); phpdbg_remove_watchpoint(watch TSRMLS_CC); @@ -599,7 +597,7 @@ static void phpdbg_print_changed_zval(phpdbg_watch_memdump *dump TSRMLS_DC) { void *oldPtr = (char *)&dump->data + ((size_t)watch->addr.ptr - (size_t)dump->page); char reenable = 1; - if (watch->addr.ptr < dump->page || watch->addr.ptr + watch->size > dump->page + dump->size) { + if ((size_t)watch->addr.ptr < (size_t)dump->page || (size_t)watch->addr.ptr + watch->size > (size_t)dump->page + dump->size) { continue; } @@ -774,8 +772,8 @@ void phpdbg_list_watchpoints(TSRMLS_D) { } void phpdbg_watch_efree(void *ptr) { - TSRMLS_FETCH(); phpdbg_btree_result *result = phpdbg_btree_find_closest(&PHPDBG_G(watchpoint_tree), (zend_ulong)ptr); + TSRMLS_FETCH(); if (result) { phpdbg_watchpoint_t *watch = result->ptr; From 9a8123fabbdeea05d9b94638d09efb1440004d50 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sat, 26 Apr 2014 00:15:32 +0200 Subject: [PATCH 024/398] Merge remote-tracking branch 'phpdbg/master' into PHP-5.6 * phpdbg/master: removed /EHa as __try/__catch syntax is used anyway fix ZEND_DEBUG usage fix CFLAGS_PHPDBGS and some formatting --- config.w32 | 9 ++++----- phpdbg_watch.c | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/config.w32 b/config.w32 index 33a7b46d4f6..17e15b6ced0 100644 --- a/config.w32 +++ b/config.w32 @@ -6,15 +6,14 @@ PHPDBG_DLL='php' + PHP_VERSION + 'phpdbg.dll'; PHPDBG_EXE='phpdbg.exe'; if (PHP_PHPDBG == "yes") { - SAPI('phpdbg', PHPDBG_SOURCES, PHPDBG_EXE); - ADD_FLAG("LIBS_PHPDBG", "ws2_32.lib user32.lib"); - DEFINE("CFLAGS", configure_subst.item("CFLAGS") + " /EHa"); + SAPI('phpdbg', PHPDBG_SOURCES, PHPDBG_EXE); + ADD_FLAG("LIBS_PHPDBG", "ws2_32.lib user32.lib"); ADD_FLAG("CFLAGS_PHPDBG", "/D YY_NO_UNISTD_H"); } if (PHP_PHPDBGS == "yes") { SAPI('phpdbgs', PHPDBG_SOURCES, PHPDBG_DLL, '/D PHP_PHPDBG_EXPORTS /I win32'); ADD_FLAG("LIBS_PHPDBGS", "ws2_32.lib user32.lib"); - DEFINE("CFLAGS", configure_subst.item("CFLAGS") + " /EHa"); - ADD_FLAG("CFLAGS_PHPDBG", "/D YY_NO_UNISTD_H"); + ADD_FLAG("CFLAGS_PHPDBGS", "/D YY_NO_UNISTD_H"); } + diff --git a/phpdbg_watch.c b/phpdbg_watch.c index 9ee580ca0bd..0359b5a7deb 100644 --- a/phpdbg_watch.c +++ b/phpdbg_watch.c @@ -702,7 +702,7 @@ remove_ht_watch: } case WATCH_ON_HASHTABLE: -#ifdef ZEND_DEBUG +#if ZEND_DEBUG if (watch->addr.ht->inconsistent) { phpdbg_notice("Watchpoint %s was unset, removing watchpoint", watch->str); zend_hash_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len); From a1edc8e396f09b0bdd997d80ac778738e4c5dc83 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sun, 27 Apr 2014 18:01:26 +0200 Subject: [PATCH 025/398] Merge remote-tracking branch 'phpdbg/master' into PHP-5.6 * phpdbg/master: C89 compat --- phpdbg_watch.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/phpdbg_watch.c b/phpdbg_watch.c index 0359b5a7deb..2efbb1237c8 100644 --- a/phpdbg_watch.c +++ b/phpdbg_watch.c @@ -464,9 +464,9 @@ PHPDBG_WATCH(array) /* {{{ */ void phpdbg_watch_HashTable_dtor(zval **zv) { phpdbg_btree_result *result; - zval_ptr_dtor_wrapper(zv); TSRMLS_FETCH(); + zval_ptr_dtor_wrapper(zv); if ((result = phpdbg_btree_find(&PHPDBG_G(watchpoint_tree), (zend_ulong)*zv))) { phpdbg_watchpoint_t *watch = result->ptr; @@ -772,9 +772,11 @@ void phpdbg_list_watchpoints(TSRMLS_D) { } void phpdbg_watch_efree(void *ptr) { - phpdbg_btree_result *result = phpdbg_btree_find_closest(&PHPDBG_G(watchpoint_tree), (zend_ulong)ptr); + phpdbg_btree_result *result; TSRMLS_FETCH(); + result = phpdbg_btree_find_closest(&PHPDBG_G(watchpoint_tree), (zend_ulong)ptr); + if (result) { phpdbg_watchpoint_t *watch = result->ptr; From eae7a94fe007daf7fc575db2bd36a582c3873fbf Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Thu, 1 May 2014 11:38:08 +0200 Subject: [PATCH 026/398] Added stdion/stdout/stderr constsnts and their php:// wrappers Fixes issue #85 --- phpdbg.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/phpdbg.c b/phpdbg.c index 064e266082e..fc121839e8c 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -533,6 +533,69 @@ static inline void php_sapi_phpdbg_flush(void *context) /* {{{ */ fflush(PHPDBG_G(io)[PHPDBG_STDOUT]); } /* }}} */ +/* copied from sapi/cli/php_cli.c cli_register_file_handles */ +static void phpdbg_register_file_handles(TSRMLS_D) /* {{{ */ +{ + zval *zin, *zout, *zerr; + php_stream *s_in, *s_out, *s_err; + php_stream_context *sc_in=NULL, *sc_out=NULL, *sc_err=NULL; + zend_constant ic, oc, ec; + + MAKE_STD_ZVAL(zin); + MAKE_STD_ZVAL(zout); + MAKE_STD_ZVAL(zerr); + + s_in = php_stream_open_wrapper_ex("php://stdin", "rb", 0, NULL, sc_in); + s_out = php_stream_open_wrapper_ex("php://stdout", "wb", 0, NULL, sc_out); + s_err = php_stream_open_wrapper_ex("php://stderr", "wb", 0, NULL, sc_err); + + if (s_in==NULL || s_out==NULL || s_err==NULL) { + FREE_ZVAL(zin); + FREE_ZVAL(zout); + FREE_ZVAL(zerr); + if (s_in) php_stream_close(s_in); + if (s_out) php_stream_close(s_out); + if (s_err) php_stream_close(s_err); + return; + } + +#if PHP_DEBUG + /* do not close stdout and stderr */ + s_out->flags |= PHP_STREAM_FLAG_NO_CLOSE; + s_err->flags |= PHP_STREAM_FLAG_NO_CLOSE; +#endif + + php_stream_to_zval(s_in, zin); + php_stream_to_zval(s_out, zout); + php_stream_to_zval(s_err, zerr); + + ic.value = *zin; + ic.flags = CONST_CS; + ic.name = zend_strndup(ZEND_STRL("STDIN")); + ic.name_len = sizeof("STDIN"); + ic.module_number = 0; + zend_register_constant(&ic TSRMLS_CC); + + oc.value = *zout; + oc.flags = CONST_CS; + oc.name = zend_strndup(ZEND_STRL("STDOUT")); + oc.name_len = sizeof("STDOUT"); + oc.module_number = 0; + zend_register_constant(&oc TSRMLS_CC); + + ec.value = *zerr; + ec.flags = CONST_CS; + ec.name = zend_strndup(ZEND_STRL("STDERR")); + ec.name_len = sizeof("STDERR"); + ec.module_number = 0; + zend_register_constant(&ec TSRMLS_CC); + + FREE_ZVAL(zin); + FREE_ZVAL(zout); + FREE_ZVAL(zerr); +} +/* }}} */ + /* {{{ sapi_module_struct phpdbg_sapi_module */ static sapi_module_struct phpdbg_sapi_module = { @@ -1262,6 +1325,9 @@ phpdbg_main: /* set default prompt */ phpdbg_set_prompt(PROMPT TSRMLS_CC); + /* Make stdin, stdout and stderr accessible from PHP scripts */ + phpdbg_register_file_handles(TSRMLS_C); + if (show_banner) { /* print blurb */ phpdbg_welcome((cleaning > 0) TSRMLS_CC); From d4b5ef2e4a0676f421a64995b7114b50fb18ec9c Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sat, 3 May 2014 11:40:25 +0200 Subject: [PATCH 027/398] Merge sapi/phpdbg into PHP-5.6 --- config.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.m4 b/config.m4 index 3534d90124d..a1b2f9faa10 100644 --- a/config.m4 +++ b/config.m4 @@ -21,7 +21,7 @@ if test "$PHP_PHPDBG" != "no"; then PHP_PHPDBG_FILES="phpdbg.c phpdbg_parser.c phpdbg_lexer.c phpdbg_prompt.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_info.c phpdbg_cmd.c phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_btree.c" if test "$PHP_READLINE" != "no"; then - PHPDBG_EXTRA_LIBS="-lreadline" + PHPDBG_EXTRA_LIBS="$PHP_READLINE_LIBS" fi PHP_SUBST(PHP_PHPDBG_CFLAGS) From 3200d99763b08cf4585adb6d7cb755bbcb4ac493 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 3 Jun 2014 21:15:02 +0000 Subject: [PATCH 028/398] Merge sapi/phpdbg into PHP-5.6 --- phpdbg.c | 47 +++++++++++++++++++++++++++++++++++------------ phpdbg_watch.c | 2 +- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index fc121839e8c..0239e692b43 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -879,6 +879,32 @@ void phpdbg_signal_handler(int sig, siginfo_t *info, void *context) { } #endif +static inline zend_mm_heap *phpdbg_mm_get_heap() { + zend_mm_heap *mm_heap; + + TSRMLS_FETCH(); + + mm_heap = zend_mm_set_heap(NULL TSRMLS_CC); + zend_mm_set_heap(mm_heap TSRMLS_CC); + + return mm_heap; +} + +void *phpdbg_malloc_wrapper(size_t size) +{ + return zend_mm_alloc(phpdbg_mm_get_heap(), size); +} + +void phpdbg_free_wrapper(void *p) +{ + zend_mm_free(phpdbg_mm_get_heap(), p); +} + +void *phpdbg_realloc_wrapper(void *ptr, size_t size) +{ + return zend_mm_realloc(phpdbg_mm_get_heap(), ptr, size); +} + int main(int argc, char **argv) /* {{{ */ { sapi_module_struct *phpdbg = &phpdbg_sapi_module; @@ -1221,20 +1247,17 @@ phpdbg_main: EXCEPTION_POINTERS *xp; __try { #endif - zend_mm_heap *mm_heap = zend_mm_set_heap(NULL TSRMLS_CC); -#if ZEND_DEBUG - if (!mm_heap->use_zend_alloc) { - mm_heap->_malloc = malloc; - mm_heap->_realloc = realloc; - mm_heap->_free = free; -#endif - PHPDBG_G(original_free_function) = mm_heap->_free; - mm_heap->_free = phpdbg_watch_efree; + zend_mm_heap *mm_heap = phpdbg_mm_get_heap(); + + if (mm_heap->use_zend_alloc) { + mm_heap->_malloc = phpdbg_malloc_wrapper; + mm_heap->_realloc = phpdbg_realloc_wrapper; + mm_heap->_free = phpdbg_free_wrapper; mm_heap->use_zend_alloc = 0; -#if ZEND_DEBUG } -#endif - zend_mm_set_heap(mm_heap TSRMLS_CC); + + PHPDBG_G(original_free_function) = mm_heap->_free; + mm_heap->_free = phpdbg_watch_efree; zend_activate(TSRMLS_C); diff --git a/phpdbg_watch.c b/phpdbg_watch.c index 2efbb1237c8..e88622444bf 100644 --- a/phpdbg_watch.c +++ b/phpdbg_watch.c @@ -580,7 +580,7 @@ void phpdbg_setup_watchpoints(TSRMLS_D) { zend_llist_init(&PHPDBG_G(watchlist_mem), sizeof(void *), phpdbg_watch_mem_dtor, 1); phpdbg_btree_init(&PHPDBG_G(watchpoint_tree), sizeof(void *) * 8); phpdbg_btree_init(&PHPDBG_G(watch_HashTables), sizeof(void *) * 8); - _zend_hash_init(&PHPDBG_G(watchpoints), 8, phpdbg_watch_dtor, 0 ZEND_FILE_LINE_CC); + zend_hash_init(&PHPDBG_G(watchpoints), 8, NULL, phpdbg_watch_dtor, 0 ZEND_FILE_LINE_CC); } static void phpdbg_print_changed_zval(phpdbg_watch_memdump *dump TSRMLS_DC) { From b264783d637ee3512da1d92107297741671dbb3b Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Wed, 4 Jun 2014 02:18:39 +0200 Subject: [PATCH 029/398] Merge sapi/phpdbg into PHP-5.6 --- phpdbg.c | 6 +++--- tests/commands/0002_set.test | 2 -- tests/commands/0103_register.test | 10 +++++----- tests/commands/0106_compile.test | 1 - tests/run-tests.php | 28 ++++++++++++++++++++-------- 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index 0239e692b43..93fdbd74240 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -159,8 +159,6 @@ static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */ zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], 8, NULL, php_phpdbg_destroy_bp_condition, 0); zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], 8, NULL, NULL, 0); - phpdbg_setup_watchpoints(TSRMLS_C); - zend_hash_init(&PHPDBG_G(seek), 8, NULL, NULL, 0); zend_hash_init(&PHPDBG_G(registered), 8, NULL, php_phpdbg_destroy_registered, 0); @@ -1256,10 +1254,12 @@ phpdbg_main: mm_heap->use_zend_alloc = 0; } + zend_activate(TSRMLS_C); + PHPDBG_G(original_free_function) = mm_heap->_free; mm_heap->_free = phpdbg_watch_efree; - zend_activate(TSRMLS_C); + phpdbg_setup_watchpoints(TSRMLS_C); #if defined(ZEND_SIGNALS) && !defined(_WIN32) zend_try { diff --git a/tests/commands/0002_set.test b/tests/commands/0002_set.test index 7720f94fff6..468ac6d9ea0 100644 --- a/tests/commands/0002_set.test +++ b/tests/commands/0002_set.test @@ -9,7 +9,6 @@ # setting notice color # Failed to find breakpoint #0 # oplog disabled -# not enabled # opened oplog test.log # nothing ################################################# @@ -19,5 +18,4 @@ set color notice none set prompt promot> set break 0 set oplog -set oplog 0 set oplog test.log diff --git a/tests/commands/0103_register.test b/tests/commands/0103_register.test index 38841591caf..703a12f7713 100644 --- a/tests/commands/0103_register.test +++ b/tests/commands/0103_register.test @@ -7,15 +7,15 @@ #[Registered test_function] #array(5) { # [0]=> -# string(1) "1" +# int(1) # [1]=> -# string(1) "2" +# int(2) # [2]=> -# string(1) "3" +# int(3) # [3]=> -# string(1) "4" +# int(4) # [4]=> -# string(1) "5" +# int(5) #} ################################################# <: diff --git a/tests/commands/0106_compile.test b/tests/commands/0106_compile.test index d79211ddf75..7193600ea3d 100644 --- a/tests/commands/0106_compile.test +++ b/tests/commands/0106_compile.test @@ -14,6 +14,5 @@ define('OUT', file_put_contents(OUT, ""); phpdbg_exec(OUT); :> -compile run quit diff --git a/tests/run-tests.php b/tests/run-tests.php index 1fb6fa12242..47a998ccae8 100644 --- a/tests/run-tests.php +++ b/tests/run-tests.php @@ -284,6 +284,8 @@ namespace phpdbg\testing { $test->purpose, $result ? "PASS" : "FAIL", PHP_EOL); + + return $result; } protected $config; @@ -426,7 +428,7 @@ namespace phpdbg\testing { */ public function getResult() { $options = sprintf( - '-i%s -qb', $this->file); + '-i%s -nqb', $this->file); if ($this->options) { $options = sprintf( @@ -492,13 +494,18 @@ namespace phpdbg\testing { * */ protected function writeDiff() { - $diff = sprintf( - '%s/%s.diff', - dirname($this->file), basename($this->file)); - if (count($this->diff['wants'])) { - if (!in_array('nodiff', $this->config['flags'])) { - if (($diff = fopen($diff, 'w+'))) { + if (!$this->config->hasFlag('nodiff')) { + if ($this->config->hasFlag('diff2stdout')) { + $difffile = "php://stdout"; + file_put_contents($difffile, "====DIFF====\n"); + } else { + $difffile = sprintf( + '%s/%s.diff', + dirname($this->file), basename($this->file)); + } + + if (($diff = fopen($difffile, 'w+'))) { foreach ($this->diff['wants'] as $line => $want) { $got = $this->diff['gets'][$line]; @@ -552,6 +559,9 @@ namespace { $cwd = dirname(__FILE__); $cmd = $_SERVER['argv']; + + $retval = 0; + { $config = new TestsConfiguration(array( 'exec' => realpath(array_shift($cmd)), @@ -571,7 +581,7 @@ namespace { $tests->logPath($path); foreach ($tests->findTests($path) as $test) { - $tests->logTest($path, $test); + $retval |= !$tests->logTest($path, $test); } $tests->logPathStats($path); @@ -579,5 +589,7 @@ namespace { $tests->logStats(); } + + die($retval); } ?> From 5e6c5e9569abaec5fdea6e9254fe38e340921c50 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Mon, 9 Jun 2014 10:06:29 +0200 Subject: [PATCH 030/398] Merge sapi/phpdbg into PHP-5.6 --- .gitignore | 1 + Makefile.frag | 15 +- config.m4 | 2 +- phpdbg.h | 7 +- phpdbg_lexer.c | 3179 ++++++++++++++--------------------------------- phpdbg_lexer.h | 373 +----- phpdbg_lexer.l | 246 ++-- phpdbg_parser.c | 556 +++++---- phpdbg_parser.h | 24 +- phpdbg_parser.y | 150 ++- phpdbg_prompt.c | 37 +- travis/ci.sh | 1 + 12 files changed, 1535 insertions(+), 3056 deletions(-) diff --git a/.gitignore b/.gitignore index 5506a2652d0..51165dab2f3 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ phpdbg *.lo *.o +*.output build diff --git a/Makefile.frag b/Makefile.frag index 45768de2eff..d787b0fb180 100644 --- a/Makefile.frag +++ b/Makefile.frag @@ -8,14 +8,17 @@ $(BUILD_SHARED): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_PHPDBG_OBJS) $(BUILD_BINARY): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_PHPDBG_OBJS) $(BUILD_PHPDBG) -$(builddir)/sapi/phpdbg/phpdbg_lexer.lo: $(srcdir)/sapi/phpdbg/phpdbg_parser.h +%.c: %.y +%.c: %.l -$(srcdir)/sapi/phpdbg/phpdbg_lexer.c: $(srcdir)/sapi/phpdbg/phpdbg_lexer.l - @(cd $(top_srcdir); $(RE2C) $(RE2C_FLAGS) --no-generation-date -cbdFo sapi/phpdbg/phpdbg_lexer.c sapi/phpdbg/phpdbg_lexer.l) +$(builddir)/phpdbg_lexer.lo: $(srcdir)/phpdbg_parser.h -$(srcdir)/sapi/phpdbg/phpdbg_parser.h: $(srcdir)/sapi/phpdbg/phpdbg_parser.c -$(srcdir)/sapi/phpdbg/phpdbg_parser.c: $(srcdir)/sapi/phpdbg/phpdbg_parser.y - @$(YACC) -p phpdbg_ -v -d $(srcdir)/sapi/phpdbg/phpdbg_parser.y -o $@ +$(srcdir)/phpdbg_lexer.c: $(srcdir)/phpdbg_lexer.l + @(cd $(top_srcdir); $(RE2C) $(RE2C_FLAGS) --no-generation-date -cbdFo $(srcdir)/phpdbg_lexer.c $(srcdir)/phpdbg_lexer.l) + +$(srcdir)/phpdbg_parser.h: $(srcdir)/phpdbg_parser.c +$(srcdir)/phpdbg_parser.c: $(srcdir)/phpdbg_parser.y + @$(YACC) -p phpdbg_ -v -d $(srcdir)/phpdbg_parser.y -o $@ install-phpdbg: $(BUILD_BINARY) @echo "Installing phpdbg binary: $(INSTALL_ROOT)$(bindir)/" diff --git a/config.m4 b/config.m4 index a1b2f9faa10..ecac1715067 100644 --- a/config.m4 +++ b/config.m4 @@ -28,7 +28,7 @@ if test "$PHP_PHPDBG" != "no"; then PHP_SUBST(PHP_PHPDBG_FILES) PHP_SUBST(PHPDBG_EXTRA_LIBS) - PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/sapi/phpdbg/Makefile.frag]) + PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/sapi/phpdbg/Makefile.frag], [$abs_srcdir/sapi/phpdbg], [$abs_builddir/sapi/phpdbg]) PHP_SELECT_SAPI(phpdbg, program, $PHP_PHPDBG_FILES, $PHP_PHPDBG_CFLAGS, [$(SAPI_PHPDBG_PATH)]) BUILD_BINARY="sapi/phpdbg/phpdbg" diff --git a/phpdbg.h b/phpdbg.h index be009e40d04..12350d5425d 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -69,11 +69,14 @@ # include #endif +#include "phpdbg_lexer.h" #include "phpdbg_cmd.h" #include "phpdbg_utils.h" #include "phpdbg_btree.h" #include "phpdbg_watch.h" +int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC); + #ifdef ZTS # define PHPDBG_G(v) TSRMG(phpdbg_globals_id, zend_phpdbg_globals *, v) #else @@ -176,10 +179,12 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg) phpdbg_frame_t frame; /* frame */ zend_uint last_line; /* last executed line */ + phpdbg_lexer_data lexer; /* lexer data */ + phpdbg_param_t *parser_stack; /* param stack during lexer / parser phase */ + #ifndef _WIN32 struct sigaction old_sigsegv_signal; /* segv signal handler */ #endif - phpdbg_btree watchpoint_tree; /* tree with watchpoints */ phpdbg_btree watch_HashTables; /* tree with original dtors of watchpoints */ HashTable watchpoints; /* watchpoints */ diff --git a/phpdbg_lexer.c b/phpdbg_lexer.c index 94a4ba9766a..420dcac042d 100644 --- a/phpdbg_lexer.c +++ b/phpdbg_lexer.c @@ -1,2271 +1,996 @@ -#line 2 "sapi/phpdbg/phpdbg_lexer.c" - -#line 4 "sapi/phpdbg/phpdbg_lexer.c" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 37 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yyg->yy_start = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yyg->yy_start - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart(yyin ,yyscanner ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#define YY_BUF_SIZE 16384 -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = yyg->yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - yy_size_t yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ - ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ - : NULL) - -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] - -void yyrestart (FILE *input_file ,yyscan_t yyscanner ); -void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); -void yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -void yypop_buffer_state (yyscan_t yyscanner ); - -static void yyensure_buffer_stack (yyscan_t yyscanner ); -static void yy_load_buffer_state (yyscan_t yyscanner ); -static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); - -#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner) - -YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner ); - -void *yyalloc (yy_size_t ,yyscan_t yyscanner ); -void *yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); -void yyfree (void * ,yyscan_t yyscanner ); - -#define yy_new_buffer yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -#define yywrap(yyscanner) 1 -#define YY_SKIP_YYWRAP - -typedef unsigned char YY_CHAR; - -typedef int yy_state_type; - -#define yytext_ptr yytext_r - -static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); -static int yy_get_next_buffer (yyscan_t yyscanner ); -static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yyg->yytext_ptr = yy_bp; \ - yyleng = (size_t) (yy_cp - yy_bp); \ - yyg->yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yyg->yy_c_buf_p = yy_cp; - -#define YY_NUM_RULES 18 -#define YY_END_OF_BUFFER 19 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static yyconst flex_int16_t yy_acclist[229] = - { 0, - 19, 4, 15, 18, 4, 17, 18, 17, 18, 4, - 7, 18, 4, 12, 15, 18, 4, 12, 15, 18, - 4, 9, 18, 4, 15, 18, 4, 15, 18, 4, - 15, 18, 4, 15, 18, 4, 15, 18, 4, 15, - 18, 3, 4, 15, 18, 4, 15, 18, 4, 15, - 18, 4, 15, 18, 4, 15, 18, 16, 18, 16, - 17, 18, 15, 18, 7, 18, 12, 15, 18, 12, - 15, 18, 9, 18, 15, 18, 15, 18, 15, 18, - 15, 18, 15, 18, 15, 18, 15, 18, 15, 18, - 15, 18, 15, 18, 4, 15, 4, 4, 4, 17, - - 17, 4, 12, 15, 4, 15, 4, 8, 4, 15, - 4, 15, 4, 15, 1, 4, 15, 4, 15, 4, - 11, 15, 4, 15, 4, 10, 15, 4, 15, 2, - 4, 15, 4, 15, 4, 15, 4, 15, 16, 16, - 17, 15, 12, 15, 15, 8, 15, 15, 15, 15, - 5, 15, 11, 15, 15, 10, 15, 15, 15, 15, - 4, 4, 13, 15, 4, 15, 4, 15, 4, 15, - 4, 15, 3, 4, 15, 4, 15, 4, 15, 13, - 15, 15, 15, 15, 15, 15, 15, 4, 6, 4, - 15, 4, 15, 4, 15, 4, 15, 4, 15, 6, - - 15, 15, 15, 15, 15, 4, 15, 4, 15, 4, - 15, 15, 15, 15, 4, 14, 15, 4, 15, 4, - 15, 14, 15, 15, 15, 4, 15, 15 - } ; - -static yyconst flex_int16_t yy_accept[127] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 2, 5, 8, - 10, 13, 17, 21, 24, 27, 30, 33, 36, 39, - 42, 46, 49, 52, 55, 58, 60, 63, 65, 67, - 70, 73, 75, 77, 79, 81, 83, 85, 87, 89, - 91, 93, 95, 97, 98, 99, 101, 102, 105, 107, - 109, 111, 113, 115, 118, 120, 123, 125, 128, 130, - 133, 135, 137, 139, 140, 142, 143, 143, 145, 146, - 147, 148, 149, 150, 151, 153, 155, 156, 158, 159, - 160, 161, 162, 165, 167, 169, 171, 173, 176, 178, - 180, 180, 182, 183, 184, 185, 186, 187, 188, 190, - - 192, 194, 196, 198, 200, 201, 202, 203, 204, 205, - 206, 208, 210, 212, 213, 214, 215, 218, 220, 222, - 224, 225, 226, 228, 229, 229 - } ; - -static yyconst flex_int32_t yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 1, 4, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 5, 6, 7, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 9, 1, 1, - 1, 1, 1, 1, 10, 10, 10, 11, 12, 10, - 13, 13, 13, 13, 13, 13, 13, 14, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 15, - 1, 1, 1, 1, 16, 1, 17, 18, 10, 19, - - 20, 21, 13, 22, 23, 13, 13, 24, 13, 25, - 26, 13, 13, 27, 28, 29, 30, 31, 13, 32, - 33, 34, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static yyconst flex_int32_t yy_meta[35] = - { 0, - 1, 2, 3, 2, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1 - } ; - -static yyconst flex_int16_t yy_base[133] = - { 0, - 0, 0, 33, 35, 38, 0, 357, 71, 74, 76, - 352, 79, 87, 90, 96, 100, 108, 109, 112, 120, - 123, 126, 138, 142, 148, 0, 104, 316, 455, 151, - 162, 313, 73, 92, 65, 146, 122, 94, 152, 127, - 155, 163, 172, 318, 131, 176, 182, 288, 190, 314, - 178, 184, 187, 211, 212, 215, 221, 224, 225, 235, - 236, 239, 245, 0, 203, 260, 259, 248, 264, 455, - 237, 190, 243, 253, 255, 222, 259, 194, 249, 250, - 277, 229, 0, 285, 286, 289, 295, 304, 307, 310, - 184, 0, 252, 283, 292, 296, 306, 309, 163, 328, - - 329, 332, 341, 344, 455, 326, 331, 330, 342, 343, - 362, 370, 371, 394, 368, 356, 410, 384, 404, 426, - 376, 378, 420, 411, 455, 442, 445, 447, 450, 148, - 452, 96 - } ; - -static yyconst flex_int16_t yy_def[133] = - { 0, - 125, 1, 126, 126, 125, 5, 125, 127, 128, 125, - 128, 127, 127, 128, 127, 127, 127, 127, 127, 127, - 127, 127, 127, 127, 127, 129, 129, 130, 125, 130, - 130, 125, 130, 130, 130, 130, 130, 130, 130, 130, - 130, 130, 127, 128, 128, 128, 125, 13, 13, 128, - 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, - 127, 127, 127, 129, 129, 130, 125, 130, 130, 125, - 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, - 130, 128, 49, 127, 127, 127, 127, 127, 127, 127, - 125, 69, 130, 130, 130, 130, 130, 130, 128, 127, - - 127, 127, 127, 127, 125, 130, 130, 130, 130, 130, - 131, 127, 127, 132, 130, 130, 131, 127, 127, 132, - 130, 130, 127, 130, 0, 125, 125, 125, 125, 125, - 125, 125 - } ; - -static yyconst flex_int16_t yy_nxt[490] = - { 0, - 8, 9, 10, 11, 12, 8, 13, 12, 14, 8, - 8, 8, 8, 8, 15, 8, 8, 8, 16, 17, - 18, 8, 8, 8, 19, 20, 21, 22, 23, 8, - 8, 8, 24, 25, 27, 10, 27, 10, 28, 10, - 10, 29, 30, 28, 31, 30, 32, 28, 28, 28, - 28, 28, 33, 28, 28, 28, 34, 35, 36, 28, - 37, 28, 38, 39, 28, 28, 40, 28, 28, 28, - 41, 42, 44, 67, 44, 46, 47, 47, 47, 45, - 44, 67, 44, 48, 71, 48, 48, 45, 44, 73, - 44, 48, 125, 48, 48, 45, 120, 44, 50, 44, - - 67, 44, 67, 44, 45, 65, 47, 51, 45, 44, - 44, 44, 44, 44, 72, 44, 45, 45, 49, 76, - 45, 44, 52, 44, 44, 55, 44, 44, 45, 44, - 67, 45, 53, 125, 45, 67, 82, 56, 54, 44, - 57, 44, 75, 44, 58, 44, 45, 60, 66, 44, - 45, 44, 59, 79, 67, 68, 45, 68, 68, 67, - 67, 62, 74, 67, 61, 125, 68, 63, 68, 68, - 67, 67, 77, 44, 80, 44, 78, 46, 47, 44, - 45, 44, 81, 47, 47, 44, 45, 44, 44, 105, - 44, 84, 45, 69, 43, 45, 83, 83, 67, 83, - - 83, 83, 67, 86, 65, 47, 83, 83, 83, 83, - 83, 85, 44, 44, 44, 44, 44, 94, 44, 45, - 45, 43, 44, 45, 44, 44, 44, 44, 44, 45, - 67, 125, 45, 45, 99, 87, 44, 44, 44, 44, - 44, 56, 44, 45, 45, 67, 44, 45, 44, 88, - 93, 67, 68, 45, 68, 68, 67, 67, 67, 95, - 67, 67, 106, 67, 91, 89, 58, 67, 67, 90, - 92, 92, 67, 92, 92, 92, 96, 78, 97, 76, - 92, 92, 92, 92, 92, 67, 44, 44, 44, 44, - 44, 67, 44, 45, 45, 100, 44, 45, 44, 107, - - 67, 98, 101, 45, 67, 44, 102, 44, 44, 108, - 44, 44, 45, 44, 67, 45, 125, 67, 45, 43, - 125, 70, 103, 109, 67, 78, 58, 110, 104, 44, - 44, 44, 44, 44, 67, 44, 45, 45, 67, 67, - 45, 114, 44, 111, 44, 44, 112, 44, 115, 45, - 67, 67, 45, 116, 125, 113, 125, 125, 114, 111, - 56, 76, 43, 44, 67, 44, 43, 43, 43, 43, - 45, 44, 44, 44, 44, 122, 67, 43, 45, 45, - 125, 125, 125, 125, 67, 44, 67, 44, 125, 125, - 119, 121, 45, 118, 66, 124, 78, 125, 66, 66, - - 66, 66, 67, 123, 125, 44, 125, 44, 125, 66, - 43, 44, 45, 44, 43, 43, 43, 43, 45, 67, - 125, 44, 58, 44, 125, 43, 66, 125, 45, 76, - 66, 66, 66, 66, 67, 125, 125, 125, 56, 125, - 125, 66, 26, 26, 26, 43, 43, 44, 44, 44, - 64, 64, 117, 117, 7, 125, 125, 125, 125, 125, - 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, - 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, - 125, 125, 125, 125, 125, 125, 125, 125, 125 - } ; - -static yyconst flex_int16_t yy_chk[490] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 3, 3, 4, 4, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 8, 35, 8, 9, 9, 10, 10, 8, - 12, 33, 12, 12, 33, 12, 12, 12, 13, 35, - 13, 13, 14, 13, 13, 13, 132, 15, 14, 15, - - 34, 16, 38, 16, 15, 27, 27, 15, 16, 17, - 18, 17, 18, 19, 34, 19, 17, 18, 13, 38, - 19, 20, 16, 20, 21, 18, 21, 22, 20, 22, - 37, 21, 17, 45, 22, 40, 45, 19, 17, 23, - 20, 23, 37, 24, 20, 24, 23, 22, 130, 25, - 24, 25, 21, 40, 36, 30, 25, 30, 30, 30, - 39, 24, 36, 41, 23, 99, 31, 25, 31, 31, - 31, 42, 39, 43, 41, 43, 39, 46, 46, 51, - 43, 51, 42, 47, 47, 52, 51, 52, 53, 91, - 53, 51, 52, 31, 49, 53, 49, 49, 72, 49, - - 49, 49, 78, 53, 65, 65, 49, 49, 49, 49, - 49, 52, 54, 55, 54, 55, 56, 72, 56, 54, - 55, 49, 57, 56, 57, 58, 59, 58, 59, 57, - 76, 82, 58, 59, 82, 55, 60, 61, 60, 61, - 62, 57, 62, 60, 61, 71, 63, 62, 63, 59, - 71, 73, 68, 63, 68, 68, 68, 79, 80, 73, - 93, 74, 93, 75, 67, 61, 62, 77, 66, 63, - 69, 69, 69, 69, 69, 69, 74, 80, 79, 77, - 69, 69, 69, 69, 69, 81, 84, 85, 84, 85, - 86, 94, 86, 84, 85, 84, 87, 86, 87, 94, - - 95, 81, 85, 87, 96, 88, 86, 88, 89, 95, - 89, 90, 88, 90, 97, 89, 50, 98, 90, 48, - 44, 32, 87, 96, 28, 97, 89, 98, 90, 100, - 101, 100, 101, 102, 106, 102, 100, 101, 108, 107, - 102, 106, 103, 100, 103, 104, 101, 104, 107, 103, - 109, 110, 104, 108, 11, 102, 7, 0, 110, 104, - 103, 109, 111, 111, 116, 111, 111, 111, 111, 111, - 111, 112, 113, 112, 113, 116, 115, 111, 112, 113, - 0, 0, 0, 0, 121, 118, 122, 118, 0, 0, - 113, 115, 118, 112, 114, 121, 122, 0, 114, 114, - - 114, 114, 114, 118, 0, 119, 0, 119, 0, 114, - 117, 117, 119, 117, 117, 117, 117, 117, 117, 124, - 0, 123, 119, 123, 0, 117, 120, 0, 123, 124, - 120, 120, 120, 120, 120, 0, 0, 0, 123, 0, - 0, 120, 126, 126, 126, 127, 127, 128, 128, 128, - 129, 129, 131, 131, 125, 125, 125, 125, 125, 125, - 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, - 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, - 125, 125, 125, 125, 125, 125, 125, 125, 125 - } ; - -#define REJECT \ -{ \ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ \ -yy_cp = yyg->yy_full_match; /* restore poss. backed-over text */ \ -++yyg->yy_lp; \ -goto find_rule; \ -} - -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -#line 1 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" -#line 2 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" - +/* Generated by re2c 0.13.5 */ +#line 1 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" /* * phpdbg_lexer.l */ #include "phpdbg.h" #include "phpdbg_cmd.h" -#define YYSTYPE phpdbg_param_t #include "phpdbg_parser.h" - +#define LEX(v) (PHPDBG_G(lexer).v) -#define YY_NO_UNISTD_H 1 -#line 629 "sapi/phpdbg/phpdbg_lexer.c" +#define YYCTYPE unsigned char +#define YYSETCONDITION(x) LEX(state) = x; +#define YYGETCONDITION() LEX(state) +#define YYCURSOR LEX(cursor) +#define YYMARKER LEX(marker) +#define yyleng LEX(len) +#define yytext ((char*) LEX(text)) +#undef YYDEBUG +#define YYDEBUG(a, b) +#define YYFILL(n) -#define INITIAL 0 +#define NORMAL 0 #define RAW 1 -#define NORMAL 2 +#define INITIAL 2 -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif +void phpdbg_init_lexer (phpdbg_param_t *stack, char *input TSRMLS_DC) { + PHPDBG_G(parser_stack) = stack; -/* Holds the entire state of the reentrant scanner. */ -struct yyguts_t - { + YYSETCONDITION(INITIAL); - /* User-defined. Not touched by flex. */ - YY_EXTRA_TYPE yyextra_r; + LEX(text) = YYCURSOR = (unsigned char *) input; + LEX(len) = strlen(input); +} - /* The rest are the same as the globals declared in the non-reentrant scanner. */ - FILE *yyin_r, *yyout_r; - size_t yy_buffer_stack_top; /**< index of top of stack. */ - size_t yy_buffer_stack_max; /**< capacity of stack. */ - YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ - char yy_hold_char; - yy_size_t yy_n_chars; - yy_size_t yyleng_r; - char *yy_c_buf_p; - int yy_init; - int yy_start; - int yy_did_buffer_switch_on_eof; - int yy_start_stack_ptr; - int yy_start_stack_depth; - int *yy_start_stack; - yy_state_type yy_last_accepting_state; - char* yy_last_accepting_cpos; +int phpdbg_lex (phpdbg_param_t* yylval) { + TSRMLS_FETCH(); /* Slow, but this is not a major problem here. TODO: Use TSRMLS_DC */ - int yylineno_r; - int yy_flex_debug_r; +restart: + LEX(text) = YYCURSOR; - yy_state_type *yy_state_buf; - yy_state_type *yy_state_ptr; - char *yy_full_match; - int yy_lp; - /* These are only needed for trailing context rules, - * but there's no conditional variable for that yet. */ - int yy_looking_for_trail_begin; - int yy_full_lp; - int *yy_full_state; - - char *yytext_r; - int yy_more_flag; - int yy_more_len; - - YYSTYPE * yylval_r; - - }; /* end struct yyguts_t */ - -static int yy_init_globals (yyscan_t yyscanner ); - - /* This must go here because YYSTYPE and YYLTYPE are included - * from bison output in section 1.*/ - # define yylval yyg->yylval_r - -int yylex_init (yyscan_t* scanner); - -int yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy (yyscan_t yyscanner ); - -int yyget_debug (yyscan_t yyscanner ); - -void yyset_debug (int debug_flag ,yyscan_t yyscanner ); - -YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner ); - -void yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); - -FILE *yyget_in (yyscan_t yyscanner ); - -void yyset_in (FILE * in_str ,yyscan_t yyscanner ); - -FILE *yyget_out (yyscan_t yyscanner ); - -void yyset_out (FILE * out_str ,yyscan_t yyscanner ); - -yy_size_t yyget_leng (yyscan_t yyscanner ); - -char *yyget_text (yyscan_t yyscanner ); - -int yyget_lineno (yyscan_t yyscanner ); - -void yyset_lineno (int line_number ,yyscan_t yyscanner ); - -int yyget_column (yyscan_t yyscanner ); - -void yyset_column (int column_no ,yyscan_t yyscanner ); - -YYSTYPE * yyget_lval (yyscan_t yyscanner ); - -void yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap (yyscan_t yyscanner ); -#else -extern int yywrap (yyscan_t yyscanner ); -#endif -#endif - - static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner); - -#ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT - -#ifdef __cplusplus -static int yyinput (yyscan_t yyscanner ); -#else -static int input (yyscan_t yyscanner ); -#endif - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - size_t n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex \ - (YYSTYPE * yylval_param ,yyscan_t yyscanner); - -#define YY_DECL int yylex \ - (YYSTYPE * yylval_param , yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL +#line 48 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - -#line 44 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" - - -#line 882 "sapi/phpdbg/phpdbg_lexer.c" - - yylval = yylval_param; - - if ( !yyg->yy_init ) - { - yyg->yy_init = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - /* Create the reject buffer large enough to save one state per allowed character. */ - if ( ! yyg->yy_state_buf ) - yyg->yy_state_buf = (yy_state_type *)yyalloc(YY_STATE_BUF_SIZE ,yyscanner); - if ( ! yyg->yy_state_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yylex()" ); - - if ( ! yyg->yy_start ) - yyg->yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + YYCTYPE yych; + unsigned int yyaccept = 0; + if (YYGETCONDITION() < 1) { + goto yyc_NORMAL; + } else { + if (YYGETCONDITION() < 2) { + goto yyc_RAW; + } else { + goto yyc_INITIAL; } + } +/* *********************************** */ +yyc_INITIAL: + { + static const unsigned char yybm[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 128, 128, 0, 0, 128, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 128, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }; - yy_load_buffer_state(yyscanner ); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = yyg->yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yyg->yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yyg->yy_start; - - yyg->yy_state_ptr = yyg->yy_state_buf; - *yyg->yy_state_ptr++ = yy_current_state; - -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 126 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - *yyg->yy_state_ptr++ = yy_current_state; - ++yy_cp; + YYDEBUG(0, *YYCURSOR); + YYFILL(3); + yych = *YYCURSOR; + if (yych <= 0x1F) { + if (yych <= '\t') { + if (yych <= 0x00) goto yy6; + if (yych <= 0x08) goto yy11; + } else { + if (yych <= '\n') goto yy4; + if (yych != '\r') goto yy11; } - while ( yy_current_state != 125 ); + } else { + if (yych <= 'e') { + if (yych <= ' ') goto yy2; + if (yych <= 'd') goto yy11; + goto yy7; + } else { + if (yych <= 'q') goto yy11; + if (yych <= 'r') goto yy9; + if (yych <= 's') goto yy8; + goto yy11; + } + } +yy2: + YYDEBUG(2, *YYCURSOR); + ++YYCURSOR; + if (yybm[0+(yych = *YYCURSOR)] & 128) { + goto yy19; + } +yy3: + YYDEBUG(3, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 161 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" + { + YYSETCONDITION(NORMAL); -yy_find_action: - yy_current_state = *--yyg->yy_state_ptr; - yyg->yy_lp = yy_accept[yy_current_state]; -find_rule: /* we branch to this label when backing up */ - for ( ; ; ) /* until we find what rule we matched */ - { - if ( yyg->yy_lp && yyg->yy_lp < yy_accept[yy_current_state + 1] ) - { - yy_act = yy_acclist[yyg->yy_lp]; - { - yyg->yy_full_match = yy_cp; - break; + YYCURSOR = LEX(text); + goto restart; +} +#line 138 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy4: + YYDEBUG(4, *YYCURSOR); + ++YYCURSOR; + if (yybm[0+(yych = *YYCURSOR)] & 128) { + goto yy19; + } + YYDEBUG(5, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 68 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" + { + return 0; +} +#line 151 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy6: + YYDEBUG(6, *YYCURSOR); + yych = *++YYCURSOR; + goto yy3; +yy7: + YYDEBUG(7, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'v') goto yy17; + goto yy3; +yy8: + YYDEBUG(8, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'h') goto yy15; + goto yy3; +yy9: + YYDEBUG(9, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'u') goto yy12; +yy10: + YYDEBUG(10, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 155 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" + { + YYSETCONDITION(RAW); + phpdbg_init_param(yylval, EMPTY_PARAM); + return T_RUN; +} +#line 180 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy11: + YYDEBUG(11, *YYCURSOR); + yych = *++YYCURSOR; + goto yy3; +yy12: + YYDEBUG(12, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'n') goto yy14; + YYDEBUG(13, *YYCURSOR); + YYCURSOR = YYMARKER; + goto yy10; +yy14: + YYDEBUG(14, *YYCURSOR); + yych = *++YYCURSOR; + goto yy10; +yy15: + YYDEBUG(15, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(16, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 150 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" + { + YYSETCONDITION(RAW); + phpdbg_init_param(yylval, EMPTY_PARAM); + return T_SHELL; +} +#line 207 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy17: + YYDEBUG(17, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(18, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 145 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" + { + YYSETCONDITION(RAW); + phpdbg_init_param(yylval, EMPTY_PARAM); + return T_EVAL; +} +#line 219 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy19: + YYDEBUG(19, *YYCURSOR); + ++YYCURSOR; + YYFILL(1); + yych = *YYCURSOR; + YYDEBUG(20, *YYCURSOR); + if (yybm[0+yych] & 128) { + goto yy19; + } + YYDEBUG(21, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 139 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" + { + /* ignore whitespace */ + + goto restart; +} +#line 237 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" + } +/* *********************************** */ +yyc_NORMAL: + { + static const unsigned char yybm[] = { + 0, 16, 16, 16, 16, 16, 16, 16, + 16, 8, 8, 16, 16, 8, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 8, 16, 16, 0, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 48, 16, + 176, 176, 176, 176, 176, 176, 176, 176, + 176, 176, 0, 16, 16, 16, 16, 16, + 16, 208, 208, 208, 208, 208, 208, 80, + 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 16, 16, 16, 16, 16, + 16, 208, 208, 208, 208, 208, 208, 80, + 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + }; + YYDEBUG(22, *YYCURSOR); + YYFILL(11); + yych = *YYCURSOR; + if (yych <= ':') { + if (yych <= ' ') { + if (yych <= '\n') { + if (yych <= 0x00) goto yy29; + if (yych <= 0x08) goto yy32; + if (yych >= '\n') goto yy27; + } else { + if (yych == '\r') goto yy24; + if (yych <= 0x1F) goto yy32; + } + } else { + if (yych <= '.') { + if (yych == '#') goto yy47; + if (yych <= '-') goto yy32; + goto yy34; + } else { + if (yych <= '/') goto yy32; + if (yych <= '0') goto yy37; + if (yych <= '9') goto yy34; + goto yy49; + } + } + } else { + if (yych <= 'i') { + if (yych <= 'd') { + if (yych == 'Z') goto yy38; + if (yych <= 'c') goto yy32; + goto yy39; + } else { + if (yych <= 'e') goto yy40; + if (yych <= 'f') goto yy41; + if (yych <= 'h') goto yy32; + goto yy30; + } + } else { + if (yych <= 's') { + if (yych <= 'm') goto yy32; + if (yych <= 'n') goto yy42; + if (yych <= 'o') goto yy43; + goto yy32; + } else { + if (yych <= 'x') { + if (yych <= 't') goto yy44; + goto yy32; + } else { + if (yych <= 'y') goto yy45; + if (yych <= 'z') goto yy46; + goto yy32; } } - --yy_cp; - yy_current_state = *--yyg->yy_state_ptr; - yyg->yy_lp = yy_accept[yy_current_state]; } + } +yy24: + YYDEBUG(24, *YYCURSOR); + ++YYCURSOR; + YYFILL(1); + yych = *YYCURSOR; + YYDEBUG(25, *YYCURSOR); + if (yybm[0+yych] & 8) { + goto yy24; + } + YYDEBUG(26, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 139 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" + { + /* ignore whitespace */ - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - -case 1: -YY_RULE_SETUP -#line 47 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" -{ - BEGIN(RAW); - phpdbg_init_param(yylval, EMPTY_PARAM); - return T_EVAL; - } - YY_BREAK -case 2: -YY_RULE_SETUP -#line 52 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" -{ - BEGIN(RAW); - phpdbg_init_param(yylval, EMPTY_PARAM); - return T_SHELL; - } - YY_BREAK -case 3: -YY_RULE_SETUP -#line 57 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" -{ - BEGIN(RAW); - phpdbg_init_param(yylval, EMPTY_PARAM); - return T_RUN; - } - YY_BREAK -case 4: -YY_RULE_SETUP -#line 63 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" -{ - BEGIN(NORMAL); - REJECT; - } - YY_BREAK - - -case 5: -YY_RULE_SETUP -#line 70 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" -{ - BEGIN(RAW); - phpdbg_init_param(yylval, EMPTY_PARAM); - return T_IF; - } - YY_BREAK - - -case 6: -YY_RULE_SETUP -#line 78 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" -{ - phpdbg_init_param(yylval, STR_PARAM); - yylval->str = zend_strndup(yytext, yyleng); - yylval->len = yyleng; - return T_PROTO; - } - YY_BREAK -case 7: -YY_RULE_SETUP -#line 84 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" -{ return T_POUND; } - YY_BREAK -case 8: -YY_RULE_SETUP -#line 85 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" -{ return T_DCOLON; } - YY_BREAK -case 9: -YY_RULE_SETUP -#line 86 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" -{ return T_COLON; } - YY_BREAK -case 10: -YY_RULE_SETUP -#line 88 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" -{ - phpdbg_init_param(yylval, NUMERIC_PARAM); - yylval->num = 1; - return T_TRUTHY; - } - YY_BREAK -case 11: -YY_RULE_SETUP -#line 93 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" -{ - phpdbg_init_param(yylval, NUMERIC_PARAM); - yylval->num = 0; - return T_FALSY; - } - YY_BREAK -case 12: -YY_RULE_SETUP -#line 98 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" -{ - phpdbg_init_param(yylval, NUMERIC_PARAM); - yylval->num = atoi(yytext); - return T_DIGITS; - } - YY_BREAK -case 13: -YY_RULE_SETUP -#line 103 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" -{ - phpdbg_init_param(yylval, ADDR_PARAM); - yylval->addr = strtoul(yytext, 0, 16); - return T_ADDR; - } - YY_BREAK -case 14: -YY_RULE_SETUP -#line 108 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" -{ - phpdbg_init_param(yylval, OP_PARAM); - yylval->str = zend_strndup(yytext, yyleng); - yylval->len = yyleng; - return T_OPCODE; - } - YY_BREAK -case 15: -YY_RULE_SETUP -#line 114 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" -{ - phpdbg_init_param(yylval, STR_PARAM); - yylval->str = zend_strndup(yytext, yyleng); - yylval->len = yyleng; - return T_ID; - } - YY_BREAK - -case 16: -YY_RULE_SETUP -#line 122 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" -{ + goto restart; +} +#line 348 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy27: + YYDEBUG(27, *YYCURSOR); + ++YYCURSOR; + if (yybm[0+(yych = *YYCURSOR)] & 8) { + goto yy24; + } +yy28: + YYDEBUG(28, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 68 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" + { + return 0; +} +#line 362 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy29: + YYDEBUG(29, *YYCURSOR); + yych = *++YYCURSOR; + goto yy28; +yy30: + YYDEBUG(30, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'f') goto yy94; + goto yy33; +yy31: + YYDEBUG(31, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 125 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" + { + phpdbg_init_param(yylval, STR_PARAM); + yylval->str = zend_strndup(yytext, yyleng); + yylval->len = yyleng; + return T_ID; +} +#line 383 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy32: + YYDEBUG(32, *YYCURSOR); + yyaccept = 0; + YYMARKER = ++YYCURSOR; + YYFILL(3); + yych = *YYCURSOR; +yy33: + YYDEBUG(33, *YYCURSOR); + if (yybm[0+yych] & 16) { + goto yy32; + } + if (yych <= '9') goto yy31; + goto yy54; +yy34: + YYDEBUG(34, *YYCURSOR); + yyaccept = 1; + YYMARKER = ++YYCURSOR; + YYFILL(3); + yych = *YYCURSOR; + YYDEBUG(35, *YYCURSOR); + if (yybm[0+yych] & 32) { + goto yy34; + } + if (yych <= 0x1F) { + if (yych <= '\n') { + if (yych <= 0x00) goto yy36; + if (yych <= 0x08) goto yy32; + } else { + if (yych != '\r') goto yy32; + } + } else { + if (yych <= '#') { + if (yych <= ' ') goto yy36; + if (yych <= '"') goto yy32; + } else { + if (yych == ':') goto yy54; + goto yy32; + } + } +yy36: + YYDEBUG(36, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 106 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" + { + phpdbg_init_param(yylval, NUMERIC_PARAM); + yylval->num = atoi(yytext); + return T_DIGITS; +} +#line 432 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy37: + YYDEBUG(37, *YYCURSOR); + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[0+yych] & 32) { + goto yy34; + } + if (yych <= 0x1F) { + if (yych <= '\n') { + if (yych <= 0x00) goto yy36; + if (yych <= 0x08) goto yy33; + goto yy36; + } else { + if (yych == '\r') goto yy36; + goto yy33; + } + } else { + if (yych <= '#') { + if (yych <= ' ') goto yy36; + if (yych <= '"') goto yy33; + goto yy36; + } else { + if (yych == 'x') goto yy90; + goto yy33; + } + } +yy38: + YYDEBUG(38, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'E') goto yy87; + goto yy33; +yy39: + YYDEBUG(39, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'i') goto yy81; + goto yy33; +yy40: + YYDEBUG(40, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'n') goto yy76; + goto yy33; +yy41: + YYDEBUG(41, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'a') goto yy73; + goto yy33; +yy42: + YYDEBUG(42, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'o') goto yy71; + goto yy33; +yy43: + YYDEBUG(43, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'f') goto yy70; + if (yych == 'n') goto yy66; + goto yy33; +yy44: + YYDEBUG(44, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'r') goto yy68; + goto yy33; +yy45: + YYDEBUG(45, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'e') goto yy65; + goto yy33; +yy46: + YYDEBUG(46, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'e') goto yy53; + goto yy33; +yy47: + YYDEBUG(47, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(48, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 84 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" + { + return T_POUND; +} +#line 523 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy49: + YYDEBUG(49, *YYCURSOR); + ++YYCURSOR; + if ((yych = *YYCURSOR) == ':') goto yy51; + YYDEBUG(50, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 90 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" + { + return T_COLON; +} +#line 534 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy51: + YYDEBUG(51, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(52, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 87 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" + { + return T_DCOLON; +} +#line 544 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy53: + YYDEBUG(53, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'n') goto yy59; + goto yy33; +yy54: + YYDEBUG(54, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == '/') goto yy56; +yy55: + YYDEBUG(55, *YYCURSOR); + YYCURSOR = YYMARKER; + if (yyaccept <= 3) { + if (yyaccept <= 1) { + if (yyaccept <= 0) { + goto yy31; + } else { + goto yy36; + } + } else { + if (yyaccept <= 2) { + goto yy64; + } else { + goto yy67; + } + } + } else { + if (yyaccept <= 5) { + if (yyaccept <= 4) { + goto yy72; + } else { + goto yy93; + } + } else { + goto yy95; + } + } +yy56: + YYDEBUG(56, *YYCURSOR); + yych = *++YYCURSOR; + if (yych != '/') goto yy55; + YYDEBUG(57, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(58, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 78 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" + { + phpdbg_init_param(yylval, STR_PARAM); + yylval->str = zend_strndup(yytext, yyleng); + yylval->len = yyleng; + return T_PROTO; +} +#line 598 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy59: + YYDEBUG(59, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'd') goto yy33; + YYDEBUG(60, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != '_') goto yy33; +yy61: + YYDEBUG(61, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[0+yych] & 64) { + goto yy62; + } + goto yy33; +yy62: + YYDEBUG(62, *YYCURSOR); + yyaccept = 2; + YYMARKER = ++YYCURSOR; + YYFILL(3); + yych = *YYCURSOR; + YYDEBUG(63, *YYCURSOR); + if (yybm[0+yych] & 64) { + goto yy62; + } + if (yych <= 0x1F) { + if (yych <= '\n') { + if (yych <= 0x00) goto yy64; + if (yych <= 0x08) goto yy32; + } else { + if (yych != '\r') goto yy32; + } + } else { + if (yych <= '#') { + if (yych <= ' ') goto yy64; + if (yych <= '"') goto yy32; + } else { + if (yych == ':') goto yy54; + goto yy32; + } + } +yy64: + YYDEBUG(64, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 118 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" + { + phpdbg_init_param(yylval, OP_PARAM); + yylval->str = zend_strndup(yytext, yyleng); + yylval->len = yyleng; + return T_OPCODE; +} +#line 652 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy65: + YYDEBUG(65, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 's') goto yy33; +yy66: + YYDEBUG(66, *YYCURSOR); + yyaccept = 3; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '\r') { + if (yych <= 0x08) { + if (yych >= 0x01) goto yy33; + } else { + if (yych <= '\n') goto yy67; + if (yych <= '\f') goto yy33; + } + } else { + if (yych <= ' ') { + if (yych <= 0x1F) goto yy33; + } else { + if (yych != '#') goto yy33; + } + } +yy67: + YYDEBUG(67, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 94 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" + { + phpdbg_init_param(yylval, NUMERIC_PARAM); + yylval->num = 1; + return T_TRUTHY; +} +#line 685 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy68: + YYDEBUG(68, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'u') goto yy33; + YYDEBUG(69, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'e') goto yy66; + goto yy33; +yy70: + YYDEBUG(70, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'f') goto yy33; +yy71: + YYDEBUG(71, *YYCURSOR); + yyaccept = 4; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '\r') { + if (yych <= 0x08) { + if (yych >= 0x01) goto yy33; + } else { + if (yych <= '\n') goto yy72; + if (yych <= '\f') goto yy33; + } + } else { + if (yych <= ' ') { + if (yych <= 0x1F) goto yy33; + } else { + if (yych != '#') goto yy33; + } + } +yy72: + YYDEBUG(72, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 100 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" + { + phpdbg_init_param(yylval, NUMERIC_PARAM); + yylval->num = 0; + return T_FALSY; +} +#line 728 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy73: + YYDEBUG(73, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy33; + YYDEBUG(74, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 's') goto yy33; + YYDEBUG(75, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'e') goto yy71; + goto yy33; +yy76: + YYDEBUG(76, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'a') goto yy33; + YYDEBUG(77, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'b') goto yy33; + YYDEBUG(78, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy33; + YYDEBUG(79, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy33; + YYDEBUG(80, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'd') goto yy66; + goto yy33; +yy81: + YYDEBUG(81, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 's') goto yy33; + YYDEBUG(82, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'a') goto yy33; + YYDEBUG(83, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'b') goto yy33; + YYDEBUG(84, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy33; + YYDEBUG(85, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy33; + YYDEBUG(86, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'd') goto yy71; + goto yy33; +yy87: + YYDEBUG(87, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'N') goto yy33; + YYDEBUG(88, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'D') goto yy33; + YYDEBUG(89, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '_') goto yy61; + goto yy33; +yy90: + YYDEBUG(90, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[0+yych] & 128) { + goto yy91; + } + goto yy33; +yy91: + YYDEBUG(91, *YYCURSOR); + yyaccept = 5; + YYMARKER = ++YYCURSOR; + YYFILL(3); + yych = *YYCURSOR; + YYDEBUG(92, *YYCURSOR); + if (yybm[0+yych] & 128) { + goto yy91; + } + if (yych <= 0x1F) { + if (yych <= '\n') { + if (yych <= 0x00) goto yy93; + if (yych <= 0x08) goto yy32; + } else { + if (yych != '\r') goto yy32; + } + } else { + if (yych <= '#') { + if (yych <= ' ') goto yy93; + if (yych <= '"') goto yy32; + } else { + if (yych == ':') goto yy54; + goto yy32; + } + } +yy93: + YYDEBUG(93, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 112 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" + { + phpdbg_init_param(yylval, ADDR_PARAM); + yylval->addr = strtoul(yytext, 0, 16); + return T_ADDR; +} +#line 848 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy94: + YYDEBUG(94, *YYCURSOR); + yyaccept = 6; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '\r') { + if (yych <= 0x08) { + if (yych >= 0x01) goto yy33; + } else { + if (yych <= '\n') goto yy95; + if (yych <= '\f') goto yy33; + } + } else { + if (yych <= ' ') { + if (yych <= 0x1F) goto yy33; + } else { + if (yych != '#') goto yy33; + } + } +yy95: + YYDEBUG(95, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 72 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" + { + YYSETCONDITION(RAW); + phpdbg_init_param(yylval, EMPTY_PARAM); + return T_IF; +} +#line 876 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" + } +/* *********************************** */ +yyc_RAW: + { + static const unsigned char yybm[] = { + 0, 64, 64, 64, 64, 64, 64, 64, + 64, 224, 128, 64, 64, 224, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 224, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + }; + YYDEBUG(96, *YYCURSOR); + YYFILL(2); + yych = *YYCURSOR; + if (yybm[0+yych] & 32) { + goto yy98; + } + if (yych <= 0x00) goto yy103; + if (yych == '\n') goto yy101; + goto yy104; +yy98: + YYDEBUG(98, *YYCURSOR); + ++YYCURSOR; + YYFILL(1); + yych = *YYCURSOR; + YYDEBUG(99, *YYCURSOR); + if (yybm[0+yych] & 32) { + goto yy98; + } + if (yych <= 0x00) goto yy100; + if (yych == '\n') goto yy106; + goto yy104; +yy100: + YYDEBUG(100, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 132 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" + { phpdbg_init_param(yylval, STR_PARAM); yylval->str = zend_strndup(yytext, yyleng); yylval->len = yyleng; - BEGIN(INITIAL); return T_INPUT; } - YY_BREAK -case 17: -/* rule 17 can match eol */ -YY_RULE_SETUP -#line 130 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" -{ /* ignore whitespace */ } - YY_BREAK -case 18: -YY_RULE_SETUP -#line 131 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" -YY_FATAL_ERROR( "flex scanner jammed" ); - YY_BREAK -#line 1129 "sapi/phpdbg/phpdbg_lexer.c" - case YY_STATE_EOF(INITIAL): - case YY_STATE_EOF(RAW): - case YY_STATE_EOF(NORMAL): - yyterminate(); - - case YY_END_OF_BUFFER: +#line 946 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy101: + YYDEBUG(101, *YYCURSOR); + ++YYCURSOR; + if (yybm[0+(yych = *YYCURSOR)] & 128) { + goto yy106; + } +yy102: + YYDEBUG(102, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 68 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yyg->yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); - - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yyg->yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yyg->yy_c_buf_p; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_END_OF_FILE: - { - yyg->yy_did_buffer_switch_on_eof = 0; - - if ( yywrap(yyscanner ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = - yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yyg->yy_c_buf_p = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; + return 0; +} +#line 960 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy103: + YYDEBUG(103, *YYCURSOR); + yych = *++YYCURSOR; + goto yy102; +yy104: + YYDEBUG(104, *YYCURSOR); + ++YYCURSOR; + YYFILL(1); + yych = *YYCURSOR; + YYDEBUG(105, *YYCURSOR); + if (yybm[0+yych] & 64) { + goto yy104; } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ -} /* end of yylex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = yyg->yytext_ptr; - register int number_to_move, i; - int ret_val; - - if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } + goto yy100; +yy106: + YYDEBUG(106, *YYCURSOR); + ++YYCURSOR; + YYFILL(1); + yych = *YYCURSOR; + YYDEBUG(107, *YYCURSOR); + if (yybm[0+yych] & 128) { + goto yy106; } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; - - else + YYDEBUG(108, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 139 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" { - yy_size_t num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + /* ignore whitespace */ - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - if ( yyg->yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart(yyin ,yyscanner); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - } - - yyg->yy_n_chars += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; + goto restart; } - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (yyscan_t yyscanner) -{ - register yy_state_type yy_current_state; - register char *yy_cp; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - yy_current_state = yyg->yy_start; - - yyg->yy_state_ptr = yyg->yy_state_buf; - *yyg->yy_state_ptr++ = yy_current_state; - - for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 126 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - *yyg->yy_state_ptr++ = yy_current_state; - } - - return yy_current_state; -} - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) -{ - register int yy_is_jam; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ - - register YY_CHAR yy_c = 1; - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 126 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 125); - if ( ! yy_is_jam ) - *yyg->yy_state_ptr++ = yy_current_state; - - (void)yyg; - return yy_is_jam ? 0 : yy_current_state; -} - - static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner) -{ - register char *yy_cp; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - yy_cp = yyg->yy_c_buf_p; - - /* undo effects of setting up yytext */ - *yy_cp = yyg->yy_hold_char; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register yy_size_t number_to_move = yyg->yy_n_chars + 2; - register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - register char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - yyg->yytext_ptr = yy_bp; - yyg->yy_hold_char = *yy_cp; - yyg->yy_c_buf_p = yy_cp; -} - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (yyscan_t yyscanner) -#else - static int input (yyscan_t yyscanner) -#endif - -{ - int c; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - *yyg->yy_c_buf_p = yyg->yy_hold_char; - - if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - /* This was really a NUL. */ - *yyg->yy_c_buf_p = '\0'; - - else - { /* need more input */ - yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; - ++yyg->yy_c_buf_p; - - switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart(yyin ,yyscanner); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap(yyscanner ) ) - return EOF; - - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(yyscanner); -#else - return input(yyscanner); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = yyg->yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ - *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ - yyg->yy_hold_char = *++yyg->yy_c_buf_p; - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * @param yyscanner The scanner object. - * @note This function does not reset the start condition to @c INITIAL . - */ - void yyrestart (FILE * input_file , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); - } - - yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); - yy_load_buffer_state(yyscanner ); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * @param yyscanner The scanner object. - */ - void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (yyscanner); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state(yyscanner ); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yyg->yy_did_buffer_switch_on_eof = 1; -} - -static void yy_load_buffer_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - yyg->yy_hold_char = *yyg->yy_c_buf_p; -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * @param yyscanner The scanner object. - * @return the allocated buffer state. - */ - YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ,yyscanner ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer(b,file ,yyscanner); - - return b; -} - -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * @param yyscanner The scanner object. - */ - void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yyfree((void *) b->yy_ch_buf ,yyscanner ); - - yyfree((void *) b ,yyscanner ); -} - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ - static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) - -{ - int oerrno = errno; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - yy_flush_buffer(b ,yyscanner); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - - b->yy_is_interactive = 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * @param yyscanner The scanner object. - */ - void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state(yyscanner ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * @param yyscanner The scanner object. - */ -void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (new_buffer == NULL) - return; - - yyensure_buffer_stack(yyscanner); - - /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - yyg->yy_buffer_stack_top++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state(yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * @param yyscanner The scanner object. - */ -void yypop_buffer_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); - YY_CURRENT_BUFFER_LVALUE = NULL; - if (yyg->yy_buffer_stack_top > 0) - --yyg->yy_buffer_stack_top; - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state(yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; +#line 992 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" } } +#line 168 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void yyensure_buffer_stack (yyscan_t yyscanner) -{ - yy_size_t num_to_alloc; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (!yyg->yy_buffer_stack) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - yyg->yy_buffer_stack_max = num_to_alloc; - yyg->yy_buffer_stack_top = 0; - return; - } - - if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc - (yyg->yy_buffer_stack, - num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; - } } - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer(b ,yyscanner ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string (yyconst char * yystr , yyscan_t yyscanner) -{ - - return yy_scan_bytes(yystr,strlen(yystr) ,yyscanner); -} - -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - yy_size_t i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) yyalloc(n ,yyscanner ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer(buf,n ,yyscanner); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) -{ - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = yyg->yy_hold_char; \ - yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ - yyg->yy_hold_char = *yyg->yy_c_buf_p; \ - *yyg->yy_c_buf_p = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the user-defined data for this scanner. - * @param yyscanner The scanner object. - */ -YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyextra; -} - -/** Get the current line number. - * @param yyscanner The scanner object. - */ -int yyget_lineno (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yylineno; -} - -/** Get the current column number. - * @param yyscanner The scanner object. - */ -int yyget_column (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yycolumn; -} - -/** Get the input stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_in (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyin; -} - -/** Get the output stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_out (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyout; -} - -/** Get the length of the current token. - * @param yyscanner The scanner object. - */ -yy_size_t yyget_leng (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyleng; -} - -/** Get the current token. - * @param yyscanner The scanner object. - */ - -char *yyget_text (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yytext; -} - -/** Set the user-defined data. This data is never touched by the scanner. - * @param user_defined The data to be associated with this scanner. - * @param yyscanner The scanner object. - */ -void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyextra = user_defined ; -} - -/** Set the current line number. - * @param line_number - * @param yyscanner The scanner object. - */ -void yyset_lineno (int line_number , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* lineno is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); - - yylineno = line_number; -} - -/** Set the current column. - * @param line_number - * @param yyscanner The scanner object. - */ -void yyset_column (int column_no , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* column is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_column called with no buffer" ); - - yycolumn = column_no; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param in_str A readable stream. - * @param yyscanner The scanner object. - * @see yy_switch_to_buffer - */ -void yyset_in (FILE * in_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyin = in_str ; -} - -void yyset_out (FILE * out_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyout = out_str ; -} - -int yyget_debug (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yy_flex_debug; -} - -void yyset_debug (int bdebug , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_flex_debug = bdebug ; -} - -/* Accessor methods for yylval and yylloc */ - -YYSTYPE * yyget_lval (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yylval; -} - -void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yylval = yylval_param; -} - -/* User-visible API */ - -/* yylex_init is special because it creates the scanner itself, so it is - * the ONLY reentrant function that doesn't take the scanner as the last argument. - * That's why we explicitly handle the declaration, instead of using our macros. - */ - -int yylex_init(yyscan_t* ptr_yy_globals) - -{ - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; - } - - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); - - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; - } - - /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - return yy_init_globals ( *ptr_yy_globals ); -} - -/* yylex_init_extra has the same functionality as yylex_init, but follows the - * convention of taking the scanner as the last argument. Note however, that - * this is a *pointer* to a scanner, as it will be allocated by this call (and - * is the reason, too, why this function also must handle its own declaration). - * The user defined value in the first argument will be available to yyalloc in - * the yyextra field. - */ - -int yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) - -{ - struct yyguts_t dummy_yyguts; - - yyset_extra (yy_user_defined, &dummy_yyguts); - - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; - } - - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); - - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; - } - - /* By setting to 0xAA, we expose bugs in - yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - yyset_extra (yy_user_defined, *ptr_yy_globals); - - return yy_init_globals ( *ptr_yy_globals ); -} - -static int yy_init_globals (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from yylex_destroy(), so don't allocate here. - */ - - yyg->yy_buffer_stack = 0; - yyg->yy_buffer_stack_top = 0; - yyg->yy_buffer_stack_max = 0; - yyg->yy_c_buf_p = (char *) 0; - yyg->yy_init = 0; - yyg->yy_start = 0; - - yyg->yy_start_stack_ptr = 0; - yyg->yy_start_stack_depth = 0; - yyg->yy_start_stack = NULL; - - yyg->yy_state_buf = 0; - yyg->yy_state_ptr = 0; - yyg->yy_full_match = 0; - yyg->yy_lp = 0; - -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = (FILE *) 0; - yyout = (FILE *) 0; -#endif - - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; -} - -/* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(yyscanner); - } - - /* Destroy the stack itself. */ - yyfree(yyg->yy_buffer_stack ,yyscanner); - yyg->yy_buffer_stack = NULL; - - /* Destroy the start condition stack. */ - yyfree(yyg->yy_start_stack ,yyscanner ); - yyg->yy_start_stack = NULL; - - yyfree ( yyg->yy_state_buf , yyscanner); - yyg->yy_state_buf = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * yylex() is called, initialization will occur. */ - yy_init_globals( yyscanner); - - /* Destroy the main struct (reentrant only). */ - yyfree ( yyscanner , yyscanner ); - yyscanner = NULL; - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) -{ - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) -{ - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *yyalloc (yy_size_t size , yyscan_t yyscanner) -{ - return (void *) malloc( size ); -} - -void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) -{ - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); -} - -void yyfree (void * ptr , yyscan_t yyscanner) -{ - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 131 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" - - - diff --git a/phpdbg_lexer.h b/phpdbg_lexer.h index 1958cef9a26..ab51e7daa87 100644 --- a/phpdbg_lexer.h +++ b/phpdbg_lexer.h @@ -1,348 +1,41 @@ -#ifndef yyHEADER_H -#define yyHEADER_H 1 -#define yyIN_HEADER 1 +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ -#line 6 "sapi/phpdbg/phpdbg_lexer.h" +#ifndef PHPDBG_LEXER_H +#define PHPDBG_LEXER_H -#line 8 "sapi/phpdbg/phpdbg_lexer.h" +#include "phpdbg_cmd.h" -#define YY_INT_ALIGNED short int +typedef struct { + unsigned int len; + unsigned char *text; + unsigned char *cursor; + unsigned char *marker; + int state; +} phpdbg_lexer_data; -/* A lexical scanner generated by flex */ +#define yyparse phpdbg_parse +#define yylex phpdbg_lex -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 37 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif +void phpdbg_init_lexer (phpdbg_param_t *stack, char *input TSRMLS_DC); -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#define YY_BUF_SIZE 16384 -#endif - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - yy_size_t yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -void yyrestart (FILE *input_file ,yyscan_t yyscanner ); -void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); -void yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -void yypop_buffer_state (yyscan_t yyscanner ); - -YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner ); - -void *yyalloc (yy_size_t ,yyscan_t yyscanner ); -void *yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); -void yyfree (void * ,yyscan_t yyscanner ); - -/* Begin user sect3 */ - -#define yywrap(yyscanner) 1 -#define YY_SKIP_YYWRAP - -#define yytext_ptr yytext_r - -#ifdef YY_HEADER_EXPORT_START_CONDITIONS -#define INITIAL 0 -#define RAW 1 -#define NORMAL 2 +int phpdbg_lex (phpdbg_param_t* yylval); #endif - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -int yylex_init (yyscan_t* scanner); - -int yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy (yyscan_t yyscanner ); - -int yyget_debug (yyscan_t yyscanner ); - -void yyset_debug (int debug_flag ,yyscan_t yyscanner ); - -YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner ); - -void yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); - -FILE *yyget_in (yyscan_t yyscanner ); - -void yyset_in (FILE * in_str ,yyscan_t yyscanner ); - -FILE *yyget_out (yyscan_t yyscanner ); - -void yyset_out (FILE * out_str ,yyscan_t yyscanner ); - -yy_size_t yyget_leng (yyscan_t yyscanner ); - -char *yyget_text (yyscan_t yyscanner ); - -int yyget_lineno (yyscan_t yyscanner ); - -void yyset_lineno (int line_number ,yyscan_t yyscanner ); - -int yyget_column (yyscan_t yyscanner ); - -void yyset_column (int column_no ,yyscan_t yyscanner ); - -YYSTYPE * yyget_lval (yyscan_t yyscanner ); - -void yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap (yyscan_t yyscanner ); -#else -extern int yywrap (yyscan_t yyscanner ); -#endif -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex \ - (YYSTYPE * yylval_param ,yyscan_t yyscanner); - -#define YY_DECL int yylex \ - (YYSTYPE * yylval_param , yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -#undef YY_NEW_FILE -#undef YY_FLUSH_BUFFER -#undef yy_set_bol -#undef yy_new_buffer -#undef yy_set_interactive -#undef YY_DO_BEFORE_ACTION - -#ifdef YY_DECL_IS_OURS -#undef YY_DECL_IS_OURS -#undef YY_DECL -#endif - -#line 131 "/usr/src/php-src/sapi/phpdbg/phpdbg_lexer.l" - - -#line 347 "sapi/phpdbg/phpdbg_lexer.h" -#undef yyIN_HEADER -#endif /* yyHEADER_H */ diff --git a/phpdbg_lexer.l b/phpdbg_lexer.l index b3536feab84..4d9c837f1e4 100644 --- a/phpdbg_lexer.l +++ b/phpdbg_lexer.l @@ -1,131 +1,169 @@ -%{ - /* * phpdbg_lexer.l */ #include "phpdbg.h" #include "phpdbg_cmd.h" -#define YYSTYPE phpdbg_param_t #include "phpdbg_parser.h" -%} +#define LEX(v) (PHPDBG_G(lexer).v) -%s RAW -%s NORMAL +#define YYCTYPE unsigned char +#define YYSETCONDITION(x) LEX(state) = x; +#define YYGETCONDITION() LEX(state) +#define YYCURSOR LEX(cursor) +#define YYMARKER LEX(marker) +#define yyleng LEX(len) +#define yytext ((char*) LEX(text)) +#undef YYDEBUG +#define YYDEBUG(a, b) +#define YYFILL(n) -%option outfile="sapi/phpdbg/phpdbg_lexer.c" header-file="sapi/phpdbg/phpdbg_lexer.h" -%option warn nodefault - -%option reentrant noyywrap never-interactive nounistd -%option bison-bridge +#define NORMAL 0 +#define RAW 1 +#define INITIAL 2 -T_TRUE "true" -T_YES "yes" -T_ON "on" -T_ENABLED "enabled" -T_FALSE "false" -T_NO "no" -T_OFF "off" -T_DISABLED "disabled" -T_EVAL "ev" -T_SHELL "sh" -T_IF "if" -T_RUN "run" -T_RUN_SHORT "r" +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); -WS [ \r\n\t]+ -DIGITS [0-9\.]+ -ID [^ \r\n\t:#]+ -ADDR 0x[a-fA-F0-9]+ -OPCODE (ZEND_|zend_)([A-Za-z])+ -INPUT [^\n]+ -%% +void phpdbg_init_lexer (phpdbg_param_t *stack, char *input TSRMLS_DC) { + PHPDBG_G(parser_stack) = stack; -{ - {T_EVAL} { - BEGIN(RAW); - phpdbg_init_param(yylval, EMPTY_PARAM); - return T_EVAL; - } - {T_SHELL} { - BEGIN(RAW); - phpdbg_init_param(yylval, EMPTY_PARAM); - return T_SHELL; - } - {T_RUN}|{T_RUN_SHORT} { - BEGIN(RAW); - phpdbg_init_param(yylval, EMPTY_PARAM); - return T_RUN; - } + YYSETCONDITION(INITIAL); - .+ { - BEGIN(NORMAL); - REJECT; - } + LEX(text) = YYCURSOR = (unsigned char *) input; + LEX(len) = strlen(input); } -{ - {T_IF} { - BEGIN(RAW); - phpdbg_init_param(yylval, EMPTY_PARAM); - return T_IF; - } +int phpdbg_lex (phpdbg_param_t* yylval) { + TSRMLS_FETCH(); /* Slow, but this is not a major problem here. TODO: Use TSRMLS_DC */ + +restart: + LEX(text) = YYCURSOR; + +/*!re2c +re2c:yyfill:check = 0; +T_TRUE "true" +T_YES "yes" +T_ON "on" +T_ENABLED "enabled" +T_FALSE "false" +T_NO "no" +T_OFF "off" +T_DISABLED "disabled" +T_EVAL "ev" +T_SHELL "sh" +T_IF "if" +T_RUN "run" +T_RUN_SHORT "r" +WS [ \r\n\t]+ +DIGITS [0-9\.]+ +ID [^ \r\n\t:#\000]+ +ADDR [0][x][a-fA-F0-9]+ +OPCODE (ZEND_|zend_)([A-Za-z])+ +INPUT [^\n\000]+ + + := yyleng = (size_t) YYCURSOR - (size_t) yytext; + +<*>[\n\000] { + return 0; } -{ - {ID}[:]{1}[//]{2} { - phpdbg_init_param(yylval, STR_PARAM); - yylval->str = zend_strndup(yytext, yyleng); - yylval->len = yyleng; - return T_PROTO; - } - [#]{1} { return T_POUND; } - [:]{2} { return T_DCOLON; } - [:]{1} { return T_COLON; } - - {T_YES}|{T_ON}|{T_ENABLED}|{T_TRUE} { - phpdbg_init_param(yylval, NUMERIC_PARAM); - yylval->num = 1; - return T_TRUTHY; - } - {T_NO}|{T_OFF}|{T_DISABLED}|{T_FALSE} { - phpdbg_init_param(yylval, NUMERIC_PARAM); - yylval->num = 0; - return T_FALSY; - } - {DIGITS} { - phpdbg_init_param(yylval, NUMERIC_PARAM); - yylval->num = atoi(yytext); - return T_DIGITS; - } - {ADDR} { - phpdbg_init_param(yylval, ADDR_PARAM); - yylval->addr = strtoul(yytext, 0, 16); - return T_ADDR; - } - {OPCODE} { - phpdbg_init_param(yylval, OP_PARAM); - yylval->str = zend_strndup(yytext, yyleng); - yylval->len = yyleng; - return T_OPCODE; - } - {ID} { - phpdbg_init_param(yylval, STR_PARAM); - yylval->str = zend_strndup(yytext, yyleng); - yylval->len = yyleng; - return T_ID; - } +{T_IF} { + YYSETCONDITION(RAW); + phpdbg_init_param(yylval, EMPTY_PARAM); + return T_IF; } -{INPUT} { +{ID}[:]{1}[//]{2} { + phpdbg_init_param(yylval, STR_PARAM); + yylval->str = zend_strndup(yytext, yyleng); + yylval->len = yyleng; + return T_PROTO; +} +[#]{1} { + return T_POUND; +} +[:]{2} { + return T_DCOLON; +} +[:]{1} { + return T_COLON; +} + +{T_YES}|{T_ON}|{T_ENABLED}|{T_TRUE} { + phpdbg_init_param(yylval, NUMERIC_PARAM); + yylval->num = 1; + return T_TRUTHY; +} + +{T_NO}|{T_OFF}|{T_DISABLED}|{T_FALSE} { + phpdbg_init_param(yylval, NUMERIC_PARAM); + yylval->num = 0; + return T_FALSY; +} + +{DIGITS} { + phpdbg_init_param(yylval, NUMERIC_PARAM); + yylval->num = atoi(yytext); + return T_DIGITS; +} + +{ADDR} { + phpdbg_init_param(yylval, ADDR_PARAM); + yylval->addr = strtoul(yytext, 0, 16); + return T_ADDR; +} + +{OPCODE} { + phpdbg_init_param(yylval, OP_PARAM); + yylval->str = zend_strndup(yytext, yyleng); + yylval->len = yyleng; + return T_OPCODE; +} + +{ID} { + phpdbg_init_param(yylval, STR_PARAM); + yylval->str = zend_strndup(yytext, yyleng); + yylval->len = yyleng; + return T_ID; +} + +{INPUT} { phpdbg_init_param(yylval, STR_PARAM); yylval->str = zend_strndup(yytext, yyleng); yylval->len = yyleng; - BEGIN(INITIAL); return T_INPUT; } -{WS} { /* ignore whitespace */ } -%% +<*>{WS} { + /* ignore whitespace */ + + goto restart; +} + +{T_EVAL} { + YYSETCONDITION(RAW); + phpdbg_init_param(yylval, EMPTY_PARAM); + return T_EVAL; +} +{T_SHELL} { + YYSETCONDITION(RAW); + phpdbg_init_param(yylval, EMPTY_PARAM); + return T_SHELL; +} +{T_RUN}|{T_RUN_SHORT} { + YYSETCONDITION(RAW); + phpdbg_init_param(yylval, EMPTY_PARAM); + return T_RUN; +} + +. { + YYSETCONDITION(NORMAL); + + YYCURSOR = LEX(text); + goto restart; +} + +*/ +} diff --git a/phpdbg_parser.c b/phpdbg_parser.c index 79af58f8c9a..f9a3e4d299a 100644 --- a/phpdbg_parser.c +++ b/phpdbg_parser.c @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.7. */ +/* A Bison parser, made by GNU Bison 2.6.2. */ /* Bison implementation for Yacc-like parsers in C @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.7" +#define YYBISON_VERSION "2.6.2" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -59,11 +59,18 @@ #define YYPULL 1 - +/* Substitute the variable and function names. */ +#define yyparse phpdbg_parse +#define yylex phpdbg_lex +#define yyerror phpdbg_error +#define yylval phpdbg_lval +#define yychar phpdbg_char +#define yydebug phpdbg_debug +#define yynerrs phpdbg_nerrs /* Copy the first part of user declarations. */ -/* Line 371 of yacc.c */ -#line 2 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" +/* Line 336 of yacc.c */ +#line 1 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" /* @@ -84,25 +91,14 @@ #include "phpdbg_parser.h" #include "phpdbg_lexer.h" +#undef yyerror +static int yyerror(void ***tsrm_ls, const char *msg); + ZEND_EXTERN_MODULE_GLOBALS(phpdbg); -int yyerror(phpdbg_param_t *stack, yyscan_t scanner, const char *msg) { - TSRMLS_FETCH(); - phpdbg_error("Parse Error: %s", msg); - { - const phpdbg_param_t *top = stack; - - while (top) { - phpdbg_param_debug( - top, "--> "); - top = top->next; - } - } - return 0; -} -/* Line 371 of yacc.c */ -#line 106 "sapi/phpdbg/phpdbg_parser.c" +/* Line 336 of yacc.c */ +#line 102 "sapi/phpdbg/phpdbg_parser.c" # ifndef YY_NULL # if defined __cplusplus && 201103L <= __cplusplus @@ -122,18 +118,18 @@ int yyerror(phpdbg_param_t *stack, yyscan_t scanner, const char *msg) { /* In a future release of Bison, this section will be replaced by #include "phpdbg_parser.h". */ -#ifndef YY_YY_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED -# define YY_YY_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED +#ifndef PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H +# define PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif #if YYDEBUG -extern int yydebug; +extern int phpdbg_debug; #endif /* "%code requires" blocks. */ -/* Line 387 of yacc.c */ -#line 40 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" +/* Line 350 of yacc.c */ +#line 31 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" #include "phpdbg.h" #ifndef YY_TYPEDEF_YY_SCANNER_T @@ -142,8 +138,8 @@ typedef void* yyscan_t; #endif -/* Line 387 of yacc.c */ -#line 147 "sapi/phpdbg/phpdbg_parser.c" +/* Line 350 of yacc.c */ +#line 143 "sapi/phpdbg/phpdbg_parser.c" /* Tokens. */ #ifndef YYTOKENTYPE @@ -203,24 +199,24 @@ typedef int YYSTYPE; #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus -int yyparse (void *YYPARSE_PARAM); +int phpdbg_parse (void *YYPARSE_PARAM); #else -int yyparse (); +int phpdbg_parse (); #endif #else /* ! YYPARSE_PARAM */ #if defined __STDC__ || defined __cplusplus -int yyparse (phpdbg_param_t *stack, yyscan_t scanner); +int phpdbg_parse (void *tsrm_ls); #else -int yyparse (); +int phpdbg_parse (); #endif #endif /* ! YYPARSE_PARAM */ -#endif /* !YY_YY_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED */ +#endif /* !PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H */ /* Copy the second part of user declarations. */ -/* Line 390 of yacc.c */ -#line 224 "sapi/phpdbg/phpdbg_parser.c" +/* Line 353 of yacc.c */ +#line 220 "sapi/phpdbg/phpdbg_parser.c" #ifdef short # undef short @@ -273,24 +269,24 @@ typedef short int yytype_int16; # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ -# define YY_(Msgid) dgettext ("bison-runtime", Msgid) +# define YY_(msgid) dgettext ("bison-runtime", msgid) # endif # endif # ifndef YY_ -# define YY_(Msgid) Msgid +# define YY_(msgid) msgid # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ -# define YYUSE(E) ((void) (E)) +# define YYUSE(e) ((void) (e)) #else -# define YYUSE(E) /* empty */ +# define YYUSE(e) /* empty */ #endif /* Identity function, used to suppress warnings about constant conditions. */ #ifndef lint -# define YYID(N) (N) +# define YYID(n) (n) #else #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) @@ -438,18 +434,18 @@ union yyalloc #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ -#define YYFINAL 24 +#define YYFINAL 25 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 33 +#define YYLAST 41 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 21 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 4 +#define YYNNTS 5 /* YYNRULES -- Number of rules. */ -#define YYNRULES 24 +#define YYNRULES 25 /* YYNRULES -- Number of states. */ -#define YYNSTATES 37 +#define YYNSTATES 38 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 @@ -496,30 +492,30 @@ static const yytype_uint8 yytranslate[] = YYRHS. */ static const yytype_uint8 yyprhs[] = { - 0, 0, 3, 5, 6, 8, 11, 15, 20, 25, - 31, 35, 41, 45, 48, 51, 54, 56, 59, 61, - 63, 65, 67, 69, 71 + 0, 0, 3, 5, 7, 8, 10, 13, 17, 22, + 27, 33, 37, 43, 47, 49, 51, 53, 55, 57, + 59, 61, 64, 67, 70, 72 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { - 22, 0, -1, 23, -1, -1, 24, -1, 23, 24, - -1, 18, 10, 14, -1, 18, 10, 12, 14, -1, - 13, 18, 10, 14, -1, 13, 18, 10, 12, 14, - -1, 18, 11, 18, -1, 18, 11, 18, 12, 14, - -1, 18, 12, 14, -1, 6, 19, -1, 3, 19, - -1, 5, 19, -1, 4, -1, 4, 19, -1, 17, - -1, 16, -1, 15, -1, 7, -1, 8, -1, 14, - -1, 18, -1 + 22, 0, -1, 23, -1, 25, -1, -1, 24, -1, + 23, 24, -1, 18, 10, 14, -1, 18, 10, 12, + 14, -1, 13, 18, 10, 14, -1, 13, 18, 10, + 12, 14, -1, 18, 11, 18, -1, 18, 11, 18, + 12, 14, -1, 18, 12, 14, -1, 17, -1, 16, + -1, 15, -1, 7, -1, 8, -1, 14, -1, 18, + -1, 6, 19, -1, 3, 19, -1, 5, 19, -1, + 4, -1, 4, 19, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { - 0, 76, 76, 77, 81, 82, 86, 91, 96, 107, - 118, 123, 129, 135, 140, 145, 150, 154, 159, 160, - 161, 162, 163, 164, 165 + 0, 66, 66, 67, 68, 72, 73, 77, 82, 87, + 97, 107, 112, 118, 124, 125, 126, 127, 128, 129, + 130, 134, 139, 144, 149, 153 }; #endif @@ -536,7 +532,7 @@ static const char *const yytname[] = "\"digits (numbers)\"", "\"literal (string)\"", "\"address\"", "\"opcode\"", "\"identifier (command or function name)\"", "\"input (input string or data)\"", "\"input\"", "$accept", "input", - "parameters", "parameter", YY_NULL + "parameters", "parameter", "full_expression", YY_NULL }; #endif @@ -554,17 +550,17 @@ static const yytype_uint16 yytoknum[] = /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 21, 22, 22, 23, 23, 24, 24, 24, 24, + 0, 21, 22, 22, 22, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24 + 24, 25, 25, 25, 25, 25 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { - 0, 2, 1, 0, 1, 2, 3, 4, 4, 5, - 3, 5, 3, 2, 2, 2, 1, 2, 1, 1, - 1, 1, 1, 1, 1 + 0, 2, 1, 1, 0, 1, 2, 3, 4, 4, + 5, 3, 5, 3, 1, 1, 1, 1, 1, 1, + 1, 2, 2, 2, 1, 2 }; /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. @@ -572,16 +568,16 @@ static const yytype_uint8 yyr2[] = means the default is an error. */ static const yytype_uint8 yydefact[] = { - 3, 0, 16, 0, 0, 21, 22, 0, 23, 20, - 19, 18, 24, 0, 2, 4, 14, 17, 15, 13, - 0, 0, 0, 0, 1, 5, 0, 0, 6, 10, - 12, 0, 8, 7, 0, 9, 11 + 4, 0, 24, 0, 0, 17, 18, 0, 19, 16, + 15, 14, 20, 0, 2, 5, 3, 22, 25, 23, + 21, 0, 0, 0, 0, 1, 6, 0, 0, 7, + 11, 13, 0, 9, 8, 0, 10, 12 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { - -1, 13, 14, 15 + -1, 13, 14, 15, 16 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing @@ -589,16 +585,16 @@ static const yytype_int8 yydefgoto[] = #define YYPACT_NINF -11 static const yytype_int8 yypact[] = { - -3, -10, 1, 2, 3, -11, -11, 6, -11, -11, - -11, -11, -4, 23, -3, -11, -11, -11, -11, -11, - 15, 4, 8, 13, -11, -11, 5, 14, -11, 17, - -11, 16, -11, -11, 18, -11, -11 + -3, -10, 10, 11, 12, -11, -11, 14, -11, -11, + -11, -11, -4, 28, 9, -11, -11, -11, -11, -11, + -11, 23, 6, 16, 21, -11, -11, 7, 22, -11, + 25, -11, 24, -11, -11, 26, -11, -11 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -11, -11, -11, 19 + -11, -11, -11, 27, -11 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -607,24 +603,26 @@ static const yytype_int8 yypgoto[] = #define YYTABLE_NINF -1 static const yytype_uint8 yytable[] = { - 1, 2, 3, 4, 5, 6, 21, 22, 23, 16, - 7, 8, 9, 10, 11, 12, 27, 31, 28, 32, - 17, 18, 19, 24, 20, 26, 29, 30, 33, 34, - 35, 0, 36, 25 + 1, 2, 3, 4, 5, 6, 22, 23, 24, 17, + 7, 8, 9, 10, 11, 12, 5, 6, 28, 32, + 29, 33, 7, 8, 9, 10, 11, 12, 25, 18, + 19, 20, 21, 27, 30, 31, 34, 35, 36, 0, + 37, 26 }; -#define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-11))) +#define yypact_value_is_default(yystate) \ + ((yystate) == (-11)) -#define yytable_value_is_error(Yytable_value) \ +#define yytable_value_is_error(yytable_value) \ YYID (0) static const yytype_int8 yycheck[] = { 3, 4, 5, 6, 7, 8, 10, 11, 12, 19, - 13, 14, 15, 16, 17, 18, 12, 12, 14, 14, - 19, 19, 19, 0, 18, 10, 18, 14, 14, 12, - 14, -1, 14, 14 + 13, 14, 15, 16, 17, 18, 7, 8, 12, 12, + 14, 14, 13, 14, 15, 16, 17, 18, 0, 19, + 19, 19, 18, 10, 18, 14, 14, 12, 14, -1, + 14, 14 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing @@ -632,9 +630,9 @@ static const yytype_int8 yycheck[] = static const yytype_uint8 yystos[] = { 0, 3, 4, 5, 6, 7, 8, 13, 14, 15, - 16, 17, 18, 22, 23, 24, 19, 19, 19, 19, - 18, 10, 11, 12, 0, 24, 10, 12, 14, 18, - 14, 12, 14, 14, 12, 14, 14 + 16, 17, 18, 22, 23, 24, 25, 19, 19, 19, + 19, 18, 10, 11, 12, 0, 24, 10, 12, 14, + 18, 14, 12, 14, 14, 12, 14, 14 }; #define yyerrok (yyerrstatus = 0) @@ -676,27 +674,56 @@ do \ } \ else \ { \ - yyerror (stack, scanner, YY_("syntax error: cannot back up")); \ + yyerror (tsrm_ls, YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (YYID (0)) -/* Error token number */ + #define YYTERROR 1 #define YYERRCODE 256 +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) + + /* This macro is provided for backward compatibility. */ + #ifndef YY_LOCATION_PRINT # define YY_LOCATION_PRINT(File, Loc) ((void) 0) #endif /* YYLEX -- calling `yylex' with the right arguments. */ + #ifdef YYLEX_PARAM # define YYLEX yylex (&yylval, YYLEX_PARAM) #else -# define YYLEX yylex (&yylval, scanner) +# define YYLEX yylex (&yylval) #endif /* Enable debugging if requested. */ @@ -719,7 +746,7 @@ do { \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ - Type, Value, stack, scanner); \ + Type, Value, tsrm_ls); \ YYFPRINTF (stderr, "\n"); \ } \ } while (YYID (0)) @@ -733,23 +760,21 @@ do { \ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, phpdbg_param_t *stack, yyscan_t scanner) +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *tsrm_ls) #else static void -yy_symbol_value_print (yyoutput, yytype, yyvaluep, stack, scanner) +yy_symbol_value_print (yyoutput, yytype, yyvaluep, tsrm_ls) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; - phpdbg_param_t *stack; - yyscan_t scanner; + void *tsrm_ls; #endif { FILE *yyo = yyoutput; YYUSE (yyo); if (!yyvaluep) return; - YYUSE (stack); - YYUSE (scanner); + YYUSE (tsrm_ls); # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); @@ -759,7 +784,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, stack, scanner) switch (yytype) { default: - break; + break; } } @@ -771,15 +796,14 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, stack, scanner) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, phpdbg_param_t *stack, yyscan_t scanner) +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *tsrm_ls) #else static void -yy_symbol_print (yyoutput, yytype, yyvaluep, stack, scanner) +yy_symbol_print (yyoutput, yytype, yyvaluep, tsrm_ls) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; - phpdbg_param_t *stack; - yyscan_t scanner; + void *tsrm_ls; #endif { if (yytype < YYNTOKENS) @@ -787,7 +811,7 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, stack, scanner) else YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - yy_symbol_value_print (yyoutput, yytype, yyvaluep, stack, scanner); + yy_symbol_value_print (yyoutput, yytype, yyvaluep, tsrm_ls); YYFPRINTF (yyoutput, ")"); } @@ -830,14 +854,13 @@ do { \ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_reduce_print (YYSTYPE *yyvsp, int yyrule, phpdbg_param_t *stack, yyscan_t scanner) +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, void *tsrm_ls) #else static void -yy_reduce_print (yyvsp, yyrule, stack, scanner) +yy_reduce_print (yyvsp, yyrule, tsrm_ls) YYSTYPE *yyvsp; int yyrule; - phpdbg_param_t *stack; - yyscan_t scanner; + void *tsrm_ls; #endif { int yynrhs = yyr2[yyrule]; @@ -851,7 +874,7 @@ yy_reduce_print (yyvsp, yyrule, stack, scanner) YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) - , stack, scanner); + , tsrm_ls); YYFPRINTF (stderr, "\n"); } } @@ -859,7 +882,7 @@ yy_reduce_print (yyvsp, yyrule, stack, scanner) # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ - yy_reduce_print (yyvsp, Rule, stack, scanner); \ + yy_reduce_print (yyvsp, Rule, tsrm_ls); \ } while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that @@ -1005,6 +1028,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, { YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ const char *yyformat = YY_NULL; @@ -1067,13 +1091,11 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, break; } yyarg[yycount++] = yytname[yyx]; - { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } + yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; } } } @@ -1093,12 +1115,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, # undef YYCASE_ } - { - YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } + yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; if (*yymsg_alloc < yysize) { @@ -1139,20 +1159,18 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, phpdbg_param_t *stack, yyscan_t scanner) +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, void *tsrm_ls) #else static void -yydestruct (yymsg, yytype, yyvaluep, stack, scanner) +yydestruct (yymsg, yytype, yyvaluep, tsrm_ls) const char *yymsg; int yytype; YYSTYPE *yyvaluep; - phpdbg_param_t *stack; - yyscan_t scanner; + void *tsrm_ls; #endif { YYUSE (yyvaluep); - YYUSE (stack); - YYUSE (scanner); + YYUSE (tsrm_ls); if (!yymsg) yymsg = "Deleting"; @@ -1162,7 +1180,7 @@ yydestruct (yymsg, yytype, yyvaluep, stack, scanner) { default: - break; + break; } } @@ -1187,43 +1205,19 @@ yyparse (YYPARSE_PARAM) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) int -yyparse (phpdbg_param_t *stack, yyscan_t scanner) +yyparse (void *tsrm_ls) #else int -yyparse (stack, scanner) - phpdbg_param_t *stack; - yyscan_t scanner; +yyparse (tsrm_ls) + void *tsrm_ls; #endif #endif { /* The lookahead symbol. */ int yychar; - -#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ -/* Suppress an incorrect diagnostic about yylval being uninitialized. */ -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ - _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") -# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ - _Pragma ("GCC diagnostic pop") -#else -/* Default value used for initialization, for pacifying older GCCs - or non-GCC compilers. */ -static YYSTYPE yyval_default; -# define YY_INITIAL_VALUE(Value) = Value -#endif -#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_END -#endif -#ifndef YY_INITIAL_VALUE -# define YY_INITIAL_VALUE(Value) /* Nothing. */ -#endif - /* The semantic value of the lookahead symbol. */ -YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); +YYSTYPE yylval; /* Number of syntax errors so far. */ int yynerrs; @@ -1254,7 +1248,7 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); int yyn; int yyresult; /* Lookahead token as an internal (translated) token number. */ - int yytoken = 0; + int yytoken; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; @@ -1272,8 +1266,9 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); Keep to zero when no symbol should be popped. */ int yylen = 0; - yyssp = yyss = yyssa; - yyvsp = yyvs = yyvsa; + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; yystacksize = YYINITDEPTH; YYDPRINTF ((stderr, "Starting parse\n")); @@ -1282,6 +1277,13 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + yyssp = yyss; + yyvsp = yyvs; goto yysetstate; /*------------------------------------------------------------. @@ -1422,9 +1424,7 @@ yybackup: yychar = YYEMPTY; yystate = yyn; - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; - YY_IGNORE_MAYBE_UNINITIALIZED_END goto yynewstate; @@ -1460,21 +1460,27 @@ yyreduce: YY_REDUCE_PRINT (yyn); switch (yyn) { - case 4: -/* Line 1792 of yacc.c */ -#line 81 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" - { phpdbg_stack_push(stack, &(yyvsp[(1) - (1)])); } + case 3: +/* Line 1802 of yacc.c */ +#line 67 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + { phpdbg_stack_push(PHPDBG_G(parser_stack), &(yyvsp[(1) - (1)])); } break; case 5: -/* Line 1792 of yacc.c */ -#line 82 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" - { phpdbg_stack_push(stack, &(yyvsp[(2) - (2)])); } +/* Line 1802 of yacc.c */ +#line 72 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + { phpdbg_stack_push(PHPDBG_G(parser_stack), &(yyvsp[(1) - (1)])); } break; case 6: -/* Line 1792 of yacc.c */ -#line 86 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" +/* Line 1802 of yacc.c */ +#line 73 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + { phpdbg_stack_push(PHPDBG_G(parser_stack), &(yyvsp[(2) - (2)])); } + break; + + case 7: +/* Line 1802 of yacc.c */ +#line 77 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = FILE_PARAM; (yyval).file.name = (yyvsp[(2) - (3)]).str; @@ -1482,9 +1488,9 @@ yyreduce: } break; - case 7: -/* Line 1792 of yacc.c */ -#line 91 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + case 8: +/* Line 1802 of yacc.c */ +#line 82 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = NUMERIC_FILE_PARAM; (yyval).file.name = (yyvsp[(1) - (4)]).str; @@ -1492,13 +1498,12 @@ yyreduce: } break; - case 8: -/* Line 1792 of yacc.c */ -#line 96 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + case 9: +/* Line 1802 of yacc.c */ +#line 87 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = FILE_PARAM; - (yyval).file.name = malloc((yyvsp[(1) - (4)]).len + - (yyvsp[(2) - (4)]).len + 1); + (yyval).file.name = malloc((yyvsp[(1) - (4)]).len + (yyvsp[(2) - (4)]).len + 1); if ((yyval).file.name) { memcpy(&(yyval).file.name[0], (yyvsp[(1) - (4)]).str, (yyvsp[(1) - (4)]).len); memcpy(&(yyval).file.name[(yyvsp[(1) - (4)]).len], (yyvsp[(2) - (4)]).str, (yyvsp[(2) - (4)]).len); @@ -1508,13 +1513,12 @@ yyreduce: } break; - case 9: -/* Line 1792 of yacc.c */ -#line 107 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + case 10: +/* Line 1802 of yacc.c */ +#line 97 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = NUMERIC_FILE_PARAM; - (yyval).file.name = malloc((yyvsp[(1) - (5)]).len + - (yyvsp[(2) - (5)]).len + 1); + (yyval).file.name = malloc((yyvsp[(1) - (5)]).len + (yyvsp[(2) - (5)]).len + 1); if ((yyval).file.name) { memcpy(&(yyval).file.name[0], (yyvsp[(1) - (5)]).str, (yyvsp[(1) - (5)]).len); memcpy(&(yyval).file.name[(yyvsp[(1) - (5)]).len], (yyvsp[(2) - (5)]).str, (yyvsp[(2) - (5)]).len); @@ -1524,9 +1528,9 @@ yyreduce: } break; - case 10: -/* Line 1792 of yacc.c */ -#line 118 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + case 11: +/* Line 1802 of yacc.c */ +#line 107 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = METHOD_PARAM; (yyval).method.class = (yyvsp[(1) - (3)]).str; @@ -1534,9 +1538,9 @@ yyreduce: } break; - case 11: -/* Line 1792 of yacc.c */ -#line 123 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + case 12: +/* Line 1802 of yacc.c */ +#line 112 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = NUMERIC_METHOD_PARAM; (yyval).method.class = (yyvsp[(1) - (5)]).str; @@ -1545,9 +1549,9 @@ yyreduce: } break; - case 12: -/* Line 1792 of yacc.c */ -#line 129 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + case 13: +/* Line 1802 of yacc.c */ +#line 118 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = NUMERIC_FUNCTION_PARAM; (yyval).str = (yyvsp[(1) - (3)]).str; @@ -1556,19 +1560,61 @@ yyreduce: } break; - case 13: -/* Line 1792 of yacc.c */ -#line 135 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" - { + case 14: +/* Line 1802 of yacc.c */ +#line 124 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 15: +/* Line 1802 of yacc.c */ +#line 125 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 16: +/* Line 1802 of yacc.c */ +#line 126 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 17: +/* Line 1802 of yacc.c */ +#line 127 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 18: +/* Line 1802 of yacc.c */ +#line 128 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 19: +/* Line 1802 of yacc.c */ +#line 129 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 20: +/* Line 1802 of yacc.c */ +#line 130 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 21: +/* Line 1802 of yacc.c */ +#line 134 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + { (yyval).type = COND_PARAM; (yyval).str = (yyvsp[(2) - (2)]).str; (yyval).len = (yyvsp[(2) - (2)]).len; } break; - case 14: -/* Line 1792 of yacc.c */ -#line 140 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + case 22: +/* Line 1802 of yacc.c */ +#line 139 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = EVAL_PARAM; (yyval).str = (yyvsp[(2) - (2)]).str; @@ -1576,9 +1622,9 @@ yyreduce: } break; - case 15: -/* Line 1792 of yacc.c */ -#line 145 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + case 23: +/* Line 1802 of yacc.c */ +#line 144 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = SHELL_PARAM; (yyval).str = (yyvsp[(2) - (2)]).str; @@ -1586,18 +1632,18 @@ yyreduce: } break; - case 16: -/* Line 1792 of yacc.c */ -#line 150 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + case 24: +/* Line 1802 of yacc.c */ +#line 149 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = RUN_PARAM; (yyval).len = 0; } break; - case 17: -/* Line 1792 of yacc.c */ -#line 154 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" + case 25: +/* Line 1802 of yacc.c */ +#line 153 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = RUN_PARAM; (yyval).str = (yyvsp[(2) - (2)]).str; @@ -1605,51 +1651,9 @@ yyreduce: } break; - case 18: -/* Line 1792 of yacc.c */ -#line 159 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" - { (yyval) = (yyvsp[(1) - (1)]); } - break; - case 19: -/* Line 1792 of yacc.c */ -#line 160 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" - { (yyval) = (yyvsp[(1) - (1)]); } - break; - - case 20: -/* Line 1792 of yacc.c */ -#line 161 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" - { (yyval) = (yyvsp[(1) - (1)]); } - break; - - case 21: -/* Line 1792 of yacc.c */ -#line 162 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" - { (yyval) = (yyvsp[(1) - (1)]); } - break; - - case 22: -/* Line 1792 of yacc.c */ -#line 163 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" - { (yyval) = (yyvsp[(1) - (1)]); } - break; - - case 23: -/* Line 1792 of yacc.c */ -#line 164 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" - { (yyval) = (yyvsp[(1) - (1)]); } - break; - - case 24: -/* Line 1792 of yacc.c */ -#line 165 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" - { (yyval) = (yyvsp[(1) - (1)]); } - break; - - -/* Line 1792 of yacc.c */ -#line 1653 "sapi/phpdbg/phpdbg_parser.c" +/* Line 1802 of yacc.c */ +#line 1657 "sapi/phpdbg/phpdbg_parser.c" default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -1699,7 +1703,7 @@ yyerrlab: { ++yynerrs; #if ! YYERROR_VERBOSE - yyerror (stack, scanner, YY_("syntax error")); + yyerror (tsrm_ls, YY_("syntax error")); #else # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ yyssp, yytoken) @@ -1726,7 +1730,7 @@ yyerrlab: yymsgp = yymsg; } } - yyerror (stack, scanner, yymsgp); + yyerror (tsrm_ls, yymsgp); if (yysyntax_error_status == 2) goto yyexhaustedlab; } @@ -1750,7 +1754,7 @@ yyerrlab: else { yydestruct ("Error: discarding", - yytoken, &yylval, stack, scanner); + yytoken, &yylval, tsrm_ls); yychar = YYEMPTY; } } @@ -1806,15 +1810,13 @@ yyerrlab1: yydestruct ("Error: popping", - yystos[yystate], yyvsp, stack, scanner); + yystos[yystate], yyvsp, tsrm_ls); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; - YY_IGNORE_MAYBE_UNINITIALIZED_END /* Shift the error token. */ @@ -1843,7 +1845,7 @@ yyabortlab: | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: - yyerror (stack, scanner, YY_("memory exhausted")); + yyerror (tsrm_ls, YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif @@ -1855,7 +1857,7 @@ yyreturn: user semantic actions for why this is necessary. */ yytoken = YYTRANSLATE (yychar); yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval, stack, scanner); + yytoken, &yylval, tsrm_ls); } /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ @@ -1864,7 +1866,7 @@ yyreturn: while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp, stack, scanner); + yystos[*yyssp], yyvsp, tsrm_ls); YYPOPSTACK (1); } #ifndef yyoverflow @@ -1880,6 +1882,30 @@ yyreturn: } -/* Line 2055 of yacc.c */ -#line 168 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" +/* Line 2048 of yacc.c */ +#line 160 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + +static int yyerror(void ***tsrm_ls, const char *msg) { + phpdbg_error("Parse Error: %s", msg); + + { + const phpdbg_param_t *top = PHPDBG_G(parser_stack); + + while (top) { + phpdbg_param_debug(top, "--> "); + top = top->next; + } + } + return 0; +} + +int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC) { + phpdbg_init_lexer(stack, input TSRMLS_CC); + +#ifdef ZTS + return yyparse(TSRMLS_C); +#else + return yyparse(NULL); +#endif +} diff --git a/phpdbg_parser.h b/phpdbg_parser.h index 6acb8963c9e..b3aadb9c62d 100644 --- a/phpdbg_parser.h +++ b/phpdbg_parser.h @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.7. */ +/* A Bison parser, made by GNU Bison 2.6.2. */ /* Bison interface for Yacc-like parsers in C @@ -30,18 +30,18 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ -#ifndef YY_YY_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED -# define YY_YY_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED +#ifndef PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H +# define PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif #if YYDEBUG -extern int yydebug; +extern int phpdbg_debug; #endif /* "%code requires" blocks. */ -/* Line 2058 of yacc.c */ -#line 40 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" +/* Line 2055 of yacc.c */ +#line 31 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" #include "phpdbg.h" #ifndef YY_TYPEDEF_YY_SCANNER_T @@ -50,7 +50,7 @@ typedef void* yyscan_t; #endif -/* Line 2058 of yacc.c */ +/* Line 2055 of yacc.c */ #line 55 "sapi/phpdbg/phpdbg_parser.h" /* Tokens. */ @@ -111,16 +111,16 @@ typedef int YYSTYPE; #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus -int yyparse (void *YYPARSE_PARAM); +int phpdbg_parse (void *YYPARSE_PARAM); #else -int yyparse (); +int phpdbg_parse (); #endif #else /* ! YYPARSE_PARAM */ #if defined __STDC__ || defined __cplusplus -int yyparse (phpdbg_param_t *stack, yyscan_t scanner); +int phpdbg_parse (void *tsrm_ls); #else -int yyparse (); +int phpdbg_parse (); #endif #endif /* ! YYPARSE_PARAM */ -#endif /* !YY_YY_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED */ +#endif /* !PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H */ diff --git a/phpdbg_parser.y b/phpdbg_parser.y index 4a84504e2e5..fd81edfc29d 100644 --- a/phpdbg_parser.y +++ b/phpdbg_parser.y @@ -1,4 +1,3 @@ -%error-verbose %{ /* @@ -19,23 +18,15 @@ #include "phpdbg_parser.h" #include "phpdbg_lexer.h" +#undef yyerror +static int yyerror(void ***tsrm_ls, const char *msg); + ZEND_EXTERN_MODULE_GLOBALS(phpdbg); -int yyerror(phpdbg_param_t *stack, yyscan_t scanner, const char *msg) { - TSRMLS_FETCH(); - phpdbg_error("Parse Error: %s", msg); - { - const phpdbg_param_t *top = stack; - - while (top) { - phpdbg_param_debug( - top, "--> "); - top = top->next; - } - } - return 0; -} %} + +%pure-parser +%error-verbose %code requires { #include "phpdbg.h" @@ -44,59 +35,58 @@ int yyerror(phpdbg_param_t *stack, yyscan_t scanner, const char *msg) { typedef void* yyscan_t; #endif } + +%parse-param { void *tsrm_ls } + %output "sapi/phpdbg/phpdbg_parser.c" %defines "sapi/phpdbg/phpdbg_parser.h" - -%define api.pure -%lex-param { yyscan_t scanner } -%parse-param { phpdbg_param_t *stack } -%parse-param { yyscan_t scanner } -%token T_EVAL "eval" -%token T_RUN "run" -%token T_SHELL "shell" -%token T_IF "if (condition)" -%token T_TRUTHY "truthy (true, on, yes or enabled)" -%token T_FALSY "falsy (false, off, no or disabled)" -%token T_STRING "string (some input, perhaps)" -%token T_COLON ": (colon)" -%token T_DCOLON ":: (double colon)" -%token T_POUND "# (pound sign)" -%token T_PROTO "protocol (file://)" -%token T_DIGITS "digits (numbers)" -%token T_LITERAL "literal (string)" -%token T_ADDR "address" -%token T_OPCODE "opcode" -%token T_ID "identifier (command or function name)" -%token T_INPUT "input (input string or data)" -%token T_UNEXPECTED "input" -%% +%token T_EVAL "eval" +%token T_RUN "run" +%token T_SHELL "shell" +%token T_IF "if (condition)" +%token T_TRUTHY "truthy (true, on, yes or enabled)" +%token T_FALSY "falsy (false, off, no or disabled)" +%token T_STRING "string (some input, perhaps)" +%token T_COLON ": (colon)" +%token T_DCOLON ":: (double colon)" +%token T_POUND "# (pound sign)" +%token T_PROTO "protocol (file://)" +%token T_DIGITS "digits (numbers)" +%token T_LITERAL "literal (string)" +%token T_ADDR "address" +%token T_OPCODE "opcode" +%token T_ID "identifier (command or function name)" +%token T_INPUT "input (input string or data)" +%token T_UNEXPECTED "input" + +%% /* Rules */ input - : parameters - | /* nothing */ - ; + : parameters + | full_expression { phpdbg_stack_push(PHPDBG_G(parser_stack), &$1); } + | /* nothing */ + ; parameters - : parameter { phpdbg_stack_push(stack, &$1); } - | parameters parameter { phpdbg_stack_push(stack, &$2); } + : parameter { phpdbg_stack_push(PHPDBG_G(parser_stack), &$1); } + | parameters parameter { phpdbg_stack_push(PHPDBG_G(parser_stack), &$2); } ; parameter - : T_ID T_COLON T_DIGITS { + : T_ID T_COLON T_DIGITS { $$.type = FILE_PARAM; $$.file.name = $2.str; $$.file.line = $3.num; } - | T_ID T_COLON T_POUND T_DIGITS { + | T_ID T_COLON T_POUND T_DIGITS { $$.type = NUMERIC_FILE_PARAM; $$.file.name = $1.str; $$.file.line = $4.num; } - | T_PROTO T_ID T_COLON T_DIGITS { + | T_PROTO T_ID T_COLON T_DIGITS { $$.type = FILE_PARAM; - $$.file.name = malloc($1.len + - $2.len + 1); + $$.file.name = malloc($1.len + $2.len + 1); if ($$.file.name) { memcpy(&$$.file.name[0], $1.str, $1.len); memcpy(&$$.file.name[$1.len], $2.str, $2.len); @@ -104,10 +94,9 @@ parameter } $$.file.line = $4.num; } - | T_PROTO T_ID T_COLON T_POUND T_DIGITS { + | T_PROTO T_ID T_COLON T_POUND T_DIGITS { $$.type = NUMERIC_FILE_PARAM; - $$.file.name = malloc($1.len + - $2.len + 1); + $$.file.name = malloc($1.len + $2.len + 1); if ($$.file.name) { memcpy(&$$.file.name[0], $1.str, $1.len); memcpy(&$$.file.name[$1.len], $2.str, $2.len); @@ -115,54 +104,81 @@ parameter } $$.file.line = $5.num; } - | T_ID T_DCOLON T_ID { + | T_ID T_DCOLON T_ID { $$.type = METHOD_PARAM; $$.method.class = $1.str; $$.method.name = $3.str; } - | T_ID T_DCOLON T_ID T_POUND T_DIGITS { + | T_ID T_DCOLON T_ID T_POUND T_DIGITS { $$.type = NUMERIC_METHOD_PARAM; $$.method.class = $1.str; $$.method.name = $3.str; $$.num = $5.num; } - | T_ID T_POUND T_DIGITS { + | T_ID T_POUND T_DIGITS { $$.type = NUMERIC_FUNCTION_PARAM; $$.str = $1.str; $$.len = $1.len; $$.num = $3.num; } - | T_IF T_INPUT { + | T_OPCODE { $$ = $1; } + | T_ADDR { $$ = $1; } + | T_LITERAL { $$ = $1; } + | T_TRUTHY { $$ = $1; } + | T_FALSY { $$ = $1; } + | T_DIGITS { $$ = $1; } + | T_ID { $$ = $1; } + ; + +full_expression + : T_IF T_INPUT { $$.type = COND_PARAM; $$.str = $2.str; $$.len = $2.len; } - | T_EVAL T_INPUT { + | T_EVAL T_INPUT { $$.type = EVAL_PARAM; $$.str = $2.str; $$.len = $2.len; } - | T_SHELL T_INPUT { + | T_SHELL T_INPUT { $$.type = SHELL_PARAM; $$.str = $2.str; $$.len = $2.len; } - | T_RUN { + | T_RUN { $$.type = RUN_PARAM; $$.len = 0; } - | T_RUN T_INPUT { + | T_RUN T_INPUT { $$.type = RUN_PARAM; $$.str = $2.str; $$.len = $2.len; } - | T_OPCODE { $$ = $1; } - | T_ADDR { $$ = $1; } - | T_LITERAL { $$ = $1; } - | T_TRUTHY { $$ = $1; } - | T_FALSY { $$ = $1; } - | T_DIGITS { $$ = $1; } - | T_ID { $$ = $1; } ; %% + +static int yyerror(void ***tsrm_ls, const char *msg) { + phpdbg_error("Parse Error: %s", msg); + + { + const phpdbg_param_t *top = PHPDBG_G(parser_stack); + + while (top) { + phpdbg_param_debug(top, "--> "); + top = top->next; + } + } + return 0; +} + +int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC) { + phpdbg_init_lexer(stack, input TSRMLS_CC); + +#ifdef ZTS + return yyparse(TSRMLS_C); +#else + return yyparse(NULL); +#endif +} diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 7a28a75129f..5379e775867 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -38,8 +38,6 @@ #include "phpdbg_lexer.h" #include "phpdbg_parser.h" -int yyparse(phpdbg_param_t *stack, yyscan_t scanner); - /* {{{ command declarations */ const phpdbg_command_t phpdbg_prompt_commands[] = { PHPDBG_COMMAND_D(exec, "set execution context", 'e', NULL, "s"), @@ -248,20 +246,10 @@ void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_ char *why = NULL; char *input = phpdbg_read_input(cmd TSRMLS_CC); phpdbg_param_t stack; - yyscan_t scanner; - YY_BUFFER_STATE state; phpdbg_init_param(&stack, STACK_PARAM); - - if (yylex_init(&scanner)) { - phpdbg_error( - "could not initialize scanner"); - break; - } - state = yy_scan_string(input, scanner); - - if (yyparse(&stack, scanner) <= 0) { + if (phpdbg_do_parse(&stack, input TSRMLS_CC) <= 0) { switch (phpdbg_stack_execute(&stack, &why TSRMLS_CC)) { case FAILURE: // if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { @@ -274,15 +262,12 @@ void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_ break; } } - + if (why) { free(why); why = NULL; } - - yy_delete_buffer(state, scanner); - yylex_destroy(scanner); - + phpdbg_stack_free(&stack); phpdbg_destroy_input(&input TSRMLS_CC); } @@ -1014,20 +999,9 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */ if (input) { do { - yyscan_t scanner; - YY_BUFFER_STATE state; - phpdbg_init_param(&stack, STACK_PARAM); - if (yylex_init(&scanner)) { - phpdbg_error( - "could not initialize scanner"); - return FAILURE; - } - - state = yy_scan_string(input, scanner); - - if (yyparse(&stack, scanner) <= 0) { + if (phpdbg_do_parse(&stack, input TSRMLS_CC) <= 0) { switch (ret = phpdbg_stack_execute(&stack, &why TSRMLS_CC)) { case FAILURE: if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { @@ -1061,9 +1035,6 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */ why = NULL; } - yy_delete_buffer(state, scanner); - yylex_destroy(scanner); - phpdbg_stack_free(&stack); phpdbg_destroy_input(&input TSRMLS_CC); diff --git a/travis/ci.sh b/travis/ci.sh index 44d56a01ffe..d9f3ac6a02b 100755 --- a/travis/ci.sh +++ b/travis/ci.sh @@ -1,6 +1,7 @@ #!/usr/bin/env sh git clone https://github.com/php/php-src cd php-src/sapi +rm -rf phpdbg git clone https://github.com/krakjoe/phpdbg.git cd ../ ./buildconf --force From 79230e5561588be7e63f3ee93c06e7065e5038a9 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sun, 15 Jun 2014 15:47:14 +0200 Subject: [PATCH 031/398] Merge sapi/phpdbg into PHP-5.6 --- .travis.yml | 11 ++++++++++- config.m4 | 1 + phpdbg_utils.c | 9 ++++++--- phpdbg_utils.h | 20 ++++++++++++++++++++ tests/run-tests.php | 22 ++++++++++++---------- travis/ci.sh | 5 +++-- 6 files changed, 52 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 353402858e0..d5b492e7cfa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,12 @@ language: c -script: ./travis/ci.sh +env: +- PHP="PHP-5.4" +- PHP="PHP-5.5" +- PHP="PHP-5.6" +- PHP="master" + +before_script: ./travis/ci.sh + +script: +- ./php-src/sapi/cli/php php-src/sapi/phpdbg/tests/run-tests.php -diff2stdout --phpdbg php-src/sapi/phpdbg/phpdbg diff --git a/config.m4 b/config.m4 index ecac1715067..1a6640eaca2 100644 --- a/config.m4 +++ b/config.m4 @@ -9,6 +9,7 @@ PHP_ARG_ENABLE(phpdbg-debug, for phpdbg debug build, [ --enable-phpdbg-debug Build phpdbg in debug mode], no, no) if test "$PHP_PHPDBG" != "no"; then + AC_HEADER_TIOCGWINSZ AC_DEFINE(HAVE_PHPDBG, 1, [ ]) if test "$PHP_PHPDBG_DEBUG" != "no"; then diff --git a/phpdbg_utils.c b/phpdbg_utils.c index c9b22a20397..98748b202a1 100644 --- a/phpdbg_utils.c +++ b/phpdbg_utils.c @@ -32,6 +32,9 @@ # include "win32/time.h" #elif defined(HAVE_SYS_IOCTL_H) # include "sys/ioctl.h" +# ifndef GWINSZ_IN_SYS_IOCTL +# include +# endif #endif ZEND_EXTERN_MODULE_GLOBALS(phpdbg); @@ -437,12 +440,12 @@ PHPDBG_API int phpdbg_get_terminal_width(TSRMLS_D) /* {{{ */ GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); columns = csbi.srWindow.Right - csbi.srWindow.Left + 1; -#elif defined(HAVE_SYS_IOCTL_H) +#elif defined(HAVE_SYS_IOCTL_H) && defined (TIOCGWINSZ) struct winsize w; - columns = ioctl(fileno(stdout), TIOCGWINSZ, &w) == 0 ? w.ws_col : 100; + columns = ioctl(fileno(stdout), TIOCGWINSZ, &w) == 0 ? w.ws_col : 80; #else - columns = 100; + columns = 80; #endif return columns; } /* }}} */ diff --git a/phpdbg_utils.h b/phpdbg_utils.h index 68ae7e44a39..56bacfc4596 100644 --- a/phpdbg_utils.h +++ b/phpdbg_utils.h @@ -124,4 +124,24 @@ PHPDBG_API int phpdbg_get_terminal_width(TSRMLS_D); /* }}} */ int phpdbg_rebuild_symtable(TSRMLS_D); +#if PHP_VERSION_ID < 50500 +/* copy from zend_hash.c PHP 5.5 for 5.4 compatibility */ +static void zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, HashPosition *pos) { + Bucket *p; + + p = pos ? (*pos) : ht->pInternalPointer; + + if (!p) { + Z_TYPE_P(key) = IS_NULL; + } else if (p->nKeyLength) { + Z_TYPE_P(key) = IS_STRING; + Z_STRVAL_P(key) = IS_INTERNED(p->arKey) ? (char*)p->arKey : estrndup(p->arKey, p->nKeyLength - 1); + Z_STRLEN_P(key) = p->nKeyLength - 1; + } else { + Z_TYPE_P(key) = IS_LONG; + Z_LVAL_P(key) = p->h; + } +} +#endif + #endif /* PHPDBG_UTILS_H */ diff --git a/tests/run-tests.php b/tests/run-tests.php index 47a998ccae8..1cc31d815e5 100644 --- a/tests/run-tests.php +++ b/tests/run-tests.php @@ -135,8 +135,8 @@ namespace phpdbg\testing { * @param array basic configuration * @param array command line */ - public function __construct(TestsConfiguration &$config) { - $this->config = &$config; + public function __construct(TestsConfiguration $config) { + $this->config = $config; if ($this->config->hasFlag('help') || $this->config->hasFlag('h')) { @@ -153,7 +153,7 @@ namespace phpdbg\testing { $paths = array(); $where = ($in != null) ? array($in) : $this->config['path']; - foreach ($where as &$path) { + foreach ($where as $path) { if ($path) { if (is_dir($path)) { $paths[] = $path; @@ -243,6 +243,7 @@ namespace phpdbg\testing { printf("\t--options\toptions to pass to phpdbg%s", PHP_EOL); printf("\t--phpdbg\tpath to phpdbg binary%s", PHP_EOL); printf('[flags]:%s', PHP_EOL); + printf("\t-diff2stdout\t\twrite diff to stdout instead of files%s", PHP_EOL); printf("\t-nodiff\t\tdo not write diffs on failure%s", PHP_EOL); printf("\t-nolog\t\tdo not write logs on failure%s", PHP_EOL); printf('[examples]:%s', PHP_EOL); @@ -266,9 +267,11 @@ namespace phpdbg\testing { $test = sprintf('%s/%s', $path, $file); if (preg_match('~\.test$~', $test)) { - yield new Test($this->config, $test); + $tests[] = new Test($this->config, $test); } } + + return $tests; } /** @@ -354,7 +357,7 @@ namespace phpdbg\testing { * @param array configuration * @param string file */ - public function __construct(TestsConfiguration &$config, &$file) { + public function __construct(TestsConfiguration $config, $file) { if (($handle = fopen($file, 'r'))) { while (($line = fgets($handle))) { $trim = trim($line); @@ -417,8 +420,8 @@ namespace phpdbg\testing { } fclose($handle); - $this->config = &$config; - $this->file = &$file; + $this->config = $config; + $this->file = $file; } } @@ -427,8 +430,7 @@ namespace phpdbg\testing { * */ public function getResult() { - $options = sprintf( - '-i%s -nqb', $this->file); + $options = sprintf('-i%s -nqb', $this->file); if ($this->options) { $options = sprintf( @@ -526,7 +528,7 @@ namespace phpdbg\testing { * Write log to disk if configuration allows it * */ - protected function writeLog(&$result = null) { + protected function writeLog($result = null) { $log = sprintf( '%s/%s.log', dirname($this->file), basename($this->file)); diff --git a/travis/ci.sh b/travis/ci.sh index d9f3ac6a02b..206b158b9b6 100755 --- a/travis/ci.sh +++ b/travis/ci.sh @@ -1,10 +1,11 @@ #!/usr/bin/env sh git clone https://github.com/php/php-src -cd php-src/sapi +cd php-src +git checkout $PHP +cd sapi rm -rf phpdbg git clone https://github.com/krakjoe/phpdbg.git cd ../ ./buildconf --force ./configure --disable-all --enable-phpdbg --enable-maintainer-zts make -make test-phpdbg From 55d97085a4eedb485f4aeb840091172b650adfcf Mon Sep 17 00:00:00 2001 From: Lior Kaplan Date: Mon, 16 Jun 2014 23:34:50 +0300 Subject: [PATCH 032/398] Update copyright year to 2014 --- phpdbg_btree.c | 2 +- phpdbg_btree.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpdbg_btree.c b/phpdbg_btree.c index 8fc2561e047..491445399b7 100644 --- a/phpdbg_btree.c +++ b/phpdbg_btree.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/phpdbg_btree.h b/phpdbg_btree.h index 5fb217db35e..af2a6ac3146 100644 --- a/phpdbg_btree.h +++ b/phpdbg_btree.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | From 679d08e8ba3b6e5b596f7c23c5402b2f92896db9 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 23 Jun 2014 10:04:40 +0200 Subject: [PATCH 033/398] Fix https://github.com/krakjoe/phpdbg/issues/91 Enable edit feature when build with libedit. Notice: coloured prompt only enable with READLINE --- config.m4 | 2 +- phpdbg.h | 2 +- phpdbg_cmd.c | 6 +++--- phpdbg_prompt.c | 5 +++++ phpdbg_utils.c | 6 +++++- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/config.m4 b/config.m4 index 1a6640eaca2..d78a439af02 100644 --- a/config.m4 +++ b/config.m4 @@ -21,7 +21,7 @@ if test "$PHP_PHPDBG" != "no"; then PHP_PHPDBG_CFLAGS="-D_GNU_SOURCE" PHP_PHPDBG_FILES="phpdbg.c phpdbg_parser.c phpdbg_lexer.c phpdbg_prompt.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_info.c phpdbg_cmd.c phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_btree.c" - if test "$PHP_READLINE" != "no"; then + if test "$PHP_READLINE" != "no" -o "$PHP_LIBEDIT" != "no"; then PHPDBG_EXTRA_LIBS="$PHP_READLINE_LIBS" fi diff --git a/phpdbg.h b/phpdbg.h index 12350d5425d..b2e7a03c213 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -64,7 +64,7 @@ # include "TSRM.h" #endif -#ifdef HAVE_LIBREADLINE +#if defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT) # include # include #endif diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index d4ce8ebc55f..a45513bee6b 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -792,7 +792,7 @@ PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack, char **why TSRMLS_DC) PHPDBG_API char* phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */ { char *cmd = NULL; -#ifndef HAVE_LIBREADLINE +#if !defined(HAVE_LIBREADLINE) && !defined(HAVE_LIBEDIT) char buf[PHPDBG_MAX_CMD]; #endif char *buffer = NULL; @@ -811,7 +811,7 @@ disconnect: return NULL; } -#ifndef HAVE_LIBREADLINE +#if !defined(HAVE_LIBREADLINE) && !defined(HAVE_LIBEDIT) if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { if (!phpdbg_write("%s", phpdbg_get_prompt(TSRMLS_C))) { goto disconnect; @@ -850,7 +850,7 @@ readline: buffer = estrdup(cmd); -#ifdef HAVE_LIBREADLINE +#if defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT) if (!buffered && cmd && !(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { free(cmd); diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 5379e775867..d91ef3f3f5c 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -732,6 +732,11 @@ PHPDBG_COMMAND(print) /* {{{ */ #else phpdbg_writeln("Readline\tno"); #endif +#ifdef HAVE_LIBEDIT + phpdbg_writeln("Libedit\t\tyes"); +#else + phpdbg_writeln("Libedit\t\tno"); +#endif phpdbg_writeln("Exec\t\t%s", PHPDBG_G(exec) ? PHPDBG_G(exec) : "none"); phpdbg_writeln("Compiled\t%s", PHPDBG_G(ops) ? "yes" : "no"); diff --git a/phpdbg_utils.c b/phpdbg_utils.c index 98748b202a1..3b4eac73279 100644 --- a/phpdbg_utils.c +++ b/phpdbg_utils.c @@ -400,12 +400,16 @@ PHPDBG_API const char *phpdbg_get_prompt(TSRMLS_D) /* {{{ */ } /* create cached prompt */ +#ifdef HAVE_LIBREADLINE + /* TODO: libedit doesn't seems to support coloured prompt */ if ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED)) { asprintf( &PHPDBG_G(prompt)[1], "\033[%sm%s\033[0m ", PHPDBG_G(colors)[PHPDBG_COLOR_PROMPT]->code, PHPDBG_G(prompt)[0]); - } else { + } else +#endif + { asprintf( &PHPDBG_G(prompt)[1], "%s ", PHPDBG_G(prompt)[0]); From 7efbccd60fda3ee235f88bbb9a1e53f6ef74f6f5 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 23 Jun 2014 10:17:43 +0200 Subject: [PATCH 034/398] Better fix for phpdbg + libedit - fix include - disable coloured prompt only with libedit --- phpdbg.h | 5 ++++- phpdbg_utils.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/phpdbg.h b/phpdbg.h index b2e7a03c213..eb4faf1f942 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -64,10 +64,13 @@ # include "TSRM.h" #endif -#if defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT) +#ifdef LIBREADLINE # include # include #endif +#ifdef HAVE_LIBEDIT +# include +#endif #include "phpdbg_lexer.h" #include "phpdbg_cmd.h" diff --git a/phpdbg_utils.c b/phpdbg_utils.c index 3b4eac73279..3ce2fade17d 100644 --- a/phpdbg_utils.c +++ b/phpdbg_utils.c @@ -400,7 +400,7 @@ PHPDBG_API const char *phpdbg_get_prompt(TSRMLS_D) /* {{{ */ } /* create cached prompt */ -#ifdef HAVE_LIBREADLINE +#ifndef HAVE_LIBEDIT /* TODO: libedit doesn't seems to support coloured prompt */ if ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED)) { asprintf( From 05955fbce52918158e1fb0219c519a9a0d6f1d5b Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Wed, 25 Jun 2014 13:56:45 +0200 Subject: [PATCH 035/398] Merge sapi/phpdbg into PHP-5.6 --- Makefile.frag | 3 +++ phpdbg.1 | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 phpdbg.1 diff --git a/Makefile.frag b/Makefile.frag index d787b0fb180..b276aaaa534 100644 --- a/Makefile.frag +++ b/Makefile.frag @@ -26,6 +26,9 @@ install-phpdbg: $(BUILD_BINARY) @$(mkinstalldirs) $(INSTALL_ROOT)$(localstatedir)/log @$(mkinstalldirs) $(INSTALL_ROOT)$(localstatedir)/run @$(INSTALL) -m 0755 $(BUILD_BINARY) $(INSTALL_ROOT)$(bindir)/$(program_prefix)phpdbg$(program_suffix)$(EXEEXT) + @echo "Installing phpdbg man page: $(INSTALL_ROOT)$(mandir)/man1/" + @$(mkinstalldirs) $(INSTALL_ROOT)$(mandir)/man1 + @$(INSTALL_DATA) sapi/phpdbg/phpdbg.1 $(INSTALL_ROOT)$(mandir)/man1/$(program_prefix)phpdbg$(program_suffix).1 clean-phpdbg: @echo "Cleaning phpdbg object files ..." diff --git a/phpdbg.1 b/phpdbg.1 new file mode 100644 index 00000000000..5e4d144c838 --- /dev/null +++ b/phpdbg.1 @@ -0,0 +1,59 @@ +.TH PHPDBG 1 +.SH NAME +phpdbg \- The interactive PHP debugger +.SH SYNOPSIS +.B phpdbg +[OPTION] +[\fB\-e\fIFILE\fR] +.SH DESCRIPTION +.B phpdbg +a lightweight, powerful, easy to use debugging platform for PHP5. +.SH OPTIONS +The following switches are implemented (just like cli SAPI): +.TP +.BR \-n +No \fBphp.ini\fR file will be used +.TP +.BR \-c \fIpath\fB|\fIfile\fR +Look for \fBphp.ini\fR file in the directory \fIpath\fR or use the specified \fIfile\fR +.TP +.BR \-z \fIfile\fR +Load Zend extension \fIfile\fR +.TP +.BR \-d \fIfoo\fB[=\fIbar\fB]\fR +Define INI entry \fIfoo\fR with value \fIbar\fR +.PP The following switches change the default behaviour of phpdbg: +.TP +.BR \-v +Disables quietness +.TP +.BR \-s +Enabled stepping +.TP +.BR -e \fIfile\fR +Sets execution context +.TP +.BR \-b +Disables use of colour on the console +.TP +.BR \-I +Ignore .phpdbginit (default init file) +.TP +.BR \-i \fIpath\fB|\ffile\fR +Override .phpgdbinit location (implies -I) +.TP +.BR \-O \fIfile\fR +Set oplog output to \fIfile\fR +.TP +.BR \-q +Do not print banner on startup +.TP +.BR \-r +Jump straight to run +.TP +.BR \-E +Enable step through eval() +.SH NOTES +Passing -rr will cause phpdbg to quit after execution, rather than returning to the console +.SH AUTHOR +Written by Felipe Pena, Joe Watkins and Bob Weinand, formatted by OndĹ™ej SurĂ˝ for Debian project. From 856801b84f167f42d628ee5111d1bf34bb0abf1a Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sun, 29 Jun 2014 12:49:10 +0200 Subject: [PATCH 036/398] Merge sapi/phpdbg into PHP-5.6 --- phpdbg_help.c | 7 +- phpdbg_lexer.c | 1069 +++++++++++++++++++++++++++-------------------- phpdbg_lexer.l | 38 +- phpdbg_list.c | 23 +- phpdbg_parser.c | 138 +++--- phpdbg_parser.y | 12 +- 6 files changed, 723 insertions(+), 564 deletions(-) diff --git a/phpdbg_help.c b/phpdbg_help.c index f2d074ded60..1e58dc69cad 100644 --- a/phpdbg_help.c +++ b/phpdbg_help.c @@ -318,8 +318,9 @@ phpdbg_help_text_t phpdbg_help_text[] = { "**Information**" CR " **list** list PHP source" CR " **info** displays information on the debug session" CR -" **print** show opcodes " CR +" **print** show opcodes" CR " **frame** select a stack frame and print a stack frame summary" CR +" **back** shows the current backtrace" CR " **help** provide help on a topic" CR CR "**Starting and Stopping Execution**" CR @@ -613,7 +614,7 @@ phpdbg_help_text_t phpdbg_help_text[] = { {"finish", "The **finish** command causes control to be passed back to the vm, continuing execution. Any " "breakpoints that are encountered within the current stack frame will be skipped. Execution " -"will then continue until the next breakpoint after leaving the stack frame or unitil " +"will then continue until the next breakpoint after leaving the stack frame or until " "completion of the script" CR CR "Note when **step**ping is enabled, any opcode steps within the current stack frame are also " @@ -629,7 +630,7 @@ phpdbg_help_text_t phpdbg_help_text[] = { "**Examples**" CR CR " $P frame 2" CR -" $P E $count" CR +" $P ev $count" CR " Go to frame 2 and print out variable **$count** in that frame" CR CR "Note that this frame scope is discarded when execution continues, with the execution frame " diff --git a/phpdbg_lexer.c b/phpdbg_lexer.c index 420dcac042d..3092dc396dd 100644 --- a/phpdbg_lexer.c +++ b/phpdbg_lexer.c @@ -96,33 +96,49 @@ yyc_INITIAL: }; YYDEBUG(0, *YYCURSOR); - YYFILL(3); + YYFILL(4); yych = *YYCURSOR; - if (yych <= 0x1F) { - if (yych <= '\t') { + if (yych <= 'D') { + if (yych <= '\n') { if (yych <= 0x00) goto yy6; if (yych <= 0x08) goto yy11; + if (yych >= '\n') goto yy4; } else { - if (yych <= '\n') goto yy4; - if (yych != '\r') goto yy11; + if (yych <= '\r') { + if (yych <= '\f') goto yy11; + } else { + if (yych != ' ') goto yy11; + } } } else { - if (yych <= 'e') { - if (yych <= ' ') goto yy2; - if (yych <= 'd') goto yy11; - goto yy7; + if (yych <= 'd') { + if (yych <= 'Q') { + if (yych <= 'E') goto yy7; + goto yy11; + } else { + if (yych <= 'R') goto yy10; + if (yych <= 'S') goto yy8; + goto yy11; + } } else { - if (yych <= 'q') goto yy11; - if (yych <= 'r') goto yy9; - if (yych <= 's') goto yy8; - goto yy11; + if (yych <= 'q') { + if (yych <= 'e') goto yy7; + goto yy11; + } else { + if (yych <= 'r') goto yy9; + if (yych <= 's') goto yy8; + goto yy11; + } } } -yy2: YYDEBUG(2, *YYCURSOR); ++YYCURSOR; - if (yybm[0+(yych = *YYCURSOR)] & 128) { - goto yy19; + if ((yych = *YYCURSOR) <= '\f') { + if (yych <= 0x08) goto yy3; + if (yych <= '\n') goto yy26; + } else { + if (yych <= '\r') goto yy26; + if (yych == ' ') goto yy26; } yy3: YYDEBUG(3, *YYCURSOR); @@ -134,49 +150,60 @@ yy3: YYCURSOR = LEX(text); goto restart; } -#line 138 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +#line 154 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" yy4: YYDEBUG(4, *YYCURSOR); ++YYCURSOR; - if (yybm[0+(yych = *YYCURSOR)] & 128) { - goto yy19; + if ((yych = *YYCURSOR) <= '\f') { + if (yych <= 0x08) goto yy5; + if (yych <= '\n') goto yy26; + } else { + if (yych <= '\r') goto yy26; + if (yych == ' ') goto yy26; } +yy5: YYDEBUG(5, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 68 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" { return 0; } -#line 151 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +#line 172 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" yy6: YYDEBUG(6, *YYCURSOR); yych = *++YYCURSOR; goto yy3; yy7: YYDEBUG(7, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'v') goto yy17; + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'V') goto yy22; + if (yych == 'v') goto yy22; goto yy3; yy8: YYDEBUG(8, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'h') goto yy15; + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'H') goto yy18; + if (yych == 'h') goto yy18; goto yy3; yy9: YYDEBUG(9, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); + if (yybm[0+yych] & 128) { + goto yy15; + } + if (yych == 'U') goto yy12; if (yych == 'u') goto yy12; + goto yy3; yy10: YYDEBUG(10, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 155 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" - { - YYSETCONDITION(RAW); - phpdbg_init_param(yylval, EMPTY_PARAM); - return T_RUN; -} -#line 180 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'U') goto yy12; + if (yych == 'u') goto yy12; + goto yy3; yy11: YYDEBUG(11, *YYCURSOR); yych = *++YYCURSOR; @@ -184,18 +211,62 @@ yy11: yy12: YYDEBUG(12, *YYCURSOR); yych = *++YYCURSOR; + if (yych == 'N') goto yy14; if (yych == 'n') goto yy14; +yy13: YYDEBUG(13, *YYCURSOR); YYCURSOR = YYMARKER; - goto yy10; + goto yy3; yy14: YYDEBUG(14, *YYCURSOR); yych = *++YYCURSOR; - goto yy10; + if (yybm[0+yych] & 128) { + goto yy15; + } + goto yy13; yy15: YYDEBUG(15, *YYCURSOR); ++YYCURSOR; + YYFILL(1); + yych = *YYCURSOR; YYDEBUG(16, *YYCURSOR); + if (yybm[0+yych] & 128) { + goto yy15; + } + YYDEBUG(17, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 155 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" + { + YYSETCONDITION(RAW); + phpdbg_init_param(yylval, EMPTY_PARAM); + return T_RUN; +} +#line 245 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy18: + YYDEBUG(18, *YYCURSOR); + yych = *++YYCURSOR; + if (yych <= '\f') { + if (yych <= 0x08) goto yy13; + if (yych >= '\v') goto yy13; + } else { + if (yych <= '\r') goto yy19; + if (yych != ' ') goto yy13; + } +yy19: + YYDEBUG(19, *YYCURSOR); + ++YYCURSOR; + YYFILL(1); + yych = *YYCURSOR; + YYDEBUG(20, *YYCURSOR); + if (yych <= '\f') { + if (yych <= 0x08) goto yy21; + if (yych <= '\n') goto yy19; + } else { + if (yych <= '\r') goto yy19; + if (yych == ' ') goto yy19; + } +yy21: + YYDEBUG(21, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 150 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" { @@ -203,11 +274,32 @@ yy15: phpdbg_init_param(yylval, EMPTY_PARAM); return T_SHELL; } -#line 207 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy17: - YYDEBUG(17, *YYCURSOR); +#line 278 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy22: + YYDEBUG(22, *YYCURSOR); + yych = *++YYCURSOR; + if (yych <= '\f') { + if (yych <= 0x08) goto yy13; + if (yych >= '\v') goto yy13; + } else { + if (yych <= '\r') goto yy23; + if (yych != ' ') goto yy13; + } +yy23: + YYDEBUG(23, *YYCURSOR); ++YYCURSOR; - YYDEBUG(18, *YYCURSOR); + YYFILL(1); + yych = *YYCURSOR; + YYDEBUG(24, *YYCURSOR); + if (yych <= '\f') { + if (yych <= 0x08) goto yy25; + if (yych <= '\n') goto yy23; + } else { + if (yych <= '\r') goto yy23; + if (yych == ' ') goto yy23; + } +yy25: + YYDEBUG(25, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 145 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" { @@ -215,17 +307,22 @@ yy17: phpdbg_init_param(yylval, EMPTY_PARAM); return T_EVAL; } -#line 219 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy19: - YYDEBUG(19, *YYCURSOR); +#line 311 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy26: + YYDEBUG(26, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(20, *YYCURSOR); - if (yybm[0+yych] & 128) { - goto yy19; + YYDEBUG(27, *YYCURSOR); + if (yych <= '\f') { + if (yych <= 0x08) goto yy28; + if (yych <= '\n') goto yy26; + } else { + if (yych <= '\r') goto yy26; + if (yych == ' ') goto yy26; } - YYDEBUG(21, *YYCURSOR); +yy28: + YYDEBUG(28, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 139 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" { @@ -233,7 +330,7 @@ yy19: goto restart; } -#line 237 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +#line 334 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" } /* *********************************** */ yyc_NORMAL: @@ -272,71 +369,60 @@ yyc_NORMAL: 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, }; - YYDEBUG(22, *YYCURSOR); + YYDEBUG(29, *YYCURSOR); YYFILL(11); yych = *YYCURSOR; - if (yych <= ':') { - if (yych <= ' ') { - if (yych <= '\n') { - if (yych <= 0x00) goto yy29; - if (yych <= 0x08) goto yy32; - if (yych >= '\n') goto yy27; - } else { - if (yych == '\r') goto yy24; - if (yych <= 0x1F) goto yy32; - } - } else { - if (yych <= '.') { - if (yych == '#') goto yy47; - if (yych <= '-') goto yy32; - goto yy34; - } else { - if (yych <= '/') goto yy32; - if (yych <= '0') goto yy37; - if (yych <= '9') goto yy34; - goto yy49; - } - } - } else { - if (yych <= 'i') { - if (yych <= 'd') { - if (yych == 'Z') goto yy38; - if (yych <= 'c') goto yy32; - goto yy39; - } else { - if (yych <= 'e') goto yy40; - if (yych <= 'f') goto yy41; - if (yych <= 'h') goto yy32; - goto yy30; - } - } else { - if (yych <= 's') { - if (yych <= 'm') goto yy32; - if (yych <= 'n') goto yy42; - if (yych <= 'o') goto yy43; - goto yy32; - } else { - if (yych <= 'x') { - if (yych <= 't') goto yy44; - goto yy32; - } else { - if (yych <= 'y') goto yy45; - if (yych <= 'z') goto yy46; - goto yy32; - } - } - } + YYDEBUG(-1, yych); + switch (yych) { + case 0x00: goto yy36; + case '\t': + case '\r': + case ' ': goto yy31; + case '\n': goto yy34; + case '#': goto yy55; + case '-': goto yy41; + case '.': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy42; + case '0': goto yy45; + case ':': goto yy57; + case 'D': + case 'd': goto yy46; + case 'E': + case 'e': goto yy47; + case 'F': + case 'f': goto yy48; + case 'I': + case 'i': goto yy37; + case 'N': + case 'n': goto yy49; + case 'O': + case 'o': goto yy50; + case 'T': + case 't': goto yy51; + case 'Y': + case 'y': goto yy52; + case 'Z': goto yy53; + case 'z': goto yy54; + default: goto yy39; } -yy24: - YYDEBUG(24, *YYCURSOR); +yy31: + YYDEBUG(31, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(25, *YYCURSOR); + YYDEBUG(32, *YYCURSOR); if (yybm[0+yych] & 8) { - goto yy24; + goto yy31; } - YYDEBUG(26, *YYCURSOR); + YYDEBUG(33, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 139 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" { @@ -344,33 +430,34 @@ yy24: goto restart; } -#line 348 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy27: - YYDEBUG(27, *YYCURSOR); +#line 434 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy34: + YYDEBUG(34, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 8) { - goto yy24; + goto yy31; } -yy28: - YYDEBUG(28, *YYCURSOR); +yy35: + YYDEBUG(35, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 68 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" { return 0; } -#line 362 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy29: - YYDEBUG(29, *YYCURSOR); +#line 448 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy36: + YYDEBUG(36, *YYCURSOR); yych = *++YYCURSOR; - goto yy28; -yy30: - YYDEBUG(30, *YYCURSOR); + goto yy35; +yy37: + YYDEBUG(37, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'f') goto yy94; - goto yy33; -yy31: - YYDEBUG(31, *YYCURSOR); + if (yych == 'F') goto yy106; + if (yych == 'f') goto yy106; + goto yy40; +yy38: + YYDEBUG(38, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 125 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" { @@ -379,48 +466,56 @@ yy31: yylval->len = yyleng; return T_ID; } -#line 383 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy32: - YYDEBUG(32, *YYCURSOR); +#line 470 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy39: + YYDEBUG(39, *YYCURSOR); yyaccept = 0; YYMARKER = ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; -yy33: - YYDEBUG(33, *YYCURSOR); +yy40: + YYDEBUG(40, *YYCURSOR); if (yybm[0+yych] & 16) { - goto yy32; + goto yy39; } - if (yych <= '9') goto yy31; - goto yy54; -yy34: - YYDEBUG(34, *YYCURSOR); + if (yych <= '9') goto yy38; + goto yy62; +yy41: + YYDEBUG(41, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[0+yych] & 32) { + goto yy42; + } + goto yy40; +yy42: + YYDEBUG(42, *YYCURSOR); yyaccept = 1; YYMARKER = ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; - YYDEBUG(35, *YYCURSOR); + YYDEBUG(43, *YYCURSOR); if (yybm[0+yych] & 32) { - goto yy34; + goto yy42; } if (yych <= 0x1F) { if (yych <= '\n') { - if (yych <= 0x00) goto yy36; - if (yych <= 0x08) goto yy32; + if (yych <= 0x00) goto yy44; + if (yych <= 0x08) goto yy39; } else { - if (yych != '\r') goto yy32; + if (yych != '\r') goto yy39; } } else { if (yych <= '#') { - if (yych <= ' ') goto yy36; - if (yych <= '"') goto yy32; + if (yych <= ' ') goto yy44; + if (yych <= '"') goto yy39; } else { - if (yych == ':') goto yy54; - goto yy32; + if (yych == ':') goto yy62; + goto yy39; } } -yy36: - YYDEBUG(36, *YYCURSOR); +yy44: + YYDEBUG(44, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 106 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" { @@ -428,164 +523,168 @@ yy36: yylval->num = atoi(yytext); return T_DIGITS; } -#line 432 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy37: - YYDEBUG(37, *YYCURSOR); +#line 527 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy45: + YYDEBUG(45, *YYCURSOR); yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); if (yybm[0+yych] & 32) { - goto yy34; + goto yy42; } if (yych <= 0x1F) { if (yych <= '\n') { - if (yych <= 0x00) goto yy36; - if (yych <= 0x08) goto yy33; - goto yy36; + if (yych <= 0x00) goto yy44; + if (yych <= 0x08) goto yy40; + goto yy44; } else { - if (yych == '\r') goto yy36; - goto yy33; + if (yych == '\r') goto yy44; + goto yy40; } } else { if (yych <= '#') { - if (yych <= ' ') goto yy36; - if (yych <= '"') goto yy33; - goto yy36; + if (yych <= ' ') goto yy44; + if (yych <= '"') goto yy40; + goto yy44; } else { - if (yych == 'x') goto yy90; - goto yy33; + if (yych == 'x') goto yy102; + goto yy40; } } -yy38: - YYDEBUG(38, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy87; - goto yy33; -yy39: - YYDEBUG(39, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'i') goto yy81; - goto yy33; -yy40: - YYDEBUG(40, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'n') goto yy76; - goto yy33; -yy41: - YYDEBUG(41, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'a') goto yy73; - goto yy33; -yy42: - YYDEBUG(42, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'o') goto yy71; - goto yy33; -yy43: - YYDEBUG(43, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'f') goto yy70; - if (yych == 'n') goto yy66; - goto yy33; -yy44: - YYDEBUG(44, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'r') goto yy68; - goto yy33; -yy45: - YYDEBUG(45, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'e') goto yy65; - goto yy33; yy46: YYDEBUG(46, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'e') goto yy53; - goto yy33; + if (yych == 'I') goto yy96; + if (yych == 'i') goto yy96; + goto yy40; yy47: YYDEBUG(47, *YYCURSOR); - ++YYCURSOR; + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'N') goto yy91; + if (yych == 'n') goto yy91; + goto yy40; +yy48: YYDEBUG(48, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'A') goto yy88; + if (yych == 'a') goto yy88; + goto yy40; +yy49: + YYDEBUG(49, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'O') goto yy84; + if (yych == 'o') goto yy84; + goto yy40; +yy50: + YYDEBUG(50, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= 'N') { + if (yych == 'F') goto yy83; + if (yych <= 'M') goto yy40; + goto yy77; + } else { + if (yych <= 'f') { + if (yych <= 'e') goto yy40; + goto yy83; + } else { + if (yych == 'n') goto yy77; + goto yy40; + } + } +yy51: + YYDEBUG(51, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'R') goto yy81; + if (yych == 'r') goto yy81; + goto yy40; +yy52: + YYDEBUG(52, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'E') goto yy76; + if (yych == 'e') goto yy76; + goto yy40; +yy53: + YYDEBUG(53, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'E') goto yy73; + goto yy40; +yy54: + YYDEBUG(54, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'e') goto yy61; + goto yy40; +yy55: + YYDEBUG(55, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(56, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 84 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" { return T_POUND; } -#line 523 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy49: - YYDEBUG(49, *YYCURSOR); +#line 634 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy57: + YYDEBUG(57, *YYCURSOR); ++YYCURSOR; - if ((yych = *YYCURSOR) == ':') goto yy51; - YYDEBUG(50, *YYCURSOR); + if ((yych = *YYCURSOR) == ':') goto yy59; + YYDEBUG(58, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 90 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" { return T_COLON; } -#line 534 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy51: - YYDEBUG(51, *YYCURSOR); +#line 645 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy59: + YYDEBUG(59, *YYCURSOR); ++YYCURSOR; - YYDEBUG(52, *YYCURSOR); + YYDEBUG(60, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 87 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" { return T_DCOLON; } -#line 544 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy53: - YYDEBUG(53, *YYCURSOR); +#line 655 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy61: + YYDEBUG(61, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'n') goto yy59; - goto yy33; -yy54: - YYDEBUG(54, *YYCURSOR); + if (yych == 'n') goto yy67; + goto yy40; +yy62: + YYDEBUG(62, *YYCURSOR); yych = *++YYCURSOR; - if (yych == '/') goto yy56; -yy55: - YYDEBUG(55, *YYCURSOR); + if (yych == '/') goto yy64; +yy63: + YYDEBUG(63, *YYCURSOR); YYCURSOR = YYMARKER; - if (yyaccept <= 3) { - if (yyaccept <= 1) { - if (yyaccept <= 0) { - goto yy31; - } else { - goto yy36; - } + if (yyaccept <= 1) { + if (yyaccept <= 0) { + goto yy38; } else { - if (yyaccept <= 2) { - goto yy64; - } else { - goto yy67; - } + goto yy44; } } else { - if (yyaccept <= 5) { - if (yyaccept <= 4) { - goto yy72; - } else { - goto yy93; - } + if (yyaccept <= 2) { + goto yy72; } else { - goto yy95; + goto yy105; } } -yy56: - YYDEBUG(56, *YYCURSOR); +yy64: + YYDEBUG(64, *YYCURSOR); yych = *++YYCURSOR; - if (yych != '/') goto yy55; - YYDEBUG(57, *YYCURSOR); + if (yych != '/') goto yy63; + YYDEBUG(65, *YYCURSOR); ++YYCURSOR; - YYDEBUG(58, *YYCURSOR); + YYDEBUG(66, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 78 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" { @@ -594,52 +693,52 @@ yy56: yylval->len = yyleng; return T_PROTO; } -#line 598 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy59: - YYDEBUG(59, *YYCURSOR); +#line 697 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy67: + YYDEBUG(67, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych != 'd') goto yy33; - YYDEBUG(60, *YYCURSOR); + if (yych != 'd') goto yy40; + YYDEBUG(68, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych != '_') goto yy33; -yy61: - YYDEBUG(61, *YYCURSOR); + if (yych != '_') goto yy40; +yy69: + YYDEBUG(69, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if (yybm[0+yych] & 64) { - goto yy62; + goto yy70; } - goto yy33; -yy62: - YYDEBUG(62, *YYCURSOR); + goto yy40; +yy70: + YYDEBUG(70, *YYCURSOR); yyaccept = 2; YYMARKER = ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; - YYDEBUG(63, *YYCURSOR); + YYDEBUG(71, *YYCURSOR); if (yybm[0+yych] & 64) { - goto yy62; + goto yy70; } if (yych <= 0x1F) { if (yych <= '\n') { - if (yych <= 0x00) goto yy64; - if (yych <= 0x08) goto yy32; + if (yych <= 0x00) goto yy72; + if (yych <= 0x08) goto yy39; } else { - if (yych != '\r') goto yy32; + if (yych != '\r') goto yy39; } } else { if (yych <= '#') { - if (yych <= ' ') goto yy64; - if (yych <= '"') goto yy32; + if (yych <= ' ') goto yy72; + if (yych <= '"') goto yy39; } else { - if (yych == ':') goto yy54; - goto yy32; + if (yych == ':') goto yy62; + goto yy39; } } -yy64: - YYDEBUG(64, *YYCURSOR); +yy72: + YYDEBUG(72, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 118 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" { @@ -648,32 +747,53 @@ yy64: yylval->len = yyleng; return T_OPCODE; } -#line 652 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy65: - YYDEBUG(65, *YYCURSOR); +#line 751 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy73: + YYDEBUG(73, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych != 's') goto yy33; -yy66: - YYDEBUG(66, *YYCURSOR); - yyaccept = 3; + if (yych != 'N') goto yy40; + YYDEBUG(74, *YYCURSOR); + yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych <= '\r') { - if (yych <= 0x08) { - if (yych >= 0x01) goto yy33; - } else { - if (yych <= '\n') goto yy67; - if (yych <= '\f') goto yy33; - } + if (yych != 'D') goto yy40; + YYDEBUG(75, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '_') goto yy69; + goto yy40; +yy76: + YYDEBUG(76, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'S') goto yy77; + if (yych != 's') goto yy40; +yy77: + YYDEBUG(77, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '\f') { + if (yych <= 0x08) goto yy40; + if (yych >= '\v') goto yy40; } else { - if (yych <= ' ') { - if (yych <= 0x1F) goto yy33; - } else { - if (yych != '#') goto yy33; - } + if (yych <= '\r') goto yy78; + if (yych != ' ') goto yy40; } -yy67: - YYDEBUG(67, *YYCURSOR); +yy78: + YYDEBUG(78, *YYCURSOR); + ++YYCURSOR; + YYFILL(1); + yych = *YYCURSOR; + YYDEBUG(79, *YYCURSOR); + if (yych <= '\f') { + if (yych <= 0x08) goto yy80; + if (yych <= '\n') goto yy78; + } else { + if (yych <= '\r') goto yy78; + if (yych == ' ') goto yy78; + } +yy80: + YYDEBUG(80, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 94 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" { @@ -681,42 +801,52 @@ yy67: yylval->num = 1; return T_TRUTHY; } -#line 685 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy68: - YYDEBUG(68, *YYCURSOR); +#line 805 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy81: + YYDEBUG(81, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych != 'u') goto yy33; - YYDEBUG(69, *YYCURSOR); + if (yych == 'U') goto yy82; + if (yych != 'u') goto yy40; +yy82: + YYDEBUG(82, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'e') goto yy66; - goto yy33; -yy70: - YYDEBUG(70, *YYCURSOR); + if (yych == 'E') goto yy77; + if (yych == 'e') goto yy77; + goto yy40; +yy83: + YYDEBUG(83, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych != 'f') goto yy33; -yy71: - YYDEBUG(71, *YYCURSOR); - yyaccept = 4; + if (yych == 'F') goto yy84; + if (yych != 'f') goto yy40; +yy84: + YYDEBUG(84, *YYCURSOR); + yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych <= '\r') { - if (yych <= 0x08) { - if (yych >= 0x01) goto yy33; - } else { - if (yych <= '\n') goto yy72; - if (yych <= '\f') goto yy33; - } + if (yych <= '\f') { + if (yych <= 0x08) goto yy40; + if (yych >= '\v') goto yy40; } else { - if (yych <= ' ') { - if (yych <= 0x1F) goto yy33; - } else { - if (yych != '#') goto yy33; - } + if (yych <= '\r') goto yy85; + if (yych != ' ') goto yy40; } -yy72: - YYDEBUG(72, *YYCURSOR); +yy85: + YYDEBUG(85, *YYCURSOR); + ++YYCURSOR; + YYFILL(1); + yych = *YYCURSOR; + YYDEBUG(86, *YYCURSOR); + if (yych <= '\f') { + if (yych <= 0x08) goto yy87; + if (yych <= '\n') goto yy85; + } else { + if (yych <= '\r') goto yy85; + if (yych == ' ') goto yy85; + } +yy87: + YYDEBUG(87, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 100 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" { @@ -724,119 +854,130 @@ yy72: yylval->num = 0; return T_FALSY; } -#line 728 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy73: - YYDEBUG(73, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych != 'l') goto yy33; - YYDEBUG(74, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych != 's') goto yy33; - YYDEBUG(75, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'e') goto yy71; - goto yy33; -yy76: - YYDEBUG(76, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych != 'a') goto yy33; - YYDEBUG(77, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych != 'b') goto yy33; - YYDEBUG(78, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych != 'l') goto yy33; - YYDEBUG(79, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych != 'e') goto yy33; - YYDEBUG(80, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'd') goto yy66; - goto yy33; -yy81: - YYDEBUG(81, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych != 's') goto yy33; - YYDEBUG(82, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych != 'a') goto yy33; - YYDEBUG(83, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych != 'b') goto yy33; - YYDEBUG(84, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych != 'l') goto yy33; - YYDEBUG(85, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych != 'e') goto yy33; - YYDEBUG(86, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'd') goto yy71; - goto yy33; -yy87: - YYDEBUG(87, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych != 'N') goto yy33; +#line 858 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy88: YYDEBUG(88, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych != 'D') goto yy33; + if (yych == 'L') goto yy89; + if (yych != 'l') goto yy40; +yy89: YYDEBUG(89, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == '_') goto yy61; - goto yy33; + if (yych == 'S') goto yy90; + if (yych != 's') goto yy40; yy90: YYDEBUG(90, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yybm[0+yych] & 128) { - goto yy91; - } - goto yy33; + if (yych == 'E') goto yy84; + if (yych == 'e') goto yy84; + goto yy40; yy91: YYDEBUG(91, *YYCURSOR); - yyaccept = 5; + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'A') goto yy92; + if (yych != 'a') goto yy40; +yy92: + YYDEBUG(92, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'B') goto yy93; + if (yych != 'b') goto yy40; +yy93: + YYDEBUG(93, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'L') goto yy94; + if (yych != 'l') goto yy40; +yy94: + YYDEBUG(94, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'E') goto yy95; + if (yych != 'e') goto yy40; +yy95: + YYDEBUG(95, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'D') goto yy77; + if (yych == 'd') goto yy77; + goto yy40; +yy96: + YYDEBUG(96, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'S') goto yy97; + if (yych != 's') goto yy40; +yy97: + YYDEBUG(97, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'A') goto yy98; + if (yych != 'a') goto yy40; +yy98: + YYDEBUG(98, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'B') goto yy99; + if (yych != 'b') goto yy40; +yy99: + YYDEBUG(99, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'L') goto yy100; + if (yych != 'l') goto yy40; +yy100: + YYDEBUG(100, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'E') goto yy101; + if (yych != 'e') goto yy40; +yy101: + YYDEBUG(101, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'D') goto yy84; + if (yych == 'd') goto yy84; + goto yy40; +yy102: + YYDEBUG(102, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[0+yych] & 128) { + goto yy103; + } + goto yy40; +yy103: + YYDEBUG(103, *YYCURSOR); + yyaccept = 3; YYMARKER = ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; - YYDEBUG(92, *YYCURSOR); + YYDEBUG(104, *YYCURSOR); if (yybm[0+yych] & 128) { - goto yy91; + goto yy103; } if (yych <= 0x1F) { if (yych <= '\n') { - if (yych <= 0x00) goto yy93; - if (yych <= 0x08) goto yy32; + if (yych <= 0x00) goto yy105; + if (yych <= 0x08) goto yy39; } else { - if (yych != '\r') goto yy32; + if (yych != '\r') goto yy39; } } else { if (yych <= '#') { - if (yych <= ' ') goto yy93; - if (yych <= '"') goto yy32; + if (yych <= ' ') goto yy105; + if (yych <= '"') goto yy39; } else { - if (yych == ':') goto yy54; - goto yy32; + if (yych == ':') goto yy62; + goto yy39; } } -yy93: - YYDEBUG(93, *YYCURSOR); +yy105: + YYDEBUG(105, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 112 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" { @@ -844,27 +985,33 @@ yy93: yylval->addr = strtoul(yytext, 0, 16); return T_ADDR; } -#line 848 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy94: - YYDEBUG(94, *YYCURSOR); - yyaccept = 6; +#line 989 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy106: + YYDEBUG(106, *YYCURSOR); + yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych <= '\r') { - if (yych <= 0x08) { - if (yych >= 0x01) goto yy33; - } else { - if (yych <= '\n') goto yy95; - if (yych <= '\f') goto yy33; - } + if (yych <= '\f') { + if (yych <= 0x08) goto yy40; + if (yych >= '\v') goto yy40; } else { - if (yych <= ' ') { - if (yych <= 0x1F) goto yy33; - } else { - if (yych != '#') goto yy33; - } + if (yych <= '\r') goto yy107; + if (yych != ' ') goto yy40; } -yy95: - YYDEBUG(95, *YYCURSOR); +yy107: + YYDEBUG(107, *YYCURSOR); + ++YYCURSOR; + YYFILL(1); + yych = *YYCURSOR; + YYDEBUG(108, *YYCURSOR); + if (yych <= '\f') { + if (yych <= 0x08) goto yy109; + if (yych <= '\n') goto yy107; + } else { + if (yych <= '\r') goto yy107; + if (yych == ' ') goto yy107; + } +yy109: + YYDEBUG(109, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 72 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" { @@ -872,7 +1019,7 @@ yy95: phpdbg_init_param(yylval, EMPTY_PARAM); return T_IF; } -#line 876 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +#line 1023 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" } /* *********************************** */ yyc_RAW: @@ -911,29 +1058,29 @@ yyc_RAW: 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, }; - YYDEBUG(96, *YYCURSOR); + YYDEBUG(110, *YYCURSOR); YYFILL(2); yych = *YYCURSOR; if (yybm[0+yych] & 32) { - goto yy98; + goto yy112; } - if (yych <= 0x00) goto yy103; - if (yych == '\n') goto yy101; - goto yy104; -yy98: - YYDEBUG(98, *YYCURSOR); + if (yych <= 0x00) goto yy117; + if (yych == '\n') goto yy115; + goto yy118; +yy112: + YYDEBUG(112, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(99, *YYCURSOR); + YYDEBUG(113, *YYCURSOR); if (yybm[0+yych] & 32) { - goto yy98; + goto yy112; } - if (yych <= 0x00) goto yy100; - if (yych == '\n') goto yy106; - goto yy104; -yy100: - YYDEBUG(100, *YYCURSOR); + if (yych <= 0x00) goto yy114; + if (yych == '\n') goto yy120; + goto yy118; +yy114: + YYDEBUG(114, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 132 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" { @@ -942,45 +1089,45 @@ yy100: yylval->len = yyleng; return T_INPUT; } -#line 946 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy101: - YYDEBUG(101, *YYCURSOR); +#line 1093 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy115: + YYDEBUG(115, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 128) { - goto yy106; + goto yy120; } -yy102: - YYDEBUG(102, *YYCURSOR); +yy116: + YYDEBUG(116, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 68 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" { return 0; } -#line 960 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy103: - YYDEBUG(103, *YYCURSOR); +#line 1107 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +yy117: + YYDEBUG(117, *YYCURSOR); yych = *++YYCURSOR; - goto yy102; -yy104: - YYDEBUG(104, *YYCURSOR); + goto yy116; +yy118: + YYDEBUG(118, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(105, *YYCURSOR); + YYDEBUG(119, *YYCURSOR); if (yybm[0+yych] & 64) { - goto yy104; + goto yy118; } - goto yy100; -yy106: - YYDEBUG(106, *YYCURSOR); + goto yy114; +yy120: + YYDEBUG(120, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(107, *YYCURSOR); + YYDEBUG(121, *YYCURSOR); if (yybm[0+yych] & 128) { - goto yy106; + goto yy120; } - YYDEBUG(108, *YYCURSOR); + YYDEBUG(122, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 139 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" { @@ -988,7 +1135,7 @@ yy106: goto restart; } -#line 992 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +#line 1139 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" } } #line 168 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" diff --git a/phpdbg_lexer.l b/phpdbg_lexer.l index 4d9c837f1e4..7b3ce38c472 100644 --- a/phpdbg_lexer.l +++ b/phpdbg_lexer.l @@ -43,21 +43,21 @@ restart: /*!re2c re2c:yyfill:check = 0; -T_TRUE "true" -T_YES "yes" -T_ON "on" -T_ENABLED "enabled" -T_FALSE "false" -T_NO "no" -T_OFF "off" -T_DISABLED "disabled" -T_EVAL "ev" -T_SHELL "sh" -T_IF "if" -T_RUN "run" +T_TRUE 'true' +T_YES 'yes' +T_ON 'on' +T_ENABLED 'enabled' +T_FALSE 'false' +T_NO 'no' +T_OFF 'off' +T_DISABLED 'disabled' +T_EVAL 'ev' +T_SHELL 'sh' +T_IF 'if' +T_RUN 'run' T_RUN_SHORT "r" WS [ \r\n\t]+ -DIGITS [0-9\.]+ +DIGITS [-]?[0-9\.]+ ID [^ \r\n\t:#\000]+ ADDR [0][x][a-fA-F0-9]+ OPCODE (ZEND_|zend_)([A-Za-z])+ @@ -69,7 +69,7 @@ INPUT [^\n\000]+ return 0; } -{T_IF} { +{T_IF}{WS} { YYSETCONDITION(RAW); phpdbg_init_param(yylval, EMPTY_PARAM); return T_IF; @@ -91,13 +91,13 @@ INPUT [^\n\000]+ return T_COLON; } -{T_YES}|{T_ON}|{T_ENABLED}|{T_TRUE} { +({T_YES}|{T_ON}|{T_ENABLED}|{T_TRUE}){WS} { phpdbg_init_param(yylval, NUMERIC_PARAM); yylval->num = 1; return T_TRUTHY; } -{T_NO}|{T_OFF}|{T_DISABLED}|{T_FALSE} { +({T_NO}|{T_OFF}|{T_DISABLED}|{T_FALSE}){WS} { phpdbg_init_param(yylval, NUMERIC_PARAM); yylval->num = 0; return T_FALSY; @@ -142,17 +142,17 @@ INPUT [^\n\000]+ goto restart; } -{T_EVAL} { +{T_EVAL}{WS} { YYSETCONDITION(RAW); phpdbg_init_param(yylval, EMPTY_PARAM); return T_EVAL; } -{T_SHELL} { +{T_SHELL}{WS} { YYSETCONDITION(RAW); phpdbg_init_param(yylval, EMPTY_PARAM); return T_SHELL; } -{T_RUN}|{T_RUN_SHORT} { +({T_RUN}|{T_RUN_SHORT}){WS} { YYSETCONDITION(RAW); phpdbg_init_param(yylval, EMPTY_PARAM); return T_RUN; diff --git a/phpdbg_list.c b/phpdbg_list.c index 037c6c38b2a..e8db4e605c7 100644 --- a/phpdbg_list.c +++ b/phpdbg_list.c @@ -130,14 +130,14 @@ void phpdbg_list_file(const char *filename, long count, long offset, int highlig char *opened = NULL; char buffer[8096] = {0,}; long line = 0; - + php_stream *stream = NULL; if (VCWD_STAT(filename, &st) == FAILURE) { phpdbg_error("Failed to stat file %s", filename); return; } - + stream = php_stream_open_wrapper(filename, "rb", USE_PATH, &opened); if (!stream) { @@ -145,11 +145,17 @@ void phpdbg_list_file(const char *filename, long count, long offset, int highlig return; } + if (offset < 0) { + count += offset; + offset = 0; + } + while (php_stream_gets(stream, buffer, sizeof(buffer)) != NULL) { + long linelen = strlen(buffer); + ++line; - if (!offset || offset <= line) { - /* Without offset, or offset reached */ + if (offset <= line) { if (!highlight) { phpdbg_write("%05ld: %s", line, buffer); } else { @@ -159,10 +165,15 @@ void phpdbg_list_file(const char *filename, long count, long offset, int highlig phpdbg_write(">%05ld: %s", line, buffer); } } + + if (buffer[linelen - 1] != '\n') { + phpdbg_write("\n"); + } } - - if ((count + (offset-1)) == line) + + if (count > 0 && count + offset - 1 < line) { break; + } } php_stream_close(stream); diff --git a/phpdbg_parser.c b/phpdbg_parser.c index f9a3e4d299a..e34c2f48ff4 100644 --- a/phpdbg_parser.c +++ b/phpdbg_parser.c @@ -436,7 +436,7 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 25 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 41 +#define YYLAST 42 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 21 @@ -493,8 +493,8 @@ static const yytype_uint8 yytranslate[] = static const yytype_uint8 yyprhs[] = { 0, 0, 3, 5, 7, 8, 10, 13, 17, 22, - 27, 33, 37, 43, 47, 49, 51, 53, 55, 57, - 59, 61, 64, 67, 70, 72 + 27, 33, 37, 43, 47, 50, 52, 54, 56, 58, + 60, 62, 64, 67, 70, 72 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ @@ -504,9 +504,9 @@ static const yytype_int8 yyrhs[] = 23, 24, -1, 18, 10, 14, -1, 18, 10, 12, 14, -1, 13, 18, 10, 14, -1, 13, 18, 10, 12, 14, -1, 18, 11, 18, -1, 18, 11, 18, - 12, 14, -1, 18, 12, 14, -1, 17, -1, 16, - -1, 15, -1, 7, -1, 8, -1, 14, -1, 18, - -1, 6, 19, -1, 3, 19, -1, 5, 19, -1, + 12, 14, -1, 18, 12, 14, -1, 6, 19, -1, + 17, -1, 16, -1, 15, -1, 7, -1, 8, -1, + 14, -1, 18, -1, 3, 19, -1, 5, 19, -1, 4, -1, 4, 19, -1 }; @@ -514,8 +514,8 @@ static const yytype_int8 yyrhs[] = static const yytype_uint8 yyrline[] = { 0, 66, 66, 67, 68, 72, 73, 77, 82, 87, - 97, 107, 112, 118, 124, 125, 126, 127, 128, 129, - 130, 134, 139, 144, 149, 153 + 97, 107, 112, 118, 124, 129, 130, 131, 132, 133, + 134, 135, 139, 144, 149, 153 }; #endif @@ -552,15 +552,15 @@ static const yytype_uint8 yyr1[] = { 0, 21, 22, 22, 22, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 25, 25, 25, 25, 25 + 24, 24, 25, 25, 25, 25 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 1, 1, 0, 1, 2, 3, 4, 4, - 5, 3, 5, 3, 1, 1, 1, 1, 1, 1, - 1, 2, 2, 2, 1, 2 + 5, 3, 5, 3, 2, 1, 1, 1, 1, 1, + 1, 1, 2, 2, 1, 2 }; /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. @@ -568,9 +568,9 @@ static const yytype_uint8 yyr2[] = means the default is an error. */ static const yytype_uint8 yydefact[] = { - 4, 0, 24, 0, 0, 17, 18, 0, 19, 16, - 15, 14, 20, 0, 2, 5, 3, 22, 25, 23, - 21, 0, 0, 0, 0, 1, 6, 0, 0, 7, + 4, 0, 24, 0, 0, 18, 19, 0, 20, 17, + 16, 15, 21, 0, 2, 5, 3, 22, 25, 23, + 14, 0, 0, 0, 0, 1, 6, 0, 0, 7, 11, 13, 0, 9, 8, 0, 10, 12 }; @@ -585,16 +585,16 @@ static const yytype_int8 yydefgoto[] = #define YYPACT_NINF -11 static const yytype_int8 yypact[] = { - -3, -10, 10, 11, 12, -11, -11, 14, -11, -11, - -11, -11, -4, 28, 9, -11, -11, -11, -11, -11, - -11, 23, 6, 16, 21, -11, -11, 7, 22, -11, - 25, -11, 24, -11, -11, 26, -11, -11 + -3, -10, 11, 12, 13, -11, -11, 15, -11, -11, + -11, -11, -4, 29, 10, -11, -11, -11, -11, -11, + -11, 24, 7, 17, 22, -11, -11, 8, 23, -11, + 26, -11, 25, -11, -11, 27, -11, -11 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -11, -11, -11, 27, -11 + -11, -11, -11, 28, -11 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -604,10 +604,10 @@ static const yytype_int8 yypgoto[] = static const yytype_uint8 yytable[] = { 1, 2, 3, 4, 5, 6, 22, 23, 24, 17, - 7, 8, 9, 10, 11, 12, 5, 6, 28, 32, - 29, 33, 7, 8, 9, 10, 11, 12, 25, 18, - 19, 20, 21, 27, 30, 31, 34, 35, 36, 0, - 37, 26 + 7, 8, 9, 10, 11, 12, 4, 5, 6, 28, + 32, 29, 33, 7, 8, 9, 10, 11, 12, 25, + 18, 19, 20, 21, 27, 30, 31, 34, 35, 36, + 0, 37, 26 }; #define yypact_value_is_default(yystate) \ @@ -619,10 +619,10 @@ static const yytype_uint8 yytable[] = static const yytype_int8 yycheck[] = { 3, 4, 5, 6, 7, 8, 10, 11, 12, 19, - 13, 14, 15, 16, 17, 18, 7, 8, 12, 12, - 14, 14, 13, 14, 15, 16, 17, 18, 0, 19, - 19, 19, 18, 10, 18, 14, 14, 12, 14, -1, - 14, 14 + 13, 14, 15, 16, 17, 18, 6, 7, 8, 12, + 12, 14, 14, 13, 14, 15, 16, 17, 18, 0, + 19, 19, 19, 18, 10, 18, 14, 14, 12, 14, + -1, 14, 14 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing @@ -1563,48 +1563,6 @@ yyreduce: case 14: /* Line 1802 of yacc.c */ #line 124 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" - { (yyval) = (yyvsp[(1) - (1)]); } - break; - - case 15: -/* Line 1802 of yacc.c */ -#line 125 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" - { (yyval) = (yyvsp[(1) - (1)]); } - break; - - case 16: -/* Line 1802 of yacc.c */ -#line 126 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" - { (yyval) = (yyvsp[(1) - (1)]); } - break; - - case 17: -/* Line 1802 of yacc.c */ -#line 127 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" - { (yyval) = (yyvsp[(1) - (1)]); } - break; - - case 18: -/* Line 1802 of yacc.c */ -#line 128 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" - { (yyval) = (yyvsp[(1) - (1)]); } - break; - - case 19: -/* Line 1802 of yacc.c */ -#line 129 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" - { (yyval) = (yyvsp[(1) - (1)]); } - break; - - case 20: -/* Line 1802 of yacc.c */ -#line 130 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" - { (yyval) = (yyvsp[(1) - (1)]); } - break; - - case 21: -/* Line 1802 of yacc.c */ -#line 134 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = COND_PARAM; (yyval).str = (yyvsp[(2) - (2)]).str; @@ -1612,6 +1570,48 @@ yyreduce: } break; + case 15: +/* Line 1802 of yacc.c */ +#line 129 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 16: +/* Line 1802 of yacc.c */ +#line 130 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 17: +/* Line 1802 of yacc.c */ +#line 131 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 18: +/* Line 1802 of yacc.c */ +#line 132 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 19: +/* Line 1802 of yacc.c */ +#line 133 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 20: +/* Line 1802 of yacc.c */ +#line 134 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 21: +/* Line 1802 of yacc.c */ +#line 135 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + case 22: /* Line 1802 of yacc.c */ #line 139 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" diff --git a/phpdbg_parser.y b/phpdbg_parser.y index fd81edfc29d..702bf78455d 100644 --- a/phpdbg_parser.y +++ b/phpdbg_parser.y @@ -121,6 +121,11 @@ parameter $$.len = $1.len; $$.num = $3.num; } + | T_IF T_INPUT { + $$.type = COND_PARAM; + $$.str = $2.str; + $$.len = $2.len; + } | T_OPCODE { $$ = $1; } | T_ADDR { $$ = $1; } | T_LITERAL { $$ = $1; } @@ -131,12 +136,7 @@ parameter ; full_expression - : T_IF T_INPUT { - $$.type = COND_PARAM; - $$.str = $2.str; - $$.len = $2.len; - } - | T_EVAL T_INPUT { + : T_EVAL T_INPUT { $$.type = EVAL_PARAM; $$.str = $2.str; $$.len = $2.len; From 18c9f8fbb9336c1a5ef1f3614b4ff37599bc237c Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sun, 6 Jul 2014 01:17:50 +0200 Subject: [PATCH 037/398] Merge sapi/phpdbg into PHP-5.6 --- Makefile.frag | 2 +- phpdbg.c | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Makefile.frag b/Makefile.frag index b276aaaa534..36c7512d697 100644 --- a/Makefile.frag +++ b/Makefile.frag @@ -28,7 +28,7 @@ install-phpdbg: $(BUILD_BINARY) @$(INSTALL) -m 0755 $(BUILD_BINARY) $(INSTALL_ROOT)$(bindir)/$(program_prefix)phpdbg$(program_suffix)$(EXEEXT) @echo "Installing phpdbg man page: $(INSTALL_ROOT)$(mandir)/man1/" @$(mkinstalldirs) $(INSTALL_ROOT)$(mandir)/man1 - @$(INSTALL_DATA) sapi/phpdbg/phpdbg.1 $(INSTALL_ROOT)$(mandir)/man1/$(program_prefix)phpdbg$(program_suffix).1 + @$(INSTALL_DATA) $(srcdir)/phpdbg.1 $(INSTALL_ROOT)$(mandir)/man1/$(program_prefix)phpdbg$(program_suffix).1 clean-phpdbg: @echo "Cleaning phpdbg object files ..." diff --git a/phpdbg.c b/phpdbg.c index 93fdbd74240..1fbd18a423a 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -856,7 +856,8 @@ int phpdbg_open_sockets(char *address, int port[2], int (*listen)[2], int (*sock return SUCCESS; } /* }}} */ -void phpdbg_signal_handler(int sig, siginfo_t *info, void *context) { +void phpdbg_signal_handler(int sig, siginfo_t *info, void *context) /* {{{ */ +{ int is_handled = FAILURE; TSRMLS_FETCH(); @@ -874,10 +875,11 @@ void phpdbg_signal_handler(int sig, siginfo_t *info, void *context) { break; } -} +} /* }}} */ #endif -static inline zend_mm_heap *phpdbg_mm_get_heap() { +static inline zend_mm_heap *phpdbg_mm_get_heap() /* {{{ */ +{ zend_mm_heap *mm_heap; TSRMLS_FETCH(); @@ -886,22 +888,22 @@ static inline zend_mm_heap *phpdbg_mm_get_heap() { zend_mm_set_heap(mm_heap TSRMLS_CC); return mm_heap; -} +} /* }}} */ -void *phpdbg_malloc_wrapper(size_t size) +void *phpdbg_malloc_wrapper(size_t size) /* {{{ */ { return zend_mm_alloc(phpdbg_mm_get_heap(), size); -} +} /* }}} */ -void phpdbg_free_wrapper(void *p) +void phpdbg_free_wrapper(void *p) /* {{{ */ { zend_mm_free(phpdbg_mm_get_heap(), p); -} +} /* }}} */ -void *phpdbg_realloc_wrapper(void *ptr, size_t size) +void *phpdbg_realloc_wrapper(void *ptr, size_t size) /* {{{ */ { return zend_mm_realloc(phpdbg_mm_get_heap(), ptr, size); -} +} /* }}} */ int main(int argc, char **argv) /* {{{ */ { From 29d8aad2f65cab8d94ce6203f9cc5eb3e2691589 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Mon, 15 Sep 2014 05:48:09 +0200 Subject: [PATCH 038/398] Merge phpdbg into PHP-5.6 --- .travis.yml | 1 - README.md | 2 +- phpdbg.c | 10 +++++----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index d5b492e7cfa..2e777fbe13d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,6 @@ env: - PHP="PHP-5.4" - PHP="PHP-5.5" - PHP="PHP-5.6" -- PHP="master" before_script: ./travis/ci.sh diff --git a/README.md b/README.md index e7e5c731a80..a2a84deb7b1 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ The interactive PHP debugger ============================ -Implemented as a SAPI module, phpdbg can excert complete control over the environment without impacting the functionality or performance of your code. +Implemented as a SAPI module, phpdbg can exert complete control over the environment without impacting the functionality or performance of your code. phpdbg aims to be a lightweight, powerful, easy to use debugging platform for PHP 5.4+ diff --git a/phpdbg.c b/phpdbg.c index 1fbd18a423a..c881559e6ed 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -1296,14 +1296,14 @@ phpdbg_main: /* do not install sigint handlers for remote consoles */ /* sending SIGINT then provides a decent way of shutting down the server */ -#if defined(ZEND_SIGNALS) && !defined(_WIN32) - if (listen[0] < 0) { - zend_try { zend_signal(SIGINT, phpdbg_sigint_handler TSRMLS_CC); } zend_end_try(); - } -#elif !defined(_WIN32) +#ifndef _WIN32 if (listen[0] < 0) { #endif +#if defined(ZEND_SIGNALS) && !defined(_WIN32) + zend_try { zend_signal(SIGINT, phpdbg_sigint_handler TSRMLS_CC); } zend_end_try(); +#else signal(SIGINT, phpdbg_sigint_handler); +#endif #ifndef _WIN32 } #endif From 88412772d295ebf7dd34409534507dc9bcac726e Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Sun, 28 Sep 2014 17:33:44 -0700 Subject: [PATCH 039/398] Fix bug #68027 - fix date parsing in XMLRPC lib --- NEWS | 5 +++- ext/xmlrpc/libxmlrpc/xmlrpc.c | 13 ++++++---- ext/xmlrpc/tests/bug68027.phpt | 44 ++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 6 deletions(-) create mode 100644 ext/xmlrpc/tests/bug68027.phpt diff --git a/NEWS b/NEWS index 9b4248e2688..be885ab1e6b 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,7 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2014, PHP 5.4.34 --Fileinfo: +- Fileinfo: . Fixed bug #66242 (libmagic: don't assume char is signed). (ArdB) - Core: @@ -12,6 +12,9 @@ PHP NEWS - OpenSSL: . Reverted fixes for bug #41631, due to regressions. (Stas) +- XMLRPC: + . Fixed bug #68027 (Global buffer overflow in mkgmtime() function). (Stas) + 18 Sep 2014, PHP 5.4.33 - Core: diff --git a/ext/xmlrpc/libxmlrpc/xmlrpc.c b/ext/xmlrpc/libxmlrpc/xmlrpc.c index ce70c2afd90..b766a5495a4 100644 --- a/ext/xmlrpc/libxmlrpc/xmlrpc.c +++ b/ext/xmlrpc/libxmlrpc/xmlrpc.c @@ -219,16 +219,19 @@ static int date_from_ISO8601 (const char *text, time_t * value) { n = 10; tm.tm_mon = 0; for(i = 0; i < 2; i++) { - XMLRPC_IS_NUMBER(text[i]) + XMLRPC_IS_NUMBER(text[i+4]) tm.tm_mon += (text[i+4]-'0')*n; n /= 10; } tm.tm_mon --; + if(tm.tm_mon < 0 || tm.tm_mon > 11) { + return -1; + } n = 10; tm.tm_mday = 0; for(i = 0; i < 2; i++) { - XMLRPC_IS_NUMBER(text[i]) + XMLRPC_IS_NUMBER(text[i+6]) tm.tm_mday += (text[i+6]-'0')*n; n /= 10; } @@ -236,7 +239,7 @@ static int date_from_ISO8601 (const char *text, time_t * value) { n = 10; tm.tm_hour = 0; for(i = 0; i < 2; i++) { - XMLRPC_IS_NUMBER(text[i]) + XMLRPC_IS_NUMBER(text[i+9]) tm.tm_hour += (text[i+9]-'0')*n; n /= 10; } @@ -244,7 +247,7 @@ static int date_from_ISO8601 (const char *text, time_t * value) { n = 10; tm.tm_min = 0; for(i = 0; i < 2; i++) { - XMLRPC_IS_NUMBER(text[i]) + XMLRPC_IS_NUMBER(text[i+12]) tm.tm_min += (text[i+12]-'0')*n; n /= 10; } @@ -252,7 +255,7 @@ static int date_from_ISO8601 (const char *text, time_t * value) { n = 10; tm.tm_sec = 0; for(i = 0; i < 2; i++) { - XMLRPC_IS_NUMBER(text[i]) + XMLRPC_IS_NUMBER(text[i+15]) tm.tm_sec += (text[i+15]-'0')*n; n /= 10; } diff --git a/ext/xmlrpc/tests/bug68027.phpt b/ext/xmlrpc/tests/bug68027.phpt new file mode 100644 index 00000000000..a5c96f1cf29 --- /dev/null +++ b/ext/xmlrpc/tests/bug68027.phpt @@ -0,0 +1,44 @@ +--TEST-- +Bug #68027 (buffer overflow in mkgmtime() function) +--SKIPIF-- + +--FILE-- +$datetime"); +print_r($obj); + +$datetime = "34770-0-08T21:46:40-0400"; +$obj = xmlrpc_decode("$datetime"); +print_r($obj); + +echo "Done\n"; +?> +--EXPECTF-- +object(stdClass)#1 (3) { + ["scalar"]=> + string(16) "6-01-01 20:00:00" + ["xmlrpc_type"]=> + string(8) "datetime" + ["timestamp"]=> + int(%d) +} +stdClass Object +( + [scalar] => 2001-0-08T21:46:40-0400 + [xmlrpc_type] => datetime + [timestamp] => %s +) +stdClass Object +( + [scalar] => 34770-0-08T21:46:40-0400 + [xmlrpc_type] => datetime + [timestamp] => %d +) +Done From 56754a7f9eba0e4f559b6ca081d9f2a447b3f159 Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Sun, 28 Sep 2014 14:19:31 -0700 Subject: [PATCH 040/398] Fixed bug #68044: Integer overflow in unserialize() (32-bits only) --- NEWS | 5 ++++- ext/standard/tests/serialize/bug68044.phpt | 12 ++++++++++++ ext/standard/var_unserializer.c | 4 ++-- ext/standard/var_unserializer.re | 2 +- 4 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 ext/standard/tests/serialize/bug68044.phpt diff --git a/NEWS b/NEWS index be885ab1e6b..e758f35b7ba 100644 --- a/NEWS +++ b/NEWS @@ -8,12 +8,15 @@ PHP NEWS - Core: . Fixed bug #67985 (Incorrect last used array index copied to new array after unset). (Tjerk) + . Fixed bug #68044 (Integer overflow in unserialize() (32-bits only)). + (CVE-2014-3669) (Stas) - OpenSSL: . Reverted fixes for bug #41631, due to regressions. (Stas) - XMLRPC: - . Fixed bug #68027 (Global buffer overflow in mkgmtime() function). (Stas) + . Fixed bug #68027 (Global buffer overflow in mkgmtime() function). + (CVE-2014-3668) (Stas) 18 Sep 2014, PHP 5.4.33 diff --git a/ext/standard/tests/serialize/bug68044.phpt b/ext/standard/tests/serialize/bug68044.phpt new file mode 100644 index 00000000000..031e44e1498 --- /dev/null +++ b/ext/standard/tests/serialize/bug68044.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #68044 Integer overflow in unserialize() (32-bits only) +--FILE-- + +===DONE== +--EXPECTF-- +Warning: Insufficient data for unserializing - %d required, 1 present in %s/bug68044.php on line 2 + +Notice: unserialize(): Error at offset 32 of 33 bytes in %s/bug68044.php on line 2 +===DONE== diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c index 657051f6f72..8129da3d825 100644 --- a/ext/standard/var_unserializer.c +++ b/ext/standard/var_unserializer.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Sat Jun 21 21:27:56 2014 */ +/* Generated by re2c 0.13.5 */ #line 1 "ext/standard/var_unserializer.re" /* +----------------------------------------------------------------------+ @@ -372,7 +372,7 @@ static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce) (*p) += 2; - if (datalen < 0 || (*p) + datalen >= max) { + if (datalen < 0 || (max - (*p)) <= datalen) { zend_error(E_WARNING, "Insufficient data for unserializing - %ld required, %ld present", datalen, (long)(max - (*p))); return 0; } diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re index 130750805f4..6de158392e1 100644 --- a/ext/standard/var_unserializer.re +++ b/ext/standard/var_unserializer.re @@ -376,7 +376,7 @@ static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce) (*p) += 2; - if (datalen < 0 || (*p) + datalen >= max) { + if (datalen < 0 || (max - (*p)) <= datalen) { zend_error(E_WARNING, "Insufficient data for unserializing - %ld required, %ld present", datalen, (long)(max - (*p))); return 0; } From ab0939e5e5449cba04b02fff3a5595f725bce0a0 Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Sun, 28 Sep 2014 17:53:49 -0700 Subject: [PATCH 041/398] Fix bug #68089 - do not accept options with embedded \0 Conflicts: ext/curl/interface.c --- NEWS | 3 +++ ext/curl/interface.c | 6 ++++++ ext/curl/tests/bug68089.phpt | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 ext/curl/tests/bug68089.phpt diff --git a/NEWS b/NEWS index e758f35b7ba..b074f9f3cb0 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,9 @@ PHP NEWS . Fixed bug #68044 (Integer overflow in unserialize() (32-bits only)). (CVE-2014-3669) (Stas) +- cURL: + . Fixed bug #68089 (NULL byte injection - cURL lib). (Stas) + - OpenSSL: . Reverted fixes for bug #41631, due to regressions. (Stas) diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 8915625047c..23b125238d3 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -170,6 +170,12 @@ static int php_curl_option_url(php_curl *ch, const char *url, const int len TSRM #if LIBCURL_VERSION_NUM < 0x071100 char *copystr = NULL; #endif + + if (strlen(url) != len) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Curl option contains invalid characters (\\0)"); + return 0; + } + /* Disable file:// if open_basedir are used */ if (PG(open_basedir) && *PG(open_basedir)) { #if LIBCURL_VERSION_NUM >= 0x071304 diff --git a/ext/curl/tests/bug68089.phpt b/ext/curl/tests/bug68089.phpt new file mode 100644 index 00000000000..3bd5889709b --- /dev/null +++ b/ext/curl/tests/bug68089.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #68089 (NULL byte injection - cURL lib) +--SKIPIF-- + +--FILE-- + +Done +--EXPECTF-- +Warning: curl_setopt(): Curl option contains invalid characters (\0) in %s/bug68089.php on line 4 +bool(false) +Done From 287c91c1f060dc85a8bdb51488c50db8614448b7 Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Sun, 28 Sep 2014 16:57:42 -0700 Subject: [PATCH 042/398] Fix bug #68113 (Heap corruption in exif_thumbnail()) --- NEWS | 6 +++++- ext/exif/exif.c | 4 ++-- ext/exif/tests/bug68113.jpg | Bin 0 -> 368 bytes ext/exif/tests/bug68113.phpt | 17 +++++++++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100755 ext/exif/tests/bug68113.jpg create mode 100644 ext/exif/tests/bug68113.phpt diff --git a/NEWS b/NEWS index b074f9f3cb0..35193d1441b 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -?? ??? 2014, PHP 5.4.34 +16 Oct 2014, PHP 5.4.34 - Fileinfo: . Fixed bug #66242 (libmagic: don't assume char is signed). (ArdB) @@ -14,6 +14,10 @@ PHP NEWS - cURL: . Fixed bug #68089 (NULL byte injection - cURL lib). (Stas) +- EXIF: + . Fixed bug #68113 (Heap corruption in exif_thumbnail()). (CVE-2014-3670) + (Stas) + - OpenSSL: . Reverted fixes for bug #41631, due to regressions. (Stas) diff --git a/ext/exif/exif.c b/ext/exif/exif.c index 38907b4d942..637ebf9289b 100644 --- a/ext/exif/exif.c +++ b/ext/exif/exif.c @@ -2426,11 +2426,11 @@ static void* exif_ifd_make_value(image_info_data *info_data, int motorola_intel data_ptr += 8; break; case TAG_FMT_SINGLE: - memmove(data_ptr, &info_data->value.f, byte_count); + memmove(data_ptr, &info_value->f, 4); data_ptr += 4; break; case TAG_FMT_DOUBLE: - memmove(data_ptr, &info_data->value.d, byte_count); + memmove(data_ptr, &info_value->d, 8); data_ptr += 8; break; } diff --git a/ext/exif/tests/bug68113.jpg b/ext/exif/tests/bug68113.jpg new file mode 100755 index 0000000000000000000000000000000000000000..3ce7a620fb108a47d08d669552b995abbacea06a GIT binary patch literal 368 zcmex= +--FILE-- + +Done +--EXPECTF-- +Warning: exif_thumbnail(bug68113.jpg): File structure corrupted in %s/bug68113.php on line 2 + +Warning: exif_thumbnail(bug68113.jpg): Invalid JPEG file in %s/bug68113.php on line 2 +bool(false) +Done \ No newline at end of file From 1803228597e82218a8c105e67975bc50e6f5bf0d Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 22 Oct 2014 15:37:04 +0200 Subject: [PATCH 043/398] Fix bug #68283: fileinfo: out-of-bounds read in elf note headers Upstream commit https://github.com/file/file/commit/39c7ac1106be844a5296d3eb5971946cc09ffda0 CVE -2014-3710 --- ext/fileinfo/libmagic/readelf.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ext/fileinfo/libmagic/readelf.c b/ext/fileinfo/libmagic/readelf.c index 1c3845fc6b1..bb6f70fb8b7 100644 --- a/ext/fileinfo/libmagic/readelf.c +++ b/ext/fileinfo/libmagic/readelf.c @@ -372,6 +372,13 @@ donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size, uint32_t namesz, descsz; unsigned char *nbuf = CAST(unsigned char *, vbuf); + if (xnh_sizeof + offset > size) { + /* + * We're out of note headers. + */ + return xnh_sizeof + offset; + } + (void)memcpy(xnh_addr, &nbuf[offset], xnh_sizeof); offset += xnh_sizeof; From de4fff0fb38e54b69918e381e0445d831fe87868 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 22 Oct 2014 15:39:49 +0200 Subject: [PATCH 044/398] NEWS --- NEWS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS b/NEWS index 35193d1441b..f99fe84d1bb 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,11 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +???, PHP 5.4.34 + +- Fileinfo: + . Fixed bug #68283 (fileinfo: out-of-bounds read in elf note headers). + (CVE-2014-3710) (Remi) + 16 Oct 2014, PHP 5.4.34 - Fileinfo: From 4d54c4bdf0213bed112af70c98e92de51cdf49f7 Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Wed, 22 Oct 2014 13:16:29 -0700 Subject: [PATCH 045/398] fix NEWS & version --- NEWS | 2 +- configure.in | 2 +- main/php_version.h | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index f99fe84d1bb..8f8cd49e7ae 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -???, PHP 5.4.34 +?? ??? ???, PHP 5.4.35 - Fileinfo: . Fixed bug #68283 (fileinfo: out-of-bounds read in elf note headers). diff --git a/configure.in b/configure.in index 19aec5936c5..91ae7fce918 100644 --- a/configure.in +++ b/configure.in @@ -119,7 +119,7 @@ int zend_sprintf(char *buffer, const char *format, ...); PHP_MAJOR_VERSION=5 PHP_MINOR_VERSION=4 -PHP_RELEASE_VERSION=34 +PHP_RELEASE_VERSION=35 PHP_EXTRA_VERSION="-dev" PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION" PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION` diff --git a/main/php_version.h b/main/php_version.h index 0ef8760e08e..a3e2cfc31f0 100644 --- a/main/php_version.h +++ b/main/php_version.h @@ -2,8 +2,8 @@ /* edit configure.in to change version number */ #define PHP_MAJOR_VERSION 5 #define PHP_MINOR_VERSION 4 -#define PHP_RELEASE_VERSION 34 +#define PHP_RELEASE_VERSION 35 #define PHP_EXTRA_VERSION "-dev" -#define PHP_VERSION "5.4.34-dev" -#define PHP_VERSION_ID 50434 +#define PHP_VERSION "5.4.35-dev" +#define PHP_VERSION_ID 50435 From 560649283cdd6b2c48a8fcd9e62f3de4f92d969f Mon Sep 17 00:00:00 2001 From: STANLEY SUFFICOOL Date: Wed, 22 Oct 2014 23:14:23 -0700 Subject: [PATCH 046/398] Implement Bug #66062 - pdo_dblib enable timeout parameter --- ext/pdo_dblib/dblib_driver.c | 39 ++++++++++++++++++++++++------- ext/pdo_dblib/pdo_dblib.c | 28 ++++------------------ ext/pdo_dblib/php_pdo_dblib_int.h | 6 ++--- 3 files changed, 39 insertions(+), 34 deletions(-) diff --git a/ext/pdo_dblib/dblib_driver.c b/ext/pdo_dblib/dblib_driver.c index 40d41148798..323c805fca7 100644 --- a/ext/pdo_dblib/dblib_driver.c +++ b/ext/pdo_dblib/dblib_driver.c @@ -61,7 +61,6 @@ static int dblib_fetch_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *info TSRMLS msg, einfo->dberr, einfo->severity, stmt ? stmt->active_query_string : ""); add_next_index_long(info, einfo->dberr); - // TODO: avoid reallocation ??? add_next_index_string(info, message); efree(message); add_next_index_long(info, einfo->oserr); @@ -145,10 +144,12 @@ static zend_long dblib_handle_doer(pdo_dbh_t *dbh, const char *sql, zend_long sq static int dblib_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, char **quoted, int *quotedlen, enum pdo_param_type paramtype TSRMLS_DC) { - pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data; + + /* pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data; */ + char *q; int l = 1; - + *quoted = q = safe_emalloc(2, unquotedlen, 3); *q++ = '\''; @@ -174,7 +175,6 @@ static int dblib_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquote static int pdo_dblib_transaction_cmd(const char *cmd, pdo_dbh_t *dbh TSRMLS_DC) { pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data; - RETCODE ret; if (FAIL == dbcmd(H->link, cmd)) { return 0; @@ -246,6 +246,23 @@ char *dblib_handle_last_id(pdo_dbh_t *dbh, const char *name, unsigned int *len T return id; } +static int dblib_set_attr(pdo_dbh_t *dbh, zend_long attr, zval *val TSRMLS_DC) +{ + switch(attr) { + case PDO_ATTR_TIMEOUT: + return 0; + default: + return 1; + } + +} + +static int dblib_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *return_value TSRMLS_DC) +{ + /* dblib_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data; */ + return 0; +} + static struct pdo_dbh_methods dblib_methods = { dblib_handle_closer, dblib_handle_preparer, @@ -254,10 +271,10 @@ static struct pdo_dbh_methods dblib_methods = { dblib_handle_begin, /* begin */ dblib_handle_commit, /* commit */ dblib_handle_rollback, /* rollback */ - NULL, /*set attr */ + dblib_set_attr, /*set attr */ dblib_handle_last_id, /* last insert id */ dblib_fetch_error, /* fetch error */ - NULL, /* get attr */ + dblib_get_attribute, /* get attr */ NULL, /* check liveness */ NULL, /* get driver methods */ NULL, /* request shutdown */ @@ -303,6 +320,12 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_ php_pdo_parse_data_source(dbh->data_source, dbh->data_source_len, vars, nvars); + if (driver_options) { + int timeout = pdo_attr_lval(driver_options, PDO_ATTR_TIMEOUT, 30 TSRMLS_CC); + dbsetlogintime(timeout); /* Connection/Login Timeout */ + dbsettime(timeout); /* Statement Timeout */ + } + H = pecalloc(1, sizeof(*H), dbh->is_persistent); H->login = dblogin(); H->err.sqlstate = dbh->error_code; @@ -311,8 +334,8 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_ goto cleanup; } - DBERRHANDLE(H->login, (EHANDLEFUNC) error_handler); - DBMSGHANDLE(H->login, (MHANDLEFUNC) msg_handler); + DBERRHANDLE(H->login, (EHANDLEFUNC) pdo_dblib_error_handler); + DBMSGHANDLE(H->login, (MHANDLEFUNC) pdo_dblib_msg_handler); if(vars[5].optval) { for(i=0;iseverity = severity; einfo->oserr = oserr; einfo->dberr = dberr; + if (einfo->oserrstr) { efree(einfo->oserrstr); } @@ -128,16 +129,10 @@ int error_handler(DBPROCESS *dbproc, int severity, int dberr, } strcpy(einfo->sqlstate, state); -#if 0 - php_error_docref(NULL TSRMLS_CC, E_WARNING, - "dblib error: %d %s (severity %d)", - dberr, dberrstr, severity); -#endif - return INT_CANCEL; } -int msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate, +int pdo_dblib_msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, DBUSMALLINT line) { pdo_dblib_err *einfo; @@ -156,10 +151,6 @@ int msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate, einfo->lastmsg = estrdup(msgtext); } -#if 0 - php_error_docref(NULL TSRMLS_CC, E_WARNING, "dblib message: %s (severity %d)", msgtext, severity); -#endif - return 0; } @@ -196,18 +187,9 @@ PHP_MINIT_FUNCTION(pdo_dblib) return FAILURE; } - /* TODO: - - dbsetifile() - dbsetmaxprocs() - dbsetlogintime() - dbsettime() - - */ - #if !PHP_DBLIB_IS_MSSQL - dberrhandle(error_handler); - dbmsghandle(msg_handler); + dberrhandle((EHANDLEFUNC) pdo_dblib_error_handler); + dbmsghandle((MHANDLEFUNC) pdo_dblib_msg_handler); #endif return SUCCESS; diff --git a/ext/pdo_dblib/php_pdo_dblib_int.h b/ext/pdo_dblib/php_pdo_dblib_int.h index e247b5c19eb..3b341478d76 100644 --- a/ext/pdo_dblib/php_pdo_dblib_int.h +++ b/ext/pdo_dblib/php_pdo_dblib_int.h @@ -37,7 +37,7 @@ # define DBSETOPT(a, b, c) dbsetopt(a, b, c) # define SYBESMSG SQLESMSG # define SYBESEOF SQLESEOF -# define SYBEFCON SQLECONN // SQLEFCON does not exist in MS SQL Server. +# define SYBEFCON SQLECONN /* SQLEFCON does not exist in MS SQL Server. */ # define SYBEMEM SQLEMEM # define SYBEPWD SQLEPWD @@ -89,10 +89,10 @@ typedef unsigned char *LPBYTE; typedef float DBFLT4; #endif -int error_handler(DBPROCESS *dbproc, int severity, int dberr, +int pdo_dblib_error_handler(DBPROCESS *dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr); -int msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate, +int pdo_dblib_msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, DBUSMALLINT line); extern pdo_driver_t pdo_dblib_driver; From 062284e4fbe8a66251eef01beb9242edd21d23a1 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Fri, 24 Oct 2014 19:22:45 +0200 Subject: [PATCH 047/398] Merge phpdbg into PHP-5.6 --- config.m4 | 22 +- config.w32 | 7 +- phpdbg.c | 530 +++++----- phpdbg.h | 156 ++- phpdbg_bp.c | 226 ++-- phpdbg_bp.h | 13 + phpdbg_break.c | 8 +- phpdbg_cmd.c | 343 ++++--- phpdbg_cmd.h | 31 +- phpdbg_eol.c | 172 ++++ phpdbg_eol.h | 46 + phpdbg_frame.c | 139 ++- phpdbg_help.c | 62 +- phpdbg_help.h | 4 +- phpdbg_info.c | 427 +++++--- phpdbg_info.h | 2 + phpdbg_io.c | 272 +++++ phpdbg_io.h | 34 + phpdbg_lexer.c | 1648 ++++++++++++++++++------------ phpdbg_lexer.l | 27 +- phpdbg_list.c | 190 ++-- phpdbg_list.h | 15 +- phpdbg_opcode.c | 22 +- phpdbg_out.c | 1305 +++++++++++++++++++++++ phpdbg_out.h | 93 ++ phpdbg_parser.c | 490 +++++---- phpdbg_parser.h | 43 +- phpdbg_parser.y | 29 +- phpdbg_print.c | 111 +- phpdbg_prompt.c | 831 +++++++++------ phpdbg_prompt.h | 11 +- phpdbg_rinit_hook.c | 101 ++ phpdbg_rinit_hook.h | 41 + phpdbg_set.c | 116 +-- phpdbg_sigio_win32.c | 120 +++ phpdbg_sigio_win32.h | 42 + phpdbg_sigsafe.c | 111 ++ phpdbg_sigsafe.h | 25 + phpdbg_utils.c | 419 +++++--- phpdbg_utils.h | 62 +- phpdbg_wait.c | 419 ++++++++ phpdbg_wait.h | 29 + phpdbg_watch.c | 224 ++-- phpdbg_watch.h | 6 +- phpdbg_webdata_transfer.c | 185 ++++ phpdbg_webdata_transfer.h | 27 + tests/commands/0002_set.test | 2 +- tests/commands/0102_print.test | 5 +- tests/commands/0104_clean.test | 10 +- tests/commands/0105_clear.test | 2 +- tests/commands/0106_compile.test | 4 +- xml.md | 759 ++++++++++++++ zend_mm_structs.h | 102 ++ 53 files changed, 7598 insertions(+), 2522 deletions(-) create mode 100644 phpdbg_eol.c create mode 100644 phpdbg_eol.h create mode 100644 phpdbg_io.c create mode 100644 phpdbg_io.h create mode 100644 phpdbg_out.c create mode 100644 phpdbg_out.h create mode 100644 phpdbg_rinit_hook.c create mode 100644 phpdbg_rinit_hook.h create mode 100644 phpdbg_sigio_win32.c create mode 100644 phpdbg_sigio_win32.h create mode 100644 phpdbg_sigsafe.c create mode 100644 phpdbg_sigsafe.h create mode 100644 phpdbg_wait.c create mode 100644 phpdbg_wait.h create mode 100644 phpdbg_webdata_transfer.c create mode 100644 phpdbg_webdata_transfer.h create mode 100644 xml.md create mode 100644 zend_mm_structs.h diff --git a/config.m4 b/config.m4 index d78a439af02..528abb5822b 100644 --- a/config.m4 +++ b/config.m4 @@ -3,12 +3,15 @@ dnl $Id$ dnl PHP_ARG_ENABLE(phpdbg, for phpdbg support, -[ --enable-phpdbg Build phpdbg], no, no) +[ --enable-phpdbg Build phpdbg], no, no) + +PHP_ARG_ENABLE(phpdbg-webhelper, for phpdbg web SAPI support, +[ --enable-phpdbg-webhelper Build phpdbg web SAPI support], yes, yes) PHP_ARG_ENABLE(phpdbg-debug, for phpdbg debug build, -[ --enable-phpdbg-debug Build phpdbg in debug mode], no, no) +[ --enable-phpdbg-debug Build phpdbg in debug mode], no, no) -if test "$PHP_PHPDBG" != "no"; then +if test "$BUILD_PHPDBG" == "" && test "$PHP_PHPDBG" != "no"; then AC_HEADER_TIOCGWINSZ AC_DEFINE(HAVE_PHPDBG, 1, [ ]) @@ -18,8 +21,19 @@ if test "$PHP_PHPDBG" != "no"; then AC_DEFINE(PHPDBG_DEBUG, 0, [ ]) fi + if test "$PHP_PHPDBG_WEBHELPER" != "no"; then + if ! test -d ext/phpdbg_webhelper; then + ln -s ../sapi/phpdbg ext/phpdbg_webhelper + fi + if test "$PHP_JSON" != "no"; then + PHP_NEW_EXTENSION(phpdbg_webhelper, phpdbg_rinit_hook.c phpdbg_webdata_transfer.c, $ext_shared) + else + AC_MSG_ERROR(Webhelper extension of phpdbg needs json enabled) + fi + fi + PHP_PHPDBG_CFLAGS="-D_GNU_SOURCE" - PHP_PHPDBG_FILES="phpdbg.c phpdbg_parser.c phpdbg_lexer.c phpdbg_prompt.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_info.c phpdbg_cmd.c phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_btree.c" + PHP_PHPDBG_FILES="phpdbg.c phpdbg_parser.c phpdbg_lexer.c phpdbg_prompt.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_info.c phpdbg_cmd.c phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_btree.c phpdbg_sigsafe.c phpdbg_wait.c phpdbg_io.c phpdbg_eol.c phpdbg_out.c" if test "$PHP_READLINE" != "no" -o "$PHP_LIBEDIT" != "no"; then PHPDBG_EXTRA_LIBS="$PHP_READLINE_LIBS" diff --git a/config.w32 b/config.w32 index 17e15b6ced0..6f0bd8f8113 100644 --- a/config.w32 +++ b/config.w32 @@ -1,7 +1,11 @@ ARG_ENABLE('phpdbg', 'Build phpdbg', 'no'); ARG_ENABLE('phpdbgs', 'Build phpdbg shared', 'no'); -PHPDBG_SOURCES='phpdbg.c phpdbg_prompt.c phpdbg_cmd.c phpdbg_info.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_win.c phpdbg_btree.c phpdbg_parser.c phpdbg_lexer.c'; +PHPDBG_SOURCES='phpdbg.c phpdbg_prompt.c phpdbg_cmd.c phpdbg_info.c phpdbg_help.c phpdbg_break.c ' + + 'phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c ' + + 'phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_win.c phpdbg_btree.c '+ + 'phpdbg_parser.c phpdbg_lexer.c phpdbg_sigsafe.c phpdbg_wait.c phpdbg_io.c ' + + 'phpdbg_sigio_win32.c phpdbg_eol.c phpdbg_out.c'; PHPDBG_DLL='php' + PHP_VERSION + 'phpdbg.dll'; PHPDBG_EXE='phpdbg.exe'; @@ -9,6 +13,7 @@ if (PHP_PHPDBG == "yes") { SAPI('phpdbg', PHPDBG_SOURCES, PHPDBG_EXE); ADD_FLAG("LIBS_PHPDBG", "ws2_32.lib user32.lib"); ADD_FLAG("CFLAGS_PHPDBG", "/D YY_NO_UNISTD_H"); + ADD_FLAG("LDFLAGS_PHPDBG", "/stack:8388608"); } if (PHP_PHPDBGS == "yes") { diff --git a/phpdbg.c b/phpdbg.c index c881559e6ed..f09dc4ee13d 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -28,7 +28,9 @@ #include "phpdbg_list.h" #include "phpdbg_utils.h" #include "phpdbg_set.h" +#include "phpdbg_io.h" #include "zend_alloc.h" +#include "phpdbg_eol.h" /* {{{ remote console headers */ #ifndef _WIN32 @@ -36,6 +38,7 @@ # include # include # include +# include # include # include # include @@ -43,6 +46,20 @@ ZEND_DECLARE_MODULE_GLOBALS(phpdbg); +static PHP_INI_MH(OnUpdateEol) +{ + if (!new_value) { + return FAILURE; + } + + return phpdbg_eol_global_update(new_value TSRMLS_CC); +} + +PHP_INI_BEGIN() + STD_PHP_INI_ENTRY("phpdbg.path", "", PHP_INI_SYSTEM | PHP_INI_PERDIR, OnUpdateString, socket_path, zend_phpdbg_globals, phpdbg_globals) + STD_PHP_INI_ENTRY("phpdbg.eol", "2", PHP_INI_ALL, OnUpdateEol, socket_path, zend_phpdbg_globals, phpdbg_globals) +PHP_INI_END() + static zend_bool phpdbg_booted = 0; #if PHP_VERSION_ID >= 50500 @@ -63,20 +80,39 @@ static inline void php_phpdbg_globals_ctor(zend_phpdbg_globals *pg) /* {{{ */ pg->exec = NULL; pg->exec_len = 0; pg->buffer = NULL; + pg->last_was_newline = 1; pg->ops = NULL; pg->vmret = 0; pg->bp_count = 0; pg->flags = PHPDBG_DEFAULT_FLAGS; pg->oplog = NULL; - pg->io[PHPDBG_STDIN] = NULL; - pg->io[PHPDBG_STDOUT] = NULL; - pg->io[PHPDBG_STDERR] = NULL; + memset(pg->io, 0, sizeof(pg->io)); pg->frame.num = 0; + pg->sapi_name_ptr = NULL; + pg->socket_fd = -1; + pg->socket_server_fd = -1; + + pg->req_id = 0; + pg->err_buf.active = 0; + pg->err_buf.type = 0; + + pg->input_buflen = 0; + pg->sigsafe_mem.mem = NULL; + pg->sigsegv_bailout = NULL; + +#ifdef PHP_WIN32 + pg->sigio_watcher_thread = INVALID_HANDLE_VALUE; + memset(&pg->swd, 0, sizeof(struct win32_sigio_watcher_data)); +#endif + + pg->eol = PHPDBG_EOL_LF; } /* }}} */ static PHP_MINIT_FUNCTION(phpdbg) /* {{{ */ { ZEND_INIT_MODULE_GLOBALS(phpdbg, php_phpdbg_globals_ctor, NULL); + REGISTER_INI_ENTRIES(); + #if PHP_VERSION_ID >= 50500 zend_execute_old = zend_execute_ex; zend_execute_ex = phpdbg_execute_ex; @@ -86,7 +122,7 @@ static PHP_MINIT_FUNCTION(phpdbg) /* {{{ */ #endif REGISTER_STRINGL_CONSTANT("PHPDBG_VERSION", PHPDBG_VERSION, sizeof(PHPDBG_VERSION)-1, CONST_CS|CONST_PERSISTENT); - + REGISTER_LONG_CONSTANT("PHPDBG_FILE", FILE_PARAM, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("PHPDBG_METHOD", METHOD_PARAM, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("PHPDBG_LINENO", NUMERIC_PARAM, CONST_CS|CONST_PERSISTENT); @@ -179,6 +215,7 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */ zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP]); zend_hash_destroy(&PHPDBG_G(seek)); zend_hash_destroy(&PHPDBG_G(registered)); + zend_hash_destroy(&PHPDBG_G(file_sources)); zend_hash_destroy(&PHPDBG_G(watchpoints)); zend_llist_destroy(&PHPDBG_G(watchlist_mem)); @@ -186,7 +223,7 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */ efree(PHPDBG_G(buffer)); PHPDBG_G(buffer) = NULL; } - + if (PHPDBG_G(exec)) { efree(PHPDBG_G(exec)); PHPDBG_G(exec) = NULL; @@ -226,7 +263,7 @@ static PHP_FUNCTION(phpdbg_exec) { char *exec = NULL; int exec_len = 0; - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &exec, &exec_len) == FAILURE) { return; } @@ -308,7 +345,7 @@ static PHP_FUNCTION(phpdbg_color) { long element = 0L; char *color = NULL; - int color_len = 0; + size_t color_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &element, &color, &color_len) == FAILURE) { return; @@ -329,7 +366,7 @@ static PHP_FUNCTION(phpdbg_color) static PHP_FUNCTION(phpdbg_prompt) { char *prompt = NULL; - int prompt_len = 0; + size_t prompt_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &prompt, &prompt_len) == FAILURE) { return; @@ -426,7 +463,12 @@ static void php_sapi_phpdbg_log_message(char *message TSRMLS_DC) /* {{{ */ * We must not request TSRM before being boot */ if (phpdbg_booted) { - phpdbg_error("%s", message); + if (PHPDBG_G(flags) & PHPDBG_IN_EVAL) { + phpdbg_error("eval", "msg=\"%s\"", "%s", message); + return; + } + + phpdbg_error("php", "msg=\"%s\"", "%s", message); switch (PG(last_error_type)) { case E_ERROR: @@ -446,7 +488,7 @@ static void php_sapi_phpdbg_log_message(char *message TSRMLS_DC) /* {{{ */ } do { - switch (phpdbg_interactive(TSRMLS_C)) { + switch (phpdbg_interactive(1 TSRMLS_CC)) { case PHPDBG_LEAVE: case PHPDBG_FINISH: case PHPDBG_UNTIL: @@ -516,9 +558,42 @@ static void php_sapi_phpdbg_register_vars(zval *track_vars_array TSRMLS_DC) /* { static inline int php_sapi_phpdbg_ub_write(const char *message, unsigned int length TSRMLS_DC) /* {{{ */ { - return phpdbg_write("%s", message); + if (PHPDBG_G(socket_fd) != -1 && !(PHPDBG_G(flags) & PHPDBG_IS_INTERACTIVE)) { + send(PHPDBG_G(socket_fd), message, length, 0); + } + return phpdbg_script(P_STDOUT, "%.*s", length, message); } /* }}} */ +/* beginning of struct, see main/streams/plain_wrapper.c line 111 */ +typedef struct { + FILE *file; + int fd; +} php_stdio_stream_data; + +static size_t phpdbg_stdiop_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC) { + php_stdio_stream_data *data = (php_stdio_stream_data*)stream->abstract; + + while (data->fd >= 0) { + struct stat stat[3]; + memset(stat, 0, sizeof(stat)); + if (((fstat(fileno(stderr), &stat[2]) < 0) & (fstat(fileno(stdout), &stat[0]) < 0)) | (fstat(data->fd, &stat[1]) < 0)) { + break; + } + + if (stat[0].st_dev == stat[1].st_dev && stat[0].st_ino == stat[1].st_ino) { + phpdbg_script(P_STDOUT, "%.*s", (int) count, buf); + return count; + } + if (stat[2].st_dev == stat[1].st_dev && stat[2].st_ino == stat[1].st_ino) { + phpdbg_script(P_STDERR, "%.*s", (int) count, buf); + return count; + } + break; + } + + return PHPDBG_G(php_stdiop_write)(stream, buf, count TSRMLS_CC); +} + #if PHP_VERSION_ID >= 50700 static inline void php_sapi_phpdbg_flush(void *context TSRMLS_DC) /* {{{ */ { @@ -528,7 +603,9 @@ static inline void php_sapi_phpdbg_flush(void *context) /* {{{ */ TSRMLS_FETCH(); #endif - fflush(PHPDBG_G(io)[PHPDBG_STDOUT]); + if (!phpdbg_active_sigsafe_mem(TSRMLS_C)) { + fflush(PHPDBG_G(io)[PHPDBG_STDOUT].ptr); + } } /* }}} */ /* copied from sapi/cli/php_cli.c cli_register_file_handles */ @@ -644,10 +721,9 @@ const opt_struct OPTIONS[] = { /* {{{ */ {'r', 0, "run"}, {'E', 0, "step-through-eval"}, {'S', 1, "sapi-name"}, -#ifndef _WIN32 {'l', 1, "listen"}, {'a', 1, "address-or-any"}, -#endif + {'x', 0, "xml output"}, {'V', 0, "version"}, {'-', 0, NULL} }; /* }}} */ @@ -679,17 +755,25 @@ static void phpdbg_welcome(zend_bool cleaning TSRMLS_DC) /* {{{ */ { /* print blurb */ if (!cleaning) { - phpdbg_notice("Welcome to phpdbg, the interactive PHP debugger, v%s", - PHPDBG_VERSION); - phpdbg_writeln("To get help using phpdbg type \"help\" and press enter"); - phpdbg_notice("Please report bugs to <%s>", PHPDBG_ISSUES); + phpdbg_xml(""); + phpdbg_notice("intro", "version=\"%s\"", "Welcome to phpdbg, the interactive PHP debugger, v%s", PHPDBG_VERSION); + phpdbg_writeln("intro", "help=\"help\"", "To get help using phpdbg type \"help\" and press enter"); + phpdbg_notice("intro", "report=\"%s\"", "Please report bugs to <%s>", PHPDBG_ISSUES); + phpdbg_xml(""); } else { - phpdbg_notice("Clean Execution Environment"); + if (!(PHPDBG_G(flags) & PHPDBG_WRITE_XML)) { + phpdbg_notice(NULL, NULL, "Clean Execution Environment"); + } - phpdbg_writeln("Classes\t\t\t%d", zend_hash_num_elements(EG(class_table))); - phpdbg_writeln("Functions\t\t%d", zend_hash_num_elements(EG(function_table))); - phpdbg_writeln("Constants\t\t%d", zend_hash_num_elements(EG(zend_constants))); - phpdbg_writeln("Includes\t\t%d", zend_hash_num_elements(&EG(included_files))); + phpdbg_write("cleaninfo", "classes=\"%d\" functions=\"%d\" constants=\"%d\" includes=\"%d\"", + "Classes %d\n" + "Functions %d\n" + "Constants %d\n" + "Includes %d\n", + zend_hash_num_elements(EG(class_table)), + zend_hash_num_elements(EG(function_table)), + zend_hash_num_elements(EG(zend_constants)), + zend_hash_num_elements(&EG(included_files))); } } /* }}} */ @@ -697,163 +781,130 @@ static inline void phpdbg_sigint_handler(int signo) /* {{{ */ { TSRMLS_FETCH(); - if (EG(in_execution)) { - /* set signalled only when not interactive */ - if (!(PHPDBG_G(flags) & PHPDBG_IS_INTERACTIVE)) { - PHPDBG_G(flags) |= PHPDBG_IS_SIGNALED; - } - } else { + if (PHPDBG_G(flags) & PHPDBG_IS_INTERACTIVE) { /* we quit remote consoles on recv SIGINT */ if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) { PHPDBG_G(flags) |= PHPDBG_IS_QUITTING; zend_bailout(); } - } -} /* }}} */ + } else { + /* set signalled only when not interactive */ + if (!(PHPDBG_G(flags) & PHPDBG_IS_INTERACTIVE)) { + if (PHPDBG_G(flags) & PHPDBG_IS_SIGNALED) { + char mem[PHPDBG_SIGSAFE_MEM_SIZE + 1]; -#ifndef _WIN32 -int phpdbg_open_socket(const char *interface, short port) /* {{{ */ -{ - int fd = socket(AF_INET, SOCK_STREAM, 0); - - switch (fd) { - case -1: - return -1; - - default: { - int reuse = 1; - - switch (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*) &reuse, sizeof(reuse))) { - case -1: - close(fd); - return -2; - - default: { - struct sockaddr_in address; - - memset(&address, 0, sizeof(address)); - - address.sin_port = htons(port); - address.sin_family = AF_INET; - - if ((*interface == '*')) { - address.sin_addr.s_addr = htonl(INADDR_ANY); - } else if (!inet_pton(AF_INET, interface, &address.sin_addr)) { - close(fd); - return -3; - } - - switch (bind(fd, (struct sockaddr *)&address, sizeof(address))) { - case -1: - close(fd); - return -4; - - default: { - listen(fd, 5); - } - } - } + phpdbg_set_sigsafe_mem(mem TSRMLS_CC); + zend_try { + phpdbg_force_interruption(TSRMLS_C); + } zend_end_try() + phpdbg_clear_sigsafe_mem(TSRMLS_C); + return; } + PHPDBG_G(flags) |= PHPDBG_IS_SIGNALED; } } - - return fd; } /* }}} */ -static inline void phpdbg_close_sockets(int (*socket)[2], FILE *streams[2]) /* {{{ */ -{ - if ((*socket)[0] >= 0) { - shutdown( - (*socket)[0], SHUT_RDWR); - close((*socket)[0]); + +static void phpdbg_remote_close(int socket, FILE *stream) { + if (socket >= 0) { + phpdbg_close_socket(socket); } - if (streams[0]) { - fclose(streams[0]); + if (stream) { + fclose(stream); } - - if ((*socket)[1] >= 0) { - shutdown( - (*socket)[1], SHUT_RDWR); - close((*socket)[1]); - } - - if (streams[1]) { - fclose(streams[1]); - } -} /* }}} */ +} /* don't inline this, want to debug it easily, will inline when done */ +static int phpdbg_remote_init(const char* address, unsigned short port, int server, int *socket, FILE **stream TSRMLS_DC) { + phpdbg_remote_close(*socket, *stream); -int phpdbg_open_sockets(char *address, int port[2], int (*listen)[2], int (*socket)[2], FILE* streams[2]) /* {{{ */ -{ - if (((*listen)[0]) < 0 && ((*listen)[1]) < 0) { - ((*listen)[0]) = phpdbg_open_socket(address, (short)port[0]); - ((*listen)[1]) = phpdbg_open_socket(address, (short)port[1]); - } - - streams[0] = NULL; - streams[1] = NULL; - - if ((*listen)[0] < 0 || (*listen)[1] < 0) { - if ((*listen)[0] < 0) { - phpdbg_rlog(stderr, - "console failed to initialize (stdin) on %s:%d", address, port[0]); - } - - if ((*listen)[1] < 0) { - phpdbg_rlog(stderr, - "console failed to initialize (stdout) on %s:%d", address, port[1]); - } - - if ((*listen)[0] >= 0) { - close((*listen)[0]); - } - - if ((*listen)[1] >= 0) { - close((*listen)[1]); - } + if (server < 0) { + phpdbg_rlog(fileno(stderr), "Initializing connection on %s:%u failed", address, port); return FAILURE; } - phpdbg_close_sockets(socket, streams); - - phpdbg_rlog(stderr, - "accepting connections on %s:%d/%d", address, port[0], port[1]); + phpdbg_rlog(fileno(stderr), "accepting connections on %s:%u", address, port); { - struct sockaddr_in address; + struct sockaddr_storage address; socklen_t size = sizeof(address); char buffer[20] = {0}; + /* XXX error checks */ + memset(&address, 0, size); + *socket = accept(server, (struct sockaddr *) &address, &size); + inet_ntop(AF_INET, &(((struct sockaddr_in *)&address)->sin_addr), buffer, sizeof(buffer)); - { - memset(&address, 0, size); - (*socket)[0] = accept( - (*listen)[0], (struct sockaddr *) &address, &size); - inet_ntop(AF_INET, &address.sin_addr, buffer, sizeof(buffer)); - - phpdbg_rlog(stderr, "connection (stdin) from %s", buffer); - } - - { - memset(&address, 0, size); - (*socket)[1] = accept( - (*listen)[1], (struct sockaddr *) &address, &size); - inet_ntop(AF_INET, &address.sin_addr, buffer, sizeof(buffer)); - - phpdbg_rlog(stderr, "connection (stdout) from %s", buffer); - } + phpdbg_rlog(fileno(stderr), "connection established from %s", buffer); } - dup2((*socket)[0], fileno(stdin)); - dup2((*socket)[1], fileno(stdout)); +#ifndef _WIN32 + dup2(*socket, fileno(stdout)); + dup2(*socket, fileno(stdin)); setbuf(stdout, NULL); - streams[0] = fdopen((*socket)[0], "r"); - streams[1] = fdopen((*socket)[1], "w"); + *stream = fdopen(*socket, "r+"); + phpdbg_set_async_io(*socket); +#endif return SUCCESS; +} + +#ifndef _WIN32 +/* This function *strictly* assumes that SIGIO is *only* used on the remote connection stream */ +void phpdbg_sigio_handler(int sig, siginfo_t *info, void *context) /* {{{ */ +{ + int flags; + size_t newlen; + size_t i/*, last_nl*/; + TSRMLS_FETCH(); + +// if (!(info->si_band & POLLIN)) { +// return; /* Not interested in writeablility etc., just interested in incoming data */ +// } + + /* only non-blocking reading, avoid non-blocking writing */ + flags = fcntl(PHPDBG_G(io)[PHPDBG_STDIN].fd, F_GETFL, 0); + fcntl(PHPDBG_G(io)[PHPDBG_STDIN].fd, F_SETFL, flags | O_NONBLOCK); + + do { + char mem[PHPDBG_SIGSAFE_MEM_SIZE + 1]; + size_t off = 0; + + if ((newlen = recv(PHPDBG_G(io)[PHPDBG_STDIN].fd, mem, PHPDBG_SIGSAFE_MEM_SIZE, MSG_PEEK)) == (size_t) -1) { + break; + } + for (i = 0; i < newlen; i++) { + switch (mem[off + i]) { + case '\x03': /* ^C char */ + if (PHPDBG_G(flags) & PHPDBG_IS_INTERACTIVE) { + break; /* or quit ??? */ + } + if (PHPDBG_G(flags) & PHPDBG_IS_SIGNALED) { + phpdbg_set_sigsafe_mem(mem TSRMLS_CC); + zend_try { + phpdbg_force_interruption(TSRMLS_C); + } zend_end_try(); + phpdbg_clear_sigsafe_mem(TSRMLS_C); + break; + } + if (!(PHPDBG_G(flags) & PHPDBG_IS_INTERACTIVE)) { + PHPDBG_G(flags) |= PHPDBG_IS_SIGNALED; + } + break; +/* case '\n': + zend_llist_add_element(PHPDBG_G(stdin), strndup() + last_nl = PHPDBG_G(stdin_buf).len + i; + break; +*/ } + } + off += i; + } while (0); + + + fcntl(PHPDBG_G(io)[PHPDBG_STDIN].fd, F_SETFL, flags); } /* }}} */ void phpdbg_signal_handler(int sig, siginfo_t *info, void *context) /* {{{ */ @@ -864,6 +915,9 @@ void phpdbg_signal_handler(int sig, siginfo_t *info, void *context) /* {{{ */ switch (sig) { case SIGBUS: case SIGSEGV: + if (PHPDBG_G(sigsegv_bailout)) { + LONGJMP(*PHPDBG_G(sigsegv_bailout), FAILURE); + } is_handled = phpdbg_watchpoint_segfault_handler(info, context TSRMLS_CC); if (is_handled == FAILURE) { #ifdef ZEND_SIGNALS @@ -936,33 +990,26 @@ int main(int argc, char **argv) /* {{{ */ char bp_tmp_file[] = "/tmp/phpdbg.XXXXXX"; #endif -#ifndef _WIN32 char *address; - int listen[2]; - int server[2]; - int socket[2]; - FILE* streams[2] = {NULL, NULL}; -#endif + int listen = -1; + int server = -1; + int socket = -1; + FILE* stream = NULL; #ifdef ZTS void ***tsrm_ls; #endif #ifndef _WIN32 + struct sigaction sigio_struct; struct sigaction signal_struct; signal_struct.sa_sigaction = phpdbg_signal_handler; signal_struct.sa_flags = SA_SIGINFO | SA_NODEFER; + sigio_struct.sa_sigaction = phpdbg_sigio_handler; + sigio_struct.sa_flags = SA_SIGINFO; +#endif address = strdup("127.0.0.1"); - socket[0] = -1; - socket[1] = -1; - listen[0] = -1; - listen[1] = -1; - server[0] = -1; - server[1] = -1; - streams[0] = NULL; - streams[1] = NULL; -#endif #ifdef PHP_WIN32 _fmode = _O_BINARY; /* sets default for file streams to binary */ @@ -991,7 +1038,7 @@ phpdbg_main: } if (!bp_tmp_file) { - phpdbg_error("Unable to create temporary file"); + phpdbg_error("tmpfile", "", "Unable to create temporary file"); return 1; } #else @@ -1125,21 +1172,12 @@ phpdbg_main: show_banner = 0; break; -#ifndef _WIN32 - /* if you pass a listen port, we will accept input on listen port */ - /* and write output to listen port * 2 */ - - case 'l': { /* set listen ports */ - if (sscanf(php_optarg, "%d/%d", &listen[0], &listen[1]) != 2) { - if (sscanf(php_optarg, "%d", &listen[0]) != 1) { - /* default to hardcoded ports */ - listen[0] = 4000; - listen[1] = 8000; - } else { - listen[1] = (listen[0] * 2); - } + /* if you pass a listen port, we will read and write on listen port */ + case 'l': /* set listen ports */ + if (sscanf(php_optarg, "%d", &listen) != 1) { + listen = 8000; } - } break; + break; case 'a': { /* set bind address */ free(address); @@ -1147,7 +1185,10 @@ phpdbg_main: address = strdup("*"); } else address = strdup(php_optarg); } break; -#endif + + case 'x': + flags |= PHPDBG_WRITE_XML; + break; case 'V': { sapi_startup(phpdbg); @@ -1180,19 +1221,6 @@ phpdbg_main: php_optind++; } -#ifndef _WIN32 - /* setup remote server if necessary */ - if (!cleaning && - (listen[0] > 0 && listen[1] > 0)) { - if (phpdbg_open_sockets(address, listen, &server, &socket, streams) == FAILURE) { - remote = 0; - exit(0); - } - /* set remote flag to stop service shutting down upon quit */ - remote = 1; - } -#endif - if (sapi_name) { phpdbg->name = sapi_name; } @@ -1247,7 +1275,24 @@ phpdbg_main: EXCEPTION_POINTERS *xp; __try { #endif - zend_mm_heap *mm_heap = phpdbg_mm_get_heap(); + zend_mm_heap *mm_heap; + + /* setup remote server if necessary */ + if (!cleaning && listen > 0) { + server = phpdbg_open_socket(address, listen TSRMLS_CC); + if (-1 > server || phpdbg_remote_init(address, listen, server, &socket, &stream TSRMLS_CC) == FAILURE) { + exit(0); + } + +#ifndef _WIN32 + sigaction(SIGIO, &sigio_struct, NULL); +#endif + + /* set remote flag to stop service shutting down upon quit */ + remote = 1; + } + + mm_heap = phpdbg_mm_get_heap(); if (mm_heap->use_zend_alloc) { mm_heap->_malloc = phpdbg_malloc_wrapper; @@ -1258,6 +1303,8 @@ phpdbg_main: zend_activate(TSRMLS_C); + phpdbg_init_list(TSRMLS_C); + PHPDBG_G(original_free_function) = mm_heap->_free; mm_heap->_free = phpdbg_watch_efree; @@ -1277,10 +1324,17 @@ phpdbg_main: sigaction(SIGBUS, &signal_struct, &PHPDBG_G(old_sigsegv_signal)); #endif + PHPDBG_G(sapi_name_ptr) = sapi_name; + + php_output_activate(TSRMLS_C); + php_output_deactivate(TSRMLS_C); + + php_output_activate(TSRMLS_C); + if (php_request_startup(TSRMLS_C) == SUCCESS) { int i; - - SG(request_info).argc = argc - php_optind + 1; + + SG(request_info).argc = argc - php_optind + 1; SG(request_info).argv = emalloc(SG(request_info).argc * sizeof(char *)); for (i = SG(request_info).argc; --i;) { SG(request_info).argv[i] = estrdup(argv[php_optind - 1 + i]); @@ -1290,14 +1344,10 @@ phpdbg_main: php_hash_environment(TSRMLS_C); } - /* make sure to turn off buffer for ev command */ - php_output_activate(TSRMLS_C); - php_output_deactivate(TSRMLS_C); - /* do not install sigint handlers for remote consoles */ /* sending SIGINT then provides a decent way of shutting down the server */ #ifndef _WIN32 - if (listen[0] < 0) { + if (listen < 0) { #endif #if defined(ZEND_SIGNALS) && !defined(_WIN32) zend_try { zend_signal(SIGINT, phpdbg_sigint_handler TSRMLS_CC); } zend_end_try(); @@ -1313,18 +1363,44 @@ phpdbg_main: /* set flags from command line */ PHPDBG_G(flags) = flags; -#ifndef _WIN32 /* setup io here */ - if (streams[0] && streams[1]) { + if (remote) { PHPDBG_G(flags) |= PHPDBG_IS_REMOTE; - +#ifndef _WIN32 signal(SIGPIPE, SIG_IGN); +#endif + } + +#ifndef _WIN32 + PHPDBG_G(io)[PHPDBG_STDIN].ptr = stdin; + PHPDBG_G(io)[PHPDBG_STDIN].fd = fileno(stdin); + PHPDBG_G(io)[PHPDBG_STDOUT].ptr = stdout; + PHPDBG_G(io)[PHPDBG_STDOUT].fd = fileno(stdout); +#else + /* XXX this is a complete mess here with FILE/fd/SOCKET, + we should let only one to survive probably. Need + a clean separation whether it's a remote or local + prompt. And what is supposed to go as user interaction, + error log, etc. */ + if (remote) { + PHPDBG_G(io)[PHPDBG_STDIN].ptr = stdin; + PHPDBG_G(io)[PHPDBG_STDIN].fd = socket; + PHPDBG_G(io)[PHPDBG_STDOUT].ptr = stdout; + PHPDBG_G(io)[PHPDBG_STDOUT].fd = socket; + } else { + PHPDBG_G(io)[PHPDBG_STDIN].ptr = stdin; + PHPDBG_G(io)[PHPDBG_STDIN].fd = fileno(stdin); + PHPDBG_G(io)[PHPDBG_STDOUT].ptr = stdout; + PHPDBG_G(io)[PHPDBG_STDOUT].fd = fileno(stdout); } #endif + PHPDBG_G(io)[PHPDBG_STDERR].ptr = stderr; + PHPDBG_G(io)[PHPDBG_STDERR].fd = fileno(stderr); - PHPDBG_G(io)[PHPDBG_STDIN] = stdin; - PHPDBG_G(io)[PHPDBG_STDOUT] = stdout; - PHPDBG_G(io)[PHPDBG_STDERR] = stderr; +#ifndef _WIN32 + PHPDBG_G(php_stdiop_write) = php_stream_stdio_ops.write; + php_stream_stdio_ops.write = phpdbg_stdiop_write; +#endif if (exec) { /* set execution context */ PHPDBG_G(exec) = phpdbg_resolve_path(exec TSRMLS_CC); @@ -1336,8 +1412,7 @@ phpdbg_main: if (oplog_file) { /* open oplog */ PHPDBG_G(oplog) = fopen(oplog_file, "w+"); if (!PHPDBG_G(oplog)) { - phpdbg_error( - "Failed to open oplog %s", oplog_file); + phpdbg_error("oplog", "path=\"%s\"", "Failed to open oplog %s", oplog_file); } free(oplog_file); } @@ -1348,7 +1423,7 @@ phpdbg_main: phpdbg_set_color_ex(PHPDBG_COLOR_NOTICE, PHPDBG_STRL("green") TSRMLS_CC); /* set default prompt */ - phpdbg_set_prompt(PROMPT TSRMLS_CC); + phpdbg_set_prompt(PHPDBG_DEFAULT_PROMPT TSRMLS_CC); /* Make stdin, stdout and stderr accessible from PHP scripts */ phpdbg_register_file_handles(TSRMLS_C); @@ -1390,14 +1465,11 @@ phpdbg_main: } } -/* #ifndef for making compiler shutting up */ -#ifndef _WIN32 phpdbg_interact: -#endif /* phpdbg main() */ do { zend_try { - phpdbg_interactive(TSRMLS_C); + phpdbg_interactive(1 TSRMLS_CC); } zend_catch { if ((PHPDBG_G(flags) & PHPDBG_IS_CLEANING)) { FILE *bp_tmp_fp = fopen(bp_tmp_file, "w"); @@ -1408,18 +1480,16 @@ phpdbg_interact: cleaning = 0; } -#ifndef _WIN32 if (!cleaning) { /* remote client disconnected */ if ((PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED)) { if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) { /* renegociate connections */ - phpdbg_open_sockets( - address, listen, &server, &socket, streams); + phpdbg_remote_init(address, listen, server, &socket, &stream TSRMLS_CC); /* set streams */ - if (streams[0] && streams[1]) { + if (stream) { PHPDBG_G(flags) &= ~PHPDBG_IS_QUITTING; } @@ -1431,7 +1501,6 @@ phpdbg_interact: } } } -#endif } zend_end_try(); } while(!cleaning && !(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)); @@ -1441,21 +1510,19 @@ phpdbg_interact: /* this is just helpful */ PG(report_memleaks) = 0; -#ifndef _WIN32 phpdbg_out: if ((PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED)) { PHPDBG_G(flags) &= ~PHPDBG_IS_DISCONNECTED; goto phpdbg_interact; } -#endif #ifdef _WIN32 } __except(phpdbg_exception_handler_win32(xp = GetExceptionInformation())) { - phpdbg_error("Access violation (Segementation fault) encountered\ntrying to abort cleanly..."); + phpdbg_error("segfault", "", "Access violation (Segementation fault) encountered\ntrying to abort cleanly..."); } -phpdbg_out: +/* phpdbg_out: */ #endif - + { int i; /* free argv */ @@ -1468,8 +1535,7 @@ phpdbg_out: #ifndef ZTS /* force cleanup of auto and core globals */ zend_hash_clean(CG(auto_globals)); - memset( - &core_globals, 0, sizeof(php_core_globals)); + memset( &core_globals, 0, sizeof(php_core_globals)); #endif if (ini_entries) { free(ini_entries); @@ -1478,15 +1544,17 @@ phpdbg_out: if (ini_override) { free(ini_override); } - + /* this must be forced */ CG(unclean_shutdown) = 0; - + /* this is just helpful */ PG(report_memleaks) = 0; php_request_shutdown((void*)0); + php_output_deactivate(TSRMLS_C); + zend_try { php_module_shutdown(TSRMLS_C); } zend_end_try(); @@ -1498,7 +1566,7 @@ phpdbg_out: if (cleaning || remote) { goto phpdbg_main; } - + #ifdef ZTS /* bugggy */ /* tsrm_shutdown(); */ @@ -1510,10 +1578,10 @@ phpdbg_out: } #endif - if (sapi_name) { - free(sapi_name); + if (PHPDBG_G(sapi_name_ptr)) { + free(PHPDBG_G(sapi_name_ptr)); } - + #ifdef _WIN32 free(bp_tmp_file); #else diff --git a/phpdbg.h b/phpdbg.h index eb4faf1f942..8c0dbb4afa0 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -29,6 +29,8 @@ # define PHPDBG_API #endif +#include +#include #include "php.h" #include "php_globals.h" #include "php_variables.h" @@ -40,20 +42,21 @@ #include "zend_ini_scanner.h" #include "zend_stream.h" #ifndef _WIN32 -# include "zend_signal.h" +# include "zend_signal.h" #endif #include "SAPI.h" #include #include #if defined(_WIN32) && !defined(__MINGW32__) -# include -# include "config.w32.h" -# undef strcasecmp -# undef strncasecmp -# define strcasecmp _stricmp -# define strncasecmp _strnicmp +# include +# include "config.w32.h" +# include "win32/php_stdint.h" +# undef strcasecmp +# undef strncasecmp +# define strcasecmp _stricmp +# define strncasecmp _strnicmp #else -# include "php_config.h" +# include "php_config.h" #endif #ifndef O_BINARY # define O_BINARY 0 @@ -64,21 +67,41 @@ # include "TSRM.h" #endif -#ifdef LIBREADLINE -# include -# include +#ifdef HAVE_LIBREADLINE +# include +# include #endif #ifdef HAVE_LIBEDIT -# include +# include #endif -#include "phpdbg_lexer.h" -#include "phpdbg_cmd.h" -#include "phpdbg_utils.h" -#include "phpdbg_btree.h" -#include "phpdbg_watch.h" +/* {{{ remote console headers */ +#ifndef _WIN32 +# include +# include +# include +# include +# include +#endif /* }}} */ -int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC); +/* {{{ strings */ +#define PHPDBG_NAME "phpdbg" +#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.4.0" +#define PHPDBG_INIT_FILENAME ".phpdbginit" +#define PHPDBG_DEFAULT_PROMPT "prompt>" +/* }}} */ + +/* Hey, apple. One shouldn't define *functions* from the standard C library as marcos. */ +#ifdef memcpy +#define memcpy_tmp(...) memcpy(__VA_ARGS__) +#undef memcpy +#define memcpy(...) memcpy_tmp(__VA_ARGS__) +#endif + +#if !defined(PHPDBG_WEBDATA_TRANSFER_H) && !defined(PHPDBG_WEBHELPER_H) #ifdef ZTS # define PHPDBG_G(v) TSRMG(phpdbg_globals_id, zend_phpdbg_globals *, v) @@ -86,6 +109,19 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC); # define PHPDBG_G(v) (phpdbg_globals.v) #endif +#include "phpdbg_sigsafe.h" +#include "phpdbg_out.h" +#include "phpdbg_lexer.h" +#include "phpdbg_cmd.h" +#include "phpdbg_utils.h" +#include "phpdbg_btree.h" +#include "phpdbg_watch.h" +#ifdef PHP_WIN32 +# include "phpdbg_sigio_win32.h" +#endif + +int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC); + #define PHPDBG_NEXT 2 #define PHPDBG_UNTIL 3 #define PHPDBG_FINISH 4 @@ -145,11 +181,14 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC); #define PHPDBG_IS_BP_ENABLED (1<<26) #define PHPDBG_IS_REMOTE (1<<27) #define PHPDBG_IS_DISCONNECTED (1<<28) +#define PHPDBG_WRITE_XML (1<<29) -#define PHPDBG_SHOW_REFCOUNTS (1<<29) +#define PHPDBG_SHOW_REFCOUNTS (1<<30) + +#define PHPDBG_IN_SIGNAL_HANDLER (1<<30) #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_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) #ifndef _WIN32 @@ -158,21 +197,27 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC); # define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_BP_ENABLED) #endif /* }}} */ -/* {{{ strings */ -#define PHPDBG_NAME "phpdbg" -#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.4.0" -#define PHPDBG_INIT_FILENAME ".phpdbginit" -/* }}} */ - /* {{{ output descriptors */ #define PHPDBG_STDIN 0 #define PHPDBG_STDOUT 1 #define PHPDBG_STDERR 2 #define PHPDBG_IO_FDS 3 /* }}} */ +#define phpdbg_try_access \ + { \ + JMP_BUF *__orig_bailout = PHPDBG_G(sigsegv_bailout); \ + JMP_BUF __bailout; \ + \ + PHPDBG_G(sigsegv_bailout) = &__bailout; \ + if (SETJMP(__bailout) == 0) { +#define phpdbg_catch_access \ + } else { \ + PHPDBG_G(sigsegv_bailout) = __orig_bailout; +#define phpdbg_end_try_access() \ + } \ + PHPDBG_G(sigsegv_bailout) = __orig_bailout; \ + } + /* {{{ structs */ ZEND_BEGIN_MODULE_GLOBALS(phpdbg) @@ -202,29 +247,52 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg) int bp_count; /* breakpoint count */ int vmret; /* return from last opcode handler execution */ + zend_op_array *(*compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC); + HashTable file_sources; + FILE *oplog; /* opline log */ - FILE *io[PHPDBG_IO_FDS]; /* io */ + struct { + FILE *ptr; + int fd; + } io[PHPDBG_IO_FDS]; /* io */ + size_t (*php_stdiop_write)(php_stream *, const char *, size_t TSRMLS_DC); + int in_script_xml; /* in output mode */ + struct { + zend_bool active; + int type; + int fd; + char *tag; + char *msg; + int msglen; + char *xml; + int xmllen; + } err_buf; /* error buffer */ + zend_ulong req_id; /* "request id" to keep track of commands */ char *prompt[2]; /* prompt */ const phpdbg_color_t *colors[PHPDBG_COLORS]; /* colors */ char *buffer; /* buffer */ + zend_bool last_was_newline; /* check if we don't need to output a newline upon next phpdbg_error or phpdbg_notice */ + + char input_buffer[PHPDBG_MAX_CMD]; /* stdin input buffer */ + int input_buflen; /* length of stdin input buffer */ + phpdbg_signal_safe_mem sigsafe_mem; /* memory to use in async safe environment (only once!) */ + + JMP_BUF *sigsegv_bailout; /* bailout address for accesibility probing */ zend_ulong flags; /* phpdbg flags */ + + char *socket_path; /* phpdbg.path ini setting */ + char *sapi_name_ptr; /* store sapi name to free it if necessary to not leak memory */ + int socket_fd; /* file descriptor to socket (wait command) (-1 if unused) */ + int socket_server_fd; /* file descriptor to master socket (wait command) (-1 if unused) */ +#ifdef PHP_WIN32 + HANDLE sigio_watcher_thread; /* sigio watcher thread handle */ + struct win32_sigio_watcher_data swd; +#endif + int8_t eol; ZEND_END_MODULE_GLOBALS(phpdbg) /* }}} */ -/* the beginning (= the important part) of the _zend_mm_heap struct defined in Zend/zend_alloc.c - Needed for realizing watchpoints */ -struct _zend_mm_heap { - int use_zend_alloc; - void *(*_malloc)(size_t); - void (*_free)(void *); - void *(*_realloc)(void *, size_t); - size_t free_bitmap; - size_t large_free_bitmap; - size_t block_size; - size_t compact_size; - zend_mm_segment *segments_list; - zend_mm_storage *storage; -}; +#endif #endif /* PHPDBG_H */ diff --git a/phpdbg_bp.c b/phpdbg_bp.c index a18316a2285..81674a0daf1 100644 --- a/phpdbg_bp.c +++ b/phpdbg_bp.c @@ -43,8 +43,7 @@ static inline phpdbg_breakbase_t *phpdbg_find_conditional_breakpoint(zend_execut */ static inline void _phpdbg_break_mapping(int id, HashTable *table TSRMLS_DC) { - zend_hash_index_update( - &PHPDBG_G(bp)[PHPDBG_BREAK_MAP], (id), (void**) &table, sizeof(void*), NULL); + zend_hash_index_update(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], (id), (void**) &table, sizeof(void*), NULL); } #define PHPDBG_BREAK_MAPPING(id, table) _phpdbg_break_mapping(id, table TSRMLS_CC) @@ -97,8 +96,8 @@ PHPDBG_API void phpdbg_reset_breakpoints(TSRMLS_D) /* {{{ */ HashTable **table = NULL; for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], &position[0]); - zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], (void**)&table, &position[0]) == SUCCESS; - zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], &position[0])) { + zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], (void **) &table, &position[0]) == SUCCESS; + zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], &position[0])) { phpdbg_breakbase_t *brake; for (zend_hash_internal_pointer_reset_ex((*table), &position[1]); @@ -117,13 +116,11 @@ PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */ zend_ulong id = 0L; if (zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP])) { - phpdbg_notice( - "Exporting %d breakpoints", - zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP])); + phpdbg_notice("exportbreakpoint", "count=\"%d\"", "Exporting %d breakpoints", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP])); /* this only looks like magic, it isn't */ for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], &position[0]); - zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], (void**)&table, &position[0]) == SUCCESS; - zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], &position[0])) { + zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], (void **) &table, &position[0]) == SUCCESS; + zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], &position[0])) { phpdbg_breakbase_t *brake; zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], NULL, NULL, &id, 0, &position[0]); @@ -223,18 +220,18 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRML { php_stream_statbuf ssb; char realpath[MAXPATHLEN]; - + if (php_stream_stat_path(path, &ssb) != FAILURE) { if (ssb.sb.st_mode & (S_IFREG|S_IFLNK)) { HashTable *broken; phpdbg_breakfile_t new_break; size_t path_len = 0L; - + if (VCWD_REALPATH(path, realpath)) { path = realpath; } path_len = strlen(path); - + if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], path, path_len, (void**)&broken) == FAILURE) { HashTable breaks; @@ -253,22 +250,21 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRML new_break.filename = estrndup(path, path_len); new_break.line = line_num; - zend_hash_index_update( - broken, line_num, (void**)&new_break, sizeof(phpdbg_breakfile_t), NULL); + zend_hash_index_update( broken, line_num, (void**)&new_break, sizeof(phpdbg_breakfile_t), NULL); - phpdbg_notice("Breakpoint #%d added at %s:%ld", + phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" file=\"%s\" line=\"%ld\"", "Breakpoint #%d added at %s:%ld", new_break.id, new_break.filename, new_break.line); PHPDBG_BREAK_MAPPING(new_break.id, broken); } else { - phpdbg_error("Breakpoint at %s:%ld exists", path, line_num); + phpdbg_error("breakpoint", "type=\"exists\" add=\"fail\" file=\"%s\" line=\"%ld\"", "Breakpoint at %s:%ld exists", path, line_num); } } else { - phpdbg_error("Cannot set breakpoint in %s, it is not a regular file", path); + phpdbg_error("breakpoint", "type=\"notregular\" add=\"fail\" file=\"%s\"", "Cannot set breakpoint in %s, it is not a regular file", path); } } else { - phpdbg_error("Cannot stat %s, it does not exist", path); + phpdbg_error("breakpoint", "type=\"nofile\" add=\"fail\" file=\"%s\"", "Cannot stat %s, it does not exist", path); } } /* }}} */ @@ -285,12 +281,12 @@ PHPDBG_API void phpdbg_set_breakpoint_symbol(const char *name, size_t name_len T zend_hash_update(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], new_break.symbol, name_len, &new_break, sizeof(phpdbg_breaksymbol_t), NULL); - phpdbg_notice("Breakpoint #%d added at %s", + phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" function=\"%s\"", "Breakpoint #%d added at %s", new_break.id, new_break.symbol); PHPDBG_BREAK_MAPPING(new_break.id, &PHPDBG_G(bp)[PHPDBG_BREAK_SYM]); } else { - phpdbg_notice("Breakpoint exists at %s", name); + phpdbg_error("breakpoint", "type=\"exists\" add=\"fail\" function=\"%s\"", "Breakpoint exists at %s", name); } } /* }}} */ @@ -324,12 +320,12 @@ PHPDBG_API void phpdbg_set_breakpoint_method(const char *class_name, const char zend_hash_update(class_table, lcname, func_len, &new_break, sizeof(phpdbg_breakmethod_t), NULL); - phpdbg_notice("Breakpoint #%d added at %s::%s", + phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" method=\"%s::%s\"", "Breakpoint #%d added at %s::%s", new_break.id, class_name, func_name); PHPDBG_BREAK_MAPPING(new_break.id, class_table); } else { - phpdbg_notice("Breakpoint exists at %s::%s", class_name, func_name); + phpdbg_error("breakpoint", "type=\"exists\" add=\"fail\" method=\"%s::%s\"", "Breakpoint exists at %s::%s", class_name, func_name); } efree(lcname); @@ -350,11 +346,11 @@ PHPDBG_API void phpdbg_set_breakpoint_opline(zend_ulong opline TSRMLS_DC) /* {{{ zend_hash_index_update(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], opline, &new_break, sizeof(phpdbg_breakline_t), NULL); - phpdbg_notice("Breakpoint #%d added at %#lx", + phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" opline=\"%#lx\"", "Breakpoint #%d added at %#lx", new_break.id, new_break.opline); PHPDBG_BREAK_MAPPING(new_break.id, &PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]); } else { - phpdbg_notice("Breakpoint exists at %#lx", opline); + phpdbg_error("breakpoint", "type=\"exists\" add=\"fail\" opline=\"%#lx\"", "Breakpoint exists at %#lx", opline); } } /* }}} */ @@ -363,11 +359,11 @@ PHPDBG_API int phpdbg_resolve_op_array_break(phpdbg_breakopline_t *brake, zend_o phpdbg_breakline_t opline_break; if (op_array->last <= brake->opline_num) { if (brake->class_name == NULL) { - phpdbg_error("There are only %d oplines in function %s (breaking at opline %ld impossible)", op_array->last, brake->func_name, brake->opline_num); + phpdbg_error("breakpoint", "type=\"maxoplines\" add=\"fail\" maxoplinenum=\"%d\" function=\"%s\" usedoplinenum=\"%ld\"", "There are only %d oplines in function %s (breaking at opline %ld impossible)", op_array->last, brake->func_name, brake->opline_num); } else if (brake->func_name == NULL) { - phpdbg_error("There are only %d oplines in file %s (breaking at opline %ld impossible)", op_array->last, brake->class_name, brake->opline_num); + phpdbg_error("breakpoint", "type=\"maxoplines\" add=\"fail\" maxoplinenum=\"%d\" file=\"%s\" usedoplinenum=\"%ld\"", "There are only %d oplines in file %s (breaking at opline %ld impossible)", op_array->last, brake->class_name, brake->opline_num); } else { - phpdbg_error("There are only %d oplines in method %s::%s (breaking at opline %ld impossible)", op_array->last, brake->class_name, brake->func_name, brake->opline_num); + phpdbg_error("breakpoint", "type=\"maxoplines\" add=\"fail\" maxoplinenum=\"%d\" method=\"%s::%s\" usedoplinenum=\"%ld\"", "There are only %d oplines in method %s::%s (breaking at opline %ld impossible)", op_array->last, brake->class_name, brake->func_name, brake->opline_num); } return FAILURE; @@ -423,7 +419,7 @@ PHPDBG_API void phpdbg_resolve_op_array_breaks(zend_op_array *op_array TSRMLS_DC zend_hash_internal_pointer_end(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]); zend_hash_get_current_data(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], (void **)&opline_break); - phpdbg_notice("Breakpoint #%d resolved at %s%s%s#%ld (opline %#lx)", + phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" symbol=\"%s\" num=\"%ld\" opline=\"%#lx\"", "Breakpoint #%d resolved at %s%s%s#%ld (opline %#lx)", brake->id, brake->class_name?brake->class_name:"", brake->class_name&&brake->func_name?"::":"", @@ -474,7 +470,7 @@ PHPDBG_API int phpdbg_resolve_opline_break(phpdbg_breakopline_t *new_break TSRML if (zend_hash_find(func_table, zend_str_tolower_dup(new_break->func_name, new_break->func_len), new_break->func_len + 1, (void **)&func) == FAILURE) { if (new_break->class_name != NULL && new_break->func_name != NULL) { - phpdbg_error("Method %s doesn't exist in class %s", new_break->func_name, new_break->class_name); + phpdbg_error("breakpoint", "type=\"nomethod\" method=\"%s::%s\"", "Method %s doesn't exist in class %s", new_break->func_name, new_break->class_name); return 2; } return FAILURE; @@ -482,9 +478,9 @@ PHPDBG_API int phpdbg_resolve_opline_break(phpdbg_breakopline_t *new_break TSRML if (func->type != ZEND_USER_FUNCTION) { if (new_break->class_name == NULL) { - phpdbg_error("%s is not an user defined function, no oplines exist", new_break->func_name); + phpdbg_error("breakpoint", "type=\"internalfunction\" function=\"%s\"", "%s is not an user defined function, no oplines exist", new_break->func_name); } else { - phpdbg_error("%s::%s is not an user defined method, no oplines exist", new_break->class_name, new_break->func_name); + phpdbg_error("breakpoint", "type=\"internalfunction\" method=\"%s::%s\"", "%s::%s is not an user defined method, no oplines exist", new_break->class_name, new_break->func_name); } return 2; } @@ -512,11 +508,11 @@ PHPDBG_API void phpdbg_set_breakpoint_method_opline(const char *class, const cha switch (phpdbg_resolve_opline_break(&new_break TSRMLS_CC)) { case FAILURE: - phpdbg_notice("Pending breakpoint #%d at %s::%s#%ld", new_break.id, new_break.class_name, new_break.func_name, opline); + phpdbg_notice("breakpoint", "pending=\"pending\" id=\"%d\" method=\"%::%s\" num=\"%ld\"", "Pending breakpoint #%d at %s::%s#%ld", new_break.id, new_break.class_name, new_break.func_name, opline); break; case SUCCESS: - phpdbg_notice("Breakpoint #%d added at %s::%s#%ld", new_break.id, new_break.class_name, new_break.func_name, opline); + phpdbg_notice("breakpoint", "id=\"%d\" method=\"%::%s\" num=\"%ld\"", "Breakpoint #%d added at %s::%s#%ld", new_break.id, new_break.class_name, new_break.func_name, opline); break; case 2: @@ -542,7 +538,7 @@ PHPDBG_API void phpdbg_set_breakpoint_method_opline(const char *class, const cha } if (zend_hash_index_exists(method_table, opline)) { - phpdbg_notice("Breakpoint already exists for %s::%s#%ld", new_break.class_name, new_break.func_name, opline); + phpdbg_error("breakpoint", "type=\"exists\" method=\"%s\" num=\"%ld\"", "Breakpoint already exists for %s::%s#%ld", new_break.class_name, new_break.func_name, opline); efree((char*)new_break.func_name); efree((char*)new_break.class_name); PHPDBG_G(bp_count)--; @@ -571,11 +567,11 @@ PHPDBG_API void phpdbg_set_breakpoint_function_opline(const char *function, zend switch (phpdbg_resolve_opline_break(&new_break TSRMLS_CC)) { case FAILURE: - phpdbg_notice("Pending breakpoint #%d at %s#%ld", new_break.id, new_break.func_name, opline); + phpdbg_notice("breakpoint", "pending=\"pending\" id=\"%d\" function=\"%s\" num=\"%ld\"", "Pending breakpoint #%d at %s#%ld", new_break.id, new_break.func_name, opline); break; case SUCCESS: - phpdbg_notice("Breakpoint #%d added at %s#%ld", new_break.id, new_break.func_name, opline); + phpdbg_notice("breakpoint", "id=\"%d\" function=\"%s\" num=\"%ld\"", "Breakpoint #%d added at %s#%ld", new_break.id, new_break.func_name, opline); break; case 2: @@ -592,7 +588,7 @@ PHPDBG_API void phpdbg_set_breakpoint_function_opline(const char *function, zend } if (zend_hash_index_exists(func_table, opline)) { - phpdbg_notice("Breakpoint already exists for %s#%ld", new_break.func_name, opline); + phpdbg_error("breakpoint", "type=\"exists\" function=\"%s\" num=\"%ld\"", "Breakpoint already exists for %s#%ld", new_break.func_name, opline); efree((char*)new_break.func_name); PHPDBG_G(bp_count)--; return; @@ -620,11 +616,11 @@ PHPDBG_API void phpdbg_set_breakpoint_file_opline(const char *file, zend_ulong o switch (phpdbg_resolve_opline_break(&new_break TSRMLS_CC)) { case FAILURE: - phpdbg_notice("Pending breakpoint #%d at %s:%ld", new_break.id, new_break.class_name, opline); + phpdbg_notice("breakpoint", "pending=\"pending\" id=\"%d\" file=\"%s\" num=\"%ld\"", "Pending breakpoint #%d at %s:%ld", new_break.id, new_break.class_name, opline); break; case SUCCESS: - phpdbg_notice("Breakpoint #%d added at %s:%ld", new_break.id, new_break.class_name, opline); + phpdbg_notice("breakpoint", "id=\"%d\" file=\"%s\" num=\"%ld\"", "Breakpoint #%d added at %s:%ld", new_break.id, new_break.class_name, opline); break; case 2: @@ -641,7 +637,7 @@ PHPDBG_API void phpdbg_set_breakpoint_file_opline(const char *file, zend_ulong o } if (zend_hash_index_exists(file_table, opline)) { - phpdbg_notice("Breakpoint already exists for %s:%ld", new_break.class_name, opline); + phpdbg_error("breakpoint", "type=\"exists\" file=\"%s\" num=\"%d\"", "Breakpoint already exists for %s:%ld", new_break.class_name, opline); efree((char*)new_break.class_name); PHPDBG_G(bp_count)--; return; @@ -660,8 +656,7 @@ PHPDBG_API void phpdbg_set_breakpoint_opcode(const char *name, size_t name_len T zend_ulong hash = zend_hash_func(name, name_len); if (zend_hash_index_exists(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], hash)) { - phpdbg_notice( - "Breakpoint exists for %s", name); + phpdbg_error("breakpoint", "type=\"exists\" opcode=\"%s\"", "Breakpoint exists for %s", name); return; } @@ -674,7 +669,7 @@ PHPDBG_API void phpdbg_set_breakpoint_opcode(const char *name, size_t name_len T PHPDBG_G(flags) |= PHPDBG_HAS_OPCODE_BP; - phpdbg_notice("Breakpoint #%d added at %s", new_break.id, name); + phpdbg_notice("breakpoint", "id=\"%d\" opcode=\"%s\"", "Breakpoint #%d added at %s", new_break.id, name); PHPDBG_BREAK_MAPPING(new_break.id, &PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE]); } /* }}} */ @@ -691,9 +686,10 @@ PHPDBG_API void phpdbg_set_breakpoint_opline_ex(phpdbg_opline_ptr_t opline TSRML zend_hash_index_update(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], (zend_ulong) opline, &new_break, sizeof(phpdbg_breakline_t), NULL); - phpdbg_notice("Breakpoint #%d added at %#lx", - new_break.id, new_break.opline); + phpdbg_notice("breakpoint", "id=\"%d\" opline=\"%#lx\"", "Breakpoint #%d added at %#lx", new_break.id, new_break.opline); PHPDBG_BREAK_MAPPING(new_break.id, &PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]); + } else { + phpdbg_error("breakpoint", "type=\"exists\" opline=\"%#lx\"", "Breakpoint exists for opline %#lx", (zend_ulong) opline); } } /* }}} */ @@ -729,8 +725,7 @@ static inline void phpdbg_create_conditional_break(phpdbg_breakcond_t *brake, co Z_STRVAL(pv)[Z_STRLEN(pv)] = '\0'; Z_TYPE(pv) = IS_STRING; - new_break.ops = zend_compile_string( - &pv, "Conditional Breakpoint Code" TSRMLS_CC); + new_break.ops = zend_compile_string(&pv, "Conditional Breakpoint Code" TSRMLS_CC); zval_dtor(&pv); @@ -739,14 +734,12 @@ static inline void phpdbg_create_conditional_break(phpdbg_breakcond_t *brake, co &PHPDBG_G(bp)[PHPDBG_BREAK_COND], hash, &new_break, sizeof(phpdbg_breakcond_t), (void**)&brake); - phpdbg_notice("Conditional breakpoint #%d added %s/%p", - brake->id, brake->code, brake->ops); + phpdbg_notice("breakpoint", "id=\"%d\" expression=\"%s\" ptr=\"%p\"", "Conditional breakpoint #%d added %s/%p", brake->id, brake->code, brake->ops); PHPDBG_G(flags) |= PHPDBG_HAS_COND_BP; PHPDBG_BREAK_MAPPING(new_break.id, &PHPDBG_G(bp)[PHPDBG_BREAK_COND]); } else { - phpdbg_error( - "Failed to compile code for expression %s", expr); + phpdbg_error("compile", "expression=\"%s\"", "Failed to compile code for expression %s", expr); efree((char*)new_break.code); PHPDBG_G(bp_count)--; } @@ -762,7 +755,7 @@ PHPDBG_API void phpdbg_set_breakpoint_expression(const char *expr, size_t expr_l phpdbg_create_conditional_break( &new_break, NULL, expr, expr_len, expr_hash TSRMLS_CC); } else { - phpdbg_notice("Conditional break %s exists", expr); + phpdbg_error("breakpoint", "type=\"exists\" expression=\"%s\"", "Conditional break %s exists", expr); } } /* }}} */ @@ -771,21 +764,18 @@ PHPDBG_API void phpdbg_set_breakpoint_at(const phpdbg_param_t *param TSRMLS_DC) phpdbg_breakcond_t new_break; phpdbg_param_t *condition; zend_ulong hash = 0L; - + if (param->next) { condition = param->next; hash = zend_inline_hash_func(condition->str, condition->len); - + if (!zend_hash_index_exists(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], hash)) { - phpdbg_create_conditional_break( - &new_break, param, - condition->str, condition->len, hash TSRMLS_CC); + phpdbg_create_conditional_break(&new_break, param, condition->str, condition->len, hash TSRMLS_CC); } else { - phpdbg_notice( - "Conditional break %s exists at the specified location", condition->str); - } + phpdbg_notice("breakpoint", "type=\"exists\" arg=\"%s\"", "Conditional break %s exists at the specified location", condition->str); + } } - + } /* }}} */ static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_file(zend_op_array *op_array TSRMLS_DC) /* {{{ */ @@ -970,7 +960,6 @@ static inline phpdbg_breakbase_t *phpdbg_find_conditional_breakpoint(zend_execut zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], (void*)&bp, &position) == SUCCESS; zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], &position)) { zval *retval = NULL; - int orig_interactive = CG(interactive); zval **orig_retval = EG(return_value_ptr_ptr); zend_op_array *orig_ops = EG(active_op_array); zend_op **orig_opline = EG(opline_ptr); @@ -995,8 +984,6 @@ static inline phpdbg_breakbase_t *phpdbg_find_conditional_breakpoint(zend_execut zend_rebuild_symbol_table(TSRMLS_C); } - CG(interactive) = 0; - zend_try { PHPDBG_G(flags) |= PHPDBG_IN_COND_BP; zend_execute(EG(active_op_array) TSRMLS_CC); @@ -1008,8 +995,6 @@ static inline phpdbg_breakbase_t *phpdbg_find_conditional_breakpoint(zend_execut breakpoint = SUCCESS; } } zend_catch { - CG(interactive) = orig_interactive; - EG(no_extensions)=1; EG(return_value_ptr_ptr) = orig_retval; EG(active_op_array) = orig_ops; @@ -1017,8 +1002,6 @@ static inline phpdbg_breakbase_t *phpdbg_find_conditional_breakpoint(zend_execut PHPDBG_G(flags) &= ~PHPDBG_IN_COND_BP; } zend_end_try(); - CG(interactive) = orig_interactive; - EG(no_extensions)=1; EG(return_value_ptr_ptr) = orig_retval; EG(active_op_array) = orig_ops; @@ -1148,10 +1131,10 @@ PHPDBG_API void phpdbg_delete_breakpoint(zend_ulong num TSRMLS_DC) /* {{{ */ break; } - phpdbg_notice("Deleted breakpoint #%ld", num); + phpdbg_notice("breakpoint", "deleted=\"success\" id=\"%ld\"", "Deleted breakpoint #%ld", num); PHPDBG_BREAK_UNMAPPING(num); } else { - phpdbg_error("Failed to find breakpoint #%ld", num); + phpdbg_error("breakpoint", "type=\"nobreakpoint\" deleted=\"fail\" id=\"%ld\"", "Failed to find breakpoint #%ld", num); } } /* }}} */ @@ -1189,7 +1172,7 @@ PHPDBG_API void phpdbg_print_breakpoint(phpdbg_breakbase_t *brake TSRMLS_DC) /* switch (brake->type) { case PHPDBG_BREAK_FILE: { - phpdbg_notice("Breakpoint #%d at %s:%ld, hits: %lu", + phpdbg_notice("breakpoint", "id=\"%d\" file=\"%s\" line=\"%ld\" hits=\"%lu\"", "Breakpoint #%d at %s:%ld, hits: %lu", ((phpdbg_breakfile_t*)brake)->id, ((phpdbg_breakfile_t*)brake)->filename, ((phpdbg_breakfile_t*)brake)->line, @@ -1197,7 +1180,7 @@ PHPDBG_API void phpdbg_print_breakpoint(phpdbg_breakbase_t *brake TSRMLS_DC) /* } break; case PHPDBG_BREAK_SYM: { - phpdbg_notice("Breakpoint #%d in %s() at %s:%u, hits: %lu", + phpdbg_notice("breakpoint", "id=\"%d\" function=\"%s\" file=\"%s\" line=\"%ld\" hits=\"%lu\"", "Breakpoint #%d in %s() at %s:%u, hits: %lu", ((phpdbg_breaksymbol_t*)brake)->id, ((phpdbg_breaksymbol_t*)brake)->symbol, zend_get_executed_filename(TSRMLS_C), @@ -1206,7 +1189,7 @@ PHPDBG_API void phpdbg_print_breakpoint(phpdbg_breakbase_t *brake TSRMLS_DC) /* } break; case PHPDBG_BREAK_OPLINE: { - phpdbg_notice("Breakpoint #%d in %#lx at %s:%u, hits: %lu", + phpdbg_notice("breakpoint", "id=\"%d\" opline=\"%#lx\" file=\"%s\" line=\"%ld\" hits=\"%lu\"", "Breakpoint #%d in %#lx at %s:%u, hits: %lu", ((phpdbg_breakline_t*)brake)->id, ((phpdbg_breakline_t*)brake)->opline, zend_get_executed_filename(TSRMLS_C), @@ -1215,7 +1198,7 @@ PHPDBG_API void phpdbg_print_breakpoint(phpdbg_breakbase_t *brake TSRMLS_DC) /* } break; case PHPDBG_BREAK_METHOD_OPLINE: { - phpdbg_notice("Breakpoint #%d in %s::%s()#%lu at %s:%u, hits: %lu", + phpdbg_notice("breakpoint", "id=\"%d\" method=\"%s::%s\" num=\"%lu\" file=\"%s\" line=\"%ld\" hits=\"%lu\"", "Breakpoint #%d in %s::%s()#%lu at %s:%u, hits: %lu", ((phpdbg_breakopline_t*)brake)->id, ((phpdbg_breakopline_t*)brake)->class_name, ((phpdbg_breakopline_t*)brake)->func_name, @@ -1226,7 +1209,7 @@ PHPDBG_API void phpdbg_print_breakpoint(phpdbg_breakbase_t *brake TSRMLS_DC) /* } break; case PHPDBG_BREAK_FUNCTION_OPLINE: { - phpdbg_notice("Breakpoint #%d in %s()#%lu at %s:%u, hits: %lu", + phpdbg_notice("breakpoint", "id=\"%d\" num=\"%lu\" function=\"%s\" file=\"%s\" line=\"%ld\" hits=\"%lu\"", "Breakpoint #%d in %s()#%lu at %s:%u, hits: %lu", ((phpdbg_breakopline_t*)brake)->id, ((phpdbg_breakopline_t*)brake)->func_name, ((phpdbg_breakopline_t*)brake)->opline_num, @@ -1236,9 +1219,8 @@ PHPDBG_API void phpdbg_print_breakpoint(phpdbg_breakbase_t *brake TSRMLS_DC) /* } break; case PHPDBG_BREAK_FILE_OPLINE: { - phpdbg_notice("Breakpoint #%d in %s:%lu at %s:%u, hits: %lu", + phpdbg_notice("breakpoint", "id=\"%d\" num=\"%lu\" file=\"%s\" line=\"%ld\" hits=\"%lu\"", "Breakpoint #%d in #%lu at %s:%u, hits: %lu", ((phpdbg_breakopline_t*)brake)->id, - ((phpdbg_breakopline_t*)brake)->class_name, ((phpdbg_breakopline_t*)brake)->opline_num, zend_get_executed_filename(TSRMLS_C), zend_get_executed_lineno(TSRMLS_C), @@ -1246,7 +1228,7 @@ PHPDBG_API void phpdbg_print_breakpoint(phpdbg_breakbase_t *brake TSRMLS_DC) /* } break; case PHPDBG_BREAK_OPCODE: { - phpdbg_notice("Breakpoint #%d in %s at %s:%u, hits: %lu", + phpdbg_notice("breakpoint", "id=\"%d\" opcode=\"%s\" file=\"%s\" line=\"%ld\" hits=\"%lu\"", "Breakpoint #%d in %s at %s:%u, hits: %lu", ((phpdbg_breakop_t*)brake)->id, ((phpdbg_breakop_t*)brake)->name, zend_get_executed_filename(TSRMLS_C), @@ -1255,7 +1237,7 @@ PHPDBG_API void phpdbg_print_breakpoint(phpdbg_breakbase_t *brake TSRMLS_DC) /* } break; case PHPDBG_BREAK_METHOD: { - phpdbg_notice("Breakpoint #%d in %s::%s() at %s:%u, hits: %lu", + phpdbg_notice("breakpoint", "id=\"%d\" method=\"%s::%s\" file=\"%s\" line=\"%ld\" hits=\"%lu\"", "Breakpoint #%d in %s::%s() at %s:%u, hits: %lu", ((phpdbg_breakmethod_t*)brake)->id, ((phpdbg_breakmethod_t*)brake)->class_name, ((phpdbg_breakmethod_t*)brake)->func_name, @@ -1267,7 +1249,7 @@ PHPDBG_API void phpdbg_print_breakpoint(phpdbg_breakbase_t *brake TSRMLS_DC) /* case PHPDBG_BREAK_COND: { if (((phpdbg_breakcond_t*)brake)->paramed) { char *param; - phpdbg_notice("Conditional breakpoint #%d: at %s if %s %s:%u, hits: %lu", + phpdbg_notice("breakpoint", "id=\"%d\" location=\"%s\" eval=\"%s\" file=\"%s\" line=\"%ld\" hits=\"%lu\"", "Conditional breakpoint #%d: at %s if %s at %s:%u, hits: %lu", ((phpdbg_breakcond_t*)brake)->id, phpdbg_param_tostring(&((phpdbg_breakcond_t*)brake)->param, ¶m TSRMLS_CC), ((phpdbg_breakcond_t*)brake)->code, @@ -1277,7 +1259,7 @@ PHPDBG_API void phpdbg_print_breakpoint(phpdbg_breakbase_t *brake TSRMLS_DC) /* if (param) free(param); } else { - phpdbg_notice("Conditional breakpoint #%d: on %s == true %s:%u, hits: %lu", + phpdbg_notice("breakpoint", "id=\"%d\" eval=\"%s\" file=\"%s\" line=\"%ld\" hits=\"%lu\"", "Conditional breakpoint #%d: on %s == true at %s:%u, hits: %lu", ((phpdbg_breakcond_t*)brake)->id, ((phpdbg_breakcond_t*)brake)->code, zend_get_executed_filename(TSRMLS_C), @@ -1289,7 +1271,7 @@ PHPDBG_API void phpdbg_print_breakpoint(phpdbg_breakbase_t *brake TSRMLS_DC) /* default: { unknown: - phpdbg_notice("Unknown breakpoint at %s:%u", + phpdbg_notice("breakpoint", "id=\"\" file=\"%s\" line=\"%ld\" hits=\"%lu\"", "Unknown breakpoint at %s:%u", zend_get_executed_filename(TSRMLS_C), zend_get_executed_lineno(TSRMLS_C)); } @@ -1350,17 +1332,19 @@ PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase_ex(zend_ulong id, HashTable PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ { + phpdbg_xml(""); + switch (type) { case PHPDBG_BREAK_SYM: if ((PHPDBG_G(flags) & PHPDBG_HAS_SYM_BP)) { HashPosition position; phpdbg_breaksymbol_t *brake; - phpdbg_writeln(SEPARATE); - phpdbg_writeln("Function Breakpoints:"); + phpdbg_out(SEPARATE "\n"); + phpdbg_out("Function Breakpoints:\n"); for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], &position); zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], (void**) &brake, &position) == SUCCESS; zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], &position)) { - phpdbg_writeln("#%d\t\t%s%s", + phpdbg_writeln("function", "id=\"%d\" name=\"%s\" disabled=\"%s\"", "#%d\t\t%s%s", brake->id, brake->symbol, ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); } @@ -1373,8 +1357,8 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ zend_uint class_len = 0; zend_ulong class_idx = 0L; - phpdbg_writeln(SEPARATE); - phpdbg_writeln("Method Breakpoints:"); + phpdbg_out(SEPARATE "\n"); + phpdbg_out("Method Breakpoints:\n"); for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], &position[0]); zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], (void**) &class_table, &position[0]) == SUCCESS; zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], &position[0])) { @@ -1386,7 +1370,7 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ for (zend_hash_internal_pointer_reset_ex(class_table, &position[1]); zend_hash_get_current_data_ex(class_table, (void**)&brake, &position[1]) == SUCCESS; zend_hash_move_forward_ex(class_table, &position[1])) { - phpdbg_writeln("#%d\t\t%s::%s%s", + phpdbg_writeln("method", "id=\"%d\" name=\"%s::%s\" disabled=\"%s\"", "#%d\t\t%s::%s%s", brake->id, brake->class_name, brake->func_name, ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); } @@ -1399,8 +1383,8 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ HashPosition position[2]; HashTable *points; - phpdbg_writeln(SEPARATE); - phpdbg_writeln("File Breakpoints:"); + phpdbg_out(SEPARATE "\n"); + phpdbg_out("File Breakpoints:\n"); for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], &position[0]); zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], (void**) &points, &position[0]) == SUCCESS; zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], &position[0])) { @@ -1409,7 +1393,7 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ for (zend_hash_internal_pointer_reset_ex(points, &position[1]); zend_hash_get_current_data_ex(points, (void**)&brake, &position[1]) == SUCCESS; zend_hash_move_forward_ex(points, &position[1])) { - phpdbg_writeln("#%d\t\t%s:%lu%s", + phpdbg_writeln("file", "id=\"%d\" name=\"%s\" line=\"%lu\" disabled=\"%s\"", "#%d\t\t%s:%lu%s", brake->id, brake->filename, brake->line, ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); } @@ -1421,8 +1405,8 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ HashPosition position; phpdbg_breakline_t *brake; - phpdbg_writeln(SEPARATE); - phpdbg_writeln("Opline Breakpoints:"); + phpdbg_out(SEPARATE "\n"); + phpdbg_out("Opline Breakpoints:\n"); for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], &position); zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], (void**) &brake, &position) == SUCCESS; zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], &position)) { @@ -1430,16 +1414,16 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ case PHPDBG_BREAK_METHOD_OPLINE: case PHPDBG_BREAK_FUNCTION_OPLINE: case PHPDBG_BREAK_FILE_OPLINE: - phpdbg_writeln("#%d\t\t%#lx\t\t(%s breakpoint)%s", brake->id, brake->opline, - brake->type == PHPDBG_BREAK_METHOD_OPLINE?"method": - brake->type == PHPDBG_BREAK_FUNCTION_OPLINE?"function": - brake->type == PHPDBG_BREAK_FILE_OPLINE?"file": + phpdbg_writeln("opline", "id=\"%d\" num=\"%#lx\" type=\"%s\" disabled=\"%s\"", "#%d\t\t%#lx\t\t(%s breakpoint)%s", brake->id, brake->opline, + brake->type == PHPDBG_BREAK_METHOD_OPLINE ? "method" : + brake->type == PHPDBG_BREAK_FUNCTION_OPLINE ? "function" : + brake->type == PHPDBG_BREAK_FILE_OPLINE ? "file" : "--- error ---", ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); break; default: - phpdbg_writeln("#%d\t\t%#lx", brake->id, brake->opline); + phpdbg_writeln("opline", "id=\"%d\" num=\"%#lx\" disabled=\"%s\"", "#%d\t\t%#lx%s", brake->id, brake->opline, ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); break; } } @@ -1452,8 +1436,8 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ zend_uint class_len = 0, method_len = 0; zend_ulong class_idx = 0L, method_idx = 0L; - phpdbg_writeln(SEPARATE); - phpdbg_writeln("Method opline Breakpoints:"); + phpdbg_out(SEPARATE "\n"); + phpdbg_out("Method opline Breakpoints:\n"); for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], &position[0]); zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], (void**) &class_table, &position[0]) == SUCCESS; zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], &position[0])) { @@ -1473,7 +1457,7 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ for (zend_hash_internal_pointer_reset_ex(method_table, &position[2]); zend_hash_get_current_data_ex(method_table, (void**)&brake, &position[2]) == SUCCESS; zend_hash_move_forward_ex(method_table, &position[2])) { - phpdbg_writeln("#%d\t\t%s::%s opline %ld%s", + phpdbg_writeln("methodopline", "id=\"%d\" name=\"%s::%s\" num=\"%ld\" disabled=\"%s\"", "#%d\t\t%s::%s opline %ld%s", brake->id, brake->class_name, brake->func_name, brake->opline_num, ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); } @@ -1491,8 +1475,8 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ zend_uint function_len = 0; zend_ulong function_idx = 0L; - phpdbg_writeln(SEPARATE); - phpdbg_writeln("Function opline Breakpoints:"); + phpdbg_out(SEPARATE "\n"); + phpdbg_out("Function opline Breakpoints:\n"); for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], &position[0]); zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], (void**) &function_table, &position[0]) == SUCCESS; zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], &position[0])) { @@ -1505,7 +1489,7 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ for (zend_hash_internal_pointer_reset_ex(function_table, &position[1]); zend_hash_get_current_data_ex(function_table, (void**)&brake, &position[1]) == SUCCESS; zend_hash_move_forward_ex(function_table, &position[1])) { - phpdbg_writeln("#%d\t\t%s opline %ld%s", + phpdbg_writeln("functionopline", "id=\"%d\" name=\"%s\" num=\"%ld\" disabled=\"%s\"", "#%d\t\t%s opline %ld%s", brake->id, brake->func_name, brake->opline_num, ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); } @@ -1521,8 +1505,8 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ zend_uint file_len = 0; zend_ulong file_idx = 0L; - phpdbg_writeln(SEPARATE); - phpdbg_writeln("File opline Breakpoints:"); + phpdbg_out(SEPARATE "\n"); + phpdbg_out("File opline Breakpoints:\n"); for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE], &position[0]); zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE], (void**) &file_table, &position[0]) == SUCCESS; zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE], &position[0])) { @@ -1535,7 +1519,7 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ for (zend_hash_internal_pointer_reset_ex(file_table, &position[1]); zend_hash_get_current_data_ex(file_table, (void**)&brake, &position[1]) == SUCCESS; zend_hash_move_forward_ex(file_table, &position[1])) { - phpdbg_writeln("#%d\t\t%s opline %ld%s", + phpdbg_writeln("fileopline", "id=\"%d\" name=\"%s\" num=\"%ld\" disabled=\"%s\"", "#%d\t\t%s opline %ld%s", brake->id, brake->class_name, brake->opline_num, ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); } @@ -1547,15 +1531,15 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ HashPosition position; phpdbg_breakcond_t *brake; - phpdbg_writeln(SEPARATE); - phpdbg_writeln("Conditional Breakpoints:"); + phpdbg_out(SEPARATE "\n"); + phpdbg_out("Conditional Breakpoints:\n"); for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], &position); zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], (void**) &brake, &position) == SUCCESS; zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], &position)) { if (brake->paramed) { switch (brake->param.type) { case STR_PARAM: - phpdbg_writeln("#%d\t\tat %s if %s%s", + phpdbg_writeln("evalfunction", "id=\"%d\" name=\"%s\" eval=\"%s\" disabled=\"%s\"", "#%d\t\tat %s if %s%s", brake->id, brake->param.str, brake->code, @@ -1563,7 +1547,7 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ break; case NUMERIC_FUNCTION_PARAM: - phpdbg_writeln("#%d\t\tat %s#%ld if %s%s", + phpdbg_writeln("evalfunctionopline", "id=\"%d\" name=\"%s\" num=\"%ld\" eval=\"%s\" disabled=\"%s\"", "#%d\t\tat %s#%ld if %s%s", brake->id, brake->param.str, brake->param.num, @@ -1572,7 +1556,7 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ break; case METHOD_PARAM: - phpdbg_writeln("#%d\t\tat %s::%s if %s%s", + phpdbg_writeln("evalmethod", "id=\"%d\" name=\"%s::%s\" eval=\"%s\" disabled=\"%s\"", "#%d\t\tat %s::%s if %s%s", brake->id, brake->param.method.class, brake->param.method.name, @@ -1581,7 +1565,7 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ break; case NUMERIC_METHOD_PARAM: - phpdbg_writeln("#%d\t\tat %s::%s#%ld if %s%s", + phpdbg_writeln("evalmethodopline", "id=\"%d\" name=\"%s::%s\" num=\"%d\" eval=\"%s\" disabled=\"%s\"", "#%d\t\tat %s::%s#%ld if %s%s", brake->id, brake->param.method.class, brake->param.method.name, @@ -1591,7 +1575,7 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ break; case FILE_PARAM: - phpdbg_writeln("#%d\t\tat %s:%lu if %s%s", + phpdbg_writeln("evalfile", "id=\"%d\" name=\"%s\" line=\"%d\" eval=\"%s\" disabled=\"%s\"", "#%d\t\tat %s:%lu if %s%s", brake->id, brake->param.file.name, brake->param.file.line, @@ -1600,7 +1584,7 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ break; case ADDR_PARAM: - phpdbg_writeln("#%d\t\tat #%lx if %s%s", + phpdbg_writeln("evalopline", "id=\"%d\" opline=\"%#lx\" eval=\"%s\" disabled=\"%s\"", "#%d\t\tat #%lx if %s%s", brake->id, brake->param.addr, brake->code, @@ -1608,11 +1592,11 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ break; default: - phpdbg_error("Invalid parameter type for conditional breakpoint"); + phpdbg_error("eval", "type=\"invalidparameter\"", "Invalid parameter type for conditional breakpoint"); return; } } else { - phpdbg_writeln("#%d\t\tif %s%s", + phpdbg_writeln("eval", "id=\"%d\" eval=\"%s\" disabled=\"%s\"", "#%d\t\tif %s%s", brake->id, brake->code, ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); } @@ -1623,15 +1607,17 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ HashPosition position; phpdbg_breakop_t *brake; - phpdbg_writeln(SEPARATE); - phpdbg_writeln("Opcode Breakpoints:"); + phpdbg_out(SEPARATE "\n"); + phpdbg_out("Opcode Breakpoints:\n"); for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], &position); zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], (void**) &brake, &position) == SUCCESS; zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], &position)) { - phpdbg_writeln("#%d\t\t%s%s", + phpdbg_writeln("opcode", "id=\"%d\" name=\"%s\" disabled=\"%s\"", "#%d\t\t%s%s", brake->id, brake->name, ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); } } break; } + + phpdbg_xml(""); } /* }}} */ diff --git a/phpdbg_bp.h b/phpdbg_bp.h index 97980e7ed78..a6227cba6c9 100644 --- a/phpdbg_bp.h +++ b/phpdbg_bp.h @@ -21,6 +21,19 @@ #ifndef PHPDBG_BP_H #define PHPDBG_BP_H +/* {{{ defines */ +#define PHPDBG_BREAK_FILE 0 +#define PHPDBG_BREAK_SYM 1 +#define PHPDBG_BREAK_OPLINE 2 +#define PHPDBG_BREAK_METHOD 3 +#define PHPDBG_BREAK_COND 4 +#define PHPDBG_BREAK_OPCODE 5 +#define PHPDBG_BREAK_FUNCTION_OPLINE 6 +#define PHPDBG_BREAK_METHOD_OPLINE 7 +#define PHPDBG_BREAK_FILE_OPLINE 8 +#define PHPDBG_BREAK_MAP 9 +#define PHPDBG_BREAK_TABLES 10 /* }}} */ + /* {{{ */ typedef struct _zend_op *phpdbg_opline_ptr_t; /* }}} */ diff --git a/phpdbg_break.c b/phpdbg_break.c index be76b22b059..386d4d95620 100644 --- a/phpdbg_break.c +++ b/phpdbg_break.c @@ -28,15 +28,15 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg); -#define PHPDBG_BREAK_COMMAND_D(f, h, a, m, l, s) \ - PHPDBG_COMMAND_D_EXP(f, h, a, m, l, s, &phpdbg_prompt_commands[10]) +#define PHPDBG_BREAK_COMMAND_D(f, h, a, m, l, s, flags) \ + PHPDBG_COMMAND_D_EXP(f, h, a, m, l, s, &phpdbg_prompt_commands[10], flags) /** * Commands */ const phpdbg_command_t phpdbg_break_commands[] = { - PHPDBG_BREAK_COMMAND_D(at, "specify breakpoint by location and condition", '@', break_at, NULL, "*c"), - PHPDBG_BREAK_COMMAND_D(del, "delete breakpoint by identifier number", '~', break_del, NULL, "n"), + PHPDBG_BREAK_COMMAND_D(at, "specify breakpoint by location and condition", '@', break_at, NULL, "*c", 0), + PHPDBG_BREAK_COMMAND_D(del, "delete breakpoint by identifier number", '~', break_del, NULL, "n", 0), PHPDBG_END_COMMAND }; diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index a45513bee6b..30ea48cfbe4 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -23,6 +23,7 @@ #include "phpdbg_utils.h" #include "phpdbg_set.h" #include "phpdbg_prompt.h" +#include "phpdbg_io.h" ZEND_EXTERN_MODULE_GLOBALS(phpdbg); @@ -39,7 +40,7 @@ static inline const char *phpdbg_command_name(const phpdbg_command_t *command, c memcpy(&buffer[pos], command->name, command->name_len); pos += command->name_len; buffer[pos] = 0; - + return buffer; } @@ -231,12 +232,12 @@ PHPDBG_API void phpdbg_copy_param(const phpdbg_param_t* src, phpdbg_param_t* des case STACK_PARAM: /* nope */ break; - + case STR_PARAM: dest->str = estrndup(src->str, src->len); dest->len = src->len; break; - + case OP_PARAM: dest->str = estrndup(src->str, src->len); dest->len = src->len; @@ -276,7 +277,7 @@ PHPDBG_API void phpdbg_copy_param(const phpdbg_param_t* src, phpdbg_param_t* des break; case EMPTY_PARAM: { /* do nothing */ } break; - + default: { /* not yet */ } @@ -291,7 +292,7 @@ PHPDBG_API zend_ulong phpdbg_hash_param(const phpdbg_param_t *param TSRMLS_DC) / case STACK_PARAM: /* nope */ break; - + case STR_PARAM: hash += zend_inline_hash_func(param->str, param->len); break; @@ -329,7 +330,7 @@ PHPDBG_API zend_ulong phpdbg_hash_param(const phpdbg_param_t *param TSRMLS_DC) / break; case EMPTY_PARAM: { /* do nothing */ } break; - + default: { /* not yet */ } @@ -347,7 +348,7 @@ PHPDBG_API zend_bool phpdbg_match_param(const phpdbg_param_t *l, const phpdbg_pa /* nope, or yep */ return 1; break; - + case NUMERIC_FUNCTION_PARAM: if (l->num != r->num) { break; @@ -402,7 +403,7 @@ PHPDBG_API zend_bool phpdbg_match_param(const phpdbg_param_t *l, const phpdbg_pa case EMPTY_PARAM: return 1; - + default: { /* not yet */ } @@ -419,43 +420,43 @@ PHPDBG_API void phpdbg_param_debug(const phpdbg_param_t *param, const char *msg) case STR_PARAM: fprintf(stderr, "%s STR_PARAM(%s=%lu)\n", msg, param->str, param->len); break; - + case ADDR_PARAM: fprintf(stderr, "%s ADDR_PARAM(%lu)\n", msg, param->addr); break; - + case NUMERIC_FILE_PARAM: fprintf(stderr, "%s NUMERIC_FILE_PARAM(%s:#%lu)\n", msg, param->file.name, param->file.line); break; - + case FILE_PARAM: fprintf(stderr, "%s FILE_PARAM(%s:%lu)\n", msg, param->file.name, param->file.line); break; - + case METHOD_PARAM: fprintf(stderr, "%s METHOD_PARAM(%s::%s)\n", msg, param->method.class, param->method.name); break; - + case NUMERIC_METHOD_PARAM: fprintf(stderr, "%s NUMERIC_METHOD_PARAM(%s::%s)\n", msg, param->method.class, param->method.name); break; - + case NUMERIC_FUNCTION_PARAM: fprintf(stderr, "%s NUMERIC_FUNCTION_PARAM(%s::%ld)\n", msg, param->str, param->num); break; - + case NUMERIC_PARAM: fprintf(stderr, "%s NUMERIC_PARAM(%ld)\n", msg, param->num); break; - + case COND_PARAM: fprintf(stderr, "%s COND_PARAM(%s=%lu)\n", msg, param->str, param->len); break; - + case OP_PARAM: fprintf(stderr, "%s OP_PARAM(%s=%lu)\n", msg, param->str, param->len); break; - + default: { /* not yet */ } @@ -467,13 +468,13 @@ PHPDBG_API void phpdbg_param_debug(const phpdbg_param_t *param, const char *msg) PHPDBG_API void phpdbg_stack_free(phpdbg_param_t *stack) { if (stack && stack->next) { phpdbg_param_t *remove = stack->next; - + while (remove) { phpdbg_param_t *next = NULL; - + if (remove->next) next = remove->next; - + switch (remove->type) { case NUMERIC_METHOD_PARAM: case METHOD_PARAM: @@ -487,29 +488,30 @@ PHPDBG_API void phpdbg_stack_free(phpdbg_param_t *stack) { case STR_PARAM: case OP_PARAM: if (remove->str) - free(remove->str); + free(remove->str); break; - + case NUMERIC_FILE_PARAM: case FILE_PARAM: if (remove->file.name) free(remove->file.name); break; - + default: { /* nothing */ } } - + free(remove); remove = NULL; - + if (next) - remove = next; + remove = next; else break; } } - + + stack->next = NULL; } /* }}} */ @@ -537,30 +539,29 @@ PHPDBG_API void phpdbg_stack_push(phpdbg_param_t *stack, phpdbg_param_t *param) stack->len++; } /* }}} */ -PHPDBG_API int phpdbg_stack_verify(const phpdbg_command_t *command, phpdbg_param_t **stack, char **why TSRMLS_DC) { +PHPDBG_API int phpdbg_stack_verify(const phpdbg_command_t *command, phpdbg_param_t **stack TSRMLS_DC) { if (command) { char buffer[128] = {0,}; const phpdbg_param_t *top = (stack != NULL) ? *stack : NULL; const char *arg = command->args; size_t least = 0L, - received = 0L, - current = 0L; + received = 0L, + current = 0L; zend_bool optional = 0; - + /* check for arg spec */ if (!(arg) || !(*arg)) { if (!top) { return SUCCESS; } - - asprintf(why, - "The command \"%s\" expected no arguments", + + phpdbg_error("command", "type=\"toomanyargs\" command=\"%s\" expected=\"0\"", "The command \"%s\" expected no arguments", phpdbg_command_name(command, buffer)); return FAILURE; } - + least = 0L; - + /* count least amount of arguments */ while (arg && *arg) { if (arg[0] == '|') { @@ -569,21 +570,19 @@ PHPDBG_API int phpdbg_stack_verify(const phpdbg_command_t *command, phpdbg_param least++; arg++; } - + arg = command->args; #define verify_arg(e, a, t) if (!(a)) { \ if (!optional) { \ - asprintf(why, \ - "The command \"%s\" expected %s and got nothing at parameter %lu", \ + phpdbg_error("command", "type=\"noarg\" command=\"%s\" expected=\"%s\" num=\"%lu\"", "The command \"%s\" expected %s and got nothing at parameter %lu", \ phpdbg_command_name(command, buffer), \ (e), \ current); \ return FAILURE;\ } \ } else if ((a)->type != (t)) { \ - asprintf(why, \ - "The command \"%s\" expected %s and got %s at parameter %lu", \ + phpdbg_error("command", "type=\"wrongarg\" command=\"%s\" expected=\"%s\" got=\"%s\" num=\"%lu\"", "The command \"%s\" expected %s and got %s at parameter %lu", \ phpdbg_command_name(command, buffer), \ (e),\ phpdbg_get_param_type((a) TSRMLS_CC), \ @@ -593,14 +592,14 @@ PHPDBG_API int phpdbg_stack_verify(const phpdbg_command_t *command, phpdbg_param while (arg && *arg) { current++; - + switch (*arg) { case '|': { current--; optional = 1; arg++; } continue; - + case 'i': verify_arg("raw input", top, STR_PARAM); break; case 's': verify_arg("string", top, STR_PARAM); break; case 'n': verify_arg("number", top, NUMERIC_PARAM); break; @@ -610,14 +609,14 @@ PHPDBG_API int phpdbg_stack_verify(const phpdbg_command_t *command, phpdbg_param case 'c': verify_arg("condition", top, COND_PARAM); break; case 'o': verify_arg("opcode", top, OP_PARAM); break; case 'b': verify_arg("boolean", top, NUMERIC_PARAM); break; - + case '*': { /* do nothing */ } break; } - + if (top ) { top = top->next; } else break; - + received++; arg++; } @@ -625,28 +624,27 @@ PHPDBG_API int phpdbg_stack_verify(const phpdbg_command_t *command, phpdbg_param #undef verify_arg if ((received < least)) { - asprintf(why, - "The command \"%s\" expected at least %lu arguments (%s) and received %lu", + phpdbg_error("command", "type=\"toofewargs\" command=\"%s\" expected=\"%d\" argtypes=\"%s\" got=\"%d\"", "The command \"%s\" expected at least %lu arguments (%s) and received %lu", phpdbg_command_name(command, buffer), least, - command->args, + command->args, received); return FAILURE; } } - + return SUCCESS; } /* {{{ */ -PHPDBG_API const phpdbg_command_t* phpdbg_stack_resolve(const phpdbg_command_t *commands, const phpdbg_command_t *parent, phpdbg_param_t **top, char **why) { +PHPDBG_API const phpdbg_command_t *phpdbg_stack_resolve(const phpdbg_command_t *commands, const phpdbg_command_t *parent, phpdbg_param_t **top TSRMLS_DC) { const phpdbg_command_t *command = commands; phpdbg_param_t *name = *top; const phpdbg_command_t *matched[3] = {NULL, NULL, NULL}; ulong matches = 0L; - + while (command && command->name && command->handler) { - if ((name->len == 1) || (command->name_len >= name->len)) { + if (name->len == 1 || command->name_len >= name->len) { /* match single letter alias */ if (command->alias && (name->len == 1)) { if (command->alias == (*name->str)) { @@ -654,85 +652,76 @@ PHPDBG_API const phpdbg_command_t* phpdbg_stack_resolve(const phpdbg_command_t * matches++; } } else { - /* match full, case insensitive, command name */ if (strncasecmp(command->name, name->str, name->len) == SUCCESS) { if (matches < 3) { - /* only allow abbreviating commands that can be aliased */ - if (((name->len != command->name_len) && command->alias) || - (name->len == command->name_len)) { + if ((name->len != command->name_len && command->alias) || name->len == command->name_len) { matched[matches] = command; matches++; } - - + /* exact match */ - if (name->len == command->name_len) + if (name->len == command->name_len) { break; - } else break; + } + } else { + break; + } } } } - + command++; } - + switch (matches) { - case 0: { + case 0: if (parent) { - asprintf( - why, - "The command \"%s %s\" could not be found", - parent->name, name->str); - } else asprintf( - why, - "The command \"%s\" could not be found", - name->str); - } return parent; - - case 1: { + phpdbg_error("command", "type=\"notfound\" command=\"%s\" subcommand=\"%s\"", "The command \"%s %s\" could not be found", parent->name, name->str); + } else { + phpdbg_error("command", "type=\"notfound\" command=\"%s\"", "The command \"%s\" could not be found", name->str); + } + return parent; + + case 1: (*top) = (*top)->next; command = matched[0]; - } break; - + break; + default: { char *list = NULL; zend_uint it = 0; size_t pos = 0; - + while (it < matches) { if (!list) { - list = malloc( - matched[it]->name_len + 1 + - ((it+1) < matches ? sizeof(", ")-1 : 0)); + list = emalloc(matched[it]->name_len + 1 + (it + 1 < matches ? sizeof(", ") - 1 : 0)); } else { - list = realloc(list, - (pos + matched[it]->name_len) + 1 + - ((it+1) < matches ? sizeof(", ")-1 : 0)); + list = erealloc(list, (pos + matched[it]->name_len) + 1 + (it + 1 < matches ? sizeof(", ") - 1 : 0)); } memcpy(&list[pos], matched[it]->name, matched[it]->name_len); pos += matched[it]->name_len; - if ((it+1) < matches) { - memcpy(&list[pos], ", ", sizeof(", ")-1); + if ((it + 1) < matches) { + memcpy(&list[pos], ", ", sizeof(", ") - 1); pos += (sizeof(", ") - 1); } - + list[pos] = 0; it++; } - - asprintf( - why, - "The command \"%s\" is ambigious, matching %lu commands (%s)", - name->str, matches, list); - free(list); - } return NULL; + + /* ", " separated matches */ + phpdbg_error("command", "type=\"ambiguous\" command=\"%s\" matches=\"%lu\" matched=\"%s\"", "The command \"%s\" is ambigious, matching %lu commands (%s)", name->str, matches, list); + efree(list); + + return NULL; + } } if (command->subs && (*top) && ((*top)->type == STR_PARAM)) { - return phpdbg_stack_resolve(command->subs, command, top, why); + return phpdbg_stack_resolve(command->subs, command, top TSRMLS_CC); } else { return command; } @@ -741,102 +730,147 @@ PHPDBG_API const phpdbg_command_t* phpdbg_stack_resolve(const phpdbg_command_t * } /* }}} */ /* {{{ */ -PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack, char **why TSRMLS_DC) { +PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack, zend_bool allow_async_unsafe TSRMLS_DC) { phpdbg_param_t *top = NULL; const phpdbg_command_t *handler = NULL; - + if (stack->type != STACK_PARAM) { - asprintf( - why, "The passed argument was not a stack !!"); + phpdbg_error("command", "type=\"nostack\"", "The passed argument was not a stack !"); return FAILURE; } - + if (!stack->len) { - asprintf( - why, "The stack contains nothing !!"); + phpdbg_error("command", "type=\"emptystack\"", "The stack contains nothing !"); return FAILURE; } - - top = (phpdbg_param_t*) stack->next; - + + top = (phpdbg_param_t *) stack->next; + switch (top->type) { case EVAL_PARAM: + phpdbg_activate_err_buf(0 TSRMLS_CC); + phpdbg_free_err_buf(TSRMLS_C); return PHPDBG_COMMAND_HANDLER(ev)(top TSRMLS_CC); case RUN_PARAM: + if (!allow_async_unsafe) { + phpdbg_error("signalsegv", "command=\"run\"", "run command is disallowed during hard interrupt"); + } + phpdbg_activate_err_buf(0 TSRMLS_CC); + phpdbg_free_err_buf(TSRMLS_C); return PHPDBG_COMMAND_HANDLER(run)(top TSRMLS_CC); - + case SHELL_PARAM: + if (!allow_async_unsafe) { + phpdbg_error("signalsegv", "command=\"sh\"", "sh command is disallowed during hard interrupt"); + return FAILURE; + } + phpdbg_activate_err_buf(0 TSRMLS_CC); + phpdbg_free_err_buf(TSRMLS_C); return PHPDBG_COMMAND_HANDLER(sh)(top TSRMLS_CC); - + case STR_PARAM: { - handler = phpdbg_stack_resolve( - phpdbg_prompt_commands, NULL, &top, why); - + handler = phpdbg_stack_resolve(phpdbg_prompt_commands, NULL, &top TSRMLS_CC); + if (handler) { - if (phpdbg_stack_verify(handler, &top, why TSRMLS_CC) == SUCCESS) { + if (!allow_async_unsafe && !(handler->flags & PHPDBG_ASYNC_SAFE)) { + phpdbg_error("signalsegv", "command=\"%s\"", "%s command is disallowed during hard interrupt", handler->name); + return FAILURE; + } + + if (phpdbg_stack_verify(handler, &top TSRMLS_CC) == SUCCESS) { + phpdbg_activate_err_buf(0 TSRMLS_CC); + phpdbg_free_err_buf(TSRMLS_C); return handler->handler(top TSRMLS_CC); } } } return FAILURE; - + default: - asprintf( - why, "The first parameter makes no sense !!"); + phpdbg_error("command", "type=\"invalidcommand\"", "The first parameter makes no sense !"); return FAILURE; } - + return SUCCESS; } /* }}} */ -PHPDBG_API char* phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */ +PHPDBG_API char *phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */ { char *cmd = NULL; -#if !defined(HAVE_LIBREADLINE) && !defined(HAVE_LIBEDIT) - char buf[PHPDBG_MAX_CMD]; -#endif char *buffer = NULL; if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { - if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && - (buffered == NULL)) { - fflush(PHPDBG_G(io)[PHPDBG_STDOUT]); + if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && (buffered == NULL) && !phpdbg_active_sigsafe_mem(TSRMLS_C)) { + fflush(PHPDBG_G(io)[PHPDBG_STDOUT].ptr); } if (buffered == NULL) { -disconnect: if (0) { +disconnect: PHPDBG_G(flags) |= (PHPDBG_IS_QUITTING|PHPDBG_IS_DISCONNECTED); zend_bailout(); return NULL; } -#if !defined(HAVE_LIBREADLINE) && !defined(HAVE_LIBEDIT) - if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { - if (!phpdbg_write("%s", phpdbg_get_prompt(TSRMLS_C))) { +#define USE_LIB_STAR (defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT)) + + /* note: EOF makes readline write prompt again in local console mode - and ignored if compiled without readline */ + /* strongly assuming to be in blocking mode... */ +#if USE_LIB_STAR +readline: + if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) +#endif + { + char buf[PHPDBG_MAX_CMD]; + int bytes = PHPDBG_G(input_buflen), len = 0; + if (PHPDBG_G(input_buflen)) { + memcpy(buf, PHPDBG_G(input_buffer), bytes); + } + + phpdbg_write("prompt", "", "%s", phpdbg_get_prompt(TSRMLS_C)); + PHPDBG_G(last_was_newline) = 1; + + do { + int i; + if (bytes <= 0) { + continue; + } + + for (i = len; i < len + bytes; i++) { + if (buf[i] == '\x03') { + if (i != len + bytes - 1) { + memmove(buf + i, buf + i + 1, len + bytes - i - 1); + } + len--; + i--; + continue; + } + if (buf[i] == '\n') { + PHPDBG_G(input_buflen) = len + bytes - 1 - i; + if (PHPDBG_G(input_buflen)) { + memcpy(PHPDBG_G(input_buffer), buf + i + 1, PHPDBG_G(input_buflen)); + } + if (i != PHPDBG_MAX_CMD - 1) { + buf[i + 1] = 0; + } + cmd = buf; + goto end; + } + } + len += bytes; + /* XXX export the timeout through INI??*/ + } while ((bytes = phpdbg_mixed_read(PHPDBG_G(io)[PHPDBG_STDIN].fd, buf + len, PHPDBG_MAX_CMD - len, -1 TSRMLS_CC)) > 0); + + if (bytes <= 0) { goto disconnect; } - } - - /* note: EOF is ignored */ -readline: - if (!fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) { - /* the user has gone away */ - if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { - goto disconnect; - } else goto readline; - } - cmd = buf; -#else - /* note: EOF makes readline write prompt again in local console mode */ -readline: - if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { - char buf[PHPDBG_MAX_CMD]; - if (fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) { - cmd = buf; - } else goto disconnect; - } else cmd = readline(phpdbg_get_prompt(TSRMLS_C)); + cmd = buf; + } +#if USE_LIB_STAR + else { + cmd = readline(phpdbg_get_prompt(TSRMLS_C)); + } if (!cmd) { goto readline; @@ -846,13 +880,15 @@ readline: add_history(cmd); } #endif - } else cmd = buffered; - + } else { + cmd = buffered; + } +end: + PHPDBG_G(last_was_newline) = 1; buffer = estrdup(cmd); -#if defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT) - if (!buffered && cmd && - !(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { +#if USE_LIB_STAR + if (!buffered && cmd && !(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { free(cmd); } #endif @@ -878,7 +914,7 @@ readline: buffer = estrdup(PHPDBG_G(buffer)); } } - + return buffer; } /* }}} */ @@ -886,4 +922,3 @@ PHPDBG_API void phpdbg_destroy_input(char **input TSRMLS_DC) /*{{{ */ { efree(*input); } /* }}} */ - diff --git a/phpdbg_cmd.h b/phpdbg_cmd.h index 571d065f59d..3896551c9a2 100644 --- a/phpdbg_cmd.h +++ b/phpdbg_cmd.h @@ -86,6 +86,8 @@ struct _phpdbg_param { #define YYSTYPE phpdbg_param_t #endif +#define PHPDBG_ASYNC_SAFE 1 + typedef int (*phpdbg_command_handler_t)(const phpdbg_param_t* TSRMLS_DC); typedef struct _phpdbg_command_t phpdbg_command_t; @@ -97,8 +99,9 @@ struct _phpdbg_command_t { char alias; /* Alias */ phpdbg_command_handler_t handler; /* Command handler */ const phpdbg_command_t *subs; /* Sub Commands */ - char *args; /* Argument Spec */ - const phpdbg_command_t *parent; /* Parent Command */ + char *args; /* Argument Spec */ + const phpdbg_command_t *parent; /* Parent Command */ + zend_bool flags; /* General flags */ }; /* }}} */ @@ -106,7 +109,7 @@ struct _phpdbg_command_t { #define PHPDBG_STRL(s) s, sizeof(s)-1 #define PHPDBG_MAX_CMD 500 #define PHPDBG_FRAME(v) (PHPDBG_G(frame).v) -#define PHPDBG_EX(v) (EG(current_execute_data)->v) +#define PHPDBG_EX(v) (EG(current_execute_data)->v) typedef struct { int num; @@ -133,9 +136,9 @@ PHPDBG_API void phpdbg_destroy_input(char** TSRMLS_DC); * Stack Management */ PHPDBG_API void phpdbg_stack_push(phpdbg_param_t *stack, phpdbg_param_t *param); -PHPDBG_API const phpdbg_command_t* phpdbg_stack_resolve(const phpdbg_command_t *commands, const phpdbg_command_t *parent, phpdbg_param_t **top, char **why); -PHPDBG_API int phpdbg_stack_verify(const phpdbg_command_t *command, phpdbg_param_t **stack, char **why TSRMLS_DC); -PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack, char **why TSRMLS_DC); +PHPDBG_API const phpdbg_command_t *phpdbg_stack_resolve(const phpdbg_command_t *commands, const phpdbg_command_t *parent, phpdbg_param_t **top TSRMLS_DC); +PHPDBG_API int phpdbg_stack_verify(const phpdbg_command_t *command, phpdbg_param_t **stack TSRMLS_DC); +PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack, zend_bool allow_async_unsafe TSRMLS_DC); PHPDBG_API void phpdbg_stack_free(phpdbg_param_t *stack); /* @@ -155,27 +158,27 @@ PHPDBG_API void phpdbg_param_debug(const phpdbg_param_t *param, const char *msg) */ #define PHPDBG_COMMAND_HANDLER(name) phpdbg_do_##name -#define PHPDBG_COMMAND_D_EXP(name, tip, alias, handler, children, args, parent) \ - {PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##handler, children, args, parent} +#define PHPDBG_COMMAND_D_EXP(name, tip, alias, handler, children, args, parent, flags) \ + {PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##handler, children, args, parent, flags} -#define PHPDBG_COMMAND_D_EX(name, tip, alias, handler, children, args) \ - {PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##handler, children, args, NULL} +#define PHPDBG_COMMAND_D_EX(name, tip, alias, handler, children, args, flags) \ + {PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##handler, children, args, NULL, flags} -#define PHPDBG_COMMAND_D(name, tip, alias, children, args) \ - {PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##name, children, args, NULL} +#define PHPDBG_COMMAND_D(name, tip, alias, children, args, flags) \ + {PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##name, children, args, NULL, flags} #define PHPDBG_COMMAND(name) int phpdbg_do_##name(const phpdbg_param_t *param TSRMLS_DC) #define PHPDBG_COMMAND_ARGS param TSRMLS_CC -#define PHPDBG_END_COMMAND {NULL, 0, NULL, 0, '\0', NULL, NULL, '\0', NULL} +#define PHPDBG_END_COMMAND {NULL, 0, NULL, 0, '\0', NULL, NULL, NULL, NULL, 0} /* * Default Switch Case */ #define phpdbg_default_switch_case() \ default: \ - phpdbg_error("Unsupported parameter type (%s) for command", phpdbg_get_param_type(param TSRMLS_CC)); \ + phpdbg_error("command", "type=\"wrongarg\" got=\"%s\"", "Unsupported parameter type (%s) for command", phpdbg_get_param_type(param TSRMLS_CC)); \ break #endif /* PHPDBG_CMD_H */ diff --git a/phpdbg_eol.c b/phpdbg_eol.c new file mode 100644 index 00000000000..fc20d567bc6 --- /dev/null +++ b/phpdbg_eol.c @@ -0,0 +1,172 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Anatol Belski | + +----------------------------------------------------------------------+ +*/ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "phpdbg.h" +#include "phpdbg_eol.h" + +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); + +#define EOL_LIST_LEN 4 +struct phpdbg_eol_rep phpdbg_eol_list[EOL_LIST_LEN] = { + {"CRLF", "\r\n", PHPDBG_EOL_CRLF}, +/* {"LFCR", "\n\r", PHPDBG_EOL_LFCR},*/ + {"LF", "\n", PHPDBG_EOL_LF}, + {"CR", "\r", PHPDBG_EOL_CR}, +}; + +int phpdbg_eol_global_update(char *name TSRMLS_DC) +{ + + if (0 == memcmp(name, "CRLF", 4) || 0 == memcmp(name, "crlf", 4) || 0 == memcmp(name, "DOS", 3) || 0 == memcmp(name, "dos", 3)) { + PHPDBG_G(eol) = PHPDBG_EOL_CRLF; + } else if (0 == memcmp(name, "LF", 2) || 0 == memcmp(name, "lf", 2) || 0 == memcmp(name, "UNIX", 4) || 0 == memcmp(name, "unix", 4)) { + PHPDBG_G(eol) = PHPDBG_EOL_LF; + } else if (0 == memcmp(name, "CR", 2) || 0 == memcmp(name, "cr", 2) || 0 == memcmp(name, "MAC", 3) || 0 == memcmp(name, "mac", 3)) { + PHPDBG_G(eol) = PHPDBG_EOL_CR; + } else { + return FAILURE; + } + + return SUCCESS; +} + +char *phpdbg_eol_name(int id) +{ + size_t i = 0; + + while (i < EOL_LIST_LEN) { + + if (id == phpdbg_eol_list[i].id) { + return phpdbg_eol_list[i].name; + } + + i++; + } + + return NULL; +} + +char *phpdbg_eol_rep(int id) +{ + size_t i = 0; + + while (i < EOL_LIST_LEN) { + + if (id == phpdbg_eol_list[i].id) { + return phpdbg_eol_list[i].rep; + } + + i++; + } + + return NULL; +} + + +/* Inspired by https://ccrma.stanford.edu/~craig/utility/flip/flip.cpp */ +void phpdbg_eol_convert(char **str, int *len TSRMLS_DC) +{ + char *in = *str, *out ; + int in_len = *len, out_len, cursor, i; + char last, cur; + + if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE) != PHPDBG_IS_REMOTE) { + return; + } + + out_len = *len; + if (PHPDBG_EOL_CRLF == PHPDBG_G(eol)) { /* XXX add LFCR case if it's gonna be needed */ + /* depending on the source EOL the out str will have all CR/LF duplicated */ + for (i = 0; i < in_len; i++) { + if (0x0a == in[i] || 0x0d == in[i]) { + out_len++; + } + } + out = (char *)emalloc(out_len); + + last = cur = in[0]; + i = cursor = 0; + for (; i < in_len;) { + if (0x0a == cur && last != 0x0d) { + out[cursor] = 0x0d; + cursor++; + out[cursor] = cur; + } else if(0x0d == cur) { + if (i + 1 < in_len && 0x0a != in[i+1]) { + out[cursor] = cur; + cursor++; + out[cursor] = 0x0a; + last = 0x0a; + } else { + out[cursor] = 0x0d; + last = 0x0d; + } + } else { + out[cursor] = cur; + last = cur; + } + + i++; + cursor++; + cur = in[i]; + } + + } else if (PHPDBG_EOL_LF == PHPDBG_G(eol) || PHPDBG_EOL_CR == PHPDBG_G(eol)) { + char want, kick; + + if (PHPDBG_EOL_LF == PHPDBG_G(eol)) { + want = 0x0a; + kick = 0x0d; + } else { + want = 0x0d; + kick = 0x0a; + } + + /* We gonna have a smaller or equally long string, estimation is almost neglecting */ + out = (char *)emalloc(out_len); + + last = cur = in[0]; + i = cursor = 0; + for (; cursor < in_len;) { + if (kick == cur) { + out[cursor] = want; + } else if (want == cur) { + if (kick != last) { + out[cursor] = want; + } + } else { + out[cursor] = cur; + } + + last = cur; + cursor++; + cur = in[cursor]; + } + } else { + return; + } + + efree(*str); + *str = erealloc(out, cursor); + *len = cursor; + in = NULL; +} diff --git a/phpdbg_eol.h b/phpdbg_eol.h new file mode 100644 index 00000000000..68b54cbe343 --- /dev/null +++ b/phpdbg_eol.h @@ -0,0 +1,46 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Anatol Belski | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHPDBG_EOL_H +#define PHPDBG_EOL_H + +#include "phpdbg.h" + +struct phpdbg_eol_rep { + char *name; + char *rep; + int id; +}; + +enum { + PHPDBG_EOL_CRLF, /* DOS */ + /*PHPDBG_EOL_LFCR,*/ /* for Risc OS? */ + PHPDBG_EOL_LF, /* UNIX */ + PHPDBG_EOL_CR /* MAC */ +}; + +int phpdbg_eol_global_update(char *name TSRMLS_DC); + +char *phpdbg_eol_name(int id); + +char *phpdbg_eol_rep(int id); + +void phpdbg_eol_convert(char **str, int *len TSRMLS_DC); + +#endif /* PHPDBG_EOL_H */ + diff --git a/phpdbg_frame.c b/phpdbg_frame.c index a235fe8cb04..df304e35411 100644 --- a/phpdbg_frame.c +++ b/phpdbg_frame.c @@ -52,22 +52,27 @@ void phpdbg_switch_frame(int frame TSRMLS_DC) /* {{{ */ int i = 0; if (PHPDBG_FRAME(num) == frame) { - phpdbg_notice("Already in frame #%d", frame); + phpdbg_notice("frame", "id=\"%d\"", "Already in frame #%d", frame); return; } - while (execute_data) { - if (i++ == frame) { - break; - } + phpdbg_try_access { + while (execute_data) { + if (i++ == frame) { + break; + } - do { - execute_data = execute_data->prev_execute_data; - } while (execute_data && execute_data->opline == NULL); - } + do { + execute_data = execute_data->prev_execute_data; + } while (execute_data && execute_data->opline == NULL); + } + } phpdbg_catch_access { + phpdbg_error("signalsegv", "", "Couldn't switch frames, invalid data source"); + return; + } phpdbg_end_try_access(); if (execute_data == NULL) { - phpdbg_error("No frame #%d", frame); + phpdbg_error("frame", "type=\"maxnum\" id=\"%d\"", "No frame #%d", frame); return; } @@ -90,7 +95,7 @@ void phpdbg_switch_frame(int frame TSRMLS_DC) /* {{{ */ EG(called_scope) = PHPDBG_EX(current_called_scope); } - phpdbg_notice("Switched to frame #%d", frame); + phpdbg_notice("frame", "id=\"%d\"", "Switched to frame #%d", frame); phpdbg_list_file( zend_get_executed_filename(TSRMLS_C), 3, @@ -104,61 +109,84 @@ static void phpdbg_dump_prototype(zval **tmp TSRMLS_DC) /* {{{ */ { zval **funcname, **class, **type, **args, **argstmp; char is_class; + int has_args = FAILURE; - zend_hash_find(Z_ARRVAL_PP(tmp), "function", sizeof("function"), - (void **)&funcname); + zend_hash_find(Z_ARRVAL_PP(tmp), "function", sizeof("function"), (void **) &funcname); - if ((is_class = zend_hash_find(Z_ARRVAL_PP(tmp), - "object", sizeof("object"), (void **)&class)) == FAILURE) { - is_class = zend_hash_find(Z_ARRVAL_PP(tmp), "class", sizeof("class"), - (void **)&class); + if ((is_class = zend_hash_find(Z_ARRVAL_PP(tmp), "object", sizeof("object"), (void **) &class)) == FAILURE) { + is_class = zend_hash_find(Z_ARRVAL_PP(tmp), "class", sizeof("class"), (void **)&class); } else { - zend_get_object_classname(*class, (const char **)&Z_STRVAL_PP(class), - (zend_uint *)&Z_STRLEN_PP(class) TSRMLS_CC); + zend_get_object_classname(*class, (const char **) &Z_STRVAL_PP(class), (zend_uint *) &Z_STRLEN_PP(class) TSRMLS_CC); } if (is_class == SUCCESS) { zend_hash_find(Z_ARRVAL_PP(tmp), "type", sizeof("type"), (void **)&type); } - phpdbg_write("%s%s%s(", + has_args = zend_hash_find(Z_ARRVAL_PP(tmp), "args", sizeof("args"), (void **)&args) == SUCCESS; + + phpdbg_xml(" symbol=\"%s%s%s\"", + is_class == FAILURE?"":Z_STRVAL_PP(class), + is_class == FAILURE?"":Z_STRVAL_PP(type), + Z_STRVAL_PP(funcname) + ); + if (has_args) { + phpdbg_xml(">"); + } else { + phpdbg_xml(" />"); + } + + phpdbg_out("%s%s%s(", is_class == FAILURE?"":Z_STRVAL_PP(class), is_class == FAILURE?"":Z_STRVAL_PP(type), Z_STRVAL_PP(funcname) ); - if (zend_hash_find(Z_ARRVAL_PP(tmp), "args", sizeof("args"), - (void **)&args) == SUCCESS) { + if (has_args) { HashPosition iterator; - const zend_function *func = phpdbg_get_function( - Z_STRVAL_PP(funcname), is_class == FAILURE ? NULL : Z_STRVAL_PP(class) TSRMLS_CC); - const zend_arg_info *arginfo = func ? func->common.arg_info : NULL; - int j = 0, m = func ? func->common.num_args : 0; + const zend_function *func = NULL; + const zend_arg_info *arginfo = NULL; + int j = 0, m; zend_bool is_variadic = 0; - zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(args), &iterator); - while (zend_hash_get_current_data_ex(Z_ARRVAL_PP(args), - (void **) &argstmp, &iterator) == SUCCESS) { - if (j) { - phpdbg_write(", "); + phpdbg_try_access { + /* assuming no autoloader call is necessary, class should have been loaded if it's in backtrace ... */ + if ((func = phpdbg_get_function(Z_STRVAL_PP(funcname), is_class == FAILURE ? NULL : Z_STRVAL_PP(class) TSRMLS_CC))) { + arginfo = func->common.arg_info; } + } phpdbg_end_try_access(); + + m = func ? func->common.num_args : 0; + + zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(args), &iterator); + while (zend_hash_get_current_data_ex(Z_ARRVAL_PP(args), (void **) &argstmp, &iterator) == SUCCESS) { + if (j) { + phpdbg_out(", "); + } + phpdbg_xml("= 50600 - is_variadic = arginfo[j].is_variadic; + is_variadic = arginfo ? arginfo[j].is_variadic : 0; #endif - phpdbg_write("%s=%s", - arginfo[j].name, is_variadic ? "[": ""); + phpdbg_xml(" variadic=\"%s\" name=\"%s\">", is_variadic ? "variadic" : "", arginfo ? arginfo[j].name : ""); + phpdbg_out("%s=%s", arginfo ? arginfo[j].name : "?", is_variadic ? "[": ""); + + } else { + phpdbg_xml(">"); } ++j; zend_print_flat_zval_r(*argstmp TSRMLS_CC); zend_hash_move_forward_ex(Z_ARRVAL_PP(args), &iterator); + + phpdbg_xml(""); } if (is_variadic) { - phpdbg_write("]"); + phpdbg_out("]"); } + phpdbg_xml(""); } - phpdbg_write(")"); + phpdbg_out(")"); } void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */ @@ -171,36 +199,47 @@ void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */ int user_defined; if (limit < 0) { - phpdbg_error("Invalid backtrace size %d", limit); + phpdbg_error("backtrace", "type=\"minnum\"", "Invalid backtrace size %d", limit); + return; } - zend_fetch_debug_backtrace( - &zbacktrace, 0, 0, limit TSRMLS_CC); + phpdbg_try_access { + zend_fetch_debug_backtrace(&zbacktrace, 0, 0, limit TSRMLS_CC); + } phpdbg_catch_access { + phpdbg_error("signalsegv", "", "Couldn't fetch backtrace, invalid data source"); + return; + } phpdbg_end_try_access(); + + phpdbg_xml(""); zend_hash_internal_pointer_reset_ex(Z_ARRVAL(zbacktrace), &position); - zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), (void**)&tmp, &position); + zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), (void **) &tmp, &position); while (1) { - user_defined = zend_hash_find(Z_ARRVAL_PP(tmp), "file", sizeof("file"), (void **)&file); - zend_hash_find(Z_ARRVAL_PP(tmp), "line", sizeof("line"), (void **)&line); + user_defined = zend_hash_find(Z_ARRVAL_PP(tmp), "file", sizeof("file"), (void **) &file); + zend_hash_find(Z_ARRVAL_PP(tmp), "line", sizeof("line"), (void **) &line); zend_hash_move_forward_ex(Z_ARRVAL(zbacktrace), &position); - if (zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), - (void**)&tmp, &position) == FAILURE) { - phpdbg_write("frame #%d: {main} at %s:%ld", i, Z_STRVAL_PP(file), Z_LVAL_PP(line)); + if (zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), (void **) &tmp, &position) == FAILURE) { + phpdbg_write("frame", "id=\"%d\" symbol=\"{main}\" file=\"%s\" line=\"%d\"", "frame #%d: {main} at %s:%ld", i, Z_STRVAL_PP(file), Z_LVAL_PP(line)); break; } if (user_defined == SUCCESS) { - phpdbg_write("frame #%d: ", i++); + phpdbg_out("frame #%d: ", i); + phpdbg_xml(" "); + phpdbg_out(" => "); + phpdbg_xml(""); + zval_dtor(&zbacktrace); } /* }}} */ diff --git a/phpdbg_help.c b/phpdbg_help.c index 1e58dc69cad..652e1706942 100644 --- a/phpdbg_help.c +++ b/phpdbg_help.c @@ -22,6 +22,7 @@ #include "phpdbg.h" #include "phpdbg_help.h" #include "phpdbg_prompt.h" +#include "phpdbg_eol.h" #include "zend.h" ZEND_EXTERN_MODULE_GLOBALS(phpdbg); @@ -61,6 +62,11 @@ void pretty_print(char *text TSRMLS_DC) unsigned int last_blank_count = 0; /* printable char offset of last blank char */ unsigned int line_count = 0; /* number printable chars on current line */ + if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) { + phpdbg_xml("", text); + return; + } + /* First pass calculates a safe size for the pretty print version */ for (p = text; *p; p++) { if (UNEXPECTED(p[0] == '*') && p[1] == '*') { @@ -128,10 +134,10 @@ void pretty_print(char *text TSRMLS_DC) *q++ = '\0'; if ((q-new)>size) { - phpdbg_error("Output overrun of %lu bytes", ((q-new) - size)); + phpdbg_error("help", "overrun=\"%lu\"", "Output overrun of %lu bytes", ((q - new) - size)); } - phpdbg_write("%s\n", new); + phpdbg_out("%s\n", new); efree(new); } /* }}} */ @@ -201,7 +207,7 @@ static int get_command( return num_matches; -} /* }}} */ +} /* }}} */ PHPDBG_COMMAND(help) /* {{{ */ { @@ -231,7 +237,7 @@ PHPDBG_COMMAND(help) /* {{{ */ pretty_print(get_help("duplicate!" TSRMLS_CC) TSRMLS_CC); return SUCCESS; } else { - phpdbg_error("Internal help error, non-unique alias \"%c\"", param->str[0]); + phpdbg_error("help", "type=\"ambiguousalias\" alias=\"%s\"", "Internal help error, non-unique alias \"%c\"", param->str[0]); return FAILURE; } @@ -259,34 +265,41 @@ PHPDBG_HELP(aliases) /* {{{ */ int len; /* Print out aliases for all commands except help as this one comes last */ - phpdbg_writeln("Below are the aliased, short versions of all supported commands"); + phpdbg_writeln("help", "", "Below are the aliased, short versions of all supported commands"); + phpdbg_xml(""); for(c = phpdbg_prompt_commands; c->name; c++) { if (c->alias && c->alias != 'h') { - phpdbg_writeln(" %c %-20s %s", c->alias, c->name, c->tip); + phpdbg_writeln("command", "alias=\"%c\" name=\"%s\" tip=\"%s\"", " %c %-20s %s", c->alias, c->name, c->tip); if (c->subs) { len = 20 - 1 - c->name_len; for(c_sub = c->subs; c_sub->alias; c_sub++) { if (c_sub->alias) { - phpdbg_writeln(" %c %c %s %-*s %s", - c->alias, c_sub->alias, (char *)c->name, len, c_sub->name, c_sub->tip); + phpdbg_writeln("subcommand", "parent_alias=\"%c\" alias=\"%c\" parent=\"%s\" name=\"%-*s\" tip=\"%s\"", " %c %c %s %-*s %s", + c->alias, c_sub->alias, c->name, len, c_sub->name, c_sub->tip); } } } } } + phpdbg_xml(""); + /* Print out aliases for help as this one comes last, with the added text on how aliases are used */ get_command("h", 1, &c, phpdbg_prompt_commands TSRMLS_CC); - phpdbg_writeln(" %c %-20s %s\n", c->alias, c->name, c->tip); + phpdbg_writeln("aliasinfo", "alias=\"%c\" name=\"%s\" tip=\"%s\"", " %c %-20s %s\n", c->alias, c->name, c->tip); + + phpdbg_xml(""); len = 20 - 1 - c->name_len; for(c_sub = c->subs; c_sub->alias; c_sub++) { if (c_sub->alias) { - phpdbg_writeln(" %c %c %s %-*s %s", + phpdbg_writeln("alias", "parent_alias=\"%c\" alias=\"%c\" parent=\"%s\" name=\"%-*s\" tip=\"%s\"", " %c %c %s %-*s %s", c->alias, c_sub->alias, c->name, len, c_sub->name, c_sub->tip); } } + phpdbg_xml(""); + pretty_print(get_help("aliases!" TSRMLS_CC) TSRMLS_CC); return SUCCESS; } /* }}} */ @@ -307,7 +320,7 @@ PHPDBG_HELP(aliases) /* {{{ */ * Also note the convention that help text not directly referenceable as a help param * has a key ending in ! */ -#define CR "\n" +#define CR "\n" phpdbg_help_text_t phpdbg_help_text[] = { /******************************** General Help Topics ********************************/ @@ -362,7 +375,7 @@ phpdbg_help_text_t phpdbg_help_text[] = { " **-c** **-c**/my/php.ini Set php.ini file to load" CR " **-d** **-d**memory_limit=4G Set a php.ini directive" CR " **-n** Disable default php.ini" CR -" **-q** Supress welcome banner" CR +" **-q** Suppress welcome banner" CR " **-v** Enable oplog output" CR " **-s** Enable stepping" CR " **-b** Disable colour" CR @@ -375,6 +388,7 @@ phpdbg_help_text_t phpdbg_help_text[] = { " **-S** **-S**cli Override SAPI name, careful!" CR " **-l** **-l**4000 Setup remote console ports" CR " **-a** **-a**192.168.0.3 Setup remote console bind address" CR +" **-x** Enable xml output (instead of normal text output)" CR " **-V** Print version number" CR " **--** **--** arg1 arg2 Use to delimit phpdbg arguments and php $argv; append any $argv " "argument after it" CR CR @@ -386,9 +400,7 @@ phpdbg_help_text_t phpdbg_help_text[] = { "bind address using the **-a** option. If **-a** is specied without an argument, then phpdbg " "will bind to all available interfaces. You should be aware of the security implications of " "doing this, so measures should be taken to secure this service if bound to a publicly accessible " -"interface/port." CR CR - -"Specify both stdin and stdout with -lstdin/stdout; by default stdout is stdin * 2." +"interface/port." }, {"phpdbginit", CR @@ -545,7 +557,7 @@ phpdbg_help_text_t phpdbg_help_text[] = { " $P break ZEND_ADD" CR " $P b ZEND_ADD" CR -" Break on any occurence of the opcode ZEND_ADD" CR CR +" Break on any occurrence of the opcode ZEND_ADD" CR CR " $P break del 2" CR " $P b ~ 2" CR @@ -642,14 +654,16 @@ phpdbg_help_text_t phpdbg_help_text[] = { "Specific info commands are show below:" CR CR " **Target** **Alias** **Purpose**" CR -" **break** **b** show current breakpoints" CR -" **files** **F** show included files" CR -" **classes** **c** show loaded classes" CR -" **funcs** **f** show loaded classes" CR -" **error** **e** show last error" CR -" **vars** **v** show active variables" CR -" **literal** **l** show active literal constants" CR -" **memory** **m** show memory manager stats" +" **break** **b** show current breakpoints" CR +" **files** **F** show included files" CR +" **classes** **c** show loaded classes" CR +" **funcs** **f** show loaded functions" CR +" **error** **e** show last error" CR +" **constants** **d** show user-defined constants" CR +" **vars** **v** show active variables" CR +" **globals** **g** show superglobal variables" CR +" **literal** **l** show active literal constants" CR +" **memory** **m** show memory manager stats" }, // ******** same issue about breakpoints in called frames diff --git a/phpdbg_help.h b/phpdbg_help.h index 16a1e771e37..4a433fda6cf 100644 --- a/phpdbg_help.h +++ b/phpdbg_help.h @@ -35,9 +35,9 @@ PHPDBG_HELP(aliases); extern const phpdbg_command_t phpdbg_help_commands[]; #define phpdbg_help_header() \ - phpdbg_notice("Welcome to phpdbg, the interactive PHP debugger, v%s", PHPDBG_VERSION); + phpdbg_notice("version", "version=\"%s\"", "Welcome to phpdbg, the interactive PHP debugger, v%s", PHPDBG_VERSION); #define phpdbg_help_footer() \ - phpdbg_notice("Please report bugs to <%s>", PHPDBG_ISSUES); + phpdbg_notice("issues", "url=\"%s\"", "Please report bugs to <%s>", PHPDBG_ISSUES); typedef struct _phpdbg_help_text_t { char *key; diff --git a/phpdbg_info.c b/phpdbg_info.c index 97f88bfa1ec..4774fa5a9e7 100644 --- a/phpdbg_info.c +++ b/phpdbg_info.c @@ -27,18 +27,20 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg); -#define PHPDBG_INFO_COMMAND_D(f, h, a, m, l, s) \ - PHPDBG_COMMAND_D_EXP(f, h, a, m, l, s, &phpdbg_prompt_commands[14]) +#define PHPDBG_INFO_COMMAND_D(f, h, a, m, l, s, flags) \ + PHPDBG_COMMAND_D_EXP(f, h, a, m, l, s, &phpdbg_prompt_commands[14], flags) const phpdbg_command_t phpdbg_info_commands[] = { - PHPDBG_INFO_COMMAND_D(break, "show breakpoints", 'b', info_break, NULL, 0), - PHPDBG_INFO_COMMAND_D(files, "show included files", 'F', info_files, NULL, 0), - PHPDBG_INFO_COMMAND_D(classes, "show loaded classes", 'c', info_classes, NULL, 0), - PHPDBG_INFO_COMMAND_D(funcs, "show loaded classes", 'f', info_funcs, NULL, 0), - PHPDBG_INFO_COMMAND_D(error, "show last error", 'e', info_error, NULL, 0), - PHPDBG_INFO_COMMAND_D(vars, "show active variables", 'v', info_vars, NULL, 0), - PHPDBG_INFO_COMMAND_D(literal, "show active literal constants", 'l', info_literal, NULL, 0), - PHPDBG_INFO_COMMAND_D(memory, "show memory manager stats", 'm', info_memory, NULL, 0), + PHPDBG_INFO_COMMAND_D(break, "show breakpoints", 'b', info_break, NULL, 0, PHPDBG_ASYNC_SAFE), + PHPDBG_INFO_COMMAND_D(files, "show included files", 'F', info_files, NULL, 0, PHPDBG_ASYNC_SAFE), + PHPDBG_INFO_COMMAND_D(classes, "show loaded classes", 'c', info_classes, NULL, 0, PHPDBG_ASYNC_SAFE), + PHPDBG_INFO_COMMAND_D(funcs, "show loaded classes", 'f', info_funcs, NULL, 0, PHPDBG_ASYNC_SAFE), + PHPDBG_INFO_COMMAND_D(error, "show last error", 'e', info_error, NULL, 0, PHPDBG_ASYNC_SAFE), + PHPDBG_INFO_COMMAND_D(constants, "show user defined constants", 'd', info_constants, NULL, 0, PHPDBG_ASYNC_SAFE), + PHPDBG_INFO_COMMAND_D(vars, "show active variables", 'v', info_vars, NULL, 0, PHPDBG_ASYNC_SAFE), + PHPDBG_INFO_COMMAND_D(globals, "show superglobals", 'g', info_globals, NULL, 0, PHPDBG_ASYNC_SAFE), + PHPDBG_INFO_COMMAND_D(literal, "show active literal constants", 'l', info_literal, NULL, 0, PHPDBG_ASYNC_SAFE), + PHPDBG_INFO_COMMAND_D(memory, "show memory manager stats", 'm', info_memory, NULL, 0, PHPDBG_ASYNC_SAFE), PHPDBG_END_COMMAND }; @@ -62,15 +64,21 @@ PHPDBG_INFO(files) /* {{{ */ HashPosition pos; char *fname; - phpdbg_notice("Included files: %d", - zend_hash_num_elements(&EG(included_files))); + phpdbg_try_access { + phpdbg_notice("includedfilecount", "num=\"%d\"", "Included files: %d", zend_hash_num_elements(&EG(included_files))); + } phpdbg_catch_access { + phpdbg_error("signalsegv", "", "Could not fetch included file count, invalid data source"); + } phpdbg_end_try_access(); - zend_hash_internal_pointer_reset_ex(&EG(included_files), &pos); - while (zend_hash_get_current_key_ex(&EG(included_files), &fname, - NULL, NULL, 0, &pos) == HASH_KEY_IS_STRING) { - phpdbg_writeln("File: %s", fname); - zend_hash_move_forward_ex(&EG(included_files), &pos); - } + phpdbg_try_access { + zend_hash_internal_pointer_reset_ex(&EG(included_files), &pos); + while (zend_hash_get_current_key_ex(&EG(included_files), &fname, NULL, NULL, 0, &pos) == HASH_KEY_IS_STRING) { + phpdbg_writeln("includedfile", "name=\"%s\"", "File: %s", fname); + zend_hash_move_forward_ex(&EG(included_files), &pos); + } + } phpdbg_catch_access { + phpdbg_error("signalsegv", "", "Could not fetch file name, invalid data source, aborting included file listing"); + } phpdbg_end_try_access(); return SUCCESS; } /* }}} */ @@ -78,23 +86,98 @@ PHPDBG_INFO(files) /* {{{ */ PHPDBG_INFO(error) /* {{{ */ { if (PG(last_error_message)) { - phpdbg_writeln("Last error: %s at %s line %d", - PG(last_error_message), PG(last_error_file), PG(last_error_lineno)); + phpdbg_try_access { + phpdbg_writeln("lasterror", "error=\"%s\" file=\"%s\" line=\"%d\"", "Last error: %s at %s line %d", PG(last_error_message), PG(last_error_file), PG(last_error_lineno)); + } phpdbg_catch_access { + phpdbg_notice("lasterror", "error=\"\"", "No error found!"); + } phpdbg_end_try_access(); } else { - phpdbg_notice("No error found!"); + phpdbg_notice("lasterror", "error=\"\"", "No error found!"); } return SUCCESS; } /* }}} */ -PHPDBG_INFO(vars) /* {{{ */ +PHPDBG_INFO(constants) /* {{{ */ { - HashTable vars; + HashPosition pos; + HashTable consts; + zend_constant *data; + + zend_hash_init(&consts, 8, NULL, NULL, 0); + + if (EG(zend_constants)) { + phpdbg_try_access { + zend_hash_internal_pointer_reset_ex(EG(zend_constants), &pos); + while (zend_hash_get_current_data_ex(EG(zend_constants), (void **) &data, &pos) == SUCCESS) { + if (data->module_number == PHP_USER_CONSTANT) { + zend_hash_update(&consts, data->name, data->name_len, (void **) &data, sizeof(zend_constant *), NULL); + } + zend_hash_move_forward_ex(EG(zend_constants), &pos); + } + } phpdbg_catch_access { + phpdbg_error("signalsegv", "", "Cannot fetch all the constants, invalid data source"); + } phpdbg_end_try_access(); + } + + phpdbg_notice("constantinfo", "num=\"%d\"", "User-defined constants (%d)", zend_hash_num_elements(&consts)); + + if (zend_hash_num_elements(&consts)) { + phpdbg_out("Address Refs Type Constant\n"); + for (zend_hash_internal_pointer_reset_ex(&consts, &pos); + zend_hash_get_current_data_ex(&consts, (void **) &data, &pos) == SUCCESS; + zend_hash_move_forward_ex(&consts, &pos)) { + data = *(zend_constant **) data; + +#define VARIABLEINFO(attrs, msg, ...) phpdbg_writeln("constant", "address=\"%p\" refcount=\"%d\" type=\"%s\" name=\"%.*s\" " attrs, "%-18p %-7d %-9s %.*s" msg, &data->value, Z_REFCOUNT(data->value), zend_zval_type_name(&data->value), data->name_len - 1, data->name, ##__VA_ARGS__) + + switch (Z_TYPE(data->value)) { + case IS_STRING: + phpdbg_try_access { + VARIABLEINFO("length=\"%d\" value=\"%.*s\"", "\nstring (%d) \"%.*s%s\"", Z_STRLEN(data->value), Z_STRLEN(data->value) < 255 ? Z_STRLEN(data->value) : 255, Z_STRVAL(data->value), Z_STRLEN(data->value) > 255 ? "..." : ""); + } phpdbg_catch_access { + VARIABLEINFO("", ""); + } phpdbg_end_try_access(); + break; + case IS_BOOL: + VARIABLEINFO("value=\"%s\"", "\nbool (%s)", Z_LVAL(data->value) ? "true" : "false"); + break; + case IS_LONG: + VARIABLEINFO("value=\"%ld\"", "\nint (%ld)", Z_LVAL(data->value)); + break; + case IS_DOUBLE: + VARIABLEINFO("value=\"%lf\"", "\ndouble (%lf)", Z_DVAL(data->value)); + break; + default: + VARIABLEINFO("", ""); + +#undef VARIABLEINFO + } + } + } + + return SUCCESS; +} /* }}} */ + +static int phpdbg_arm_auto_global(zend_auto_global *auto_global TSRMLS_DC) { + if (auto_global->armed) { + if (PHPDBG_G(flags) & PHPDBG_IN_SIGNAL_HANDLER) { + phpdbg_notice("variableinfo", "unreachable=\"%.*s\"", "Cannot show information about superglobal variable %.*s", auto_global->name_len, auto_global->name); + } else { + auto_global->armed = auto_global->auto_global_callback(auto_global->name, auto_global->name_len TSRMLS_CC); + } + } + + return 0; +} + +static int phpdbg_print_symbols(zend_bool show_globals TSRMLS_DC) { + HashTable vars, *symtable; HashPosition pos; char *var; zval **data; if (!EG(active_op_array)) { - phpdbg_error("No active op array!"); + phpdbg_error("inactive", "type=\"op_array\"", "No active op array!"); return SUCCESS; } @@ -102,100 +185,112 @@ PHPDBG_INFO(vars) /* {{{ */ zend_rebuild_symbol_table(TSRMLS_C); if (!EG(active_symbol_table)) { - phpdbg_error("No active symbol table!"); + phpdbg_error("inactive", "type=\"symbol_table\"", "No active symbol table!"); return SUCCESS; } } - zend_hash_init(&vars, 8, NULL, NULL, 0); - zend_hash_internal_pointer_reset_ex(EG(active_symbol_table), &pos); - while (zend_hash_get_current_key_ex(EG(active_symbol_table), &var, - NULL, NULL, 0, &pos) == HASH_KEY_IS_STRING) { - zend_hash_get_current_data_ex(EG(active_symbol_table), (void **)&data, &pos); - if (*var != '_') { - zend_hash_update( - &vars, var, strlen(var)+1, (void**)data, sizeof(zval*), NULL); - } - zend_hash_move_forward_ex(EG(active_symbol_table), &pos); + if (show_globals) { + /* that array should only be manipulated during init, so safe for async access during execution */ + zend_hash_apply(CG(auto_globals), (apply_func_t) phpdbg_arm_auto_global TSRMLS_CC); + symtable = &EG(symbol_table); + } else { + symtable = EG(active_symbol_table); } - { + zend_hash_init(&vars, 8, NULL, NULL, 0); + + phpdbg_try_access { + zend_hash_internal_pointer_reset_ex(symtable, &pos); + while (zend_hash_get_current_key_ex(symtable, &var, NULL, NULL, 0, &pos) == HASH_KEY_IS_STRING) { + zend_hash_get_current_data_ex(symtable, (void **)&data, &pos); + if (zend_is_auto_global(var, strlen(var) TSRMLS_CC) ^ !show_globals) { + zend_hash_update(&vars, var, strlen(var)+1, (void**)data, sizeof(zval*), NULL); + } + zend_hash_move_forward_ex(symtable, &pos); + } + } phpdbg_catch_access { + phpdbg_error("signalsegv", "", "Cannot fetch all data from the symbol table, invalid data source"); + } phpdbg_end_try_access(); + + if (show_globals) { + phpdbg_notice("variableinfo", "num=\"%d\"", "Superglobal variables (%d)", zend_hash_num_elements(&vars)); + } else { zend_op_array *ops = EG(active_op_array); - + if (ops->function_name) { if (ops->scope) { - phpdbg_notice( - "Variables in %s::%s() (%d)", ops->scope->name, ops->function_name, zend_hash_num_elements(&vars)); + phpdbg_notice("variableinfo", "method=\"%s::%s\" num=\"%d\"", "Variables in %s::%s() (%d)", ops->scope->name, ops->function_name, zend_hash_num_elements(&vars)); } else { - phpdbg_notice( - "Variables in %s() (%d)", ops->function_name, zend_hash_num_elements(&vars)); + phpdbg_notice("variableinfo", "function=\"%s\" num=\"%d\"", "Variables in %s() (%d)", ops->function_name, zend_hash_num_elements(&vars)); } } else { if (ops->filename) { - phpdbg_notice( - "Variables in %s (%d)", ops->filename, zend_hash_num_elements(&vars)); + phpdbg_notice("variableinfo", "file=\"%s\" num=\"%d\"", "Variables in %s (%d)", ops->filename, zend_hash_num_elements(&vars)); } else { - phpdbg_notice( - "Variables @ %p (%d)", ops, zend_hash_num_elements(&vars)); + phpdbg_notice("variableinfo", "opline=\"%p\" num=\"%d\"", "Variables @ %p (%d)", ops, zend_hash_num_elements(&vars)); } } } if (zend_hash_num_elements(&vars)) { - phpdbg_writeln("Address\t\tRefs\tType\t\tVariable"); + phpdbg_out("Address Refs Type Variable\n"); for (zend_hash_internal_pointer_reset_ex(&vars, &pos); - zend_hash_get_current_data_ex(&vars, (void**) &data, &pos) == SUCCESS; - zend_hash_move_forward_ex(&vars, &pos)) { + zend_hash_get_current_data_ex(&vars, (void**) &data, &pos) == SUCCESS; + zend_hash_move_forward_ex(&vars, &pos)) { char *var; + zend_bool invalid_data = 1; zend_hash_get_current_key_ex(&vars, &var, NULL, NULL, 0, &pos); - if (*data) { - phpdbg_write( - "%p\t%d\t", - *data, - Z_REFCOUNT_PP(data)); + phpdbg_try_access { + if (!(invalid_data = !*data)) { +#define VARIABLEINFO(attrs, msg, ...) phpdbg_writeln("variable", "address=\"%p\" refcount=\"%d\" type=\"%s\" refstatus=\"%s\" name=\"%s\" " attrs, "%-18p %-7d %-9s %s$%s" msg, *data, Z_REFCOUNT_PP(data), zend_zval_type_name(*data), Z_ISREF_PP(data) ? "&": "", var, ##__VA_ARGS__) - switch (Z_TYPE_PP(data)) { - case IS_STRING: phpdbg_write("(string)\t"); break; - case IS_LONG: phpdbg_write("(integer)\t"); break; - case IS_DOUBLE: phpdbg_write("(float)\t"); break; - case IS_RESOURCE: phpdbg_write("(resource)\t"); break; - case IS_ARRAY: phpdbg_write("(array)\t"); break; - case IS_OBJECT: phpdbg_write("(object)\t"); break; - case IS_NULL: phpdbg_write("(null)\t"); break; - } - - if (Z_TYPE_PP(data) == IS_RESOURCE) { - int type; - - phpdbg_writeln( - "%s$%s", Z_ISREF_PP(data) ? "&": "", var); - if (zend_list_find(Z_RESVAL_PP(data), &type)) { - phpdbg_write( - "|-------(typeof)------> (%s)", - zend_rsrc_list_get_rsrc_type(type TSRMLS_CC)); - } else { - phpdbg_write( - "|-------(typeof)------> (unknown)"); + switch (Z_TYPE_PP(data)) { + case IS_RESOURCE: + phpdbg_try_access { + int type; + VARIABLEINFO("type=\"%s\"", "\n|-------(typeof)------> (%s)\n", zend_list_find(Z_RESVAL_PP(data), &type) ? zend_rsrc_list_get_rsrc_type(type TSRMLS_CC) : "unknown"); + } phpdbg_catch_access { + VARIABLEINFO("type=\"unknown\"", "\n|-------(typeof)------> (unknown)\n"); + } phpdbg_end_try_access(); + break; + case IS_OBJECT: + phpdbg_try_access { + VARIABLEINFO("instanceof=\"%s\"", "\n|-----(instanceof)----> (%s)\n", Z_OBJCE_PP(data)->name); + } phpdbg_catch_access { + VARIABLEINFO("instanceof=\"%s\"", "\n|-----(instanceof)----> (unknown)\n"); + } phpdbg_end_try_access(); + break; + case IS_STRING: + phpdbg_try_access { + VARIABLEINFO("length=\"%d\" value=\"%.*s\"", "\nstring (%d) \"%.*s%s\"", Z_STRLEN_PP(data), Z_STRLEN_PP(data) < 255 ? Z_STRLEN_PP(data) : 255, Z_STRVAL_PP(data), Z_STRLEN_PP(data) > 255 ? "..." : ""); + } phpdbg_catch_access { + VARIABLEINFO("", ""); + } phpdbg_end_try_access(); + break; + case IS_BOOL: + VARIABLEINFO("value=\"%s\"", "\nbool (%s)", Z_LVAL_PP(data) ? "true" : "false"); + break; + case IS_LONG: + VARIABLEINFO("value=\"%ld\"", "\nint (%ld)", Z_LVAL_PP(data)); + break; + case IS_DOUBLE: + VARIABLEINFO("value=\"%lf\"", "\ndouble (%lf)", Z_DVAL_PP(data)); + break; + default: + VARIABLEINFO("", ""); } - phpdbg_writeln(EMPTY); - } else if (Z_TYPE_PP(data) == IS_OBJECT) { - phpdbg_writeln( - "%s$%s", Z_ISREF_PP(data) ? "&": "", var); - phpdbg_write( - "|-----(instanceof)----> (%s)", Z_OBJCE_PP(data)->name); - phpdbg_writeln(EMPTY); - } else { - phpdbg_write( - "%s$%s", Z_ISREF_PP(data) ? "&": "", var); } - } else { - phpdbg_write( - "n/a\tn/a\tn/a\t$%s", var); + +#undef VARIABLEINFO + } phpdbg_end_try_access(); + + if (invalid_data) { + phpdbg_writeln("variable", "name=\"%s\"", "n/a\tn/a\tn/a\t$%s", var); } - phpdbg_writeln(EMPTY); } } @@ -204,42 +299,47 @@ PHPDBG_INFO(vars) /* {{{ */ return SUCCESS; } /* }}} */ +PHPDBG_INFO(vars) /* {{{ */ +{ + return phpdbg_print_symbols(0 TSRMLS_CC); +} + +PHPDBG_INFO(globals) /* {{{ */ +{ + return phpdbg_print_symbols(1 TSRMLS_CC); +} + PHPDBG_INFO(literal) /* {{{ */ { + /* literals are assumed to not be manipulated during executing of their op_array and as such async safe */ if ((EG(in_execution) && EG(active_op_array)) || PHPDBG_G(ops)) { zend_op_array *ops = EG(active_op_array) ? EG(active_op_array) : PHPDBG_G(ops); int literal = 0, count = ops->last_literal-1; if (ops->function_name) { if (ops->scope) { - phpdbg_notice( - "Literal Constants in %s::%s() (%d)", ops->scope->name, ops->function_name, count); + phpdbg_notice("literalinfo", "method=\"%s::%s\" num=\"%d\"", "Literal Constants in %s::%s() (%d)", ops->scope->name, ops->function_name, count); } else { - phpdbg_notice( - "Literal Constants in %s() (%d)", ops->function_name, count); + phpdbg_notice("literalinfo", "function=\"%s\" num=\"%d\"", "Literal Constants in %s() (%d)", ops->function_name, count); } } else { if (ops->filename) { - phpdbg_notice( - "Literal Constants in %s (%d)", ops->filename, count); + phpdbg_notice("literalinfo", "file=\"%s\" num=\"%d\"", "Literal Constants in %s (%d)", ops->filename, count); } else { - phpdbg_notice( - "Literal Constants @ %p (%d)", ops, count); + phpdbg_notice("literalinfo", "opline=\"%p\" num=\"%d\"", "Literal Constants @ %p (%d)", ops, count); } } while (literal < ops->last_literal) { if (Z_TYPE(ops->literals[literal].constant) != IS_NULL) { - phpdbg_write("|-------- C%u -------> [", literal); - zend_print_zval( - &ops->literals[literal].constant, 0); - phpdbg_write("]"); - phpdbg_writeln(EMPTY); + phpdbg_write("literal", "id=\"%u\"", "|-------- C%u -------> [", literal); + zend_print_zval(&ops->literals[literal].constant, 0); + phpdbg_out("]\n"); } literal++; } } else { - phpdbg_error("Not executing!"); + phpdbg_error("inactive", "type=\"execution\"", "Not executing!"); } return SUCCESS; @@ -247,28 +347,40 @@ PHPDBG_INFO(literal) /* {{{ */ PHPDBG_INFO(memory) /* {{{ */ { - if (is_zend_mm(TSRMLS_C)) { - phpdbg_notice("Memory Manager Information"); - phpdbg_notice("Current"); - phpdbg_writeln("|-------> Used:\t%.3f kB", - (float) (zend_memory_usage(0 TSRMLS_CC)/1024)); - phpdbg_writeln("|-------> Real:\t%.3f kB", - (float) (zend_memory_usage(1 TSRMLS_CC)/1024)); - phpdbg_notice("Peak"); - phpdbg_writeln("|-------> Used:\t%.3f kB", - (float) (zend_memory_peak_usage(0 TSRMLS_CC)/1024)); - phpdbg_writeln("|-------> Real:\t%.3f kB", - (float) (zend_memory_peak_usage(1 TSRMLS_CC)/1024)); + size_t used, real, peak_used, peak_real; + zend_mm_heap *heap; + zend_bool is_mm; + + if (PHPDBG_G(flags) & PHPDBG_IN_SIGNAL_HANDLER) { + heap = zend_mm_set_heap(phpdbg_original_heap_sigsafe_mem(TSRMLS_C) TSRMLS_CC); + } + if ((is_mm = is_zend_mm(TSRMLS_C))) { + used = zend_memory_usage(0 TSRMLS_CC); + real = zend_memory_usage(1 TSRMLS_CC); + peak_used = zend_memory_peak_usage(0 TSRMLS_CC); + peak_real = zend_memory_peak_usage(1 TSRMLS_CC); + } + if (PHPDBG_G(flags) & PHPDBG_IN_SIGNAL_HANDLER) { + zend_mm_set_heap(heap TSRMLS_CC); + } + + if (is_mm) { + phpdbg_notice("meminfo", "", "Memory Manager Information"); + phpdbg_notice("current", "", "Current"); + phpdbg_writeln("used", "mem=\"%.3f\"", "|-------> Used:\t%.3f kB", (float) (used / 1024)); + phpdbg_writeln("real", "mem=\"%.3f\"", "|-------> Real:\t%.3f kB", (float) (real / 1024)); + phpdbg_notice("peak", "", "Peak"); + phpdbg_writeln("used", "mem=\"%.3f\"", "|-------> Used:\t%.3f kB", (float) (peak_used / 1024)); + phpdbg_writeln("real", "mem=\"%.3f\"", "|-------> Real:\t%.3f kB", (float) (peak_real / 1024)); } else { - phpdbg_error("Memory Manager Disabled!"); + phpdbg_error("inactive", "type=\"memory_manager\"", "Memory Manager Disabled!"); } return SUCCESS; } /* }}} */ static inline void phpdbg_print_class_name(zend_class_entry **ce TSRMLS_DC) /* {{{ */ { - phpdbg_write( - "%s %s %s (%d)", + phpdbg_writeln("class", "type=\"%s\" flags=\"%s\" name=\"%s\" methodcount=\"%d\"", "%s %s %s (%d)", ((*ce)->type == ZEND_USER_CLASS) ? "User" : "Internal", ((*ce)->ce_flags & ZEND_ACC_INTERFACE) ? @@ -287,44 +399,44 @@ PHPDBG_INFO(classes) /* {{{ */ zend_hash_init(&classes, 8, NULL, NULL, 0); - for (zend_hash_internal_pointer_reset_ex(EG(class_table), &position); - zend_hash_get_current_data_ex(EG(class_table), (void**)&ce, &position) == SUCCESS; - zend_hash_move_forward_ex(EG(class_table), &position)) { - - if ((*ce)->type == ZEND_USER_CLASS) { - zend_hash_next_index_insert( - &classes, ce, sizeof(ce), NULL); + phpdbg_try_access { + for (zend_hash_internal_pointer_reset_ex(EG(class_table), &position); + zend_hash_get_current_data_ex(EG(class_table), (void**)&ce, &position) == SUCCESS; + zend_hash_move_forward_ex(EG(class_table), &position)) { + if ((*ce)->type == ZEND_USER_CLASS) { + zend_hash_next_index_insert(&classes, ce, sizeof(ce), NULL); + } } - } + } phpdbg_catch_access { + phpdbg_notice("signalsegv", "", "Not all classes could be fetched, possibly invalid data source"); + } phpdbg_end_try_access(); - phpdbg_notice("User Classes (%d)", - zend_hash_num_elements(&classes)); + phpdbg_notice("classinfo", "num=\"%d\"", "User Classes (%d)", zend_hash_num_elements(&classes)); + /* once added, assume that classes are stable... until shutdown. */ for (zend_hash_internal_pointer_reset_ex(&classes, &position); - zend_hash_get_current_data_ex(&classes, (void**)&ce, &position) == SUCCESS; - zend_hash_move_forward_ex(&classes, &position)) { + zend_hash_get_current_data_ex(&classes, (void**)&ce, &position) == SUCCESS; + zend_hash_move_forward_ex(&classes, &position)) { phpdbg_print_class_name(ce TSRMLS_CC); - phpdbg_writeln(EMPTY); if ((*ce)->parent) { - zend_class_entry *pce = (*ce)->parent; + zend_class_entry *pce; + + phpdbg_xml(""); + pce = (*ce)->parent; do { - phpdbg_write("|-------- "); + phpdbg_out("|-------- "); phpdbg_print_class_name(&pce TSRMLS_CC); - phpdbg_writeln(EMPTY); } while ((pce = pce->parent)); + phpdbg_xml(""); } if ((*ce)->info.user.filename) { - phpdbg_writeln( - "|---- in %s on line %u", - (*ce)->info.user.filename, - (*ce)->info.user.line_start); + phpdbg_writeln("classsource", "file=\"%s\" line=\"%u\"", "|---- in %s on line %u", (*ce)->info.user.filename, (*ce)->info.user.line_start); } else { - phpdbg_writeln("|---- no source code"); + phpdbg_writeln("classsource", "", "|---- no source code"); } - phpdbg_writeln(EMPTY); } zend_hash_destroy(&classes); @@ -340,29 +452,34 @@ PHPDBG_INFO(funcs) /* {{{ */ zend_hash_init(&functions, 8, NULL, NULL, 0); - for (zend_hash_internal_pointer_reset_ex(EG(function_table), &position); - zend_hash_get_current_data_ex(EG(function_table), (void**)&zf, &position) == SUCCESS; - zend_hash_move_forward_ex(EG(function_table), &position)) { - - if (zf->type == ZEND_USER_FUNCTION) { - zend_hash_next_index_insert( - &functions, (void**) &zf, sizeof(zend_function), NULL); + phpdbg_try_access { + for (zend_hash_internal_pointer_reset_ex(EG(function_table), &position); + zend_hash_get_current_data_ex(EG(function_table), (void**)&zf, &position) == SUCCESS; + zend_hash_move_forward_ex(EG(function_table), &position)) { + if (zf->type == ZEND_USER_FUNCTION) { + zend_hash_next_index_insert(&functions, (void**) &zf, sizeof(zend_function), NULL); + } } - } + } phpdbg_catch_access { + phpdbg_notice("signalsegv", "", "Not all functions could be fetched, possibly invalid data source"); + } phpdbg_end_try_access(); - phpdbg_notice("User Functions (%d)", - zend_hash_num_elements(&functions)); + phpdbg_notice("functioninfo", "num=\"%d\"", "User Functions (%d)", zend_hash_num_elements(&functions)); for (zend_hash_internal_pointer_reset_ex(&functions, &position); zend_hash_get_current_data_ex(&functions, (void**)&pzf, &position) == SUCCESS; zend_hash_move_forward_ex(&functions, &position)) { zend_op_array *op_array = &((*pzf)->op_array); - phpdbg_writeln( - "|-------- %s in %s on line %d", - op_array->function_name ? op_array->function_name : "{main}", - op_array->filename ? op_array->filename : "(no source code)", - op_array->line_start); + phpdbg_write("function", "name=\"%s\"", "|-------- %s", op_array->function_name ? op_array->function_name : "{main}"); + + if (op_array->filename) { + phpdbg_writeln("functionsource", "file=\"%s\" line=\"%d\"", " in %s on line %d", + op_array->filename, + op_array->line_start); + } else { + phpdbg_writeln("functionsource", "", " (no source code)"); + } } zend_hash_destroy(&functions); diff --git a/phpdbg_info.h b/phpdbg_info.h index c36e6bebd65..aac9fa3ab3b 100644 --- a/phpdbg_info.h +++ b/phpdbg_info.h @@ -30,7 +30,9 @@ PHPDBG_INFO(break); PHPDBG_INFO(classes); PHPDBG_INFO(funcs); PHPDBG_INFO(error); +PHPDBG_INFO(constants); PHPDBG_INFO(vars); +PHPDBG_INFO(globals); PHPDBG_INFO(literal); PHPDBG_INFO(memory); diff --git a/phpdbg_io.c b/phpdbg_io.c new file mode 100644 index 00000000000..97f0356285c --- /dev/null +++ b/phpdbg_io.c @@ -0,0 +1,272 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Anatol Belski | + +----------------------------------------------------------------------+ +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "phpdbg_io.h" + +#ifdef PHP_WIN32 +#undef UNICODE +#include "win32/inet.h" +#include +#include +#include +#include "win32/sockets.h" + +#else + +#if HAVE_SYS_TYPES_H +#include +#endif +#include +#include +#if HAVE_ARPA_INET_H +#include +#endif +#include +#include +#include +#endif + +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); + +PHPDBG_API int phpdbg_consume_bytes(int sock, char *ptr, int len, int tmo TSRMLS_DC) { + int got_now, i = len, j; + char *p = ptr; +#ifndef PHP_WIN32 + struct pollfd pfd; + + if (tmo < 0) goto recv_once; + pfd.fd = sock; + pfd.events = POLLIN; + + j = poll(&pfd, 1, tmo); + + if (j == 0) { +#else + struct fd_set readfds; + struct timeval ttmo; + + if (tmo < 0) goto recv_once; + FD_ZERO(&readfds); + FD_SET(sock, &readfds); + + ttmo.tv_sec = 0; + ttmo.tv_usec = tmo*1000; + + j = select(0, &readfds, NULL, NULL, &ttmo); + + if (j <= 0) { +#endif + return -1; + } + +recv_once: + while(i > 0) { + if (tmo < 0) { + /* There's something to read. Read what's available and proceed + disregarding whether len could be exhausted or not.*/ + int can_read = recv(sock, p, i, MSG_PEEK); +#ifndef _WIN32 + if (can_read == -1 && errno == EINTR) { + continue; + } +#endif + i = can_read; + } + +#ifdef _WIN32 + got_now = recv(sock, p, i, 0); +#else + do { + got_now = recv(sock, p, i, 0); + } while (got_now == -1 && errno == EINTR); +#endif + + if (got_now == -1) { + write(PHPDBG_G(io)[PHPDBG_STDERR].fd, ZEND_STRL("Read operation timed out!\n")); + return -1; + } + i -= got_now; + p += got_now; + } + + return p - ptr; +} + +PHPDBG_API int phpdbg_send_bytes(int sock, const char *ptr, int len) { + int sent, i = len; + const char *p = ptr; +/* XXX poll/select needed here? */ + while(i > 0) { + sent = send(sock, p, i, 0); + if (sent == -1) { + return -1; + } + i -= sent; + p += sent; + } + + return len; +} + + +PHPDBG_API int phpdbg_mixed_read(int sock, char *ptr, int len, int tmo TSRMLS_DC) { + if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) { + return phpdbg_consume_bytes(sock, ptr, len, tmo TSRMLS_CC); + } + + return read(sock, ptr, len); +} + + +PHPDBG_API int phpdbg_mixed_write(int sock, const char *ptr, int len TSRMLS_DC) { + if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) { + return phpdbg_send_bytes(sock, ptr, len); + } + + return write(sock, ptr, len); +} + + +PHPDBG_API int phpdbg_open_socket(const char *interface, unsigned short port TSRMLS_DC) { + struct addrinfo res; + int fd = phpdbg_create_listenable_socket(interface, port, &res TSRMLS_CC); + + if (fd == -1) { + return -1; + } + + if (bind(fd, res.ai_addr, res.ai_addrlen) == -1) { + phpdbg_close_socket(fd); + return -4; + } + + listen(fd, 5); + + return fd; +} + + +PHPDBG_API int phpdbg_create_listenable_socket(const char *addr, unsigned short port, struct addrinfo *addr_res TSRMLS_DC) { + int sock = -1, rc; + int reuse = 1; + struct in6_addr serveraddr; + struct addrinfo hints, *res = NULL; + char port_buf[8]; + int8_t any_addr = *addr == '*'; + + do { + memset(&hints, 0, sizeof hints); + if (any_addr) { + hints.ai_flags = AI_PASSIVE; + } else { + hints.ai_flags = AI_NUMERICSERV; + } + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + + rc = inet_pton(AF_INET, addr, &serveraddr); + if (1 == rc) { + hints.ai_family = AF_INET; + if (!any_addr) { + hints.ai_flags |= AI_NUMERICHOST; + } + } else { + rc = inet_pton(AF_INET6, addr, &serveraddr); + if (1 == rc) { + hints.ai_family = AF_INET6; + if (!any_addr) { + hints.ai_flags |= AI_NUMERICHOST; + } + } else { + /* XXX get host by name ??? */ + } + } + + snprintf(port_buf, 7, "%u", port); + if (!any_addr) { + rc = getaddrinfo(addr, port_buf, &hints, &res); + } else { + rc = getaddrinfo(NULL, port_buf, &hints, &res); + } + + if (0 != rc) { +#ifndef PHP_WIN32 + if (rc == EAI_SYSTEM) { + char buf[128]; + int wrote; + + wrote = snprintf(buf, 128, "Could not translate address '%s'", addr); + buf[wrote] = '\0'; + write(PHPDBG_G(io)[PHPDBG_STDERR].fd, buf, strlen(buf)); + + return sock; + } else { +#endif + char buf[256]; + int wrote; + + wrote = snprintf(buf, 256, "Host '%s' not found. %s", addr, estrdup(gai_strerror(rc))); + buf[wrote] = '\0'; + write(PHPDBG_G(io)[PHPDBG_STDERR].fd, buf, strlen(buf)); + + return sock; +#ifndef PHP_WIN32 + } +#endif + return sock; + } + + if((sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) == -1) { + char buf[128]; + int wrote; + + wrote = sprintf(buf, "Unable to create socket"); + buf[wrote] = '\0'; + write(PHPDBG_G(io)[PHPDBG_STDERR].fd, buf, strlen(buf)); + + return sock; + } + + if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*) &reuse, sizeof(reuse)) == -1) { + phpdbg_close_socket(sock); + return sock; + } + + + } while (0); + + *addr_res = *res; + + return sock; +} + +PHPDBG_API void phpdbg_close_socket(int sock) { + if (socket >= 0) { +#ifdef _WIN32 + closesocket(sock); +#else + shutdown(sock, SHUT_RDWR); + close(sock); +#endif + } +} + diff --git a/phpdbg_io.h b/phpdbg_io.h new file mode 100644 index 00000000000..3ac8f4112d0 --- /dev/null +++ b/phpdbg_io.h @@ -0,0 +1,34 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Anatol Belski | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHPDBG_IO_H +#define PHPDBG_IO_H + +#include "phpdbg.h" + +PHPDBG_API int phpdbg_consume_bytes(int sock, char *ptr, int len, int tmo TSRMLS_DC); +PHPDBG_API int phpdbg_send_bytes(int sock, const char *ptr, int len); +PHPDBG_API int phpdbg_mixed_read(int sock, char *ptr, int len, int tmo TSRMLS_DC); +PHPDBG_API int phpdbg_mixed_write(int sock, const char *ptr, int len TSRMLS_DC); + +PHPDBG_API int phpdbg_create_listenable_socket(const char *addr, unsigned short port, struct addrinfo *res TSRMLS_DC); +PHPDBG_API int phpdbg_open_socket(const char *interface, unsigned short port TSRMLS_DC); +PHPDBG_API void phpdbg_close_socket(int sock); + +#endif /* PHPDBG_IO_H */ + diff --git a/phpdbg_lexer.c b/phpdbg_lexer.c index 3092dc396dd..90f3a449daa 100644 --- a/phpdbg_lexer.c +++ b/phpdbg_lexer.c @@ -1,5 +1,5 @@ /* Generated by re2c 0.13.5 */ -#line 1 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" +#line 1 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" /* * phpdbg_lexer.l */ @@ -23,8 +23,9 @@ #define YYFILL(n) #define NORMAL 0 -#define RAW 1 -#define INITIAL 2 +#define PRE_RAW 1 +#define RAW 2 +#define INITIAL 3 ZEND_EXTERN_MODULE_GLOBALS(phpdbg); @@ -44,14 +45,18 @@ restart: LEX(text) = YYCURSOR; -#line 48 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +#line 49 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" { YYCTYPE yych; unsigned int yyaccept = 0; - if (YYGETCONDITION() < 1) { - goto yyc_NORMAL; + if (YYGETCONDITION() < 2) { + if (YYGETCONDITION() < 1) { + goto yyc_NORMAL; + } else { + goto yyc_PRE_RAW; + } } else { - if (YYGETCONDITION() < 2) { + if (YYGETCONDITION() < 3) { goto yyc_RAW; } else { goto yyc_INITIAL; @@ -62,10 +67,10 @@ yyc_INITIAL: { static const unsigned char yybm[] = { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 128, 128, 0, 0, 128, 0, 0, + 0, 192, 96, 0, 0, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 128, 0, 0, 0, 0, 0, 0, 0, + 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -98,1046 +103,1417 @@ yyc_INITIAL: YYDEBUG(0, *YYCURSOR); YYFILL(4); yych = *YYCURSOR; - if (yych <= 'D') { - if (yych <= '\n') { - if (yych <= 0x00) goto yy6; - if (yych <= 0x08) goto yy11; - if (yych >= '\n') goto yy4; + if (yybm[0+yych] & 32) { + goto yy4; + } + if (yych <= 'E') { + if (yych <= '\f') { + if (yych <= 0x00) goto yy7; + if (yych != '\t') goto yy12; } else { - if (yych <= '\r') { - if (yych <= '\f') goto yy11; + if (yych <= 0x1F) { + if (yych >= 0x0E) goto yy12; } else { - if (yych != ' ') goto yy11; + if (yych <= ' ') goto yy2; + if (yych <= 'D') goto yy12; + goto yy8; } } } else { if (yych <= 'd') { - if (yych <= 'Q') { - if (yych <= 'E') goto yy7; - goto yy11; - } else { - if (yych <= 'R') goto yy10; - if (yych <= 'S') goto yy8; - goto yy11; - } + if (yych <= 'Q') goto yy12; + if (yych <= 'R') goto yy11; + if (yych <= 'S') goto yy9; + goto yy12; } else { if (yych <= 'q') { - if (yych <= 'e') goto yy7; - goto yy11; + if (yych <= 'e') goto yy8; + goto yy12; } else { - if (yych <= 'r') goto yy9; - if (yych <= 's') goto yy8; - goto yy11; + if (yych <= 'r') goto yy10; + if (yych <= 's') goto yy9; + goto yy12; } } } +yy2: YYDEBUG(2, *YYCURSOR); ++YYCURSOR; if ((yych = *YYCURSOR) <= '\f') { + if (yych <= 0x00) goto yy29; if (yych <= 0x08) goto yy3; - if (yych <= '\n') goto yy26; + if (yych <= '\n') goto yy29; } else { - if (yych <= '\r') goto yy26; - if (yych == ' ') goto yy26; + if (yych <= '\r') goto yy29; + if (yych == ' ') goto yy29; } yy3: YYDEBUG(3, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 161 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" +#line 176 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" { YYSETCONDITION(NORMAL); YYCURSOR = LEX(text); goto restart; } -#line 154 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +#line 161 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" yy4: YYDEBUG(4, *YYCURSOR); ++YYCURSOR; - if ((yych = *YYCURSOR) <= '\f') { - if (yych <= 0x08) goto yy5; - if (yych <= '\n') goto yy26; - } else { - if (yych <= '\r') goto yy26; - if (yych == ' ') goto yy26; - } -yy5: + YYFILL(1); + yych = *YYCURSOR; YYDEBUG(5, *YYCURSOR); + if (yybm[0+yych] & 128) { + goto yy28; + } + if (yych <= 0x00) goto yy27; + if (yych == '\n') goto yy4; +yy6: + YYDEBUG(6, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 68 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" +#line 69 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" { return 0; } -#line 172 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy6: - YYDEBUG(6, *YYCURSOR); - yych = *++YYCURSOR; - goto yy3; +#line 180 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" yy7: YYDEBUG(7, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'V') goto yy22; - if (yych == 'v') goto yy22; + yych = *++YYCURSOR; goto yy3; yy8: YYDEBUG(8, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'H') goto yy18; - if (yych == 'h') goto yy18; + if (yych == 'V') goto yy23; + if (yych == 'v') goto yy23; goto yy3; yy9: YYDEBUG(9, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yybm[0+yych] & 128) { - goto yy15; - } - if (yych == 'U') goto yy12; - if (yych == 'u') goto yy12; + if (yych == 'H') goto yy19; + if (yych == 'h') goto yy19; goto yy3; yy10: YYDEBUG(10, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'U') goto yy12; - if (yych == 'u') goto yy12; + if (yybm[0+yych] & 64) { + goto yy16; + } + if (yych == 'U') goto yy13; + if (yych == 'u') goto yy13; goto yy3; yy11: YYDEBUG(11, *YYCURSOR); - yych = *++YYCURSOR; + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'U') goto yy13; + if (yych == 'u') goto yy13; goto yy3; yy12: YYDEBUG(12, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'N') goto yy14; - if (yych == 'n') goto yy14; + goto yy3; yy13: YYDEBUG(13, *YYCURSOR); - YYCURSOR = YYMARKER; - goto yy3; + yych = *++YYCURSOR; + if (yych == 'N') goto yy15; + if (yych == 'n') goto yy15; yy14: YYDEBUG(14, *YYCURSOR); - yych = *++YYCURSOR; - if (yybm[0+yych] & 128) { - goto yy15; - } - goto yy13; + YYCURSOR = YYMARKER; + goto yy3; yy15: YYDEBUG(15, *YYCURSOR); + yych = *++YYCURSOR; + if (yybm[0+yych] & 64) { + goto yy16; + } + goto yy14; +yy16: + YYDEBUG(16, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(16, *YYCURSOR); - if (yybm[0+yych] & 128) { - goto yy15; - } YYDEBUG(17, *YYCURSOR); + if (yybm[0+yych] & 64) { + goto yy16; + } + YYDEBUG(18, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 155 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" +#line 163 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" { - YYSETCONDITION(RAW); + YYSETCONDITION(PRE_RAW); phpdbg_init_param(yylval, EMPTY_PARAM); return T_RUN; } -#line 245 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy18: - YYDEBUG(18, *YYCURSOR); - yych = *++YYCURSOR; - if (yych <= '\f') { - if (yych <= 0x08) goto yy13; - if (yych >= '\v') goto yy13; - } else { - if (yych <= '\r') goto yy19; - if (yych != ' ') goto yy13; - } +#line 253 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" yy19: YYDEBUG(19, *YYCURSOR); + yych = *++YYCURSOR; + if (yych <= '\f') { + if (yych <= 0x08) goto yy14; + if (yych >= '\v') goto yy14; + } else { + if (yych <= '\r') goto yy20; + if (yych != ' ') goto yy14; + } +yy20: + YYDEBUG(20, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(20, *YYCURSOR); - if (yych <= '\f') { - if (yych <= 0x08) goto yy21; - if (yych <= '\n') goto yy19; - } else { - if (yych <= '\r') goto yy19; - if (yych == ' ') goto yy19; - } -yy21: YYDEBUG(21, *YYCURSOR); + if (yych <= '\f') { + if (yych <= 0x08) goto yy22; + if (yych <= '\n') goto yy20; + } else { + if (yych <= '\r') goto yy20; + if (yych == ' ') goto yy20; + } +yy22: + YYDEBUG(22, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 150 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" +#line 158 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" { - YYSETCONDITION(RAW); + YYSETCONDITION(PRE_RAW); phpdbg_init_param(yylval, EMPTY_PARAM); return T_SHELL; } -#line 278 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy22: - YYDEBUG(22, *YYCURSOR); - yych = *++YYCURSOR; - if (yych <= '\f') { - if (yych <= 0x08) goto yy13; - if (yych >= '\v') goto yy13; - } else { - if (yych <= '\r') goto yy23; - if (yych != ' ') goto yy13; - } +#line 286 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" yy23: YYDEBUG(23, *YYCURSOR); + yych = *++YYCURSOR; + if (yych <= '\f') { + if (yych <= 0x08) goto yy14; + if (yych >= '\v') goto yy14; + } else { + if (yych <= '\r') goto yy24; + if (yych != ' ') goto yy14; + } +yy24: + YYDEBUG(24, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(24, *YYCURSOR); - if (yych <= '\f') { - if (yych <= 0x08) goto yy25; - if (yych <= '\n') goto yy23; - } else { - if (yych <= '\r') goto yy23; - if (yych == ' ') goto yy23; - } -yy25: YYDEBUG(25, *YYCURSOR); + if (yych <= '\f') { + if (yych <= 0x08) goto yy26; + if (yych <= '\n') goto yy24; + } else { + if (yych <= '\r') goto yy24; + if (yych == ' ') goto yy24; + } +yy26: + YYDEBUG(26, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 145 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" +#line 153 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" { - YYSETCONDITION(RAW); + YYSETCONDITION(PRE_RAW); phpdbg_init_param(yylval, EMPTY_PARAM); return T_EVAL; } -#line 311 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy26: - YYDEBUG(26, *YYCURSOR); +#line 319 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" +yy27: + YYDEBUG(27, *YYCURSOR); + yych = *++YYCURSOR; + goto yy6; +yy28: + YYDEBUG(28, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(27, *YYCURSOR); - if (yych <= '\f') { - if (yych <= 0x08) goto yy28; - if (yych <= '\n') goto yy26; - } else { - if (yych <= '\r') goto yy26; - if (yych == ' ') goto yy26; +yy29: + YYDEBUG(29, *YYCURSOR); + if (yybm[0+yych] & 128) { + goto yy28; } -yy28: - YYDEBUG(28, *YYCURSOR); + if (yych <= 0x00) goto yy27; + if (yych == '\n') goto yy4; + YYDEBUG(30, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 139 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" +#line 147 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" { /* ignore whitespace */ goto restart; } -#line 334 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +#line 344 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" } /* *********************************** */ yyc_NORMAL: { static const unsigned char yybm[] = { - 0, 16, 16, 16, 16, 16, 16, 16, - 16, 8, 8, 16, 16, 8, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 8, 16, 16, 0, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 48, 16, - 176, 176, 176, 176, 176, 176, 176, 176, - 176, 176, 0, 16, 16, 16, 16, 16, - 16, 208, 208, 208, 208, 208, 208, 80, - 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 16, 16, 16, 16, 16, - 16, 208, 208, 208, 208, 208, 208, 80, - 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, + 0, 8, 8, 8, 8, 8, 8, 8, + 8, 66, 68, 8, 8, 66, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 66, 8, 8, 0, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 24, 8, + 152, 152, 152, 152, 152, 152, 152, 152, + 152, 152, 0, 8, 8, 8, 8, 8, + 8, 168, 168, 168, 168, 168, 168, 40, + 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 8, 8, 8, 8, 8, + 8, 168, 168, 168, 168, 168, 168, 40, + 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, }; - YYDEBUG(29, *YYCURSOR); + YYDEBUG(31, *YYCURSOR); YYFILL(11); yych = *YYCURSOR; - YYDEBUG(-1, yych); - switch (yych) { - case 0x00: goto yy36; - case '\t': - case '\r': - case ' ': goto yy31; - case '\n': goto yy34; - case '#': goto yy55; - case '-': goto yy41; - case '.': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy42; - case '0': goto yy45; - case ':': goto yy57; - case 'D': - case 'd': goto yy46; - case 'E': - case 'e': goto yy47; - case 'F': - case 'f': goto yy48; - case 'I': - case 'i': goto yy37; - case 'N': - case 'n': goto yy49; - case 'O': - case 'o': goto yy50; - case 'T': - case 't': goto yy51; - case 'Y': - case 'y': goto yy52; - case 'Z': goto yy53; - case 'z': goto yy54; - default: goto yy39; + if (yybm[0+yych] & 2) { + goto yy33; } -yy31: - YYDEBUG(31, *YYCURSOR); + if (yych <= 'N') { + if (yych <= '0') { + if (yych <= '#') { + if (yych <= '\t') { + if (yych <= 0x00) goto yy39; + goto yy43; + } else { + if (yych <= '\n') goto yy36; + if (yych <= '"') goto yy43; + goto yy58; + } + } else { + if (yych <= '-') { + if (yych <= ',') goto yy43; + goto yy40; + } else { + if (yych <= '.') goto yy45; + if (yych <= '/') goto yy43; + goto yy48; + } + } + } else { + if (yych <= 'E') { + if (yych <= ':') { + if (yych <= '9') goto yy45; + goto yy60; + } else { + if (yych <= 'C') goto yy43; + if (yych <= 'D') goto yy49; + goto yy50; + } + } else { + if (yych <= 'H') { + if (yych <= 'F') goto yy51; + goto yy43; + } else { + if (yych <= 'I') goto yy42; + if (yych <= 'M') goto yy43; + goto yy52; + } + } + } + } else { + if (yych <= 'f') { + if (yych <= 'Y') { + if (yych <= 'S') { + if (yych <= 'O') goto yy53; + goto yy43; + } else { + if (yych <= 'T') goto yy54; + if (yych <= 'X') goto yy43; + goto yy55; + } + } else { + if (yych <= 'c') { + if (yych <= 'Z') goto yy56; + goto yy43; + } else { + if (yych <= 'd') goto yy49; + if (yych <= 'e') goto yy50; + goto yy51; + } + } + } else { + if (yych <= 'o') { + if (yych <= 'i') { + if (yych <= 'h') goto yy43; + goto yy42; + } else { + if (yych <= 'm') goto yy43; + if (yych <= 'n') goto yy52; + goto yy53; + } + } else { + if (yych <= 'x') { + if (yych == 't') goto yy54; + goto yy43; + } else { + if (yych <= 'y') goto yy55; + if (yych <= 'z') goto yy57; + goto yy43; + } + } + } + } +yy33: + YYDEBUG(33, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(32, *YYCURSOR); - if (yybm[0+yych] & 8) { - goto yy31; + YYDEBUG(34, *YYCURSOR); + if (yybm[0+yych] & 2) { + goto yy33; } - YYDEBUG(33, *YYCURSOR); + if (yych <= 0x00) goto yy39; + if (yych == '\n') goto yy36; + YYDEBUG(35, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 139 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" +#line 147 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" { /* ignore whitespace */ goto restart; } -#line 434 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy34: - YYDEBUG(34, *YYCURSOR); - ++YYCURSOR; - if (yybm[0+(yych = *YYCURSOR)] & 8) { - goto yy31; - } -yy35: - YYDEBUG(35, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 68 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" - { - return 0; -} -#line 448 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +#line 493 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" yy36: YYDEBUG(36, *YYCURSOR); - yych = *++YYCURSOR; - goto yy35; -yy37: + ++YYCURSOR; + YYFILL(1); + yych = *YYCURSOR; YYDEBUG(37, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'F') goto yy106; - if (yych == 'f') goto yy106; - goto yy40; + if (yybm[0+yych] & 2) { + goto yy33; + } + if (yych <= 0x00) goto yy39; + if (yych == '\n') goto yy36; yy38: YYDEBUG(38, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 125 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" +#line 69 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" + { + return 0; +} +#line 512 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" +yy39: + YYDEBUG(39, *YYCURSOR); + yych = *++YYCURSOR; + goto yy38; +yy40: + YYDEBUG(40, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[0+yych] & 16) { + goto yy45; + } + if (yych == 'r') goto yy113; + goto yy44; +yy41: + YYDEBUG(41, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 133 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" { phpdbg_init_param(yylval, STR_PARAM); yylval->str = zend_strndup(yytext, yyleng); yylval->len = yyleng; return T_ID; } -#line 470 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy39: - YYDEBUG(39, *YYCURSOR); +#line 536 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" +yy42: + YYDEBUG(42, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'F') goto yy109; + if (yych == 'f') goto yy109; + goto yy44; +yy43: + YYDEBUG(43, *YYCURSOR); yyaccept = 0; YYMARKER = ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; -yy40: - YYDEBUG(40, *YYCURSOR); - if (yybm[0+yych] & 16) { - goto yy39; +yy44: + YYDEBUG(44, *YYCURSOR); + if (yybm[0+yych] & 8) { + goto yy43; } - if (yych <= '9') goto yy38; - goto yy62; -yy41: - YYDEBUG(41, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yybm[0+yych] & 32) { - goto yy42; - } - goto yy40; -yy42: - YYDEBUG(42, *YYCURSOR); + if (yych <= '9') goto yy41; + goto yy65; +yy45: + YYDEBUG(45, *YYCURSOR); yyaccept = 1; YYMARKER = ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; - YYDEBUG(43, *YYCURSOR); - if (yybm[0+yych] & 32) { - goto yy42; + YYDEBUG(46, *YYCURSOR); + if (yybm[0+yych] & 16) { + goto yy45; } if (yych <= 0x1F) { if (yych <= '\n') { - if (yych <= 0x00) goto yy44; - if (yych <= 0x08) goto yy39; + if (yych <= 0x00) goto yy47; + if (yych <= 0x08) goto yy43; } else { - if (yych != '\r') goto yy39; + if (yych != '\r') goto yy43; } } else { if (yych <= '#') { - if (yych <= ' ') goto yy44; - if (yych <= '"') goto yy39; + if (yych <= ' ') goto yy47; + if (yych <= '"') goto yy43; } else { - if (yych == ':') goto yy62; - goto yy39; + if (yych == ':') goto yy65; + goto yy43; } } -yy44: - YYDEBUG(44, *YYCURSOR); +yy47: + YYDEBUG(47, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 106 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" +#line 114 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" { phpdbg_init_param(yylval, NUMERIC_PARAM); yylval->num = atoi(yytext); return T_DIGITS; } -#line 527 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy45: - YYDEBUG(45, *YYCURSOR); +#line 592 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" +yy48: + YYDEBUG(48, *YYCURSOR); yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); - if (yybm[0+yych] & 32) { - goto yy42; + if (yybm[0+yych] & 16) { + goto yy45; } if (yych <= 0x1F) { if (yych <= '\n') { - if (yych <= 0x00) goto yy44; - if (yych <= 0x08) goto yy40; - goto yy44; + if (yych <= 0x00) goto yy47; + if (yych <= 0x08) goto yy44; + goto yy47; } else { - if (yych == '\r') goto yy44; - goto yy40; + if (yych == '\r') goto yy47; + goto yy44; } } else { if (yych <= '#') { - if (yych <= ' ') goto yy44; - if (yych <= '"') goto yy40; - goto yy44; + if (yych <= ' ') goto yy47; + if (yych <= '"') goto yy44; + goto yy47; } else { - if (yych == 'x') goto yy102; - goto yy40; + if (yych == 'x') goto yy105; + goto yy44; } } -yy46: - YYDEBUG(46, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'I') goto yy96; - if (yych == 'i') goto yy96; - goto yy40; -yy47: - YYDEBUG(47, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'N') goto yy91; - if (yych == 'n') goto yy91; - goto yy40; -yy48: - YYDEBUG(48, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'A') goto yy88; - if (yych == 'a') goto yy88; - goto yy40; yy49: YYDEBUG(49, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'O') goto yy84; - if (yych == 'o') goto yy84; - goto yy40; + if (yych == 'I') goto yy99; + if (yych == 'i') goto yy99; + goto yy44; yy50: YYDEBUG(50, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 'N') { - if (yych == 'F') goto yy83; - if (yych <= 'M') goto yy40; - goto yy77; - } else { - if (yych <= 'f') { - if (yych <= 'e') goto yy40; - goto yy83; - } else { - if (yych == 'n') goto yy77; - goto yy40; - } - } + if (yych == 'N') goto yy94; + if (yych == 'n') goto yy94; + goto yy44; yy51: YYDEBUG(51, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'R') goto yy81; - if (yych == 'r') goto yy81; - goto yy40; + if (yych == 'A') goto yy91; + if (yych == 'a') goto yy91; + goto yy44; yy52: YYDEBUG(52, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy76; - if (yych == 'e') goto yy76; - goto yy40; + if (yych == 'O') goto yy87; + if (yych == 'o') goto yy87; + goto yy44; yy53: YYDEBUG(53, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy73; - goto yy40; + if (yych <= 'N') { + if (yych == 'F') goto yy86; + if (yych <= 'M') goto yy44; + goto yy80; + } else { + if (yych <= 'f') { + if (yych <= 'e') goto yy44; + goto yy86; + } else { + if (yych == 'n') goto yy80; + goto yy44; + } + } yy54: YYDEBUG(54, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'e') goto yy61; - goto yy40; + if (yych == 'R') goto yy84; + if (yych == 'r') goto yy84; + goto yy44; yy55: YYDEBUG(55, *YYCURSOR); - ++YYCURSOR; + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'E') goto yy79; + if (yych == 'e') goto yy79; + goto yy44; +yy56: YYDEBUG(56, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'E') goto yy76; + goto yy44; +yy57: + YYDEBUG(57, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'e') goto yy64; + goto yy44; +yy58: + YYDEBUG(58, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(59, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 84 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" +#line 92 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" { return T_POUND; } -#line 634 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy57: - YYDEBUG(57, *YYCURSOR); +#line 699 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" +yy60: + YYDEBUG(60, *YYCURSOR); ++YYCURSOR; - if ((yych = *YYCURSOR) == ':') goto yy59; - YYDEBUG(58, *YYCURSOR); + if ((yych = *YYCURSOR) == ':') goto yy62; + YYDEBUG(61, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 90 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" +#line 98 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" { return T_COLON; } -#line 645 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy59: - YYDEBUG(59, *YYCURSOR); +#line 710 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" +yy62: + YYDEBUG(62, *YYCURSOR); ++YYCURSOR; - YYDEBUG(60, *YYCURSOR); + YYDEBUG(63, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 87 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" +#line 95 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" { return T_DCOLON; } -#line 655 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy61: - YYDEBUG(61, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'n') goto yy67; - goto yy40; -yy62: - YYDEBUG(62, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == '/') goto yy64; -yy63: - YYDEBUG(63, *YYCURSOR); - YYCURSOR = YYMARKER; - if (yyaccept <= 1) { - if (yyaccept <= 0) { - goto yy38; - } else { - goto yy44; - } - } else { - if (yyaccept <= 2) { - goto yy72; - } else { - goto yy105; - } - } +#line 720 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" yy64: YYDEBUG(64, *YYCURSOR); - yych = *++YYCURSOR; - if (yych != '/') goto yy63; + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'n') goto yy70; + goto yy44; +yy65: YYDEBUG(65, *YYCURSOR); - ++YYCURSOR; + yych = *++YYCURSOR; + if (yych == '/') goto yy67; +yy66: YYDEBUG(66, *YYCURSOR); + YYCURSOR = YYMARKER; + if (yyaccept <= 2) { + if (yyaccept <= 1) { + if (yyaccept <= 0) { + goto yy41; + } else { + goto yy47; + } + } else { + goto yy75; + } + } else { + if (yyaccept <= 3) { + goto yy108; + } else { + goto yy119; + } + } +yy67: + YYDEBUG(67, *YYCURSOR); + yych = *++YYCURSOR; + if (yych != '/') goto yy66; + YYDEBUG(68, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(69, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 78 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" +#line 86 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" { phpdbg_init_param(yylval, STR_PARAM); yylval->str = zend_strndup(yytext, yyleng); yylval->len = yyleng; return T_PROTO; } -#line 697 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy67: - YYDEBUG(67, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych != 'd') goto yy40; - YYDEBUG(68, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych != '_') goto yy40; -yy69: - YYDEBUG(69, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yybm[0+yych] & 64) { - goto yy70; - } - goto yy40; +#line 766 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" yy70: YYDEBUG(70, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'd') goto yy44; + YYDEBUG(71, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != '_') goto yy44; +yy72: + YYDEBUG(72, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[0+yych] & 32) { + goto yy73; + } + goto yy44; +yy73: + YYDEBUG(73, *YYCURSOR); yyaccept = 2; YYMARKER = ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; - YYDEBUG(71, *YYCURSOR); - if (yybm[0+yych] & 64) { - goto yy70; + YYDEBUG(74, *YYCURSOR); + if (yybm[0+yych] & 32) { + goto yy73; } if (yych <= 0x1F) { if (yych <= '\n') { - if (yych <= 0x00) goto yy72; - if (yych <= 0x08) goto yy39; + if (yych <= 0x00) goto yy75; + if (yych <= 0x08) goto yy43; } else { - if (yych != '\r') goto yy39; + if (yych != '\r') goto yy43; } } else { if (yych <= '#') { - if (yych <= ' ') goto yy72; - if (yych <= '"') goto yy39; + if (yych <= ' ') goto yy75; + if (yych <= '"') goto yy43; } else { - if (yych == ':') goto yy62; - goto yy39; + if (yych == ':') goto yy65; + goto yy43; } } -yy72: - YYDEBUG(72, *YYCURSOR); +yy75: + YYDEBUG(75, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 118 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" +#line 126 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" { phpdbg_init_param(yylval, OP_PARAM); yylval->str = zend_strndup(yytext, yyleng); yylval->len = yyleng; return T_OPCODE; } -#line 751 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy73: - YYDEBUG(73, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych != 'N') goto yy40; - YYDEBUG(74, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych != 'D') goto yy40; - YYDEBUG(75, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == '_') goto yy69; - goto yy40; +#line 820 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" yy76: YYDEBUG(76, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'S') goto yy77; - if (yych != 's') goto yy40; -yy77: + if (yych != 'N') goto yy44; YYDEBUG(77, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych <= '\f') { - if (yych <= 0x08) goto yy40; - if (yych >= '\v') goto yy40; - } else { - if (yych <= '\r') goto yy78; - if (yych != ' ') goto yy40; - } -yy78: + if (yych != 'D') goto yy44; YYDEBUG(78, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '_') goto yy72; + goto yy44; +yy79: + YYDEBUG(79, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'S') goto yy80; + if (yych != 's') goto yy44; +yy80: + YYDEBUG(80, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[0+yych] & 64) { + goto yy81; + } + goto yy44; +yy81: + YYDEBUG(81, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(79, *YYCURSOR); - if (yych <= '\f') { - if (yych <= 0x08) goto yy80; - if (yych <= '\n') goto yy78; - } else { - if (yych <= '\r') goto yy78; - if (yych == ' ') goto yy78; + YYDEBUG(82, *YYCURSOR); + if (yybm[0+yych] & 64) { + goto yy81; } -yy80: - YYDEBUG(80, *YYCURSOR); + YYDEBUG(83, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 94 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" +#line 102 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" { phpdbg_init_param(yylval, NUMERIC_PARAM); yylval->num = 1; return T_TRUTHY; } -#line 805 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy81: - YYDEBUG(81, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'U') goto yy82; - if (yych != 'u') goto yy40; -yy82: - YYDEBUG(82, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy77; - if (yych == 'e') goto yy77; - goto yy40; -yy83: - YYDEBUG(83, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'F') goto yy84; - if (yych != 'f') goto yy40; +#line 866 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" yy84: YYDEBUG(84, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych <= '\f') { - if (yych <= 0x08) goto yy40; - if (yych >= '\v') goto yy40; - } else { - if (yych <= '\r') goto yy85; - if (yych != ' ') goto yy40; - } + if (yych == 'U') goto yy85; + if (yych != 'u') goto yy44; yy85: YYDEBUG(85, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'E') goto yy80; + if (yych == 'e') goto yy80; + goto yy44; +yy86: + YYDEBUG(86, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'F') goto yy87; + if (yych != 'f') goto yy44; +yy87: + YYDEBUG(87, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '\f') { + if (yych <= 0x08) goto yy44; + if (yych >= '\v') goto yy44; + } else { + if (yych <= '\r') goto yy88; + if (yych != ' ') goto yy44; + } +yy88: + YYDEBUG(88, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(86, *YYCURSOR); + YYDEBUG(89, *YYCURSOR); if (yych <= '\f') { - if (yych <= 0x08) goto yy87; - if (yych <= '\n') goto yy85; + if (yych <= 0x08) goto yy90; + if (yych <= '\n') goto yy88; } else { - if (yych <= '\r') goto yy85; - if (yych == ' ') goto yy85; + if (yych <= '\r') goto yy88; + if (yych == ' ') goto yy88; } -yy87: - YYDEBUG(87, *YYCURSOR); +yy90: + YYDEBUG(90, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 100 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" +#line 108 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" { phpdbg_init_param(yylval, NUMERIC_PARAM); yylval->num = 0; return T_FALSY; } -#line 858 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy88: - YYDEBUG(88, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'L') goto yy89; - if (yych != 'l') goto yy40; -yy89: - YYDEBUG(89, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'S') goto yy90; - if (yych != 's') goto yy40; -yy90: - YYDEBUG(90, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy84; - if (yych == 'e') goto yy84; - goto yy40; +#line 919 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" yy91: YYDEBUG(91, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'A') goto yy92; - if (yych != 'a') goto yy40; + if (yych == 'L') goto yy92; + if (yych != 'l') goto yy44; yy92: YYDEBUG(92, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'B') goto yy93; - if (yych != 'b') goto yy40; + if (yych == 'S') goto yy93; + if (yych != 's') goto yy44; yy93: YYDEBUG(93, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'L') goto yy94; - if (yych != 'l') goto yy40; + if (yych == 'E') goto yy87; + if (yych == 'e') goto yy87; + goto yy44; yy94: YYDEBUG(94, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy95; - if (yych != 'e') goto yy40; + if (yych == 'A') goto yy95; + if (yych != 'a') goto yy44; yy95: YYDEBUG(95, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'D') goto yy77; - if (yych == 'd') goto yy77; - goto yy40; + if (yych == 'B') goto yy96; + if (yych != 'b') goto yy44; yy96: YYDEBUG(96, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'S') goto yy97; - if (yych != 's') goto yy40; + if (yych == 'L') goto yy97; + if (yych != 'l') goto yy44; yy97: YYDEBUG(97, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'A') goto yy98; - if (yych != 'a') goto yy40; + if (yych == 'E') goto yy98; + if (yych != 'e') goto yy44; yy98: YYDEBUG(98, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'B') goto yy99; - if (yych != 'b') goto yy40; + if (yych == 'D') goto yy80; + if (yych == 'd') goto yy80; + goto yy44; yy99: YYDEBUG(99, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'L') goto yy100; - if (yych != 'l') goto yy40; + if (yych == 'S') goto yy100; + if (yych != 's') goto yy44; yy100: YYDEBUG(100, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy101; - if (yych != 'e') goto yy40; + if (yych == 'A') goto yy101; + if (yych != 'a') goto yy44; yy101: YYDEBUG(101, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'D') goto yy84; - if (yych == 'd') goto yy84; - goto yy40; + if (yych == 'B') goto yy102; + if (yych != 'b') goto yy44; yy102: YYDEBUG(102, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yybm[0+yych] & 128) { - goto yy103; - } - goto yy40; + if (yych == 'L') goto yy103; + if (yych != 'l') goto yy44; yy103: YYDEBUG(103, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'E') goto yy104; + if (yych != 'e') goto yy44; +yy104: + YYDEBUG(104, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'D') goto yy87; + if (yych == 'd') goto yy87; + goto yy44; +yy105: + YYDEBUG(105, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[0+yych] & 128) { + goto yy106; + } + goto yy44; +yy106: + YYDEBUG(106, *YYCURSOR); yyaccept = 3; YYMARKER = ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; - YYDEBUG(104, *YYCURSOR); + YYDEBUG(107, *YYCURSOR); if (yybm[0+yych] & 128) { - goto yy103; + goto yy106; } if (yych <= 0x1F) { if (yych <= '\n') { - if (yych <= 0x00) goto yy105; - if (yych <= 0x08) goto yy39; + if (yych <= 0x00) goto yy108; + if (yych <= 0x08) goto yy43; } else { - if (yych != '\r') goto yy39; + if (yych != '\r') goto yy43; } } else { if (yych <= '#') { - if (yych <= ' ') goto yy105; - if (yych <= '"') goto yy39; + if (yych <= ' ') goto yy108; + if (yych <= '"') goto yy43; } else { - if (yych == ':') goto yy62; - goto yy39; + if (yych == ':') goto yy65; + goto yy43; } } -yy105: - YYDEBUG(105, *YYCURSOR); +yy108: + YYDEBUG(108, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 112 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" +#line 120 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" { phpdbg_init_param(yylval, ADDR_PARAM); yylval->addr = strtoul(yytext, 0, 16); return T_ADDR; } -#line 989 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy106: - YYDEBUG(106, *YYCURSOR); +#line 1050 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" +yy109: + YYDEBUG(109, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if (yych <= '\f') { - if (yych <= 0x08) goto yy40; - if (yych >= '\v') goto yy40; + if (yych <= 0x08) goto yy44; + if (yych >= '\v') goto yy44; } else { - if (yych <= '\r') goto yy107; - if (yych != ' ') goto yy40; + if (yych <= '\r') goto yy110; + if (yych != ' ') goto yy44; } -yy107: - YYDEBUG(107, *YYCURSOR); +yy110: + YYDEBUG(110, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(108, *YYCURSOR); + YYDEBUG(111, *YYCURSOR); if (yych <= '\f') { - if (yych <= 0x08) goto yy109; - if (yych <= '\n') goto yy107; + if (yych <= 0x08) goto yy112; + if (yych <= '\n') goto yy110; } else { - if (yych <= '\r') goto yy107; - if (yych == ' ') goto yy107; + if (yych <= '\r') goto yy110; + if (yych == ' ') goto yy110; } -yy109: - YYDEBUG(109, *YYCURSOR); +yy112: + YYDEBUG(112, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 72 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" +#line 80 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" { YYSETCONDITION(RAW); phpdbg_init_param(yylval, EMPTY_PARAM); return T_IF; } -#line 1023 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +#line 1084 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" +yy113: + YYDEBUG(113, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= ' ') { + if (yych <= '\f') { + if (yych <= 0x08) goto yy44; + if (yych >= '\v') goto yy44; + } else { + if (yych <= '\r') goto yy114; + if (yych <= 0x1F) goto yy44; + } + } else { + if (yych <= '.') { + if (yych <= ',') goto yy44; + if (yych <= '-') goto yy116; + goto yy117; + } else { + if (yych <= '/') goto yy44; + if (yych <= '9') goto yy117; + goto yy44; + } + } +yy114: + YYDEBUG(114, *YYCURSOR); + ++YYCURSOR; + YYFILL(2); + yych = *YYCURSOR; + YYDEBUG(115, *YYCURSOR); + if (yych <= ' ') { + if (yych <= '\f') { + if (yych <= 0x08) goto yy66; + if (yych <= '\n') goto yy114; + goto yy66; + } else { + if (yych <= '\r') goto yy114; + if (yych <= 0x1F) goto yy66; + goto yy114; + } + } else { + if (yych <= '.') { + if (yych <= ',') goto yy66; + if (yych <= '-') goto yy120; + goto yy121; + } else { + if (yych <= '/') goto yy66; + if (yych <= '9') goto yy121; + goto yy66; + } + } +yy116: + YYDEBUG(116, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '.') goto yy117; + if (yych <= '/') goto yy44; + if (yych >= ':') goto yy44; +yy117: + YYDEBUG(117, *YYCURSOR); + yyaccept = 4; + YYMARKER = ++YYCURSOR; + YYFILL(3); + yych = *YYCURSOR; + YYDEBUG(118, *YYCURSOR); + if (yych <= ' ') { + if (yych <= '\n') { + if (yych <= 0x00) goto yy119; + if (yych <= 0x08) goto yy43; + } else { + if (yych == '\r') goto yy119; + if (yych <= 0x1F) goto yy43; + } + } else { + if (yych <= '.') { + if (yych == '#') goto yy119; + if (yych <= '-') goto yy43; + goto yy117; + } else { + if (yych <= '/') goto yy43; + if (yych <= '9') goto yy117; + if (yych <= ':') goto yy65; + goto yy43; + } + } +yy119: + YYDEBUG(119, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 73 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" + { + char *text = yytext + 2; + while (*++text < '0'); + yylval->num = atoi(text); + return T_REQ_ID; +} +#line 1179 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" +yy120: + YYDEBUG(120, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == '.') goto yy121; + if (yych <= '/') goto yy66; + if (yych >= ':') goto yy66; +yy121: + YYDEBUG(121, *YYCURSOR); + ++YYCURSOR; + YYFILL(1); + yych = *YYCURSOR; + YYDEBUG(122, *YYCURSOR); + if (yych == '.') goto yy121; + if (yych <= '/') goto yy119; + if (yych <= '9') goto yy121; + goto yy119; + } +/* *********************************** */ +yyc_PRE_RAW: + { + static const unsigned char yybm[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 160, 48, 0, 0, 160, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 160, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 64, 0, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }; + YYDEBUG(123, *YYCURSOR); + YYFILL(2); + yych = *YYCURSOR; + if (yybm[0+yych] & 16) { + goto yy127; + } + if (yych <= '\r') { + if (yych <= 0x08) { + if (yych <= 0x00) goto yy130; + goto yy132; + } else { + if (yych <= '\t') goto yy125; + if (yych <= '\f') goto yy132; + } + } else { + if (yych <= ' ') { + if (yych <= 0x1F) goto yy132; + } else { + if (yych == '-') goto yy131; + goto yy132; + } + } +yy125: + YYDEBUG(125, *YYCURSOR); + ++YYCURSOR; + if ((yych = *YYCURSOR) <= '\f') { + if (yych <= 0x00) goto yy142; + if (yych <= 0x08) goto yy126; + if (yych <= '\n') goto yy142; + } else { + if (yych <= '\r') goto yy142; + if (yych == ' ') goto yy142; + } +yy126: + YYDEBUG(126, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 169 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" + { + YYSETCONDITION(RAW); + + YYCURSOR = LEX(text); + goto restart; +} +#line 1277 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" +yy127: + YYDEBUG(127, *YYCURSOR); + ++YYCURSOR; + YYFILL(1); + yych = *YYCURSOR; + YYDEBUG(128, *YYCURSOR); + if (yybm[0+yych] & 128) { + goto yy141; + } + if (yych <= 0x00) goto yy140; + if (yych == '\n') goto yy127; +yy129: + YYDEBUG(129, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 69 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" + { + return 0; +} +#line 1296 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" +yy130: + YYDEBUG(130, *YYCURSOR); + yych = *++YYCURSOR; + goto yy126; +yy131: + YYDEBUG(131, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'r') goto yy133; + goto yy126; +yy132: + YYDEBUG(132, *YYCURSOR); + yych = *++YYCURSOR; + goto yy126; +yy133: + YYDEBUG(133, *YYCURSOR); + ++YYCURSOR; + YYFILL(2); + yych = *YYCURSOR; + YYDEBUG(134, *YYCURSOR); + if (yybm[0+yych] & 32) { + goto yy133; + } + if (yych <= '.') { + if (yych <= ',') goto yy135; + if (yych <= '-') goto yy136; + goto yy137; + } else { + if (yych <= '/') goto yy135; + if (yych <= '9') goto yy137; + } +yy135: + YYDEBUG(135, *YYCURSOR); + YYCURSOR = YYMARKER; + goto yy126; +yy136: + YYDEBUG(136, *YYCURSOR); + yych = *++YYCURSOR; + if (yybm[0+yych] & 64) { + goto yy137; + } + goto yy135; +yy137: + YYDEBUG(137, *YYCURSOR); + ++YYCURSOR; + YYFILL(1); + yych = *YYCURSOR; + YYDEBUG(138, *YYCURSOR); + if (yybm[0+yych] & 64) { + goto yy137; + } + YYDEBUG(139, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 73 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" + { + char *text = yytext + 2; + while (*++text < '0'); + yylval->num = atoi(text); + return T_REQ_ID; +} +#line 1357 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" +yy140: + YYDEBUG(140, *YYCURSOR); + yych = *++YYCURSOR; + goto yy129; +yy141: + YYDEBUG(141, *YYCURSOR); + ++YYCURSOR; + YYFILL(1); + yych = *YYCURSOR; +yy142: + YYDEBUG(142, *YYCURSOR); + if (yybm[0+yych] & 128) { + goto yy141; + } + if (yych <= 0x00) goto yy140; + if (yych == '\n') goto yy127; + YYDEBUG(143, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 147 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" + { + /* ignore whitespace */ + + goto restart; +} +#line 1382 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" } /* *********************************** */ yyc_RAW: { static const unsigned char yybm[] = { - 0, 64, 64, 64, 64, 64, 64, 64, - 64, 224, 128, 64, 64, 224, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 224, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, + 0, 128, 128, 128, 128, 128, 128, 128, + 128, 160, 64, 128, 128, 160, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 160, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, }; - YYDEBUG(110, *YYCURSOR); - YYFILL(2); + YYDEBUG(144, *YYCURSOR); + YYFILL(1); yych = *YYCURSOR; if (yybm[0+yych] & 32) { - goto yy112; + goto yy146; } - if (yych <= 0x00) goto yy117; - if (yych == '\n') goto yy115; - goto yy118; -yy112: - YYDEBUG(112, *YYCURSOR); + if (yych <= 0x00) goto yy152; + if (yych == '\n') goto yy149; + goto yy153; +yy146: + YYDEBUG(146, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(113, *YYCURSOR); + YYDEBUG(147, *YYCURSOR); if (yybm[0+yych] & 32) { - goto yy112; + goto yy146; } - if (yych <= 0x00) goto yy114; - if (yych == '\n') goto yy120; - goto yy118; -yy114: - YYDEBUG(114, *YYCURSOR); + if (yych <= 0x00) goto yy152; + if (yych == '\n') goto yy149; + goto yy153; +yy148: + YYDEBUG(148, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 132 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" +#line 140 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" { phpdbg_init_param(yylval, STR_PARAM); yylval->str = zend_strndup(yytext, yyleng); yylval->len = yyleng; return T_INPUT; } -#line 1093 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy115: - YYDEBUG(115, *YYCURSOR); +#line 1452 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" +yy149: + YYDEBUG(149, *YYCURSOR); ++YYCURSOR; - if (yybm[0+(yych = *YYCURSOR)] & 128) { - goto yy120; + YYFILL(1); + yych = *YYCURSOR; + YYDEBUG(150, *YYCURSOR); + if (yybm[0+yych] & 64) { + goto yy149; } -yy116: - YYDEBUG(116, *YYCURSOR); + if (yych <= '\f') { + if (yych <= 0x00) goto yy152; + if (yych == '\t') goto yy155; + } else { + if (yych <= '\r') goto yy155; + if (yych == ' ') goto yy155; + } +yy151: + YYDEBUG(151, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 68 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" +#line 69 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" { return 0; } -#line 1107 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" -yy117: - YYDEBUG(117, *YYCURSOR); +#line 1476 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" +yy152: + YYDEBUG(152, *YYCURSOR); yych = *++YYCURSOR; - goto yy116; -yy118: - YYDEBUG(118, *YYCURSOR); + goto yy151; +yy153: + YYDEBUG(153, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(119, *YYCURSOR); - if (yybm[0+yych] & 64) { - goto yy118; - } - goto yy114; -yy120: - YYDEBUG(120, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(121, *YYCURSOR); + YYDEBUG(154, *YYCURSOR); if (yybm[0+yych] & 128) { - goto yy120; + goto yy153; } - YYDEBUG(122, *YYCURSOR); + goto yy148; +yy155: + YYDEBUG(155, *YYCURSOR); + ++YYCURSOR; + YYFILL(1); + yych = *YYCURSOR; + YYDEBUG(156, *YYCURSOR); + if (yybm[0+yych] & 64) { + goto yy149; + } + if (yych <= '\f') { + if (yych <= 0x00) goto yy152; + if (yych == '\t') goto yy155; + } else { + if (yych <= '\r') goto yy155; + if (yych == ' ') goto yy155; + } + YYDEBUG(157, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 139 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" +#line 147 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" { /* ignore whitespace */ goto restart; } -#line 1139 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.c" +#line 1515 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.c" } } -#line 168 "/var/root/php-src/sapi/phpdbg/phpdbg_lexer.l" +#line 183 "/Users/Bob/php-src-5.6/sapi/phpdbg/phpdbg_lexer.l" } diff --git a/phpdbg_lexer.l b/phpdbg_lexer.l index 7b3ce38c472..0c27fc22ace 100644 --- a/phpdbg_lexer.l +++ b/phpdbg_lexer.l @@ -21,8 +21,9 @@ #define YYFILL(n) #define NORMAL 0 -#define RAW 1 -#define INITIAL 2 +#define PRE_RAW 1 +#define RAW 2 +#define INITIAL 3 ZEND_EXTERN_MODULE_GLOBALS(phpdbg); @@ -65,10 +66,17 @@ INPUT [^\n\000]+ := yyleng = (size_t) YYCURSOR - (size_t) yytext; -<*>[\n\000] { +<*>{WS}?[\n\000] { return 0; } +[-][r]{WS}?{DIGITS} { + char *text = yytext + 2; + while (*++text < '0'); + yylval->num = atoi(text); + return T_REQ_ID; +} + {T_IF}{WS} { YYSETCONDITION(RAW); phpdbg_init_param(yylval, EMPTY_PARAM); @@ -143,21 +151,28 @@ INPUT [^\n\000]+ } {T_EVAL}{WS} { - YYSETCONDITION(RAW); + YYSETCONDITION(PRE_RAW); phpdbg_init_param(yylval, EMPTY_PARAM); return T_EVAL; } {T_SHELL}{WS} { - YYSETCONDITION(RAW); + YYSETCONDITION(PRE_RAW); phpdbg_init_param(yylval, EMPTY_PARAM); return T_SHELL; } ({T_RUN}|{T_RUN_SHORT}){WS} { - YYSETCONDITION(RAW); + YYSETCONDITION(PRE_RAW); phpdbg_init_param(yylval, EMPTY_PARAM); return T_RUN; } +. { + YYSETCONDITION(RAW); + + YYCURSOR = LEX(text); + goto restart; +} + . { YYSETCONDITION(NORMAL); diff --git a/phpdbg_list.c b/phpdbg_list.c index e8db4e605c7..80b5d2b1892 100644 --- a/phpdbg_list.c +++ b/phpdbg_list.c @@ -34,21 +34,21 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg); -#define PHPDBG_LIST_COMMAND_D(f, h, a, m, l, s) \ - PHPDBG_COMMAND_D_EXP(f, h, a, m, l, s, &phpdbg_prompt_commands[13]) +#define PHPDBG_LIST_COMMAND_D(f, h, a, m, l, s, flags) \ + PHPDBG_COMMAND_D_EXP(f, h, a, m, l, s, &phpdbg_prompt_commands[13], flags) const phpdbg_command_t phpdbg_list_commands[] = { - PHPDBG_LIST_COMMAND_D(lines, "lists the specified lines", 'l', list_lines, NULL, "l"), - PHPDBG_LIST_COMMAND_D(class, "lists the specified class", 'c', list_class, NULL, "s"), - PHPDBG_LIST_COMMAND_D(method, "lists the specified method", 'm', list_method, NULL, "m"), - PHPDBG_LIST_COMMAND_D(func, "lists the specified function", 'f', list_func, NULL, "s"), + PHPDBG_LIST_COMMAND_D(lines, "lists the specified lines", 'l', list_lines, NULL, "l", PHPDBG_ASYNC_SAFE), + PHPDBG_LIST_COMMAND_D(class, "lists the specified class", 'c', list_class, NULL, "s", PHPDBG_ASYNC_SAFE), + PHPDBG_LIST_COMMAND_D(method, "lists the specified method", 'm', list_method, NULL, "m", PHPDBG_ASYNC_SAFE), + PHPDBG_LIST_COMMAND_D(func, "lists the specified function", 'f', list_func, NULL, "s", PHPDBG_ASYNC_SAFE), PHPDBG_END_COMMAND }; PHPDBG_LIST(lines) /* {{{ */ { if (!PHPDBG_G(exec) && !zend_is_executing(TSRMLS_C)) { - phpdbg_error("Not executing, and execution context not set"); + phpdbg_error("inactive", "type=\"execution\"", "Not executing, and execution context not set"); return SUCCESS; } @@ -59,7 +59,7 @@ PHPDBG_LIST(lines) /* {{{ */ (param->num < 0 ? param->num : 0) + zend_get_executed_lineno(TSRMLS_C), 0 TSRMLS_CC); break; - + case FILE_PARAM: phpdbg_list_file(param->file.name, param->file.line, 0, 0 TSRMLS_CC); break; @@ -81,19 +81,19 @@ PHPDBG_LIST(method) /* {{{ */ { zend_class_entry **ce; - if (zend_lookup_class(param->method.class, strlen(param->method.class), &ce TSRMLS_CC) == SUCCESS) { + if (phpdbg_safe_class_lookup(param->method.class, strlen(param->method.class), &ce TSRMLS_CC) == SUCCESS) { zend_function *function; char *lcname = zend_str_tolower_dup(param->method.name, strlen(param->method.name)); if (zend_hash_find(&(*ce)->function_table, lcname, strlen(lcname)+1, (void**) &function) == SUCCESS) { phpdbg_list_function(function TSRMLS_CC); } else { - phpdbg_error("Could not find %s::%s", param->method.class, param->method.name); + phpdbg_error("list", "type=\"notfound\" method=\"%s::%s\"", "Could not find %s::%s", param->method.class, param->method.name); } efree(lcname); } else { - phpdbg_error("Could not find the class %s", param->method.class); + phpdbg_error("list", "type=\"notfound\" class=\"%s\"", "Could not find the class %s", param->method.class); } return SUCCESS; @@ -103,7 +103,7 @@ PHPDBG_LIST(class) /* {{{ */ { zend_class_entry **ce; - if (zend_lookup_class(param->str, param->len, &ce TSRMLS_CC) == SUCCESS) { + if (phpdbg_safe_class_lookup(param->str, param->len, &ce TSRMLS_CC) == SUCCESS) { if ((*ce)->type == ZEND_USER_CLASS) { if ((*ce)->info.user.filename) { phpdbg_list_file( @@ -112,71 +112,62 @@ PHPDBG_LIST(class) /* {{{ */ (*ce)->info.user.line_start, 0 TSRMLS_CC ); } else { - phpdbg_error("The source of the requested class (%s) cannot be found", (*ce)->name); + phpdbg_error("list", "type=\"nosource\" class=\"%s\"", "The source of the requested class (%s) cannot be found", (*ce)->name); } } else { - phpdbg_error("The class requested (%s) is not user defined", (*ce)->name); + phpdbg_error("list", "type=\"internalclass\" class=\"%s\"", "The class requested (%s) is not user defined", (*ce)->name); } } else { - phpdbg_error("The requested class (%s) could not be found", param->str); + phpdbg_error("list", "type=\"notfound\" class=\"%s\"", "The requested class (%s) could not be found", param->str); } return SUCCESS; } /* }}} */ -void phpdbg_list_file(const char *filename, long count, long offset, int highlight TSRMLS_DC) /* {{{ */ +void phpdbg_list_file(const char *filename, uint count, int offset, uint highlight TSRMLS_DC) /* {{{ */ { - struct stat st; - char *opened = NULL; - char buffer[8096] = {0,}; - long line = 0; + uint line, lastline; + phpdbg_file_source **data; - php_stream *stream = NULL; - - if (VCWD_STAT(filename, &st) == FAILURE) { - phpdbg_error("Failed to stat file %s", filename); + 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..."); return; } - stream = php_stream_open_wrapper(filename, "rb", USE_PATH, &opened); - - if (!stream) { - phpdbg_error("Failed to open file %s to list", filename); - return; - } - if (offset < 0) { count += offset; offset = 0; } - - while (php_stream_gets(stream, buffer, sizeof(buffer)) != NULL) { - long linelen = strlen(buffer); - ++line; - - if (offset <= line) { - if (!highlight) { - phpdbg_write("%05ld: %s", line, buffer); + lastline = offset + count; + + if (lastline > (*data)->lines) { + lastline = (*data)->lines; + } + + phpdbg_xml("", filename); + + for (line = offset; line < lastline;) { + uint linestart = (*data)->line[line++]; + uint linelen = (*data)->line[line] - linestart; + char *buffer = (*data)->buf + linestart; + + if (!highlight) { + phpdbg_write("line", "line=\"%u\" code=\"%.*s\"", " %05u: %.*s", line, linelen, buffer); + } else { + if (highlight != line) { + phpdbg_write("line", "line=\"%u\" code=\"%.*s\"", " %05u: %.*s", line, linelen, buffer); } else { - if (highlight != line) { - phpdbg_write(" %05ld: %s", line, buffer); - } else { - phpdbg_write(">%05ld: %s", line, buffer); - } - } - - if (buffer[linelen - 1] != '\n') { - phpdbg_write("\n"); + phpdbg_write("line", "line=\"%u\" code=\"%.*s\" current=\"current\"", ">%05u: %.*s", line, linelen, buffer); } } - if (count > 0 && count + offset - 1 < line) { - break; + if (*(buffer + linelen - 1) != '\n' || !linelen) { + phpdbg_out("\n"); } } - - php_stream_close(stream); + + phpdbg_xml(""); } /* }}} */ void phpdbg_list_function(const zend_function *fbc TSRMLS_DC) /* {{{ */ @@ -184,14 +175,13 @@ void phpdbg_list_function(const zend_function *fbc TSRMLS_DC) /* {{{ */ const zend_op_array *ops; if (fbc->type != ZEND_USER_FUNCTION) { - phpdbg_error("The function requested (%s) is not user defined", fbc->common.function_name); + phpdbg_error("list", "type=\"internalfunction\" function=\"%s\"", "The function requested (%s) is not user defined", fbc->common.function_name); return; } - ops = (zend_op_array*)fbc; + ops = (zend_op_array *)fbc; - phpdbg_list_file(ops->filename, - ops->line_end - ops->line_start + 1, ops->line_start, 0 TSRMLS_CC); + phpdbg_list_file(ops->filename, ops->line_end - ops->line_start + 1, ops->line_start, 0 TSRMLS_CC); } /* }}} */ void phpdbg_list_function_byname(const char *str, size_t len TSRMLS_DC) /* {{{ */ @@ -209,11 +199,11 @@ void phpdbg_list_function_byname(const char *str, size_t len TSRMLS_DC) /* {{{ * func_table = &EG(scope)->function_table; } else { - phpdbg_error("No active class"); + phpdbg_error("inactive", "type=\"noclasses\"", "No active class"); return; } } else if (!EG(function_table)) { - phpdbg_error("No function table loaded"); + phpdbg_error("inactive", "type=\"function_table\"", "No function table loaded"); return; } else { func_table = EG(function_table); @@ -222,12 +212,86 @@ void phpdbg_list_function_byname(const char *str, size_t len TSRMLS_DC) /* {{{ * /* use lowercase names, case insensitive */ func_name = zend_str_tolower_dup(func_name, func_name_len); - if (zend_hash_find(func_table, func_name, func_name_len+1, (void**)&fbc) == SUCCESS) { - phpdbg_list_function(fbc TSRMLS_CC); - } else { - phpdbg_error("Function %s not found", func_name); - } + phpdbg_try_access { + if (zend_hash_find(func_table, func_name, func_name_len+1, (void**)&fbc) == SUCCESS) { + phpdbg_list_function(fbc TSRMLS_CC); + } else { + phpdbg_error("list", "type=\"nofunction\" function=\"%s\"", "Function %s not found", func_name); + } + } phpdbg_catch_access { + phpdbg_error("signalsegv", "function=\"%s\"", "Could not list function %s, invalid data source", func_name); + } phpdbg_end_try_access(); efree(func_name); } /* }}} */ +zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type TSRMLS_DC) { + phpdbg_file_source data, *dataptr; + zend_file_handle fake = {0}; + zend_op_array *ret; + char *filename = (char *)(file->opened_path ? file->opened_path : file->filename); + uint line; + char *bufptr, *endptr; + + zend_stream_fixup(file, &data.buf, &data.len TSRMLS_CC); + + data.filename = filename; + data.line[0] = 0; + + if (file->handle.stream.mmap.old_closer) { + /* do not unmap */ + file->handle.stream.closer = file->handle.stream.mmap.old_closer; + } + +#if HAVE_MMAP + if (file->handle.stream.mmap.map) { + data.map = file->handle.stream.mmap.map; + } +#endif + + fake.type = ZEND_HANDLE_MAPPED; + fake.handle.stream.mmap.buf = data.buf; + fake.handle.stream.mmap.len = data.len; + fake.free_filename = 0; + fake.opened_path = file->opened_path; + fake.filename = filename; + fake.opened_path = file->opened_path; + + *(dataptr = emalloc(sizeof(phpdbg_file_source) + sizeof(uint) * data.len)) = data; + 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;) { + if (*bufptr == '\n') { + dataptr->line[++line] = (uint)(bufptr - data.buf) + 1; + } + } + dataptr->lines = ++line; + dataptr->line[line] = endptr - data.buf; + dataptr = erealloc(dataptr, sizeof(phpdbg_file_source) + sizeof(uint) * line); + + ret = PHPDBG_G(compile_file)(&fake, type TSRMLS_CC); + + fake.opened_path = NULL; + zend_file_handle_dtor(&fake TSRMLS_CC); + + return ret; +} + +void phpdbg_free_file_source(phpdbg_file_source *data) { +#if HAVE_MMAP + if (data->map) { + munmap(data->map, data->len + ZEND_MMAP_AHEAD); + } else +#endif + if (data->buf) { + efree(data->buf); + } + + efree(data); +} + +void phpdbg_init_list(TSRMLS_D) { + PHPDBG_G(compile_file) = zend_compile_file; + zend_hash_init(&PHPDBG_G(file_sources), 1, NULL, (dtor_func_t) phpdbg_free_file_source, 0); + zend_compile_file = phpdbg_compile_file; +} diff --git a/phpdbg_list.h b/phpdbg_list.h index 14905f65673..c88328bfeaf 100644 --- a/phpdbg_list.h +++ b/phpdbg_list.h @@ -34,8 +34,21 @@ PHPDBG_LIST(func); void phpdbg_list_function_byname(const char *, size_t TSRMLS_DC); void phpdbg_list_function(const zend_function* TSRMLS_DC); -void phpdbg_list_file(const char*, long, long, int TSRMLS_DC); +void phpdbg_list_file(const char*, uint, int, uint TSRMLS_DC); extern const phpdbg_command_t phpdbg_list_commands[]; +void phpdbg_init_list(TSRMLS_D); + +typedef struct { + char *filename; + char *buf; + size_t len; +#if HAVE_MMAP + void *map; +#endif + uint lines; + uint line[1]; +} phpdbg_file_source; + #endif /* PHPDBG_LIST_H */ diff --git a/phpdbg_opcode.c b/phpdbg_opcode.c index 6b13625fc14..331718accc2 100644 --- a/phpdbg_opcode.c +++ b/phpdbg_opcode.c @@ -92,8 +92,7 @@ char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars TSRM case ZEND_JMPZNZ: decode[1] = phpdbg_decode_op(ops, &op->op1, op->op1_type, vars TSRMLS_CC); - asprintf( - &decode[2], "J%u or J%lu", op->op2.opline_num, op->extended_value); + asprintf(&decode[2], "J%u or J%lu", op->op2.opline_num, op->extended_value); goto result; case ZEND_JMPZ: @@ -103,13 +102,9 @@ char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars TSRM #ifdef ZEND_JMP_SET case ZEND_JMP_SET: -#endif -#ifdef ZEND_JMP_SET_VAR - case ZEND_JMP_SET_VAR: #endif decode[1] = phpdbg_decode_op(ops, &op->op1, op->op1_type, vars TSRMLS_CC); - asprintf( - &decode[2], "J%ld", op->op2.jmp_addr - ops->opcodes); + asprintf(&decode[2], "J%ld", op->op2.jmp_addr - ops->opcodes); goto result; case ZEND_RECV_INIT: @@ -121,8 +116,7 @@ char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars TSRM result: decode[3] = phpdbg_decode_op(ops, &op->result, op->result_type, vars TSRMLS_CC); format: - asprintf( - &decode[0], + asprintf(&decode[0], "%-20s %-20s %-20s", decode[1] ? decode[1] : "", decode[2] ? decode[2] : "", @@ -153,7 +147,7 @@ void phpdbg_print_opline_ex(zend_execute_data *execute_data, HashTable *vars, ze if (ignore_flags || (!(PHPDBG_G(flags) & PHPDBG_IS_QUIET) || (PHPDBG_G(flags) & PHPDBG_IS_STEPPING))) { /* output line info */ - phpdbg_notice("L%-5u %16p %-30s %s %s", + phpdbg_notice("opline", "line=\"%u\" opline=\"%p\" opcode=\"%s\" op=\"%s\" file=\"%s\"", "L%-5u %16p %-30s %s %s", opline->lineno, opline, phpdbg_decode_opcode(opline->opcode), @@ -162,7 +156,7 @@ void phpdbg_print_opline_ex(zend_execute_data *execute_data, HashTable *vars, ze } if (!ignore_flags && PHPDBG_G(oplog)) { - phpdbg_log_ex(PHPDBG_G(oplog), "L%-5u %16p %-30s %s %s", + phpdbg_log_ex(fileno(PHPDBG_G(oplog)), "L%-5u %16p %-30s %s %s", opline->lineno, opline, phpdbg_decode_opcode(opline->opcode), @@ -333,12 +327,6 @@ const char *phpdbg_decode_opcode(zend_uchar opcode) /* {{{ */ #ifdef ZEND_SEPARATE CASE(ZEND_SEPARATE); #endif -#ifdef ZEND_QM_ASSIGN_VAR - CASE(ZEND_QM_ASSIGN_VAR); -#endif -#ifdef ZEND_JMP_SET_VAR - CASE(ZEND_JMP_SET_VAR); -#endif #ifdef ZEND_DISCARD_EXCEPTION CASE(ZEND_DISCARD_EXCEPTION); #endif diff --git a/phpdbg_out.c b/phpdbg_out.c new file mode 100644 index 00000000000..a4793f144f6 --- /dev/null +++ b/phpdbg_out.c @@ -0,0 +1,1305 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#include "zend.h" +#include "php.h" +#include "spprintf.h" +#include "phpdbg.h" +#include "phpdbg_io.h" +#include "phpdbg_eol.h" +#include "ext/standard/html.h" + +#ifdef _WIN32 +# include "win32/time.h" +#endif + +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); + +/* copied from php-src/main/snprintf.c and slightly modified */ +/* + * NUM_BUF_SIZE is the size of the buffer used for arithmetic conversions + * + * XXX: this is a magic number; do not decrease it + * Emax = 1023 + * NDIG = 320 + * NUM_BUF_SIZE >= strlen("-") + Emax + strlrn(".") + NDIG + strlen("E+1023") + 1; + */ +#define NUM_BUF_SIZE 2048 + +/* + * Descriptor for buffer area + */ +struct buf_area { + char *buf_end; + char *nextb; /* pointer to next byte to read/write */ +}; + +typedef struct buf_area buffy; + +/* + * The INS_CHAR macro inserts a character in the buffer and writes + * the buffer back to disk if necessary + * It uses the char pointers sp and bep: + * sp points to the next available character in the buffer + * bep points to the end-of-buffer+1 + * While using this macro, note that the nextb pointer is NOT updated. + * + * NOTE: Evaluation of the c argument should not have any side-effects + */ +#define INS_CHAR(c, sp, bep, cc) \ + { \ + if (sp < bep) \ + { \ + *sp++ = c; \ + } \ + cc++; \ + } + +#define NUM( c ) ( c - '0' ) + +#define STR_TO_DEC( str, num ) \ + num = NUM( *str++ ) ; \ + while ( isdigit((int)*str ) ) \ + { \ + num *= 10 ; \ + num += NUM( *str++ ) ; \ + } + +/* + * This macro does zero padding so that the precision + * requirement is satisfied. The padding is done by + * adding '0's to the left of the string that is going + * to be printed. + */ +#define FIX_PRECISION( adjust, precision, s, s_len ) \ + if ( adjust ) \ + while ( s_len < precision ) \ + { \ + *--s = '0' ; \ + s_len++ ; \ + } + +/* + * Macro that does padding. The padding is done by printing + * the character ch. + */ +#define PAD( width, len, ch ) do \ + { \ + INS_CHAR( ch, sp, bep, cc ) ; \ + width-- ; \ + } \ + while ( width > len ) + +/* + * Prefix the character ch to the string str + * Increase length + * Set the has_prefix flag + */ +#define PREFIX( str, length, ch ) *--str = ch ; length++ ; has_prefix = YES + + +#ifdef HAVE_LOCALE_H +#include +#define LCONV_DECIMAL_POINT (*lconv->decimal_point) +#else +#define LCONV_DECIMAL_POINT '.' +#endif +#define NUL '\0' +#define S_NULL "(null)" +#define S_NULL_LEN 6 +#define FLOAT_DIGITS 6 + +/* + * Do format conversion placing the output in buffer + */ +static int format_converter(register buffy *odp, const char *fmt, zend_bool escape_xml, va_list ap TSRMLS_DC) { + char *sp; + char *bep; + int cc = 0; + int i; + + char *s = NULL, *free_s = NULL; + int s_len, free_zcopy; + zval *zvp, zcopy; + + int min_width = 0; + int precision = 0; + enum { + LEFT, RIGHT + } adjust; + char pad_char; + char prefix_char; + + double fp_num; + wide_int i_num = (wide_int) 0; + u_wide_int ui_num; + + char num_buf[NUM_BUF_SIZE]; + char char_buf[2]; /* for printing %% and % */ + +#ifdef HAVE_LOCALE_H + struct lconv *lconv = NULL; +#endif + + /* + * Flag variables + */ + length_modifier_e modifier; + boolean_e alternate_form; + boolean_e print_sign; + boolean_e print_blank; + boolean_e adjust_precision; + boolean_e adjust_width; + bool_int is_negative; + + sp = odp->nextb; + bep = odp->buf_end; + + while (*fmt) { + if (*fmt != '%') { + INS_CHAR(*fmt, sp, bep, cc); + } else { + /* + * Default variable settings + */ + adjust = RIGHT; + alternate_form = print_sign = print_blank = NO; + pad_char = ' '; + prefix_char = NUL; + free_zcopy = 0; + + fmt++; + + /* + * Try to avoid checking for flags, width or precision + */ + if (isascii((int)*fmt) && !islower((int)*fmt)) { + /* + * Recognize flags: -, #, BLANK, + + */ + for (;; fmt++) { + if (*fmt == '-') + adjust = LEFT; + else if (*fmt == '+') + print_sign = YES; + else if (*fmt == '#') + alternate_form = YES; + else if (*fmt == ' ') + print_blank = YES; + else if (*fmt == '0') + pad_char = '0'; + else + break; + } + + /* + * Check if a width was specified + */ + if (isdigit((int)*fmt)) { + STR_TO_DEC(fmt, min_width); + adjust_width = YES; + } else if (*fmt == '*') { + min_width = va_arg(ap, int); + fmt++; + adjust_width = YES; + if (min_width < 0) { + adjust = LEFT; + min_width = -min_width; + } + } else + adjust_width = NO; + + /* + * Check if a precision was specified + */ + if (*fmt == '.') { + adjust_precision = YES; + fmt++; + if (isdigit((int)*fmt)) { + STR_TO_DEC(fmt, precision); + } else if (*fmt == '*') { + precision = va_arg(ap, int); + fmt++; + if (precision < 0) + precision = 0; + } else + precision = 0; + + if (precision > FORMAT_CONV_MAX_PRECISION && *fmt != 's' && *fmt != 'v' && *fmt != 'b') { + precision = FORMAT_CONV_MAX_PRECISION; + } + } else + adjust_precision = NO; + } else + adjust_precision = adjust_width = NO; + + /* + * Modifier check + */ + switch (*fmt) { + case 'L': + fmt++; + modifier = LM_LONG_DOUBLE; + break; + case 'I': + fmt++; +#if SIZEOF_LONG_LONG + if (*fmt == '6' && *(fmt+1) == '4') { + fmt += 2; + modifier = LM_LONG_LONG; + } else +#endif + if (*fmt == '3' && *(fmt+1) == '2') { + fmt += 2; + modifier = LM_LONG; + } else { +#ifdef _WIN64 + modifier = LM_LONG_LONG; +#else + modifier = LM_LONG; +#endif + } + break; + case 'l': + fmt++; +#if SIZEOF_LONG_LONG + if (*fmt == 'l') { + fmt++; + modifier = LM_LONG_LONG; + } else +#endif + modifier = LM_LONG; + break; + case 'z': + fmt++; + modifier = LM_SIZE_T; + break; + case 'j': + fmt++; +#if SIZEOF_INTMAX_T + modifier = LM_INTMAX_T; +#else + modifier = LM_SIZE_T; +#endif + break; + case 't': + fmt++; +#if SIZEOF_PTRDIFF_T + modifier = LM_PTRDIFF_T; +#else + modifier = LM_SIZE_T; +#endif + break; + case 'h': + fmt++; + if (*fmt == 'h') { + fmt++; + } + /* these are promoted to int, so no break */ + default: + modifier = LM_STD; + break; + } + + /* + * Argument extraction and printing. + * First we determine the argument type. + * Then, we convert the argument to a string. + * On exit from the switch, s points to the string that + * must be printed, s_len has the length of the string + * The precision requirements, if any, are reflected in s_len. + * + * NOTE: pad_char may be set to '0' because of the 0 flag. + * It is reset to ' ' by non-numeric formats + */ + switch (*fmt) { + case 'Z': + zvp = (zval*) va_arg(ap, zval*); + zend_make_printable_zval(zvp, &zcopy, &free_zcopy); + if (free_zcopy) { + zvp = &zcopy; + } + s_len = Z_STRLEN_P(zvp); + s = Z_STRVAL_P(zvp); + if (adjust_precision && precision < s_len) { + s_len = precision; + } + break; + case 'u': + switch(modifier) { + default: + i_num = (wide_int) va_arg(ap, unsigned int); + break; + case LM_LONG_DOUBLE: + goto fmt_error; + case LM_LONG: + i_num = (wide_int) va_arg(ap, unsigned long int); + break; + case LM_SIZE_T: + i_num = (wide_int) va_arg(ap, size_t); + break; +#if SIZEOF_LONG_LONG + case LM_LONG_LONG: + i_num = (wide_int) va_arg(ap, u_wide_int); + break; +#endif +#if SIZEOF_INTMAX_T + case LM_INTMAX_T: + i_num = (wide_int) va_arg(ap, uintmax_t); + break; +#endif +#if SIZEOF_PTRDIFF_T + case LM_PTRDIFF_T: + i_num = (wide_int) va_arg(ap, ptrdiff_t); + break; +#endif + } + /* + * The rest also applies to other integer formats, so fall + * into that case. + */ + case 'd': + case 'i': + /* + * Get the arg if we haven't already. + */ + if ((*fmt) != 'u') { + switch(modifier) { + default: + i_num = (wide_int) va_arg(ap, int); + break; + case LM_LONG_DOUBLE: + goto fmt_error; + case LM_LONG: + i_num = (wide_int) va_arg(ap, long int); + break; + case LM_SIZE_T: +#if SIZEOF_SSIZE_T + i_num = (wide_int) va_arg(ap, ssize_t); +#else + i_num = (wide_int) va_arg(ap, size_t); +#endif + break; +#if SIZEOF_LONG_LONG + case LM_LONG_LONG: + i_num = (wide_int) va_arg(ap, wide_int); + break; +#endif +#if SIZEOF_INTMAX_T + case LM_INTMAX_T: + i_num = (wide_int) va_arg(ap, intmax_t); + break; +#endif +#if SIZEOF_PTRDIFF_T + case LM_PTRDIFF_T: + i_num = (wide_int) va_arg(ap, ptrdiff_t); + break; +#endif + } + } + s = ap_php_conv_10(i_num, (*fmt) == 'u', &is_negative, + &num_buf[NUM_BUF_SIZE], &s_len); + FIX_PRECISION(adjust_precision, precision, s, s_len); + + if (*fmt != 'u') { + if (is_negative) { + prefix_char = '-'; + } else if (print_sign) { + prefix_char = '+'; + } else if (print_blank) { + prefix_char = ' '; + } + } + break; + + + case 'o': + switch(modifier) { + default: + ui_num = (u_wide_int) va_arg(ap, unsigned int); + break; + case LM_LONG_DOUBLE: + goto fmt_error; + case LM_LONG: + ui_num = (u_wide_int) va_arg(ap, unsigned long int); + break; + case LM_SIZE_T: + ui_num = (u_wide_int) va_arg(ap, size_t); + break; +#if SIZEOF_LONG_LONG + case LM_LONG_LONG: + ui_num = (u_wide_int) va_arg(ap, u_wide_int); + break; +#endif +#if SIZEOF_INTMAX_T + case LM_INTMAX_T: + ui_num = (u_wide_int) va_arg(ap, uintmax_t); + break; +#endif +#if SIZEOF_PTRDIFF_T + case LM_PTRDIFF_T: + ui_num = (u_wide_int) va_arg(ap, ptrdiff_t); + break; +#endif + } + s = ap_php_conv_p2(ui_num, 3, *fmt, &num_buf[NUM_BUF_SIZE], &s_len); + FIX_PRECISION(adjust_precision, precision, s, s_len); + if (alternate_form && *s != '0') { + *--s = '0'; + s_len++; + } + break; + + + case 'x': + case 'X': + switch(modifier) { + default: + ui_num = (u_wide_int) va_arg(ap, unsigned int); + break; + case LM_LONG_DOUBLE: + goto fmt_error; + case LM_LONG: + ui_num = (u_wide_int) va_arg(ap, unsigned long int); + break; + case LM_SIZE_T: + ui_num = (u_wide_int) va_arg(ap, size_t); + break; +#if SIZEOF_LONG_LONG + case LM_LONG_LONG: + ui_num = (u_wide_int) va_arg(ap, u_wide_int); + break; +#endif +#if SIZEOF_INTMAX_T + case LM_INTMAX_T: + ui_num = (u_wide_int) va_arg(ap, uintmax_t); + break; +#endif +#if SIZEOF_PTRDIFF_T + case LM_PTRDIFF_T: + ui_num = (u_wide_int) va_arg(ap, ptrdiff_t); + break; +#endif + } + s = ap_php_conv_p2(ui_num, 4, *fmt, &num_buf[NUM_BUF_SIZE], &s_len); + FIX_PRECISION(adjust_precision, precision, s, s_len); + if (alternate_form && i_num != 0) { + *--s = *fmt; /* 'x' or 'X' */ + *--s = '0'; + s_len += 2; + } + break; + + + case 's': + case 'v': + s = va_arg(ap, char *); + if (s != NULL) { + if (adjust_precision) { + s_len = precision; + } else { + s_len = strlen(s); + } + + if (escape_xml) { + /* added: support for xml escaping */ + + int old_slen = s_len, i = 0; + char *old_s = s, *s_ptr; + free_s = s_ptr = s = emalloc(old_slen * 6 + 1); + do { + if (old_s[i] == '&' || old_s[i] == '"' || old_s[i] == '<') { + *s_ptr++ = '&'; + switch (old_s[i]) { + case '"': + s_len += 5; + *s_ptr++ = 'q'; + *s_ptr++ = 'u'; + *s_ptr++ = 'o'; + *s_ptr++ = 't'; + break; + case '<': + s_len += 3; + *s_ptr++ = 'l'; + *s_ptr++ = 't'; + break; + case '&': + s_len += 4; + *s_ptr++ = 'a'; + *s_ptr++ = 'm'; + *s_ptr++ = 'p'; + break; + } + *s_ptr++ = ';'; + } else { + *s_ptr++ = old_s[i]; + } + } while (i++ < old_slen); + } + } else { + s = S_NULL; + s_len = S_NULL_LEN; + } + pad_char = ' '; + break; + + + case 'b': + if (escape_xml) { + s = PHPDBG_G(err_buf).xml; + } else { + s = PHPDBG_G(err_buf).msg; + } + + if (s != NULL) { + if (escape_xml) { + s_len = PHPDBG_G(err_buf).xmllen; + } else { + s_len = PHPDBG_G(err_buf).msglen; + } + + if (adjust_precision && precision != s_len) { + s_len = precision; + } + } else { + s = ""; + s_len = 0; + } + pad_char = ' '; + break; + + + case 'r': + if (PHPDBG_G(req_id)) { + s_len = spprintf(&s, 0, "req=\"%lu\"", PHPDBG_G(req_id)); + free_s = s; + } else { + s = ""; + s_len = 0; + } + break; + + + case 'f': + case 'F': + case 'e': + case 'E': + + switch(modifier) { + case LM_LONG_DOUBLE: + fp_num = (double) va_arg(ap, long double); + break; + case LM_STD: + fp_num = va_arg(ap, double); + break; + default: + goto fmt_error; + } + + if (zend_isnan(fp_num)) { + s = "NAN"; + s_len = 3; + } else if (zend_isinf(fp_num)) { + s = "INF"; + s_len = 3; + } else { +#ifdef HAVE_LOCALE_H + if (!lconv) { + lconv = localeconv(); + } +#endif + s = php_conv_fp((*fmt == 'f')?'F':*fmt, fp_num, alternate_form, + (adjust_precision == NO) ? FLOAT_DIGITS : precision, + (*fmt == 'f')?LCONV_DECIMAL_POINT:'.', + &is_negative, &num_buf[1], &s_len); + if (is_negative) + prefix_char = '-'; + else if (print_sign) + prefix_char = '+'; + else if (print_blank) + prefix_char = ' '; + } + break; + + + case 'g': + case 'k': + case 'G': + case 'H': + switch(modifier) { + case LM_LONG_DOUBLE: + fp_num = (double) va_arg(ap, long double); + break; + case LM_STD: + fp_num = va_arg(ap, double); + break; + default: + goto fmt_error; + } + + if (zend_isnan(fp_num)) { + s = "NAN"; + s_len = 3; + break; + } else if (zend_isinf(fp_num)) { + if (fp_num > 0) { + s = "INF"; + s_len = 3; + } else { + s = "-INF"; + s_len = 4; + } + break; + } + + if (adjust_precision == NO) { + precision = FLOAT_DIGITS; + } else if (precision == 0) { + precision = 1; + } + /* + * * We use &num_buf[ 1 ], so that we have room for the sign + */ +#ifdef HAVE_LOCALE_H + if (!lconv) { + lconv = localeconv(); + } +#endif + s = php_gcvt(fp_num, precision, (*fmt=='H' || *fmt == 'k') ? '.' : LCONV_DECIMAL_POINT, (*fmt == 'G' || *fmt == 'H')?'E':'e', &num_buf[1]); + if (*s == '-') { + prefix_char = *s++; + } else if (print_sign) { + prefix_char = '+'; + } else if (print_blank) { + prefix_char = ' '; + } + + s_len = strlen(s); + + if (alternate_form && (strchr(s, '.')) == NULL) { + s[s_len++] = '.'; + } + break; + + + case 'c': + char_buf[0] = (char) (va_arg(ap, int)); + s = &char_buf[0]; + s_len = 1; + pad_char = ' '; + break; + + + case '%': + char_buf[0] = '%'; + s = &char_buf[0]; + s_len = 1; + pad_char = ' '; + break; + + + case 'n': + *(va_arg(ap, int *)) = cc; + goto skip_output; + + /* + * Always extract the argument as a "char *" pointer. We + * should be using "void *" but there are still machines + * that don't understand it. + * If the pointer size is equal to the size of an unsigned + * integer we convert the pointer to a hex number, otherwise + * we print "%p" to indicate that we don't handle "%p". + */ + case 'p': + if (sizeof(char *) <= sizeof(u_wide_int)) { + ui_num = (u_wide_int)((size_t) va_arg(ap, char *)); + s = ap_php_conv_p2(ui_num, 4, 'x', + &num_buf[NUM_BUF_SIZE], &s_len); + if (ui_num != 0) { + *--s = 'x'; + *--s = '0'; + s_len += 2; + } + } else { + s = "%p"; + s_len = 2; + } + pad_char = ' '; + break; + + + case NUL: + /* + * The last character of the format string was %. + * We ignore it. + */ + continue; + + +fmt_error: + php_error(E_ERROR, "Illegal length modifier specified '%c' in s[np]printf call", *fmt); + /* + * The default case is for unrecognized %'s. + * We print % to help the user identify what + * option is not understood. + * This is also useful in case the user wants to pass + * the output of format_converter to another function + * that understands some other % (like syslog). + * Note that we can't point s inside fmt because the + * unknown could be preceded by width etc. + */ + default: + char_buf[0] = '%'; + char_buf[1] = *fmt; + s = char_buf; + s_len = 2; + pad_char = ' '; + break; + } + + if (prefix_char != NUL) { + *--s = prefix_char; + s_len++; + } + if (adjust_width && adjust == RIGHT && min_width > s_len) { + if (pad_char == '0' && prefix_char != NUL) { + INS_CHAR(*s, sp, bep, cc) + s++; + s_len--; + min_width--; + } + PAD(min_width, s_len, pad_char); + } + /* + * Print the string s. + */ + for (i = s_len; i != 0; i--) { + INS_CHAR(*s, sp, bep, cc); + s++; + } + + if (adjust_width && adjust == LEFT && min_width > s_len) + PAD(min_width, s_len, pad_char); + if (free_zcopy) { + zval_dtor(&zcopy); + } + } +skip_output: + if (free_s) { + efree(free_s); + free_s = NULL; + } + + fmt++; + } + odp->nextb = sp; + return (cc); +} + +static void strx_printv(int *ccp, char *buf, size_t len, const char *format, zend_bool escape_xml, va_list ap TSRMLS_DC) { + buffy od; + int cc; + + /* + * First initialize the descriptor + * Notice that if no length is given, we initialize buf_end to the + * highest possible address. + */ + if (len == 0) { + od.buf_end = (char *) ~0; + od.nextb = (char *) ~0; + } else { + od.buf_end = &buf[len-1]; + od.nextb = buf; + } + + /* + * Do the conversion + */ + cc = format_converter(&od, format, escape_xml, ap TSRMLS_CC); + if (len != 0 && od.nextb <= od.buf_end) { + *(od.nextb) = '\0'; + } + if (ccp) { + *ccp = cc; + } +} + +static int phpdbg_xml_vsnprintf(char *buf, size_t len, const char *format, zend_bool escape_xml, va_list ap TSRMLS_DC) { + int cc; + + strx_printv(&cc, buf, len, format, escape_xml, ap TSRMLS_CC); + return (cc); +} + +PHPDBG_API int phpdbg_xml_vasprintf(char **buf, const char *format, zend_bool escape_xml, va_list ap TSRMLS_DC) { + va_list ap2; + int cc; + + va_copy(ap2, ap); + cc = phpdbg_xml_vsnprintf(NULL, 0, format, escape_xml, ap2 TSRMLS_CC); + va_end(ap2); + + *buf = NULL; + + if (cc >= 0) { + if ((*buf = emalloc(++cc)) != NULL) { + if ((cc = phpdbg_xml_vsnprintf(*buf, cc, format, escape_xml, ap TSRMLS_CC)) < 0) { + efree(*buf); + *buf = NULL; + } + } + } + + return cc; +} +/* copy end */ + +PHPDBG_API int _phpdbg_xml_asprintf(char **buf TSRMLS_DC, const char *format, zend_bool escape_xml, ...) { + int ret; + va_list va; + + va_start(va, escape_xml); + ret = phpdbg_xml_vasprintf(buf, format, escape_xml, va TSRMLS_CC); + va_end(va); + + return ret; +} + +PHPDBG_API int _phpdbg_asprintf(char **buf TSRMLS_DC, const char *format, ...) { + int ret; + va_list va; + + va_start(va, format); + ret = phpdbg_xml_vasprintf(buf, format, 0, va TSRMLS_CC); + va_end(va); + + return ret; +} + +static int phpdbg_encode_xml(char **buf, char *msg, int msglen, int from, char *to) { + int i; + int tolen = to ? strlen(to) : 5; + char *tmp = *buf = emalloc(msglen * tolen); + for (i = 0; i++ < msglen; msg++) { + if (*msg == '&') { + memcpy(tmp, ZEND_STRL("&")); + tmp += sizeof("&") - 1; + } else if (*msg == '<') { + memcpy(tmp, ZEND_STRL("<")); + tmp += sizeof("<") - 1; + } else if (((int) *msg) == from) { + memcpy(tmp, to, tolen); + tmp += tolen; + } else { + *tmp++ = *msg; + } + } + + { + int len = tmp - *buf; + *buf = erealloc(*buf, len + 1); + return len; + } +} + +static void phpdbg_encode_ctrl_chars(char **buf, int *buflen) { + char *tmp, *tmpptr; + int len; + int i; + + tmp = tmpptr = emalloc(*buflen * 5); + + for (i = 0; i < *buflen; i++) { + if ((*buf)[i] < 0x20) { + *tmpptr++ = '&'; + *tmpptr++ = '#'; + if ((unsigned int) ((*buf)[i]) > 9) { + *tmpptr++ = ((*buf)[i] / 10) + '0'; + } + *tmpptr++ = ((*buf)[i] % 10) + '0'; + *tmpptr++ = ';'; + } else { + *tmpptr++ = (*buf)[i]; + } + } + + len = tmpptr - tmp; + + efree(*buf); + *buf = erealloc(tmp, len + 1); + *buflen = len; +} + +static int phpdbg_process_print(int fd, int type, const char *tag, const char *msg, int msglen, const char *xml, int xmllen TSRMLS_DC) { + char *msgout = NULL, *buf; + int msgoutlen, xmloutlen, buflen; + const char *severity; + + if ((PHPDBG_G(flags) & PHPDBG_WRITE_XML) && PHPDBG_G(in_script_xml) && PHPDBG_G(in_script_xml) != type) { + phpdbg_mixed_write(fd, ZEND_STRL("") TSRMLS_CC); + PHPDBG_G(in_script_xml) = 0; + } + + switch (type) { + case P_ERROR: + severity = "error"; + if (!PHPDBG_G(last_was_newline)) { + if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) { + phpdbg_mixed_write(fd, ZEND_STRL("\n" "") TSRMLS_CC); + } else { + phpdbg_mixed_write(fd, ZEND_STRL("\n") TSRMLS_CC); + } + PHPDBG_G(last_was_newline) = 1; + } + if (PHPDBG_G(flags) & PHPDBG_IS_COLOURED) { + msgoutlen = phpdbg_asprintf(&msgout, "\033[%sm[%.*s]\033[0m\n", PHPDBG_G(colors)[PHPDBG_COLOR_ERROR]->code, msglen, msg); + } else { + msgoutlen = phpdbg_asprintf(&msgout, "[%.*s]\n", msglen, msg); + } + break; + + case P_NOTICE: + severity = "notice"; + if (!PHPDBG_G(last_was_newline)) { + if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) { + phpdbg_mixed_write(fd, ZEND_STRL("\n" "") TSRMLS_CC); + } else { + phpdbg_mixed_write(fd, ZEND_STRL("\n") TSRMLS_CC); + } + PHPDBG_G(last_was_newline) = 1; + } + if (PHPDBG_G(flags) & PHPDBG_IS_COLOURED) { + msgoutlen = phpdbg_asprintf(&msgout, "\033[%sm[%.*s]\033[0m\n", PHPDBG_G(colors)[PHPDBG_COLOR_NOTICE]->code, msglen, msg); + } else { + msgoutlen = phpdbg_asprintf(&msgout, "[%.*s]\n", msglen, msg); + } + break; + + case P_WRITELN: + severity = "normal"; + if (msg) { + msgoutlen = phpdbg_asprintf(&msgout, "%.*s\n", msglen, msg); + } else { + msgoutlen = 1; + msgout = estrdup("\n"); + } + PHPDBG_G(last_was_newline) = 1; + break; + + case P_WRITE: + severity = "normal"; + if (msg) { + msgout = estrndup(msg, msglen); + msgoutlen = msglen; + PHPDBG_G(last_was_newline) = msg[msglen - 1] == '\n'; + } else { + msgoutlen = 0; + msgout = estrdup(""); + } + break; + + case P_STDOUT: + case P_STDERR: + if (msg) { + PHPDBG_G(last_was_newline) = msg[msglen - 1] == '\n'; + if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) { + if (PHPDBG_G(in_script_xml) != type) { + char *stream_buf; + int stream_buflen = phpdbg_asprintf(&stream_buf, "", type == P_STDERR ? "stderr" : "stdout"); + phpdbg_mixed_write(fd, stream_buf, stream_buflen TSRMLS_CC); + efree(stream_buf); + PHPDBG_G(in_script_xml) = type; + } +#if PHP_VERSION_ID >= 50600 + buf = php_escape_html_entities((unsigned char *) msg, msglen, (size_t *) &buflen, 0, ENT_NOQUOTES, PG(internal_encoding) && PG(internal_encoding)[0] ? PG(internal_encoding) : (SG(default_charset) ? SG(default_charset) : "UTF-8") TSRMLS_CC); +#else + buf = php_escape_html_entities((unsigned char *) msg, msglen, (size_t *) &buflen, 0, ENT_NOQUOTES, SG(default_charset) ? SG(default_charset) : "UTF-8" TSRMLS_CC); +#endif + phpdbg_encode_ctrl_chars(&buf, &buflen); + phpdbg_mixed_write(fd, buf, buflen TSRMLS_CC); + efree(buf); + } else { + phpdbg_mixed_write(fd, msg, msglen TSRMLS_CC); + } + return msglen; + } + break; + + /* no formatting on logging output */ + case P_LOG: + severity = "log"; + if (msg) { + struct timeval tp; + if (gettimeofday(&tp, NULL) == SUCCESS) { + msgoutlen = phpdbg_asprintf(&msgout, "[%ld %.8F]: %.*s\n", tp.tv_sec, tp.tv_usec / 1000000., msglen, msg); + } else { + msgoutlen = FAILURE; + } + } + break; + } + + if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) { + char *xmlout; + + if (PHPDBG_G(req_id)) { + char *xmlbuf = NULL; + xmllen = phpdbg_asprintf(&xmlbuf, "req=\"%lu\" %.*s", PHPDBG_G(req_id), xmllen, xml); + xml = xmlbuf; + } + if (msgout) { + buflen = phpdbg_encode_xml(&buf, msgout, msgoutlen, '"', """); + xmloutlen = phpdbg_asprintf(&xmlout, "<%s severity=\"%s\" %.*s msgout=\"%.*s\" />", tag, severity, xmllen, xml, buflen, buf); + + efree(buf); + } else { + xmloutlen = phpdbg_asprintf(&xmlout, "<%s severity=\"%s\" %.*s msgout=\"\" />", tag, severity, xmllen, xml); + } + + phpdbg_encode_ctrl_chars(&xmlout, &xmloutlen); + phpdbg_eol_convert(&xmlout, &xmloutlen TSRMLS_CC); + phpdbg_mixed_write(fd, xmlout, xmloutlen TSRMLS_CC); + efree(xmlout); + } else if (msgout) { + phpdbg_eol_convert(&msgout, &msgoutlen TSRMLS_CC); + phpdbg_mixed_write(fd, msgout, msgoutlen TSRMLS_CC); + } + + if (PHPDBG_G(req_id) && (PHPDBG_G(flags) & PHPDBG_WRITE_XML)) { + efree((char *) xml); + } + + if (msgout) { + efree(msgout); + } + + return msgout ? msgoutlen : xmloutlen; +} /* }}} */ + +PHPDBG_API int phpdbg_vprint(int type TSRMLS_DC, int fd, const char *tag, const char *xmlfmt, const char *strfmt, va_list args) { + char *msg = NULL, *xml = NULL; + int msglen = 0, xmllen = 0; + int len; + va_list argcpy; + + if (strfmt != NULL && strlen(strfmt) > 0L) { + va_copy(argcpy, args); + msglen = phpdbg_xml_vasprintf(&msg, strfmt, 0, argcpy TSRMLS_CC); + va_end(argcpy); + } + + if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) { + if (xmlfmt != NULL && strlen(xmlfmt) > 0L) { + va_copy(argcpy, args); + xmllen = phpdbg_xml_vasprintf(&xml, xmlfmt, 1, argcpy TSRMLS_CC); + va_end(argcpy); + } else { + xml = estrdup(""); + } + } + + if (PHPDBG_G(err_buf).active && type != P_STDOUT && type != P_STDERR) { + PHPDBG_G(err_buf).type = type; + PHPDBG_G(err_buf).fd = fd; + PHPDBG_G(err_buf).tag = estrdup(tag); + PHPDBG_G(err_buf).msg = msg; + PHPDBG_G(err_buf).msglen = msglen; + if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) { + PHPDBG_G(err_buf).xml = xml; + PHPDBG_G(err_buf).xmllen = xmllen; + } + + return msglen; + } + + len = phpdbg_process_print(fd, type, tag, msg, msglen, xml, xmllen TSRMLS_CC); + + if (msg) { + efree(msg); + } + + if (xml) { + efree(xml); + } + + return len; +} + +PHPDBG_API void phpdbg_free_err_buf(TSRMLS_D) { + if (PHPDBG_G(err_buf).type == 0) { + return; + } + + PHPDBG_G(err_buf).type = 0; + + efree(PHPDBG_G(err_buf).tag); + efree(PHPDBG_G(err_buf).msg); + if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) { + efree(PHPDBG_G(err_buf).xml); + } +} + +PHPDBG_API void phpdbg_activate_err_buf(zend_bool active TSRMLS_DC) { + PHPDBG_G(err_buf).active = active; +} + +PHPDBG_API int phpdbg_output_err_buf(const char *tag, const char *xmlfmt, const char *strfmt TSRMLS_DC, ...) { + int len; + va_list args; + int errbuf_active = PHPDBG_G(err_buf).active; + + PHPDBG_G(err_buf).active = 0; + +#ifdef ZTS + va_start(args, tsrm_ls); +#else + va_start(args, strfmt); +#endif + len = phpdbg_vprint(PHPDBG_G(err_buf).type TSRMLS_CC, PHPDBG_G(err_buf).fd, tag ? tag : PHPDBG_G(err_buf).tag, xmlfmt, strfmt, args); + va_end(args); + + PHPDBG_G(err_buf).active = errbuf_active; + phpdbg_free_err_buf(TSRMLS_C); + + return len; +} + +PHPDBG_API int phpdbg_print(int type TSRMLS_DC, int fd, const char *tag, const char *xmlfmt, const char *strfmt, ...) { + va_list args; + int len; + + va_start(args, strfmt); + len = phpdbg_vprint(type TSRMLS_CC, fd, tag, xmlfmt, strfmt, args); + va_end(args); + + return len; +} + +PHPDBG_API int phpdbg_xml_internal(int fd TSRMLS_DC, const char *fmt, ...) { + int len = 0; + + if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) { + va_list args; + char *buffer; + int buflen; + + va_start(args, fmt); + buflen = phpdbg_xml_vasprintf(&buffer, fmt, 1, args TSRMLS_CC); + va_end(args); + + phpdbg_encode_ctrl_chars(&buffer, &buflen); + + if (PHPDBG_G(in_script_xml)) { + phpdbg_mixed_write(fd, ZEND_STRL("") TSRMLS_CC); + PHPDBG_G(in_script_xml) = 0; + } + + len = phpdbg_mixed_write(fd, buffer, buflen TSRMLS_CC); + efree(buffer); + } + + return len; +} + +PHPDBG_API int phpdbg_log_internal(int fd TSRMLS_DC, const char *fmt, ...) { + va_list args; + char *buffer; + int buflen; + int len = 0; + + va_start(args, fmt); + buflen = phpdbg_xml_vasprintf(&buffer, fmt, 0, args TSRMLS_CC); + va_end(args); + + len = phpdbg_mixed_write(fd, buffer, buflen TSRMLS_CC); + efree(buffer); + + return len; +} + +PHPDBG_API int phpdbg_out_internal(int fd TSRMLS_DC, const char *fmt, ...) { + va_list args; + char *buffer; + int buflen; + int len = 0; + + va_start(args, fmt); + buflen = phpdbg_xml_vasprintf(&buffer, fmt, 0, args TSRMLS_CC); + va_end(args); + + if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) { + char *msg; + int msglen; + + msglen = phpdbg_encode_xml(&msg, buffer, buflen, 256, NULL); + phpdbg_encode_ctrl_chars(&msg, &msglen); + phpdbg_eol_convert(&msg, &msglen TSRMLS_CC); + + if (PHPDBG_G(in_script_xml)) { + phpdbg_mixed_write(fd, ZEND_STRL("") TSRMLS_CC); + PHPDBG_G(in_script_xml) = 0; + } + + phpdbg_mixed_write(fd, ZEND_STRL("") TSRMLS_CC); + len = phpdbg_mixed_write(fd, msg, msglen TSRMLS_CC); + phpdbg_mixed_write(fd, ZEND_STRL("") TSRMLS_CC); + } else { + phpdbg_eol_convert(&buffer, &buflen TSRMLS_CC); + len = phpdbg_mixed_write(fd, buffer, buflen TSRMLS_CC); + } + + return len; +} + + +PHPDBG_API int phpdbg_rlog_internal(int fd TSRMLS_DC, const char *fmt, ...) { /* {{{ */ + int rc = 0; + + va_list args; + struct timeval tp; + + va_start(args, fmt); + if (gettimeofday(&tp, NULL) == SUCCESS) { + char friendly[100]; + char *format = NULL, *buffer = NULL, *outbuf = NULL; + const time_t tt = tp.tv_sec; + +#ifdef PHP_WIN32 + strftime(friendly, 100, "%a %b %d %H.%%04d %Y", localtime(&tt)); +#else + strftime(friendly, 100, "%a %b %d %T.%%04d %Y", localtime(&tt)); +#endif + phpdbg_asprintf(&buffer, friendly, tp.tv_usec/1000); + phpdbg_asprintf(&format, "[%s]: %s\n", buffer, fmt); + rc = phpdbg_xml_vasprintf(&outbuf, format, 0, args TSRMLS_CC); + + if (outbuf) { + rc = phpdbg_mixed_write(fd, outbuf, rc TSRMLS_CC); + efree(outbuf); + } + + efree(format); + efree(buffer); + } + va_end(args); + + return rc; +} /* }}} */ diff --git a/phpdbg_out.h b/phpdbg_out.h new file mode 100644 index 00000000000..ea25b04279d --- /dev/null +++ b/phpdbg_out.h @@ -0,0 +1,93 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHPDBG_OUT_H +#define PHPDBG_OUT_H + +/** + * Error/notice/formatting helpers + */ +enum { + P_ERROR = 1, + P_NOTICE, + P_WRITELN, + P_WRITE, + P_STDOUT, + P_STDERR, + P_LOG +}; + +#ifdef ZTS +PHPDBG_API int phpdbg_print(int severity TSRMLS_DC, int fd, const char *tag, const char *xmlfmt, const char *strfmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 6, 7); +PHPDBG_API int phpdbg_xml_internal(int fd TSRMLS_DC, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4); +PHPDBG_API int phpdbg_log_internal(int fd TSRMLS_DC, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4); +PHPDBG_API int phpdbg_out_internal(int fd TSRMLS_DC, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4); +PHPDBG_API int phpdbg_rlog_internal(int fd TSRMLS_DC, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4); +#else +PHPDBG_API int phpdbg_print(int severity, int fd, const char *tag, const char *xmlfmt, const char *strfmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 5, 6); +PHPDBG_API int phpdbg_xml_internal(int fd, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 2, 3); +PHPDBG_API int phpdbg_log_internal(int fd, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 2, 3); +PHPDBG_API int phpdbg_out_internal(int fd, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 2, 3); +PHPDBG_API int phpdbg_rlog_internal(int fd, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 2, 3); +#endif + + +#define phpdbg_error(tag, xmlfmt, strfmt, ...) phpdbg_print(P_ERROR TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT].fd, tag, xmlfmt, strfmt, ##__VA_ARGS__) +#define phpdbg_notice(tag, xmlfmt, strfmt, ...) phpdbg_print(P_NOTICE TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT].fd, tag, xmlfmt, strfmt, ##__VA_ARGS__) +#define phpdbg_writeln(tag, xmlfmt, strfmt, ...) phpdbg_print(P_WRITELN TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT].fd, tag, xmlfmt, strfmt, ##__VA_ARGS__) +#define phpdbg_write(tag, xmlfmt, strfmt, ...) phpdbg_print(P_WRITE TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT].fd, tag, xmlfmt, strfmt, ##__VA_ARGS__) +#define phpdbg_script(type, fmt, ...) phpdbg_print(type TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT].fd, NULL, NULL, fmt, ##__VA_ARGS__) +#define phpdbg_log(fmt, ...) phpdbg_log_internal(PHPDBG_G(io)[PHPDBG_STDOUT].fd TSRMLS_CC, fmt, ##__VA_ARGS__) +#define phpdbg_xml(fmt, ...) phpdbg_xml_internal(PHPDBG_G(io)[PHPDBG_STDOUT].fd TSRMLS_CC, fmt, ##__VA_ARGS__) +#define phpdbg_out(fmt, ...) phpdbg_out_internal(PHPDBG_G(io)[PHPDBG_STDOUT].fd TSRMLS_CC, fmt, ##__VA_ARGS__) + +#define phpdbg_error_ex(out, tag, xmlfmt, strfmt, ...) phpdbg_print(P_ERROR TSRMLS_CC, out, tag, xmlfmt, strfmt, ##__VA_ARGS__) +#define phpdbg_notice_ex(out, tag, xmlfmt, strfmt, ...) phpdbg_print(P_NOTICE TSRMLS_CC, out, tag, xmlfmt, strfmt, ##__VA_ARGS__) +#define phpdbg_writeln_ex(out, tag, xmlfmt, strfmt, ...) phpdbg_print(P_WRITELN TSRMLS_CC, out, tag, xmlfmt, strfmt, ##__VA_ARGS__) +#define phpdbg_write_ex(out, tag, xmlfmt, strfmt, ...) phpdbg_print(P_WRITE TSRMLS_CC, out, tag, xmlfmt, strfmt, ##__VA_ARGS__) +#define phpdbg_script_ex(out, type, fmt, ...) phpdbg_print(type TSRMLS_CC, out, NULL, NULL, fmt, ##__VA_ARGS__) +#define phpdbg_log_ex(out, fmt, ...) phpdbg_log_internal(PHPDBG_G(io)[PHPDBG_STDOUT].fd TSRMLS_CC, fmt, ##__VA_ARGS__) +#define phpdbg_xml_ex(out, fmt, ...) phpdbg_xml_internal(PHPDBG_G(io)[PHPDBG_STDOUT].fd TSRMLS_CC, fmt, ##__VA_ARGS__) +#define phpdbg_out_ex(out, fmt, ...) phpdbg_out_internal(PHPDBG_G(io)[PHPDBG_STDOUT].fd TSRMLS_CC, fmt, ##__VA_ARGS__) + +#define phpdbg_rlog(fd, fmt, ...) phpdbg_rlog_internal(fd TSRMLS_CC, fmt, ##__VA_ARGS__) + +#define phpdbg_xml_asprintf(buf, ...) _phpdbg_xml_asprintf(buf TSRMLS_CC, ##__VA_ARGS__) +PHPDBG_API int _phpdbg_xml_asprintf(char **buf TSRMLS_DC, const char *format, zend_bool escape_xml, ...); + +#define phpdbg_asprintf(buf, ...) _phpdbg_asprintf(buf TSRMLS_CC, ##__VA_ARGS__) +PHPDBG_API int _phpdbg_asprintf(char **buf TSRMLS_DC, const char *format, ...); + + +#if PHPDBG_DEBUG +# define phpdbg_debug(fmt, ...) phpdbg_log_ex(PHPDBG_G(io)[PHPDBG_STDERR].fd TSRMLS_CC, fmt, ##__VA_ARGS__) +#else +# define phpdbg_debug(fmt, ...) +#endif + +PHPDBG_API void phpdbg_free_err_buf(TSRMLS_D); +PHPDBG_API void phpdbg_activate_err_buf(zend_bool active TSRMLS_DC); +PHPDBG_API int phpdbg_output_err_buf(const char *tag, const char *xmlfmt, const char *strfmt TSRMLS_DC, ...); + + +/* {{{ For separation */ +#define SEPARATE "------------------------------------------------" /* }}} */ + +#endif /* PHPDBG_OUT_H */ diff --git a/phpdbg_parser.c b/phpdbg_parser.c index e34c2f48ff4..c7668683699 100644 --- a/phpdbg_parser.c +++ b/phpdbg_parser.c @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.6.2. */ +/* A Bison parser, made by GNU Bison 2.5. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.6.2" +#define YYBISON_VERSION "2.5" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -58,6 +58,8 @@ /* Pull parsers. */ #define YYPULL 1 +/* Using locations. */ +#define YYLSP_NEEDED 0 /* Substitute the variable and function names. */ #define yyparse phpdbg_parse @@ -68,9 +70,11 @@ #define yydebug phpdbg_debug #define yynerrs phpdbg_nerrs + /* Copy the first part of user declarations. */ -/* Line 336 of yacc.c */ -#line 1 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + +/* Line 268 of yacc.c */ +#line 1 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" /* @@ -97,16 +101,14 @@ static int yyerror(void ***tsrm_ls, const char *msg); ZEND_EXTERN_MODULE_GLOBALS(phpdbg); -/* Line 336 of yacc.c */ -#line 102 "sapi/phpdbg/phpdbg_parser.c" -# ifndef YY_NULL -# if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULL nullptr -# else -# define YY_NULL 0 -# endif -# endif +/* Line 268 of yacc.c */ +#line 107 "sapi/phpdbg/phpdbg_parser.c" + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE @@ -116,20 +118,15 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg); # define YYERROR_VERBOSE 1 #endif -/* In a future release of Bison, this section will be replaced - by #include "phpdbg_parser.h". */ -#ifndef PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H -# define PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif -#if YYDEBUG -extern int phpdbg_debug; +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 #endif + /* "%code requires" blocks. */ -/* Line 350 of yacc.c */ -#line 31 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + +/* Line 288 of yacc.c */ +#line 31 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" #include "phpdbg.h" #ifndef YY_TYPEDEF_YY_SCANNER_T @@ -138,8 +135,9 @@ typedef void* yyscan_t; #endif -/* Line 350 of yacc.c */ -#line 143 "sapi/phpdbg/phpdbg_parser.c" + +/* Line 288 of yacc.c */ +#line 141 "sapi/phpdbg/phpdbg_parser.c" /* Tokens. */ #ifndef YYTOKENTYPE @@ -164,7 +162,8 @@ typedef void* yyscan_t; T_OPCODE = 272, T_ID = 273, T_INPUT = 274, - T_UNEXPECTED = 275 + T_UNEXPECTED = 275, + T_REQ_ID = 276 }; #endif /* Tokens. */ @@ -186,6 +185,8 @@ typedef void* yyscan_t; #define T_ID 273 #define T_INPUT 274 #define T_UNEXPECTED 275 +#define T_REQ_ID 276 + @@ -197,26 +198,11 @@ typedef int YYSTYPE; #endif -#ifdef YYPARSE_PARAM -#if defined __STDC__ || defined __cplusplus -int phpdbg_parse (void *YYPARSE_PARAM); -#else -int phpdbg_parse (); -#endif -#else /* ! YYPARSE_PARAM */ -#if defined __STDC__ || defined __cplusplus -int phpdbg_parse (void *tsrm_ls); -#else -int phpdbg_parse (); -#endif -#endif /* ! YYPARSE_PARAM */ - -#endif /* !PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H */ - /* Copy the second part of user declarations. */ -/* Line 353 of yacc.c */ -#line 220 "sapi/phpdbg/phpdbg_parser.c" + +/* Line 343 of yacc.c */ +#line 206 "sapi/phpdbg/phpdbg_parser.c" #ifdef short # undef short @@ -322,7 +308,6 @@ YYID (yyi) # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ - /* Use EXIT_SUCCESS as a witness for stdlib.h. */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif @@ -414,42 +399,42 @@ union yyalloc #endif #if defined YYCOPY_NEEDED && YYCOPY_NEEDED -/* Copy COUNT objects from SRC to DST. The source and destination do +/* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(Dst, Src, Count) \ - __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else -# define YYCOPY(Dst, Src, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (Dst)[yyi] = (Src)[yyi]; \ - } \ +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ while (YYID (0)) # endif # endif #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ -#define YYFINAL 25 +#define YYFINAL 26 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 42 +#define YYLAST 48 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 21 +#define YYNTOKENS 22 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 5 +#define YYNNTS 6 /* YYNRULES -- Number of rules. */ -#define YYNRULES 25 +#define YYNRULES 28 /* YYNRULES -- Number of states. */ -#define YYNSTATES 38 +#define YYNSTATES 43 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 275 +#define YYMAXUTOK 276 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -484,7 +469,7 @@ static const yytype_uint8 yytranslate[] = 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20 + 15, 16, 17, 18, 19, 20, 21 }; #if YYDEBUG @@ -492,34 +477,35 @@ static const yytype_uint8 yytranslate[] = YYRHS. */ static const yytype_uint8 yyprhs[] = { - 0, 0, 3, 5, 7, 8, 10, 13, 17, 22, - 27, 33, 37, 43, 47, 50, 52, 54, 56, 58, - 60, 62, 64, 67, 70, 72 + 0, 0, 3, 5, 7, 8, 10, 13, 16, 20, + 25, 30, 36, 40, 46, 50, 53, 55, 57, 59, + 61, 63, 65, 67, 69, 70, 74, 78, 81 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { - 22, 0, -1, 23, -1, 25, -1, -1, 24, -1, - 23, 24, -1, 18, 10, 14, -1, 18, 10, 12, - 14, -1, 13, 18, 10, 14, -1, 13, 18, 10, - 12, 14, -1, 18, 11, 18, -1, 18, 11, 18, - 12, 14, -1, 18, 12, 14, -1, 6, 19, -1, - 17, -1, 16, -1, 15, -1, 7, -1, 8, -1, - 14, -1, 18, -1, 3, 19, -1, 5, 19, -1, - 4, -1, 4, 19, -1 + 23, 0, -1, 24, -1, 27, -1, -1, 25, -1, + 24, 25, -1, 24, 26, -1, 18, 10, 14, -1, + 18, 10, 12, 14, -1, 13, 18, 10, 14, -1, + 13, 18, 10, 12, 14, -1, 18, 11, 18, -1, + 18, 11, 18, 12, 14, -1, 18, 12, 14, -1, + 6, 19, -1, 17, -1, 16, -1, 15, -1, 7, + -1, 8, -1, 14, -1, 18, -1, 21, -1, -1, + 3, 26, 19, -1, 5, 26, 19, -1, 4, 26, + -1, 4, 26, 19, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { - 0, 66, 66, 67, 68, 72, 73, 77, 82, 87, - 97, 107, 112, 118, 124, 129, 130, 131, 132, 133, - 134, 135, 139, 144, 149, 153 + 0, 67, 67, 68, 69, 73, 74, 75, 79, 84, + 89, 99, 109, 114, 120, 126, 131, 132, 133, 134, + 135, 136, 137, 141, 142, 146, 151, 156, 160 }; #endif -#if YYDEBUG || YYERROR_VERBOSE || 1 +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = @@ -531,8 +517,9 @@ static const char *const yytname[] = "\":: (double colon)\"", "\"# (pound sign)\"", "\"protocol (file://)\"", "\"digits (numbers)\"", "\"literal (string)\"", "\"address\"", "\"opcode\"", "\"identifier (command or function name)\"", - "\"input (input string or data)\"", "\"input\"", "$accept", "input", - "parameters", "parameter", "full_expression", YY_NULL + "\"input (input string or data)\"", "\"input\"", + "\"request id (-r %d)\"", "$accept", "input", "parameters", "parameter", + "req_id", "full_expression", 0 }; #endif @@ -543,24 +530,24 @@ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275 + 275, 276 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 21, 22, 22, 22, 23, 23, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 25, 25, 25, 25 + 0, 22, 23, 23, 23, 24, 24, 24, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 26, 26, 27, 27, 27, 27 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { - 0, 2, 1, 1, 0, 1, 2, 3, 4, 4, - 5, 3, 5, 3, 2, 1, 1, 1, 1, 1, - 1, 1, 2, 2, 1, 2 + 0, 2, 1, 1, 0, 1, 2, 2, 3, 4, + 4, 5, 3, 5, 3, 2, 1, 1, 1, 1, + 1, 1, 1, 1, 0, 3, 3, 2, 3 }; /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. @@ -568,33 +555,35 @@ static const yytype_uint8 yyr2[] = means the default is an error. */ static const yytype_uint8 yydefact[] = { - 4, 0, 24, 0, 0, 18, 19, 0, 20, 17, - 16, 15, 21, 0, 2, 5, 3, 22, 25, 23, - 14, 0, 0, 0, 0, 1, 6, 0, 0, 7, - 11, 13, 0, 9, 8, 0, 10, 12 + 4, 24, 24, 24, 0, 19, 20, 0, 21, 18, + 17, 16, 22, 0, 2, 5, 3, 23, 0, 27, + 0, 15, 0, 0, 0, 0, 1, 6, 7, 25, + 28, 26, 0, 0, 8, 12, 14, 0, 10, 9, + 0, 11, 13 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { - -1, 13, 14, 15, 16 + -1, 13, 14, 15, 18, 16 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -11 +#define YYPACT_NINF -16 static const yytype_int8 yypact[] = { - -3, -10, 11, 12, 13, -11, -11, 15, -11, -11, - -11, -11, -4, 29, 10, -11, -11, -11, -11, -11, - -11, 24, 7, 17, 22, -11, -11, 8, 23, -11, - 26, -11, 25, -11, -11, 27, -11, -11 + -3, -15, -15, -15, -10, -16, -16, 3, -16, -16, + -16, -16, 22, 29, 10, -16, -16, -16, 11, 17, + 19, -16, 30, 8, 21, 27, -16, -16, -16, -16, + -16, -16, 23, 28, -16, 31, -16, 32, -16, -16, + 33, -16, -16 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -11, -11, -11, 28, -11 + -16, -16, -16, 34, 5, -16 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -603,26 +592,26 @@ static const yytype_int8 yypgoto[] = #define YYTABLE_NINF -1 static const yytype_uint8 yytable[] = { - 1, 2, 3, 4, 5, 6, 22, 23, 24, 17, + 1, 2, 3, 4, 5, 6, 17, 19, 20, 21, 7, 8, 9, 10, 11, 12, 4, 5, 6, 28, - 32, 29, 33, 7, 8, 9, 10, 11, 12, 25, - 18, 19, 20, 21, 27, 30, 31, 34, 35, 36, - 0, 37, 26 + 33, 22, 34, 7, 8, 9, 10, 11, 12, 26, + 29, 17, 23, 24, 25, 37, 30, 38, 31, 35, + 32, 36, 39, 40, 0, 0, 41, 42, 27 }; #define yypact_value_is_default(yystate) \ - ((yystate) == (-11)) + ((yystate) == (-16)) #define yytable_value_is_error(yytable_value) \ YYID (0) static const yytype_int8 yycheck[] = { - 3, 4, 5, 6, 7, 8, 10, 11, 12, 19, - 13, 14, 15, 16, 17, 18, 6, 7, 8, 12, - 12, 14, 14, 13, 14, 15, 16, 17, 18, 0, - 19, 19, 19, 18, 10, 18, 14, 14, 12, 14, - -1, 14, 14 + 3, 4, 5, 6, 7, 8, 21, 2, 3, 19, + 13, 14, 15, 16, 17, 18, 6, 7, 8, 14, + 12, 18, 14, 13, 14, 15, 16, 17, 18, 0, + 19, 21, 10, 11, 12, 12, 19, 14, 19, 18, + 10, 14, 14, 12, -1, -1, 14, 14, 14 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing @@ -630,9 +619,10 @@ static const yytype_int8 yycheck[] = static const yytype_uint8 yystos[] = { 0, 3, 4, 5, 6, 7, 8, 13, 14, 15, - 16, 17, 18, 22, 23, 24, 25, 19, 19, 19, - 19, 18, 10, 11, 12, 0, 24, 10, 12, 14, - 18, 14, 12, 14, 14, 12, 14, 14 + 16, 17, 18, 23, 24, 25, 27, 21, 26, 26, + 26, 19, 18, 10, 11, 12, 0, 25, 26, 19, + 19, 19, 10, 12, 14, 18, 14, 12, 14, 14, + 12, 14, 14 }; #define yyerrok (yyerrstatus = 0) @@ -662,18 +652,17 @@ static const yytype_uint8 yystos[] = #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ yyerror (tsrm_ls, YY_("syntax error: cannot back up")); \ YYERROR; \ } \ @@ -683,33 +672,32 @@ while (YYID (0)) #define YYTERROR 1 #define YYERRCODE 256 + /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. If N is 0, then set CURRENT to the empty location which ends the previous symbol: RHS[0] (always defined). */ +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) #ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (YYID (N)) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC (Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC (Rhs, 0).last_column; \ - } \ +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ while (YYID (0)) #endif -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) - - /* This macro is provided for backward compatibility. */ @@ -770,8 +758,6 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, tsrm_ls) void *tsrm_ls; #endif { - FILE *yyo = yyoutput; - YYUSE (yyo); if (!yyvaluep) return; YYUSE (tsrm_ls); @@ -1026,12 +1012,12 @@ static int yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken) { - YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); YYSIZE_T yysize = yysize0; YYSIZE_T yysize1; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ - const char *yyformat = YY_NULL; + const char *yyformat = 0; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per @@ -1091,7 +1077,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, break; } yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); + yysize1 = yysize + yytnamerr (0, yytname[yyx]); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; @@ -1185,6 +1171,20 @@ yydestruct (yymsg, yytype, yyvaluep, tsrm_ls) } +/* Prevent warnings from -Wmissing-prototypes. */ +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (void *tsrm_ls); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ /*----------. @@ -1230,7 +1230,7 @@ YYSTYPE yylval; `yyss': related to states. `yyvs': related to semantic values. - Refer to the stacks through separate pointers, to allow yyoverflow + Refer to the stacks thru separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ @@ -1284,6 +1284,7 @@ YYSTYPE yylval; The wasted elements are never initialized. */ yyssp = yyss; yyvsp = yyvs; + goto yysetstate; /*------------------------------------------------------------. @@ -1461,26 +1462,37 @@ yyreduce: switch (yyn) { case 3: -/* Line 1802 of yacc.c */ -#line 67 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + +/* Line 1806 of yacc.c */ +#line 68 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" { phpdbg_stack_push(PHPDBG_G(parser_stack), &(yyvsp[(1) - (1)])); } break; case 5: -/* Line 1802 of yacc.c */ -#line 72 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + +/* Line 1806 of yacc.c */ +#line 73 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" { phpdbg_stack_push(PHPDBG_G(parser_stack), &(yyvsp[(1) - (1)])); } break; case 6: -/* Line 1802 of yacc.c */ -#line 73 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + +/* Line 1806 of yacc.c */ +#line 74 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" { phpdbg_stack_push(PHPDBG_G(parser_stack), &(yyvsp[(2) - (2)])); } break; case 7: -/* Line 1802 of yacc.c */ -#line 77 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + +/* Line 1806 of yacc.c */ +#line 75 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" + { (yyval) = (yyvsp[(1) - (2)]); } + break; + + case 8: + +/* Line 1806 of yacc.c */ +#line 79 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = FILE_PARAM; (yyval).file.name = (yyvsp[(2) - (3)]).str; @@ -1488,9 +1500,10 @@ yyreduce: } break; - case 8: -/* Line 1802 of yacc.c */ -#line 82 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + case 9: + +/* Line 1806 of yacc.c */ +#line 84 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = NUMERIC_FILE_PARAM; (yyval).file.name = (yyvsp[(1) - (4)]).str; @@ -1498,9 +1511,10 @@ yyreduce: } break; - case 9: -/* Line 1802 of yacc.c */ -#line 87 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + case 10: + +/* Line 1806 of yacc.c */ +#line 89 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = FILE_PARAM; (yyval).file.name = malloc((yyvsp[(1) - (4)]).len + (yyvsp[(2) - (4)]).len + 1); @@ -1513,9 +1527,10 @@ yyreduce: } break; - case 10: -/* Line 1802 of yacc.c */ -#line 97 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + case 11: + +/* Line 1806 of yacc.c */ +#line 99 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = NUMERIC_FILE_PARAM; (yyval).file.name = malloc((yyvsp[(1) - (5)]).len + (yyvsp[(2) - (5)]).len + 1); @@ -1528,9 +1543,10 @@ yyreduce: } break; - case 11: -/* Line 1802 of yacc.c */ -#line 107 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + case 12: + +/* Line 1806 of yacc.c */ +#line 109 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = METHOD_PARAM; (yyval).method.class = (yyvsp[(1) - (3)]).str; @@ -1538,9 +1554,10 @@ yyreduce: } break; - case 12: -/* Line 1802 of yacc.c */ -#line 112 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + case 13: + +/* Line 1806 of yacc.c */ +#line 114 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = NUMERIC_METHOD_PARAM; (yyval).method.class = (yyvsp[(1) - (5)]).str; @@ -1549,9 +1566,10 @@ yyreduce: } break; - case 13: -/* Line 1802 of yacc.c */ -#line 118 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + case 14: + +/* Line 1806 of yacc.c */ +#line 120 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = NUMERIC_FUNCTION_PARAM; (yyval).str = (yyvsp[(1) - (3)]).str; @@ -1560,9 +1578,10 @@ yyreduce: } break; - case 14: -/* Line 1802 of yacc.c */ -#line 124 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + case 15: + +/* Line 1806 of yacc.c */ +#line 126 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = COND_PARAM; (yyval).str = (yyvsp[(2) - (2)]).str; @@ -1570,90 +1589,109 @@ yyreduce: } break; - case 15: -/* Line 1802 of yacc.c */ -#line 129 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" - { (yyval) = (yyvsp[(1) - (1)]); } - break; - case 16: -/* Line 1802 of yacc.c */ -#line 130 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + +/* Line 1806 of yacc.c */ +#line 131 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 17: -/* Line 1802 of yacc.c */ -#line 131 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + +/* Line 1806 of yacc.c */ +#line 132 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 18: -/* Line 1802 of yacc.c */ -#line 132 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + +/* Line 1806 of yacc.c */ +#line 133 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 19: -/* Line 1802 of yacc.c */ -#line 133 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + +/* Line 1806 of yacc.c */ +#line 134 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 20: -/* Line 1802 of yacc.c */ -#line 134 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + +/* Line 1806 of yacc.c */ +#line 135 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 21: -/* Line 1802 of yacc.c */ -#line 135 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + +/* Line 1806 of yacc.c */ +#line 136 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 22: -/* Line 1802 of yacc.c */ -#line 139 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" - { - (yyval).type = EVAL_PARAM; - (yyval).str = (yyvsp[(2) - (2)]).str; - (yyval).len = (yyvsp[(2) - (2)]).len; - } + +/* Line 1806 of yacc.c */ +#line 137 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" + { (yyval) = (yyvsp[(1) - (1)]); } break; case 23: -/* Line 1802 of yacc.c */ -#line 144 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" - { - (yyval).type = SHELL_PARAM; - (yyval).str = (yyvsp[(2) - (2)]).str; - (yyval).len = (yyvsp[(2) - (2)]).len; + +/* Line 1806 of yacc.c */ +#line 141 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" + { PHPDBG_G(req_id) = (yyvsp[(1) - (1)]).num; } + break; + + case 25: + +/* Line 1806 of yacc.c */ +#line 146 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" + { + (yyval).type = EVAL_PARAM; + (yyval).str = (yyvsp[(3) - (3)]).str; + (yyval).len = (yyvsp[(3) - (3)]).len; } break; - case 24: -/* Line 1802 of yacc.c */ -#line 149 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + case 26: + +/* Line 1806 of yacc.c */ +#line 151 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" + { + (yyval).type = SHELL_PARAM; + (yyval).str = (yyvsp[(3) - (3)]).str; + (yyval).len = (yyvsp[(3) - (3)]).len; + } + break; + + case 27: + +/* Line 1806 of yacc.c */ +#line 156 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = RUN_PARAM; (yyval).len = 0; } break; - case 25: -/* Line 1802 of yacc.c */ -#line 153 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + case 28: + +/* Line 1806 of yacc.c */ +#line 160 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = RUN_PARAM; - (yyval).str = (yyvsp[(2) - (2)]).str; - (yyval).len = (yyvsp[(2) - (2)]).len; + (yyval).str = (yyvsp[(3) - (3)]).str; + (yyval).len = (yyvsp[(3) - (3)]).len; } break; -/* Line 1802 of yacc.c */ -#line 1657 "sapi/phpdbg/phpdbg_parser.c" + +/* Line 1806 of yacc.c */ +#line 1695 "sapi/phpdbg/phpdbg_parser.c" default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -1840,7 +1878,7 @@ yyabortlab: yyresult = 1; goto yyreturn; -#if !defined yyoverflow || YYERROR_VERBOSE +#if !defined(yyoverflow) || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -1882,12 +1920,13 @@ yyreturn: } -/* Line 2048 of yacc.c */ -#line 160 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + +/* Line 2067 of yacc.c */ +#line 167 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" static int yyerror(void ***tsrm_ls, const char *msg) { - phpdbg_error("Parse Error: %s", msg); + phpdbg_error("command", "type=\"parseerror\" msg=\"%s\"", "Parse Error: %s", msg); { const phpdbg_param_t *top = PHPDBG_G(parser_stack); @@ -1909,3 +1948,4 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC) { return yyparse(NULL); #endif } + diff --git a/phpdbg_parser.h b/phpdbg_parser.h index b3aadb9c62d..dfa155d7184 100644 --- a/phpdbg_parser.h +++ b/phpdbg_parser.h @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.6.2. */ +/* A Bison parser, made by GNU Bison 2.5. */ /* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,18 +30,10 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ -#ifndef PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H -# define PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif -#if YYDEBUG -extern int phpdbg_debug; -#endif /* "%code requires" blocks. */ -/* Line 2055 of yacc.c */ -#line 31 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y" + +/* Line 2068 of yacc.c */ +#line 31 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" #include "phpdbg.h" #ifndef YY_TYPEDEF_YY_SCANNER_T @@ -50,8 +42,9 @@ typedef void* yyscan_t; #endif -/* Line 2055 of yacc.c */ -#line 55 "sapi/phpdbg/phpdbg_parser.h" + +/* Line 2068 of yacc.c */ +#line 48 "sapi/phpdbg/phpdbg_parser.h" /* Tokens. */ #ifndef YYTOKENTYPE @@ -76,7 +69,8 @@ typedef void* yyscan_t; T_OPCODE = 272, T_ID = 273, T_INPUT = 274, - T_UNEXPECTED = 275 + T_UNEXPECTED = 275, + T_REQ_ID = 276 }; #endif /* Tokens. */ @@ -98,6 +92,8 @@ typedef void* yyscan_t; #define T_ID 273 #define T_INPUT 274 #define T_UNEXPECTED 275 +#define T_REQ_ID 276 + @@ -109,18 +105,5 @@ typedef int YYSTYPE; #endif -#ifdef YYPARSE_PARAM -#if defined __STDC__ || defined __cplusplus -int phpdbg_parse (void *YYPARSE_PARAM); -#else -int phpdbg_parse (); -#endif -#else /* ! YYPARSE_PARAM */ -#if defined __STDC__ || defined __cplusplus -int phpdbg_parse (void *tsrm_ls); -#else -int phpdbg_parse (); -#endif -#endif /* ! YYPARSE_PARAM */ -#endif /* !PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H */ + diff --git a/phpdbg_parser.y b/phpdbg_parser.y index 702bf78455d..e4353976f3e 100644 --- a/phpdbg_parser.y +++ b/phpdbg_parser.y @@ -59,6 +59,7 @@ typedef void* yyscan_t; %token T_ID "identifier (command or function name)" %token T_INPUT "input (input string or data)" %token T_UNEXPECTED "input" +%token T_REQ_ID "request id (-r %d)" %% /* Rules */ @@ -71,6 +72,7 @@ input parameters : parameter { phpdbg_stack_push(PHPDBG_G(parser_stack), &$1); } | parameters parameter { phpdbg_stack_push(PHPDBG_G(parser_stack), &$2); } + | parameters req_id { $$ = $1; } ; parameter @@ -135,32 +137,37 @@ parameter | T_ID { $$ = $1; } ; +req_id + : T_REQ_ID { PHPDBG_G(req_id) = $1.num; } + | /* empty */ +; + full_expression - : T_EVAL T_INPUT { + : T_EVAL req_id T_INPUT { $$.type = EVAL_PARAM; - $$.str = $2.str; - $$.len = $2.len; + $$.str = $3.str; + $$.len = $3.len; } - | T_SHELL T_INPUT { + | T_SHELL req_id T_INPUT { $$.type = SHELL_PARAM; - $$.str = $2.str; - $$.len = $2.len; + $$.str = $3.str; + $$.len = $3.len; } - | T_RUN { + | T_RUN req_id { $$.type = RUN_PARAM; $$.len = 0; } - | T_RUN T_INPUT { + | T_RUN req_id T_INPUT { $$.type = RUN_PARAM; - $$.str = $2.str; - $$.len = $2.len; + $$.str = $3.str; + $$.len = $3.len; } ; %% static int yyerror(void ***tsrm_ls, const char *msg) { - phpdbg_error("Parse Error: %s", msg); + phpdbg_error("command", "type=\"parseerror\" msg=\"%s\"", "Parse Error: %s", msg); { const phpdbg_param_t *top = PHPDBG_G(parser_stack); diff --git a/phpdbg_print.c b/phpdbg_print.c index 76321a5042d..80eeddb39d1 100644 --- a/phpdbg_print.c +++ b/phpdbg_print.c @@ -26,16 +26,16 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg); -#define PHPDBG_PRINT_COMMAND_D(f, h, a, m, l, s) \ - PHPDBG_COMMAND_D_EXP(f, h, a, m, l, s, &phpdbg_prompt_commands[9]) +#define PHPDBG_PRINT_COMMAND_D(f, h, a, m, l, s, flags) \ + PHPDBG_COMMAND_D_EXP(f, h, a, m, l, s, &phpdbg_prompt_commands[9], flags) const phpdbg_command_t phpdbg_print_commands[] = { - PHPDBG_PRINT_COMMAND_D(exec, "print out the instructions in the execution context", 'e', print_exec, NULL, 0), - PHPDBG_PRINT_COMMAND_D(opline, "print out the instruction in the current opline", 'o', print_opline, NULL, 0), - PHPDBG_PRINT_COMMAND_D(class, "print out the instructions in the specified class", 'c', print_class, NULL, "s"), - PHPDBG_PRINT_COMMAND_D(method, "print out the instructions in the specified method", 'm', print_method, NULL, "m"), - PHPDBG_PRINT_COMMAND_D(func, "print out the instructions in the specified function", 'f', print_func, NULL, "s"), - PHPDBG_PRINT_COMMAND_D(stack, "print out the instructions in the current stack", 's', print_stack, NULL, 0), + PHPDBG_PRINT_COMMAND_D(exec, "print out the instructions in the execution context", 'e', print_exec, NULL, 0, PHPDBG_ASYNC_SAFE), + PHPDBG_PRINT_COMMAND_D(opline, "print out the instruction in the current opline", 'o', print_opline, NULL, 0, PHPDBG_ASYNC_SAFE), + PHPDBG_PRINT_COMMAND_D(class, "print out the instructions in the specified class", 'c', print_class, NULL, "s", PHPDBG_ASYNC_SAFE), + PHPDBG_PRINT_COMMAND_D(method, "print out the instructions in the specified method", 'm', print_method, NULL, "m", PHPDBG_ASYNC_SAFE), + PHPDBG_PRINT_COMMAND_D(func, "print out the instructions in the specified function", 'f', print_func, NULL, "s", PHPDBG_ASYNC_SAFE), + PHPDBG_PRINT_COMMAND_D(stack, "print out the instructions in the current stack", 's', print_stack, NULL, 0, PHPDBG_ASYNC_SAFE), PHPDBG_END_COMMAND }; @@ -44,7 +44,7 @@ PHPDBG_PRINT(opline) /* {{{ */ if (EG(in_execution) && EG(current_execute_data)) { phpdbg_print_opline(EG(current_execute_data), 1 TSRMLS_CC); } else { - phpdbg_error("Not Executing!"); + phpdbg_error("inactive", "type=\"execution\"", "Not Executing!"); } return SUCCESS; @@ -56,21 +56,22 @@ static inline void phpdbg_print_function_helper(zend_function *method TSRMLS_DC) case ZEND_USER_FUNCTION: { zend_op_array* op_array = &(method->op_array); HashTable vars; - + if (op_array) { zend_op *opline = &(op_array->opcodes[0]); zend_uint opcode = 0, end = op_array->last-1; if (method->common.scope) { - phpdbg_writeln("\tL%d-%d %s::%s() %s", - op_array->line_start, op_array->line_end, + phpdbg_writeln("printoplineinfo", "type=\"User\" startline=\"%d\" endline=\"%d\" method=\"%s::%s\" file=\"%s\"", "\tL%d-%d %s::%s() %s", + op_array->line_start, + op_array->line_end, method->common.scope->name, method->common.function_name, op_array->filename ? op_array->filename : "unknown"); } else { - phpdbg_writeln("\tL%d-%d %s() %s", - method->common.function_name ? op_array->line_start : 0, + phpdbg_writeln("printoplineinfo", "type=\"User\" startline=\"%d\" endline=\"%d\" function=\"%s\" file=\"%s\"", "\tL%d-%d %s() %s", + method->common.function_name ? op_array->line_start : 0, method->common.function_name ? op_array->line_end : 0, method->common.function_name ? method->common.function_name : "{main}", op_array->filename ? op_array->filename : "unknown"); @@ -80,14 +81,14 @@ static inline void phpdbg_print_function_helper(zend_function *method TSRMLS_DC) do { char *decode = phpdbg_decode_opline(op_array, opline, &vars TSRMLS_CC); if (decode != NULL) { - phpdbg_writeln("\t\tL%u\t%p %-30s %s", + phpdbg_writeln("print", "line=\"%u\" opline=\"%p\" opcode=\"%s\" op=\"%s\"", "\t\tL%u\t%p %-30s %s", opline->lineno, - opline, + opline, phpdbg_decode_opcode(opline->opcode), decode); free(decode); } else { - phpdbg_error("\tFailed to decode opline %16p", opline); + phpdbg_error("print", "type=\"decodefailure\" opline=\"%16p\"", "\tFailed to decode opline %16p", opline); } opline++; } while (opcode++ < end); @@ -97,9 +98,9 @@ static inline void phpdbg_print_function_helper(zend_function *method TSRMLS_DC) default: { if (method->common.scope) { - phpdbg_writeln("\tInternal %s::%s()", method->common.scope->name, method->common.function_name); + phpdbg_writeln("printoplineinfo", "type=\"Internal\" method=\"%s::%s\"", "Internal %s::%s()", method->common.scope->name, method->common.function_name); } else { - phpdbg_writeln("\tInternal %s()", method->common.function_name); + phpdbg_writeln("printoplineinfo", "type=\"Internal\" function=\"%s\"", "\tInternal %s()", method->common.function_name); } } } @@ -108,17 +109,17 @@ static inline void phpdbg_print_function_helper(zend_function *method TSRMLS_DC) PHPDBG_PRINT(exec) /* {{{ */ { if (PHPDBG_G(exec)) { - if (!PHPDBG_G(ops)) { + if (!PHPDBG_G(ops) && !(PHPDBG_G(flags) & PHPDBG_IN_SIGNAL_HANDLER)) { phpdbg_compile(TSRMLS_C); } if (PHPDBG_G(ops)) { - phpdbg_notice("Context %s", PHPDBG_G(exec)); + phpdbg_notice("printinfo", "file=\"%s\" num=\"%d\"", "Context %s (%d ops)", PHPDBG_G(exec), PHPDBG_G(ops)->last); phpdbg_print_function_helper((zend_function*) PHPDBG_G(ops) TSRMLS_CC); } } else { - phpdbg_error("No execution context set"); + phpdbg_error("inactive", "type=\"nocontext\"", "No execution context set"); } return SUCCESS; @@ -127,24 +128,24 @@ return SUCCESS; PHPDBG_PRINT(stack) /* {{{ */ { zend_op_array *ops = EG(active_op_array); - + if (EG(in_execution) && ops) { if (ops->function_name) { if (ops->scope) { - phpdbg_notice("Stack in %s::%s()", ops->scope->name, ops->function_name); + phpdbg_notice("printinfo", "method=\"%s::%s\" num=\"%d\"", "Stack in %s::%s() (%d ops)", ops->scope->name, ops->function_name, ops->last); } else { - phpdbg_notice("Stack in %s()", ops->function_name); + phpdbg_notice("printinfo", "function=\"%s\" num=\"%d\"", "Stack in %s() (%d ops)", ops->function_name, ops->last); } } else { if (ops->filename) { - phpdbg_notice("Stack in %s", ops->filename); + phpdbg_notice("printinfo", "file=\"%s\" num=\"%d\"", "Stack in %s (%d ops)", ops->filename, ops->last); } else { - phpdbg_notice("Stack @ %p", ops); + phpdbg_notice("printinfo", "opline=\"%p\" num=\"%d\"", "Stack @ %p (%d ops)", ops, ops->last); } } phpdbg_print_function_helper((zend_function*) ops TSRMLS_CC); } else { - phpdbg_error("Not Executing!"); + phpdbg_error("inactive", "type=\"execution\"", "Not Executing!"); } return SUCCESS; @@ -154,8 +155,8 @@ PHPDBG_PRINT(class) /* {{{ */ { zend_class_entry **ce; - if (zend_lookup_class(param->str, param->len, &ce TSRMLS_CC) == SUCCESS) { - phpdbg_notice("%s %s: %s", + if (phpdbg_safe_class_lookup(param->str, param->len, &ce TSRMLS_CC) == SUCCESS) { + phpdbg_notice("printinfo", "type=\"%s\" flag=\"%s\" class=\"%s\" num=\"%d\"", "%s %s: %s (%d methods)", ((*ce)->type == ZEND_USER_CLASS) ? "User" : "Internal", ((*ce)->ce_flags & ZEND_ACC_INTERFACE) ? @@ -163,9 +164,11 @@ PHPDBG_PRINT(class) /* {{{ */ ((*ce)->ce_flags & ZEND_ACC_ABSTRACT) ? "Abstract Class" : "Class", - (*ce)->name); + (*ce)->name, + zend_hash_num_elements(&(*ce)->function_table)); + + phpdbg_xml(""); - phpdbg_writeln("Methods (%d):", zend_hash_num_elements(&(*ce)->function_table)); if (zend_hash_num_elements(&(*ce)->function_table)) { HashPosition position; zend_function *method; @@ -176,8 +179,10 @@ PHPDBG_PRINT(class) /* {{{ */ phpdbg_print_function_helper(method TSRMLS_CC); } } + + phpdbg_xml(""); } else { - phpdbg_error("The class %s could not be found", param->str); + phpdbg_error("print", "type=\"noclass\" class=\"%s\"", "The class %s could not be found", param->str); } return SUCCESS; @@ -187,23 +192,24 @@ PHPDBG_PRINT(method) /* {{{ */ { zend_class_entry **ce; - if (zend_lookup_class(param->method.class, strlen(param->method.class), &ce TSRMLS_CC) == SUCCESS) { + if (phpdbg_safe_class_lookup(param->method.class, strlen(param->method.class), &ce TSRMLS_CC) == SUCCESS) { zend_function *fbc; char *lcname = zend_str_tolower_dup(param->method.name, strlen(param->method.name)); if (zend_hash_find(&(*ce)->function_table, lcname, strlen(lcname)+1, (void**)&fbc) == SUCCESS) { - phpdbg_notice("%s Method %s", + phpdbg_notice("printinfo", "type=\"%s\" flags=\"Method\" symbol=\"%s\" num=\"%d\"", "%s Method %s (%d ops)", (fbc->type == ZEND_USER_FUNCTION) ? "User" : "Internal", - fbc->common.function_name); + fbc->common.function_name, + (fbc->type == ZEND_USER_FUNCTION) ? fbc->op_array.last : 0); phpdbg_print_function_helper(fbc TSRMLS_CC); } else { - phpdbg_error("The method %s could not be found", param->method.name); + phpdbg_error("print", "type=\"nomethod\" method=\"%s::%s\"", "The method %s::%s could not be found", param->method.class, param->method.name); } efree(lcname); } else { - phpdbg_error("The class %s could not be found", param->method.class); + phpdbg_error("print", "type=\"noclass\" class=\"%s\"", "The class %s could not be found", param->method.class); } return SUCCESS; @@ -224,28 +230,33 @@ PHPDBG_PRINT(func) /* {{{ */ func_table = &EG(scope)->function_table; } else { - phpdbg_error("No active class"); + phpdbg_error("inactive", "type=\"noclasses\"", "No active class"); return SUCCESS; } } else if (!EG(function_table)) { - phpdbg_error("No function table loaded"); + phpdbg_error("inactive", "type=\"function_table\"", "No function table loaded"); return SUCCESS; } else { func_table = EG(function_table); } - lcname = zend_str_tolower_dup(func_name, func_name_len); + lcname = zend_str_tolower_dup(func_name, func_name_len); - if (zend_hash_find(func_table, lcname, strlen(lcname)+1, (void**)&fbc) == SUCCESS) { - phpdbg_notice("%s %s %s", - (fbc->type == ZEND_USER_FUNCTION) ? "User" : "Internal", - (fbc->common.scope) ? "Method" : "Function", - fbc->common.function_name); + phpdbg_try_access { + if (zend_hash_find(func_table, lcname, func_name_len + 1, (void **) &fbc) == SUCCESS) { + phpdbg_notice("printinfo", "type=\"%s\" flags=\"%s\" symbol=\"%s\" num=\"%d\"", "%s %s %s (%d ops)", + (fbc->type == ZEND_USER_FUNCTION) ? "User" : "Internal", + (fbc->common.scope) ? "Method" : "Function", + fbc->common.function_name, + (fbc->type == ZEND_USER_FUNCTION) ? fbc->op_array.last : 0); - phpdbg_print_function_helper(fbc TSRMLS_CC); - } else { - phpdbg_error("The function %s could not be found", func_name); - } + phpdbg_print_function_helper(fbc TSRMLS_CC); + } else { + phpdbg_error("print", "type=\"nofunction\" function=\"%s\"", "The function %s could not be found", func_name); + } + } phpdbg_catch_access { + phpdbg_error("signalsegv", "function=\"%.*s\"", "Couldn't fetch function %.*s, invalid data source", (int) func_name_len, func_name); + } phpdbg_end_try_access(); efree(lcname); diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index d91ef3f3f5c..82444fbf1d3 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -23,6 +23,7 @@ #include "zend.h" #include "zend_compile.h" #include "phpdbg.h" + #include "phpdbg_help.h" #include "phpdbg_print.h" #include "phpdbg_info.h" @@ -37,56 +38,76 @@ #include "phpdbg_frame.h" #include "phpdbg_lexer.h" #include "phpdbg_parser.h" +#include "phpdbg_wait.h" +#include "phpdbg_eol.h" + +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); + +#ifdef HAVE_LIBDL +#ifdef PHP_WIN32 +#include "win32/param.h" +#include "win32/winutil.h" +#define GET_DL_ERROR() php_win_err() +#elif defined(NETWARE) +#include +#define GET_DL_ERROR() dlerror() +#else +#include +#define GET_DL_ERROR() DL_ERROR() +#endif +#endif /* {{{ command declarations */ const phpdbg_command_t phpdbg_prompt_commands[] = { - PHPDBG_COMMAND_D(exec, "set execution context", 'e', NULL, "s"), - PHPDBG_COMMAND_D(step, "step through execution", 's', NULL, 0), - PHPDBG_COMMAND_D(continue,"continue execution", 'c', NULL, 0), - PHPDBG_COMMAND_D(run, "attempt execution", 'r', NULL, "|s"), - PHPDBG_COMMAND_D(ev, "evaluate some code", 0, NULL, "i"), - PHPDBG_COMMAND_D(until, "continue past the current line", 'u', NULL, 0), - PHPDBG_COMMAND_D(finish, "continue past the end of the stack", 'F', NULL, 0), - PHPDBG_COMMAND_D(leave, "continue until the end of the stack", 'L', NULL, 0), - PHPDBG_COMMAND_D(print, "print something", 'p', phpdbg_print_commands, 0), - PHPDBG_COMMAND_D(break, "set breakpoint", 'b', phpdbg_break_commands, "|*c"), - PHPDBG_COMMAND_D(back, "show trace", 't', NULL, "|n"), - PHPDBG_COMMAND_D(frame, "switch to a frame", 'f', NULL, "|n"), - PHPDBG_COMMAND_D(list, "lists some code", 'l', phpdbg_list_commands, "*"), - PHPDBG_COMMAND_D(info, "displays some informations", 'i', phpdbg_info_commands, "s"), - PHPDBG_COMMAND_D(clean, "clean the execution environment", 'X', NULL, 0), - PHPDBG_COMMAND_D(clear, "clear breakpoints", 'C', NULL, 0), - PHPDBG_COMMAND_D(help, "show help menu", 'h', phpdbg_help_commands, "|s"), - PHPDBG_COMMAND_D(set, "set phpdbg configuration", 'S', phpdbg_set_commands, "s"), - PHPDBG_COMMAND_D(register,"register a function", 'R', NULL, "s"), - PHPDBG_COMMAND_D(source, "execute a phpdbginit", '<', NULL, "s"), - PHPDBG_COMMAND_D(export, "export breaks to a .phpdbginit script", '>', NULL, "s"), - PHPDBG_COMMAND_D(sh, "shell a command", 0, NULL, "i"), - PHPDBG_COMMAND_D(quit, "exit phpdbg", 'q', NULL, 0), - PHPDBG_COMMAND_D(watch, "set watchpoint", 'w', phpdbg_watch_commands, "|ss"), + PHPDBG_COMMAND_D(exec, "set execution context", 'e', NULL, "s", 0), + PHPDBG_COMMAND_D(step, "step through execution", 's', NULL, 0, PHPDBG_ASYNC_SAFE), + PHPDBG_COMMAND_D(continue,"continue execution", 'c', NULL, 0, PHPDBG_ASYNC_SAFE), + PHPDBG_COMMAND_D(run, "attempt execution", 'r', NULL, "|s", 0), + PHPDBG_COMMAND_D(ev, "evaluate some code", 0 , NULL, "i", PHPDBG_ASYNC_SAFE), /* restricted ASYNC_SAFE */ + PHPDBG_COMMAND_D(until, "continue past the current line", 'u', NULL, 0, 0), + PHPDBG_COMMAND_D(finish, "continue past the end of the stack", 'F', NULL, 0, 0), + PHPDBG_COMMAND_D(leave, "continue until the end of the stack", 'L', NULL, 0, 0), + PHPDBG_COMMAND_D(print, "print something", 'p', phpdbg_print_commands, 0, 0), + PHPDBG_COMMAND_D(break, "set breakpoint", 'b', phpdbg_break_commands, "|*c", 0), + PHPDBG_COMMAND_D(back, "show trace", 't', NULL, "|n", PHPDBG_ASYNC_SAFE), + PHPDBG_COMMAND_D(frame, "switch to a frame", 'f', NULL, "|n", PHPDBG_ASYNC_SAFE), + PHPDBG_COMMAND_D(list, "lists some code", 'l', phpdbg_list_commands, "*", PHPDBG_ASYNC_SAFE), + PHPDBG_COMMAND_D(info, "displays some informations", 'i', phpdbg_info_commands, "s", PHPDBG_ASYNC_SAFE), + PHPDBG_COMMAND_D(clean, "clean the execution environment", 'X', NULL, 0, 0), + PHPDBG_COMMAND_D(clear, "clear breakpoints", 'C', NULL, 0, 0), + PHPDBG_COMMAND_D(help, "show help menu", 'h', phpdbg_help_commands, "|s", PHPDBG_ASYNC_SAFE), + PHPDBG_COMMAND_D(set, "set phpdbg configuration", 'S', phpdbg_set_commands, "s", PHPDBG_ASYNC_SAFE), + PHPDBG_COMMAND_D(register,"register a function", 'R', NULL, "s", 0), + PHPDBG_COMMAND_D(source, "execute a phpdbginit", '<', NULL, "s", 0), + PHPDBG_COMMAND_D(export, "export breaks to a .phpdbginit script", '>', NULL, "s", PHPDBG_ASYNC_SAFE), + PHPDBG_COMMAND_D(sh, "shell a command", 0 , NULL, "i", 0), + PHPDBG_COMMAND_D(quit, "exit phpdbg", 'q', NULL, 0, PHPDBG_ASYNC_SAFE), + PHPDBG_COMMAND_D(wait, "wait for other process", 'W', NULL, 0, 0), + PHPDBG_COMMAND_D(watch, "set watchpoint", 'w', phpdbg_watch_commands, "|ss", 0), + PHPDBG_COMMAND_D(eol, "set EOL", 'E', NULL, "|s", 0), PHPDBG_END_COMMAND }; /* }}} */ -ZEND_EXTERN_MODULE_GLOBALS(phpdbg); - static inline int phpdbg_call_register(phpdbg_param_t *stack TSRMLS_DC) /* {{{ */ { phpdbg_param_t *name = NULL; if (stack->type == STACK_PARAM) { + char *lc_name; + name = stack->next; - + if (!name || name->type != STR_PARAM) { return FAILURE; } - - if (zend_hash_exists( - &PHPDBG_G(registered), name->str, name->len+1)) { + lc_name = zend_str_tolower_dup(name->str, name->len); + + if (zend_hash_exists(&PHPDBG_G(registered), lc_name, name->len+1)) { zval fname, *fretval; zend_fcall_info fci; - ZVAL_STRINGL(&fname, name->str, name->len, 1); + ZVAL_STRINGL(&fname, lc_name, name->len, 1); memset(&fci, 0, sizeof(zend_fcall_info)); @@ -101,62 +122,59 @@ static inline int phpdbg_call_register(phpdbg_param_t *stack TSRMLS_DC) /* {{{ * if (name->next) { zval params; phpdbg_param_t *next = name->next; - + array_init(¶ms); while (next) { char *buffered = NULL; - + switch (next->type) { case OP_PARAM: case COND_PARAM: case STR_PARAM: - add_next_index_stringl( - ¶ms, - next->str, - next->len, 1); + add_next_index_stringl(¶ms, next->str, next->len, 1); break; - + case NUMERIC_PARAM: add_next_index_long(¶ms, next->num); break; - + case METHOD_PARAM: spprintf(&buffered, 0, "%s::%s", next->method.class, next->method.name); add_next_index_string(¶ms, buffered, 0); break; - + case NUMERIC_METHOD_PARAM: spprintf(&buffered, 0, "%s::%s#%ld", next->method.class, next->method.name, next->num); add_next_index_string(¶ms, buffered, 0); break; - + case NUMERIC_FUNCTION_PARAM: spprintf(&buffered, 0, "%s#%ld", next->str, next->num); add_next_index_string(¶ms, buffered, 0); break; - + case FILE_PARAM: - spprintf(&buffered, 0, "%s:%ld", + spprintf(&buffered, 0, "%s:%ld", next->file.name, next->file.line); add_next_index_string(¶ms, buffered, 0); break; - + case NUMERIC_FILE_PARAM: - spprintf(&buffered, 0, "%s:#%ld", + spprintf(&buffered, 0, "%s:#%ld", next->file.name, next->file.line); add_next_index_string(¶ms, buffered, 0); break; - + default: { /* not yet */ } } - - next = next->next; + + next = next->next; } zend_fcall_info_args(&fci, ¶ms TSRMLS_CC); @@ -165,22 +183,25 @@ static inline int phpdbg_call_register(phpdbg_param_t *stack TSRMLS_DC) /* {{{ * fci.param_count = 0; } - phpdbg_debug( - "created %d params from arguments", - fci.param_count); + phpdbg_activate_err_buf(0 TSRMLS_CC); + phpdbg_free_err_buf(TSRMLS_C); + + phpdbg_debug("created %d params from arguments", fci.param_count); zend_call_function(&fci, NULL TSRMLS_CC); if (fretval) { - zend_print_zval_r( - fretval, 0 TSRMLS_CC); - phpdbg_writeln(EMPTY); + zend_print_zval_r(fretval, 0 TSRMLS_CC); + phpdbg_out("\n"); } zval_dtor(&fname); + efree(lc_name); return SUCCESS; - } + } + + efree(lc_name); } return FAILURE; @@ -189,7 +210,7 @@ static inline int phpdbg_call_register(phpdbg_param_t *stack TSRMLS_DC) /* {{{ * void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_init TSRMLS_DC) /* {{{ */ { struct stat sb; - + if (init_file && VCWD_STAT(init_file, &sb) != -1) { FILE *fp = fopen(init_file, "r"); if (fp) { @@ -219,8 +240,7 @@ void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_ in_code = 0; code[code_len] = '\0'; { - zend_eval_stringl( - code, code_len, NULL, "phpdbginit code" TSRMLS_CC); + zend_eval_stringl(code, code_len, NULL, "phpdbginit code" TSRMLS_CC); } free(code); code = NULL; @@ -243,30 +263,26 @@ void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_ } { - char *why = NULL; char *input = phpdbg_read_input(cmd TSRMLS_CC); phpdbg_param_t stack; phpdbg_init_param(&stack, STACK_PARAM); + phpdbg_activate_err_buf(1 TSRMLS_CC); + if (phpdbg_do_parse(&stack, input TSRMLS_CC) <= 0) { - switch (phpdbg_stack_execute(&stack, &why TSRMLS_CC)) { + switch (phpdbg_stack_execute(&stack, 1 /* allow_async_unsafe == 1 */ TSRMLS_CC)) { case FAILURE: -// if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { - if (phpdbg_call_register(&stack TSRMLS_CC) == FAILURE) { - phpdbg_error( - "Unrecognized command in %s:%d: %s, %s!", - init_file, line, input, why); - } -// } + phpdbg_activate_err_buf(0 TSRMLS_CC); + if (phpdbg_call_register(&stack TSRMLS_CC) == FAILURE) { + phpdbg_output_err_buf("initfailure", "%b file=\"%s\" line=\"%d\" input=\"%s\"", "Unrecognized command in %s:%d: %s, %b!" TSRMLS_CC, init_file, line, input); + } break; } } - if (why) { - free(why); - why = NULL; - } + phpdbg_activate_err_buf(0 TSRMLS_CC); + phpdbg_free_err_buf(TSRMLS_C); phpdbg_stack_free(&stack); phpdbg_destroy_input(&input TSRMLS_CC); @@ -282,8 +298,7 @@ next_line: fclose(fp); } else { - phpdbg_error( - "Failed to open %s for initialization", init_file); + phpdbg_error("initfailure", "type=\"openfile\" file=\"%s\"", "Failed to open %s for initialization", init_file); } if (free_init) { @@ -315,8 +330,7 @@ void phpdbg_init(char *init_file, size_t init_file_len, zend_bool use_default TS scan_dir[i] = 0; } - asprintf( - &init_file, "%s/%s", scan_dir, PHPDBG_INIT_FILENAME); + asprintf(&init_file, "%s/%s", scan_dir, PHPDBG_INIT_FILENAME); phpdbg_try_file_init(init_file, strlen(init_file), 1 TSRMLS_CC); if (i == -1) { break; @@ -342,36 +356,38 @@ PHPDBG_COMMAND(exec) /* {{{ */ if ((res_len != PHPDBG_G(exec_len)) || (memcmp(res, PHPDBG_G(exec), res_len) != SUCCESS)) { if (PHPDBG_G(exec)) { - phpdbg_notice("Unsetting old execution context: %s", PHPDBG_G(exec)); + phpdbg_notice("exec", "type=\"unset\" context=\"%s\"", "Unsetting old execution context: %s", PHPDBG_G(exec)); efree(PHPDBG_G(exec)); PHPDBG_G(exec) = NULL; PHPDBG_G(exec_len) = 0L; } if (PHPDBG_G(ops)) { - phpdbg_notice("Destroying compiled opcodes"); + phpdbg_notice("exec", "type=\"unsetops\"", "Destroying compiled opcodes"); phpdbg_clean(0 TSRMLS_CC); } PHPDBG_G(exec) = res; PHPDBG_G(exec_len) = res_len; - + + VCWD_CHDIR_FILE(res); + *SG(request_info).argv = PHPDBG_G(exec); php_hash_environment(TSRMLS_C); - phpdbg_notice("Set execution context: %s", PHPDBG_G(exec)); + phpdbg_notice("exec", "type=\"set\" context=\"%s\"", "Set execution context: %s", PHPDBG_G(exec)); if (phpdbg_compile(TSRMLS_C) == FAILURE) { - phpdbg_error("Failed to compile %s", PHPDBG_G(exec)); + phpdbg_error("compile", "type=\"compilefailure\" context=\"%s\"", "Failed to compile %s", PHPDBG_G(exec)); } } else { - phpdbg_notice("Execution context not changed"); + phpdbg_notice("exec", "type=\"unchanged\"", "Execution context not changed"); } } else { - phpdbg_error("Cannot use %s as execution context, not a valid file or symlink", param->str); + phpdbg_error("exec", "type=\"invalid\" context=\"%s\"", "Cannot use %s as execution context, not a valid file or symlink", param->str); } } else { - phpdbg_error("Cannot stat %s, ensure the file exists", param->str); + phpdbg_error("exec", "type=\"notfound\" context=\"%s\"", "Cannot stat %s, ensure the file exists", param->str); } return SUCCESS; } /* }}} */ @@ -381,27 +397,24 @@ int phpdbg_compile(TSRMLS_D) /* {{{ */ zend_file_handle fh; if (!PHPDBG_G(exec)) { - phpdbg_error("No execution context"); + phpdbg_error("inactive", "type=\"nocontext\"", "No execution context"); return SUCCESS; } if (EG(in_execution)) { - phpdbg_error("Cannot compile while in execution"); + phpdbg_error("inactive", "type=\"isrunning\"", "Cannot compile while in execution"); return FAILURE; } - phpdbg_notice("Attempting compilation of %s", PHPDBG_G(exec)); - - if (php_stream_open_for_zend_ex(PHPDBG_G(exec), &fh, - USE_PATH|STREAM_OPEN_FOR_INCLUDE TSRMLS_CC) == SUCCESS) { + if (php_stream_open_for_zend_ex(PHPDBG_G(exec), &fh, USE_PATH|STREAM_OPEN_FOR_INCLUDE TSRMLS_CC) == SUCCESS) { PHPDBG_G(ops) = zend_compile_file(&fh, ZEND_INCLUDE TSRMLS_CC); zend_destroy_file_handle(&fh TSRMLS_CC); - phpdbg_notice("Success"); + phpdbg_notice("compile", "context=\"%s\"", "Successful compilation of %s", PHPDBG_G(exec)); return SUCCESS; } else { - phpdbg_error("Could not open file %s", PHPDBG_G(exec)); + phpdbg_error("compile", "type=\"openfailure\" context=\"%s\"", "Could not open file %s", PHPDBG_G(exec)); } return FAILURE; @@ -424,23 +437,18 @@ PHPDBG_COMMAND(continue) /* {{{ */ PHPDBG_COMMAND(until) /* {{{ */ { if (!EG(in_execution)) { - phpdbg_error("Not executing"); + phpdbg_error("inactive", "type=\"noexec\"", "Not executing"); return SUCCESS; } PHPDBG_G(flags) |= PHPDBG_IN_UNTIL; { - zend_uint next = 0, - self = (EG(current_execute_data)->opline - EG(active_op_array)->opcodes); + zend_uint next = 0, self = (EG(current_execute_data)->opline - EG(active_op_array)->opcodes); zend_op *opline = &EG(active_op_array)->opcodes[self]; for (next = self; next < EG(active_op_array)->last; next++) { if (EG(active_op_array)->opcodes[next].lineno != opline->lineno) { - zend_hash_index_update( - &PHPDBG_G(seek), - (zend_ulong) &EG(active_op_array)->opcodes[next], - &EG(active_op_array)->opcodes[next], - sizeof(zend_op), NULL); + zend_hash_index_update(&PHPDBG_G(seek), (zend_ulong) &EG(active_op_array)->opcodes[next], &EG(active_op_array)->opcodes[next], sizeof(zend_op), NULL); break; } } @@ -452,14 +460,13 @@ PHPDBG_COMMAND(until) /* {{{ */ PHPDBG_COMMAND(finish) /* {{{ */ { if (!EG(in_execution)) { - phpdbg_error("Not executing"); + phpdbg_error("inactive", "type=\"noexec\"", "Not executing"); return SUCCESS; } PHPDBG_G(flags) |= PHPDBG_IN_FINISH; { - zend_uint next = 0, - self = (EG(current_execute_data)->opline - EG(active_op_array)->opcodes); + zend_uint next = 0, self = (EG(current_execute_data)->opline - EG(active_op_array)->opcodes); for (next = self; next < EG(active_op_array)->last; next++) { switch (EG(active_op_array)->opcodes[next].opcode) { @@ -469,11 +476,7 @@ PHPDBG_COMMAND(finish) /* {{{ */ #ifdef ZEND_YIELD case ZEND_YIELD: #endif - zend_hash_index_update( - &PHPDBG_G(seek), - (zend_ulong) &EG(active_op_array)->opcodes[next], - &EG(active_op_array)->opcodes[next], - sizeof(zend_op), NULL); + zend_hash_index_update(&PHPDBG_G(seek), (zend_ulong) &EG(active_op_array)->opcodes[next], &EG(active_op_array)->opcodes[next], sizeof(zend_op), NULL); break; } } @@ -485,14 +488,13 @@ PHPDBG_COMMAND(finish) /* {{{ */ PHPDBG_COMMAND(leave) /* {{{ */ { if (!EG(in_execution)) { - phpdbg_error("Not executing"); + phpdbg_error("inactive", "type=\"noexec\"", "Not executing"); return SUCCESS; } PHPDBG_G(flags) |= PHPDBG_IN_LEAVE; { - zend_uint next = 0, - self = (EG(current_execute_data)->opline - EG(active_op_array)->opcodes); + zend_uint next = 0, self = (EG(current_execute_data)->opline - EG(active_op_array)->opcodes); for (next = self; next < EG(active_op_array)->last; next++) { switch (EG(active_op_array)->opcodes[next].opcode) { @@ -502,11 +504,7 @@ PHPDBG_COMMAND(leave) /* {{{ */ #ifdef ZEND_YIELD case ZEND_YIELD: #endif - zend_hash_index_update( - &PHPDBG_G(seek), - (zend_ulong) &EG(active_op_array)->opcodes[next], - &EG(active_op_array)->opcodes[next], - sizeof(zend_op), NULL); + zend_hash_index_update(&PHPDBG_G(seek), (zend_ulong) &EG(active_op_array)->opcodes[next], &EG(active_op_array)->opcodes[next], sizeof(zend_op), NULL); break; } } @@ -518,8 +516,10 @@ PHPDBG_COMMAND(leave) /* {{{ */ PHPDBG_COMMAND(frame) /* {{{ */ { if (!param) { - phpdbg_notice("Currently in frame #%d", PHPDBG_G(frame).num); - } else phpdbg_switch_frame(param->num TSRMLS_CC); + phpdbg_notice("frame", "id=\"%d\"", "Currently in frame #%d", PHPDBG_G(frame).num); + } else { + phpdbg_switch_frame(param->num TSRMLS_CC); + } return SUCCESS; } /* }}} */ @@ -528,9 +528,7 @@ static inline void phpdbg_handle_exception(TSRMLS_D) /* }}} */ { zend_fcall_info fci; - zval fname, - *trace, - exception; + zval fname, *trace, exception; /* get filename and linenumber before unsetting exception */ const char *filename = zend_get_executed_filename(TSRMLS_C); @@ -541,10 +539,6 @@ static inline void phpdbg_handle_exception(TSRMLS_D) /* }}} */ zval_copy_ctor(&exception); EG(exception) = NULL; - phpdbg_error( - "Uncaught %s!", - Z_OBJCE(exception)->name); - /* call __toString */ ZVAL_STRINGL(&fname, "__tostring", sizeof("__tostring")-1, 1); fci.size = sizeof(fci); @@ -559,16 +553,15 @@ static inline void phpdbg_handle_exception(TSRMLS_D) /* }}} */ zend_call_function(&fci, NULL TSRMLS_CC); if (trace) { - phpdbg_writeln( - "Uncaught %s", Z_STRVAL_P(trace)); - /* remember to dtor trace */ + phpdbg_writeln("exception", "name=\"%s\" trace=\"%.*s\"", "Uncaught %s!\n%.*s", Z_OBJCE(exception)->name, Z_STRLEN_P(trace), Z_STRVAL_P(trace)); + zval_ptr_dtor(&trace); + } else { + phpdbg_error("exception", "name=\"%s\"", "Uncaught %s!", Z_OBJCE(exception)->name); } /* output useful information about address */ - phpdbg_writeln( - "Stacked entered at %p in %s on line %u", - EG(active_op_array)->opcodes, filename, lineno); + phpdbg_writeln("exception", "opline=\"%p\" file=\"%s\" line=\"%u\"", "Stack entered at %p in %s on line %u", EG(active_op_array)->opcodes, filename, lineno); zval_dtor(&fname); zval_dtor(&exception); @@ -577,7 +570,7 @@ static inline void phpdbg_handle_exception(TSRMLS_D) /* }}} */ PHPDBG_COMMAND(run) /* {{{ */ { if (EG(in_execution)) { - phpdbg_error("Cannot start another execution while one is in progress"); + phpdbg_error("inactive", "type=\"isrunning\"", "Cannot start another execution while one is in progress"); return SUCCESS; } @@ -587,10 +580,10 @@ PHPDBG_COMMAND(run) /* {{{ */ 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) { - phpdbg_error("Failed to compile %s, cannot run", PHPDBG_G(exec)); + phpdbg_error("compile", "type=\"compilefailure\" context=\"%s\"", "Failed to compile %s, cannot run", PHPDBG_G(exec)); goto out; } } @@ -619,7 +612,7 @@ PHPDBG_COMMAND(run) /* {{{ */ int argc = 0; int i; char *argv_str = strtok(param->str, " "); - + while (argv_str) { if (argc >= 4 && argc == (argc & -argc)) { argv = erealloc(argv, (argc * 2 + 1) * sizeof(char *)); @@ -635,27 +628,31 @@ PHPDBG_COMMAND(run) /* {{{ */ efree(SG(request_info).argv); SG(request_info).argv = erealloc(argv, ++argc * sizeof(char *)); SG(request_info).argc = argc; - + php_hash_environment(TSRMLS_C); } zend_try { - php_output_activate(TSRMLS_C); PHPDBG_G(flags) ^= PHPDBG_IS_INTERACTIVE; zend_execute(EG(active_op_array) TSRMLS_CC); PHPDBG_G(flags) ^= PHPDBG_IS_INTERACTIVE; - php_output_deactivate(TSRMLS_C); + phpdbg_notice("stop", "type=\"normal\"", "Script ended normally"); } zend_catch { EG(active_op_array) = orig_op_array; EG(opline_ptr) = orig_opline; EG(return_value_ptr_ptr) = orig_retval_ptr; if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { - phpdbg_error("Caught exit/error from VM"); + phpdbg_error("stop", "type=\"bailout\"", "Caught exit/error from VM"); restore = 0; } } zend_end_try(); + if (PHPDBG_G(socket_fd) != -1) { + close(PHPDBG_G(socket_fd)); + PHPDBG_G(socket_fd) = -1; + } + if (restore) { if (EG(exception)) { phpdbg_handle_exception(TSRMLS_C); @@ -666,7 +663,7 @@ PHPDBG_COMMAND(run) /* {{{ */ EG(return_value_ptr_ptr) = orig_retval_ptr; } } else { - phpdbg_error("Nothing to execute!"); + phpdbg_error("inactive", "type=\"nocontext\"", "Nothing to execute!"); } out: @@ -674,31 +671,56 @@ out: return SUCCESS; } /* }}} */ +int phpdbg_output_ev_variable(char *name, size_t len, char *keyname, size_t keylen, HashTable *parent, zval **zv TSRMLS_DC) { + phpdbg_notice("eval", "variable=\"%.*s\"", "Printing variable %.*s", (int) len, name); + phpdbg_xml(""); + zend_print_zval_r(*zv, 0 TSRMLS_CC); + phpdbg_xml(""); + phpdbg_out("\n"); + + efree(name); + efree(keyname); + + return SUCCESS; +} + 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; + 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(); + return SUCCESS; + } + if (!(PHPDBG_G(flags) & PHPDBG_IS_STEPONEVAL)) { - PHPDBG_G(flags) &= ~ PHPDBG_IS_STEPPING; + PHPDBG_G(flags) &= ~PHPDBG_IS_STEPPING; } /* disable stepping while eval() in progress */ PHPDBG_G(flags) |= PHPDBG_IN_EVAL; zend_try { - if (zend_eval_stringl(param->str, param->len, - &retval, "eval()'d code" TSRMLS_CC) == SUCCESS) { - zend_print_zval_r( - &retval, 0 TSRMLS_CC); - phpdbg_writeln(EMPTY); + if (zend_eval_stringl(param->str, param->len,&retval, "eval()'d code" TSRMLS_CC) == SUCCESS) { + phpdbg_xml(""); + if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) { + zval *zvp = &retval; + phpdbg_xml_var_dump(&zvp TSRMLS_CC); + } + zend_print_zval_r(&retval, 0 TSRMLS_CC); + phpdbg_xml(""); + phpdbg_out("\n"); zval_dtor(&retval); } } zend_end_try(); PHPDBG_G(flags) &= ~PHPDBG_IN_EVAL; /* switch stepping back on */ - if (stepping && - !(PHPDBG_G(flags) & PHPDBG_IS_STEPONEVAL)) { + if (stepping && !(PHPDBG_G(flags) & PHPDBG_IS_STEPONEVAL)) { PHPDBG_G(flags) |= PHPDBG_IS_STEPPING; } @@ -710,7 +732,7 @@ PHPDBG_COMMAND(ev) /* {{{ */ PHPDBG_COMMAND(back) /* {{{ */ { if (!EG(in_execution)) { - phpdbg_error("Not executing!"); + phpdbg_error("inactive", "type=\"noexec\"", "Not executing!"); return SUCCESS; } @@ -725,62 +747,54 @@ PHPDBG_COMMAND(back) /* {{{ */ PHPDBG_COMMAND(print) /* {{{ */ { - phpdbg_writeln(SEPARATE); - phpdbg_notice("Execution Context Information"); + phpdbg_out("Execution Context Information\n\n"); + phpdbg_xml(""); #ifdef HAVE_LIBREADLINE - phpdbg_writeln("Readline\tyes"); + phpdbg_writeln("print", "readline=\"yes\"", "Readline yes"); #else - phpdbg_writeln("Readline\tno"); + phpdbg_writeln("print", "readline=\"no\"", "Readline no"); #endif #ifdef HAVE_LIBEDIT - phpdbg_writeln("Libedit\t\tyes"); + phpdbg_writeln("print", "libedit=\"yes\"", "Libedit yes"); #else - phpdbg_writeln("Libedit\t\tno"); + phpdbg_writeln("print", "libedit=\"no\"", "Libedit no"); #endif - phpdbg_writeln("Exec\t\t%s", PHPDBG_G(exec) ? PHPDBG_G(exec) : "none"); - phpdbg_writeln("Compiled\t%s", PHPDBG_G(ops) ? "yes" : "no"); - phpdbg_writeln("Stepping\t%s", (PHPDBG_G(flags) & PHPDBG_IS_STEPPING) ? "on" : "off"); - phpdbg_writeln("Quietness\t%s", (PHPDBG_G(flags) & PHPDBG_IS_QUIET) ? "on" : "off"); - phpdbg_writeln("Oplog\t\t%s", PHPDBG_G(oplog) ? "on" : "off"); + phpdbg_writeln("print", "context=\"%s\"", "Exec %s", PHPDBG_G(exec) ? PHPDBG_G(exec) : "none"); + phpdbg_writeln("print", "compiled=\"%s\"", "Compiled %s", PHPDBG_G(ops) ? "yes" : "no"); + phpdbg_writeln("print", "stepping=\"%s\"", "Stepping %s", (PHPDBG_G(flags) & PHPDBG_IS_STEPPING) ? "on" : "off"); + phpdbg_writeln("print", "quiet=\"%s\"", "Quietness %s", (PHPDBG_G(flags) & PHPDBG_IS_QUIET) ? "on" : "off"); + phpdbg_writeln("print", "oplog=\"%s\"", "Oplog %s", PHPDBG_G(oplog) ? "on" : "off"); if (PHPDBG_G(ops)) { - phpdbg_writeln("Opcodes\t\t%d", PHPDBG_G(ops)->last); - - if (PHPDBG_G(ops)->last_var) { - phpdbg_writeln("Variables\t%d", PHPDBG_G(ops)->last_var-1); - } else { - phpdbg_writeln("Variables\tNone"); - } + phpdbg_writeln("print", "ops=\"%d\"", "Opcodes %d", PHPDBG_G(ops)->last); + phpdbg_writeln("print", "vars=\"%d\"", "Variables %d", PHPDBG_G(ops)->last_var ? PHPDBG_G(ops)->last_var - 1 : 0); } - phpdbg_writeln("Executing\t%s", EG(in_execution) ? "yes" : "no"); + phpdbg_writeln("print", "executing=\"%d\"", "Executing %s", EG(in_execution) ? "yes" : "no"); if (EG(in_execution)) { - phpdbg_writeln("VM Return\t%d", PHPDBG_G(vmret)); + phpdbg_writeln("print", "vmret=\"%d\"", "VM Return %d", PHPDBG_G(vmret)); } - phpdbg_writeln("Classes\t\t%d", zend_hash_num_elements(EG(class_table))); - phpdbg_writeln("Functions\t%d", zend_hash_num_elements(EG(function_table))); - phpdbg_writeln("Constants\t%d", zend_hash_num_elements(EG(zend_constants))); - phpdbg_writeln("Included\t%d", zend_hash_num_elements(&EG(included_files))); - - phpdbg_writeln(SEPARATE); + phpdbg_writeln("print", "classes=\"%d\"", "Classes %d", zend_hash_num_elements(EG(class_table))); + phpdbg_writeln("print", "functions=\"%d\"", "Functions %d", zend_hash_num_elements(EG(function_table))); + phpdbg_writeln("print", "constants=\"%d\"", "Constants %d", zend_hash_num_elements(EG(zend_constants))); + phpdbg_writeln("print", "includes=\"%d\"", "Included %d", zend_hash_num_elements(&EG(included_files))); + phpdbg_xml(""); return SUCCESS; } /* }}} */ PHPDBG_COMMAND(info) /* {{{ */ { - phpdbg_error( - "No information command selected!"); + phpdbg_error("info", "type=\"toofewargs\" expected=\"1\"", "No information command selected!"); return SUCCESS; } /* }}} */ PHPDBG_COMMAND(set) /* {{{ */ { - phpdbg_error( - "No set command selected!"); + phpdbg_error("set", "type=\"toofewargs\" expected=\"1\"", "No set command selected!"); return SUCCESS; } /* }}} */ @@ -789,8 +803,8 @@ PHPDBG_COMMAND(break) /* {{{ */ { if (!param) { phpdbg_set_breakpoint_file( - zend_get_executed_filename(TSRMLS_C), - zend_get_executed_lineno(TSRMLS_C) TSRMLS_CC); + zend_get_executed_filename(TSRMLS_C), + zend_get_executed_lineno(TSRMLS_C) TSRMLS_CC); } else switch (param->type) { case ADDR_PARAM: phpdbg_set_breakpoint_opline(param->addr TSRMLS_CC); @@ -799,7 +813,7 @@ PHPDBG_COMMAND(break) /* {{{ */ if (PHPDBG_G(exec)) { phpdbg_set_breakpoint_file(phpdbg_current_file(TSRMLS_C), param->num TSRMLS_CC); } else { - phpdbg_error("Execution context not set!"); + phpdbg_error("inactive", "type=\"noexec\"", "Execution context not set!"); } break; case METHOD_PARAM: @@ -837,42 +851,226 @@ PHPDBG_COMMAND(sh) /* {{{ */ { FILE *fd = NULL; if ((fd=VCWD_POPEN((char*)param->str, "w"))) { - /* do something perhaps ?? do we want input ?? */ + /* TODO: do something perhaps ?? do we want input ?? */ fclose(fd); } else { - phpdbg_error( - "Failed to execute %s", param->str); + phpdbg_error("sh", "type=\"failure\" smd=\"%s\"", "Failed to execute %s", param->str); } - + + return SUCCESS; +} /* }}} */ + +static int add_module_info(zend_module_entry *module TSRMLS_DC) { + phpdbg_write("module", "name=\"%s\"", "%s\n", module->name); + return 0; +} + +static int add_zendext_info(zend_extension *ext TSRMLS_DC) { + phpdbg_write("extension", "name=\"%s\"", "%s\n", ext->name); + return 0; +} + +PHPDBG_API const char *phpdbg_load_module_or_extension(char **path, char **name TSRMLS_DC) { + DL_HANDLE handle; + char *extension_dir; + + extension_dir = INI_STR("extension_dir"); + + if (strchr(*path, '/') != NULL || strchr(*path, DEFAULT_SLASH) != NULL) { + /* path is fine */ + } else if (extension_dir && extension_dir[0]) { + char *libpath; + int extension_dir_len = strlen(extension_dir); + if (IS_SLASH(extension_dir[extension_dir_len-1])) { + spprintf(&libpath, 0, "%s%s", extension_dir, *path); /* SAFE */ + } else { + spprintf(&libpath, 0, "%s%c%s", extension_dir, DEFAULT_SLASH, *path); /* SAFE */ + } + efree(*path); + *path = libpath; + } else { + phpdbg_error("dl", "type=\"relpath\"", "Not a full path given or extension_dir ini setting is not set"); + + return NULL; + } + + handle = DL_LOAD(*path); + + if (!handle) { +#if PHP_WIN32 + char *err = GET_DL_ERROR(); + if (err && *err != "") { + phpdbg_error("dl", "type=\"unknown\"", "%s", err); + LocalFree(err); + } else { + phpdbg_error("dl", "type=\"unknown\"", "Unknown reason"); + } +#else + phpdbg_error("dl", "type=\"unknown\"", "%s", GET_DL_ERROR()); +#endif + return NULL; + } + +#if ZEND_EXTENSIONS_SUPPORT + do { + zend_extension *new_extension; + zend_extension_version_info *extension_version_info; + + extension_version_info = (zend_extension_version_info *) DL_FETCH_SYMBOL(handle, "extension_version_info"); + if (!extension_version_info) { + extension_version_info = (zend_extension_version_info *) DL_FETCH_SYMBOL(handle, "_extension_version_info"); + } + new_extension = (zend_extension *) DL_FETCH_SYMBOL(handle, "zend_extension_entry"); + if (!new_extension) { + new_extension = (zend_extension *) DL_FETCH_SYMBOL(handle, "_zend_extension_entry"); + } + if (!extension_version_info || !new_extension) { + break; + } + if (extension_version_info->zend_extension_api_no != ZEND_EXTENSION_API_NO &&(!new_extension->api_no_check || new_extension->api_no_check(ZEND_EXTENSION_API_NO) != SUCCESS)) { + phpdbg_error("dl", "type=\"wrongapi\" extension=\"%s\" apineeded=\"%d\" apiinstalled=\"%d\"", "%s requires Zend Engine API version %d, which does not match the installed Zend Engine API version %d", new_extension->name, extension_version_info->zend_extension_api_no, ZEND_EXTENSION_API_NO); + + goto quit; + } else if (strcmp(ZEND_EXTENSION_BUILD_ID, extension_version_info->build_id) && (!new_extension->build_id_check || new_extension->build_id_check(ZEND_EXTENSION_BUILD_ID) != SUCCESS)) { + phpdbg_error("dl", "type=\"wrongbuild\" extension=\"%s\" buildneeded=\"%s\" buildinstalled=\"%s\"", "%s was built with configuration %s, whereas running engine is %s", new_extension->name, extension_version_info->build_id, ZEND_EXTENSION_BUILD_ID); + + goto quit; + } + + *name = new_extension->name; + + zend_register_extension(new_extension, handle); + + if (new_extension->startup) { + if (new_extension->startup(new_extension) != SUCCESS) { + phpdbg_error("dl", "type=\"startupfailure\" extension=\"%s\"", "Unable to startup Zend extension %s", new_extension->name); + + goto quit; + } + zend_append_version_info(new_extension); + } + + return "Zend extension"; + } while (0); +#endif + + do { + zend_module_entry *module_entry; + zend_module_entry *(*get_module)(void); + + get_module = (zend_module_entry *(*)(void)) DL_FETCH_SYMBOL(handle, "get_module"); + if (!get_module) { + get_module = (zend_module_entry *(*)(void)) DL_FETCH_SYMBOL(handle, "_get_module"); + } + + if (!get_module) { + break; + } + + module_entry = get_module(); + *name = (char *) module_entry->name; + + if (strcmp(ZEND_EXTENSION_BUILD_ID, module_entry->build_id)) { + phpdbg_error("dl", "type=\"wrongbuild\" module=\"%s\" buildneeded=\"%s\" buildinstalled=\"%s\"", "%s was built with configuration %s, whereas running engine is %s", module_entry->name, module_entry->build_id, ZEND_EXTENSION_BUILD_ID); + + goto quit; + } + + module_entry->type = MODULE_PERSISTENT; + module_entry->module_number = zend_next_free_module(); + module_entry->handle = handle; + + if ((module_entry = zend_register_module_ex(module_entry TSRMLS_CC)) == NULL) { + phpdbg_error("dl", "type=\"registerfailure\" module=\"%s\"", "Unable to register module %s", module_entry->name); + + goto quit; + } + + if (zend_startup_module_ex(module_entry TSRMLS_CC) == FAILURE) { + phpdbg_error("dl", "type=\"startupfailure\" module=\"%s\"", "Unable to startup module %s", module_entry->name); + + goto quit; + } + + if (module_entry->request_startup_func) { + if (module_entry->request_startup_func(MODULE_PERSISTENT, module_entry->module_number TSRMLS_CC) == FAILURE) { + phpdbg_error("dl", "type=\"initfailure\" module=\"%s\"", "Unable to initialize module %s", module_entry->name); + + goto quit; + } + } + + return "module"; + } while (0); + + phpdbg_error("dl", "type=\"nophpso\"", "This shared object is nor a Zend extension nor a module"); + +quit: + DL_UNLOAD(handle); + return NULL; +} + +PHPDBG_COMMAND(dl) /* {{{ */ +{ + const char *type; + char *name, *path; + + if (!param || param->type == EMPTY_PARAM) { + phpdbg_notice("dl", "extensiontype=\"Zend extension\"", "Zend extensions"); + zend_llist_apply(&zend_extensions, (llist_apply_func_t) add_zendext_info TSRMLS_CC); + phpdbg_out("\n"); + phpdbg_notice("dl", "extensiontype=\"module\"", "Modules"); + zend_hash_apply(&module_registry, (apply_func_t) add_module_info TSRMLS_CC); + } else switch (param->type) { + case STR_PARAM: +#ifdef HAVE_LIBDL + path = estrndup(param->str, param->len); + + phpdbg_activate_err_buf(1 TSRMLS_CC); + if ((type = phpdbg_load_module_or_extension(&path, &name TSRMLS_CC)) == NULL) { + phpdbg_error("dl", "path=\"%s\" %b", "Could not load %s, not found or invalid zend extension / module: %b", path); + efree(name); + } else { + phpdbg_notice("dl", "extensiontype=\"%s\" name=\"%s\" path=\"%s\"", "Successfully loaded the %s %s at path %s", type, name, path); + } + phpdbg_activate_err_buf(0 TSRMLS_CC); + phpdbg_free_err_buf(TSRMLS_C); + efree(path); +#else + phpdbg_error("dl", "type=\"unsupported\" path=\"%.*s\"", "Cannot dynamically load %.*s - dynamic modules are not supported", (int) param->len, param->str); +#endif + break; + + phpdbg_default_switch_case(); + } + return SUCCESS; } /* }}} */ PHPDBG_COMMAND(source) /* {{{ */ { struct stat sb; - + if (VCWD_STAT(param->str, &sb) != -1) { phpdbg_try_file_init(param->str, param->len, 0 TSRMLS_CC); } else { - phpdbg_error( - "Failed to stat %s, file does not exist", param->str); + phpdbg_error("source", "type=\"notfound\" file=\"%s\"", "Failed to stat %s, file does not exist", param->str); } - + return SUCCESS; } /* }}} */ PHPDBG_COMMAND(export) /* {{{ */ { FILE *handle = VCWD_FOPEN(param->str, "w+"); - + if (handle) { phpdbg_export_breakpoints(handle TSRMLS_CC); fclose(handle); } else { - phpdbg_error( - "Failed to open or create %s, check path and permissions", param->str); + phpdbg_error("export", "type=\"openfailure\" file=\"%s\"", "Failed to open or create %s, check path and permissions", param->str); } - + return SUCCESS; } /* }}} */ @@ -884,18 +1082,15 @@ PHPDBG_COMMAND(register) /* {{{ */ if (!zend_hash_exists(&PHPDBG_G(registered), lcname, lcname_len+1)) { if (zend_hash_find(EG(function_table), lcname, lcname_len+1, (void**) &function) == SUCCESS) { - zend_hash_update( - &PHPDBG_G(registered), lcname, lcname_len+1, (void*)&function, sizeof(zend_function), NULL); + zend_hash_update(&PHPDBG_G(registered), lcname, lcname_len+1, (void*)&function, sizeof(zend_function), NULL); function_add_ref(function); - phpdbg_notice( - "Registered %s", lcname); + phpdbg_notice("register", "function=\"%s\"", "Registered %s", lcname); } else { - phpdbg_error("The requested function (%s) could not be found", param->str); + phpdbg_error("register", "type=\"notfoundc\" function=\"%s\"", "The requested function (%s) could not be found", param->str); } } else { - phpdbg_error( - "The requested name (%s) is already in use", lcname); + phpdbg_error("register", "type=\"inuse\" function=\"%s\"", "The requested name (%s) is already in use", lcname); } efree(lcname); @@ -916,37 +1111,43 @@ PHPDBG_COMMAND(quit) /* {{{ */ PHPDBG_COMMAND(clean) /* {{{ */ { if (EG(in_execution)) { - phpdbg_error("Cannot clean environment while executing"); + phpdbg_error("inactive", "type=\"isrunning\"", "Cannot clean environment while executing"); return SUCCESS; } - phpdbg_notice("Cleaning Execution Environment"); + phpdbg_out("Cleaning Execution Environment\n"); + phpdbg_xml(""); - phpdbg_writeln("Classes\t\t\t%d", zend_hash_num_elements(EG(class_table))); - phpdbg_writeln("Functions\t\t%d", zend_hash_num_elements(EG(function_table))); - phpdbg_writeln("Constants\t\t%d", zend_hash_num_elements(EG(zend_constants))); - phpdbg_writeln("Includes\t\t%d", zend_hash_num_elements(&EG(included_files))); + phpdbg_writeln("clean", "classes=\"%d\"", "Classes %d", zend_hash_num_elements(EG(class_table))); + phpdbg_writeln("clean", "functions=\"%d\"", "Functions %d", zend_hash_num_elements(EG(function_table))); + 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_clean(1 TSRMLS_CC); + phpdbg_xml(""); + return SUCCESS; } /* }}} */ PHPDBG_COMMAND(clear) /* {{{ */ { - phpdbg_notice("Clearing Breakpoints"); + phpdbg_out("Clearing Breakpoints\n"); + phpdbg_xml(""); - phpdbg_writeln("File\t\t\t%d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE])); - phpdbg_writeln("Functions\t\t%d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM])); - phpdbg_writeln("Methods\t\t\t%d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD])); - phpdbg_writeln("Oplines\t\t\t%d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE])); - phpdbg_writeln("File oplines\t\t\t%d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE])); - phpdbg_writeln("Function oplines\t\t\t%d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE])); - phpdbg_writeln("Method oplines\t\t\t%d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE])); - phpdbg_writeln("Conditionals\t\t%d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_COND])); + phpdbg_writeln("clear", "files=\"%d\"", "File %d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE])); + phpdbg_writeln("clear", "functions=\"%d\"", "Functions %d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM])); + phpdbg_writeln("clear", "methods=\"%d\"", "Methods %d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD])); + phpdbg_writeln("clear", "oplines=\"%d\"", "Oplines %d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE])); + phpdbg_writeln("clear", "fileoplines=\"%d\"", "File oplines %d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE])); + phpdbg_writeln("clear", "functionoplines=\"%d\"", "Function oplines %d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE])); + phpdbg_writeln("clear", "methodoplines=\"%d\"", "Method oplines %d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE])); + phpdbg_writeln("clear", "eval=\"%d\"", "Conditionals %d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_COND])); phpdbg_clear_breakpoints(TSRMLS_C); + phpdbg_xml(""); + return SUCCESS; } /* }}} */ @@ -981,7 +1182,7 @@ PHPDBG_COMMAND(watch) /* {{{ */ } else switch (param->type) { case STR_PARAM: if (phpdbg_create_var_watchpoint(param->str, param->len TSRMLS_CC) != FAILURE) { - phpdbg_notice("Set watchpoint on %.*s", (int)param->len, param->str); + phpdbg_notice("watch", "variable=\"%.*s\"", "Set watchpoint on %.*s", (int) param->len, param->str); } break; @@ -991,10 +1192,9 @@ PHPDBG_COMMAND(watch) /* {{{ */ return SUCCESS; } /* }}} */ -int phpdbg_interactive(TSRMLS_D) /* {{{ */ +int phpdbg_interactive(zend_bool allow_async_unsafe TSRMLS_DC) /* {{{ */ { int ret = SUCCESS; - char *why = NULL; char *input = NULL; phpdbg_param_t stack; @@ -1007,42 +1207,49 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */ phpdbg_init_param(&stack, STACK_PARAM); if (phpdbg_do_parse(&stack, input TSRMLS_CC) <= 0) { - switch (ret = phpdbg_stack_execute(&stack, &why TSRMLS_CC)) { + phpdbg_activate_err_buf(1 TSRMLS_CC); + +#ifdef PHP_WIN32 +#define PARA ((phpdbg_param_t *)stack.next)->type + if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE && (RUN_PARAM == PARA || EVAL_PARAM == PARA)) { + sigio_watcher_start(); + } +#endif + switch (ret = phpdbg_stack_execute(&stack, allow_async_unsafe TSRMLS_CC)) { case FAILURE: if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { - if (phpdbg_call_register(&stack TSRMLS_CC) == FAILURE) { - if (why) { - phpdbg_error("%s", why); - } + if (!allow_async_unsafe || phpdbg_call_register(&stack TSRMLS_CC) == FAILURE) { + phpdbg_output_err_buf(NULL, "%b", "%b" TSRMLS_CC); } } - - if (why) { - free(why); - why = NULL; - } break; case PHPDBG_LEAVE: case PHPDBG_FINISH: case PHPDBG_UNTIL: case PHPDBG_NEXT: { + phpdbg_activate_err_buf(0 TSRMLS_CC); + phpdbg_free_err_buf(TSRMLS_C); if (!EG(in_execution) && !(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { - phpdbg_error("Not running"); + phpdbg_error("command", "type=\"noexec\"", "Not running"); } goto out; } } - } - if (why) { - free(why); - why = NULL; + phpdbg_activate_err_buf(0 TSRMLS_CC); + phpdbg_free_err_buf(TSRMLS_C); +#ifdef PHP_WIN32 + if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE && (RUN_PARAM == PARA || EVAL_PARAM == PARA)) { + sigio_watcher_stop(); + } +#undef PARA +#endif } phpdbg_stack_free(&stack); phpdbg_destroy_input(&input TSRMLS_CC); - + PHPDBG_G(req_id) = 0; } while ((input = phpdbg_read_input(NULL TSRMLS_CC))); } @@ -1050,10 +1257,7 @@ out: if (input) { phpdbg_stack_free(&stack); phpdbg_destroy_input(&input TSRMLS_CC); - } - - if (why) { - free(why); + PHPDBG_G(req_id) = 0; } if (EG(in_execution)) { @@ -1105,9 +1309,9 @@ static inline zend_execute_data *phpdbg_create_execute_data(zend_op_array *op_ar ZEND_MM_ALIGNED_SIZE(sizeof(zval**) * op_array->last_var * (EG(active_symbol_table) ? 1 : 2)) + ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)) * op_array->T TSRMLS_CC); - EX(CVs) = (zval***)((char*)execute_data + ZEND_MM_ALIGNED_SIZE(sizeof(zend_execute_data))); - memset(EX(CVs), 0, sizeof(zval**) * op_array->last_var); - EX(Ts) = (temp_variable *)(((char*)EX(CVs)) + ZEND_MM_ALIGNED_SIZE(sizeof(zval**) * op_array->last_var * (EG(active_symbol_table) ? 1 : 2))); + EX(CVs) = (zval ***)((char *)execute_data + ZEND_MM_ALIGNED_SIZE(sizeof(zend_execute_data))); + memset(EX(CVs), 0, sizeof(zval **) * op_array->last_var); + EX(Ts) = (temp_variable *)(((char *) EX(CVs)) + ZEND_MM_ALIGNED_SIZE(sizeof(zval **) * op_array->last_var * (EG(active_symbol_table) ? 1 : 2))); EX(fbc) = NULL; EX(called_scope) = NULL; EX(object) = NULL; @@ -1125,16 +1329,16 @@ static inline zend_execute_data *phpdbg_create_execute_data(zend_op_array *op_ar if (op_array->this_var != -1 && EG(This)) { Z_ADDREF_P(EG(This)); /* For $this pointer */ if (!EG(active_symbol_table)) { - EX_CV(op_array->this_var) = (zval**)EX_CVs() + (op_array->last_var + op_array->this_var); + EX_CV(op_array->this_var) = (zval**) EX_CVs() + (op_array->last_var + op_array->this_var); *EX_CV(op_array->this_var) = EG(This); } else { - if (zend_hash_add(EG(active_symbol_table), "this", sizeof("this"), &EG(This), sizeof(zval *), (void**)&EX_CV(op_array->this_var))==FAILURE) { + if (zend_hash_add(EG(active_symbol_table), "this", sizeof("this"), &EG(This), sizeof(zval *), (void **) &EX_CV(op_array->this_var))==FAILURE) { Z_DELREF_P(EG(This)); } } } - EX(opline) = UNEXPECTED((op_array->fn_flags & ZEND_ACC_INTERACTIVE) != 0) && EG(start_op) ? EG(start_op) : op_array->opcodes; + EX(opline) = op_array->opcodes; EG(opline_ptr) = &EX(opline); EX(function_state).function = (zend_function *) op_array; @@ -1144,6 +1348,27 @@ static inline zend_execute_data *phpdbg_create_execute_data(zend_op_array *op_ar #endif } /* }}} */ +#define DO_INTERACTIVE(allow_async_unsafe) do { \ + 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 \ + ); \ + } \ + \ + switch (phpdbg_interactive(allow_async_unsafe TSRMLS_CC)) { \ + case PHPDBG_LEAVE: \ + case PHPDBG_FINISH: \ + case PHPDBG_UNTIL: \ + case PHPDBG_NEXT:{ \ + goto next; \ + } \ + } \ +} while (0) + #if PHP_VERSION_ID >= 50500 void phpdbg_execute_ex(zend_execute_data *execute_data TSRMLS_DC) /* {{{ */ { @@ -1180,41 +1405,17 @@ zend_vm_enter: #endif while (1) { - if ((PHPDBG_G(flags) & PHPDBG_BP_RESOLVE_MASK)) { /* resolve nth opline breakpoints */ phpdbg_resolve_op_array_breaks(EG(active_op_array) TSRMLS_CC); } - + #ifdef ZEND_WIN32 if (EG(timed_out)) { zend_timeout(0); } #endif -#define DO_INTERACTIVE() do { \ - 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 \ - ); \ - } \ - \ -/* do { */\ - switch (phpdbg_interactive(TSRMLS_C)) { \ - case PHPDBG_LEAVE: \ - case PHPDBG_FINISH: \ - case PHPDBG_UNTIL: \ - case PHPDBG_NEXT:{ \ - goto next; \ - } \ - } \ -/* } while (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)); */\ -} while (0) - /* allow conditional breakpoints and initialization to access the vm uninterrupted */ if ((PHPDBG_G(flags) & PHPDBG_IN_COND_BP) || @@ -1232,8 +1433,7 @@ zend_vm_enter: if (PHPDBG_G(flags) & PHPDBG_IN_UNTIL) { if (zend_hash_index_exists(&PHPDBG_G(seek), address)) { PHPDBG_G(flags) &= ~PHPDBG_IN_UNTIL; - zend_hash_clean( - &PHPDBG_G(seek)); + zend_hash_clean(&PHPDBG_G(seek)); } else { /* skip possible breakpoints */ goto next; @@ -1244,8 +1444,7 @@ zend_vm_enter: if (PHPDBG_G(flags) & PHPDBG_IN_FINISH) { if (zend_hash_index_exists(&PHPDBG_G(seek), address)) { PHPDBG_G(flags) &= ~PHPDBG_IN_FINISH; - zend_hash_clean( - &PHPDBG_G(seek)); + zend_hash_clean(&PHPDBG_G(seek)); } /* skip possible breakpoints */ goto next; @@ -1255,14 +1454,12 @@ zend_vm_enter: if (PHPDBG_G(flags) & PHPDBG_IN_LEAVE) { if (zend_hash_index_exists(&PHPDBG_G(seek), address)) { PHPDBG_G(flags) &= ~PHPDBG_IN_LEAVE; - zend_hash_clean( - &PHPDBG_G(seek)); - phpdbg_notice( - "Breaking for leave at %s:%u", + zend_hash_clean(&PHPDBG_G(seek)); + phpdbg_notice("breakpoint", "id=\"leave\" file=\"%s\" line=\"%u\"", "Breaking for leave at %s:%u", zend_get_executed_filename(TSRMLS_C), zend_get_executed_lineno(TSRMLS_C) ); - DO_INTERACTIVE(); + DO_INTERACTIVE(1); } else { /* skip possible breakpoints */ goto next; @@ -1271,18 +1468,17 @@ zend_vm_enter: } /* not while in conditionals */ - phpdbg_print_opline_ex( - execute_data, &vars, 0 TSRMLS_CC); + phpdbg_print_opline_ex(execute_data, &vars, 0 TSRMLS_CC); if (PHPDBG_G(flags) & PHPDBG_IS_STEPPING && (PHPDBG_G(flags) & PHPDBG_STEP_OPCODE || execute_data->opline->lineno != PHPDBG_G(last_line))) { PHPDBG_G(flags) &= ~PHPDBG_IS_STEPPING; - DO_INTERACTIVE(); + DO_INTERACTIVE(1); } /* check if some watchpoint was hit */ { if (phpdbg_print_changed_zvals(TSRMLS_C) == SUCCESS) { - DO_INTERACTIVE(); + DO_INTERACTIVE(1); } } @@ -1294,21 +1490,36 @@ zend_vm_enter: && (brake = phpdbg_find_breakpoint(execute_data TSRMLS_CC)) && (brake->type != PHPDBG_BREAK_FILE || execute_data->opline->lineno != PHPDBG_G(last_line))) { phpdbg_hit_breakpoint(brake, 1 TSRMLS_CC); - DO_INTERACTIVE(); + DO_INTERACTIVE(1); } } -next: if (PHPDBG_G(flags) & PHPDBG_IS_SIGNALED) { - phpdbg_writeln(EMPTY); - phpdbg_notice("Program received signal SIGINT"); PHPDBG_G(flags) &= ~PHPDBG_IS_SIGNALED; - DO_INTERACTIVE(); + + phpdbg_out("\n"); + phpdbg_notice("signal", "type=\"SIGINT\"", "Program received signal SIGINT"); + DO_INTERACTIVE(1); } +next: + PHPDBG_G(last_line) = execute_data->opline->lineno; + /* stupid hack to make zend_do_fcall_common_helper return ZEND_VM_ENTER() instead of recursively calling zend_execute() and eventually segfaulting */ + if ((execute_data->opline->opcode == ZEND_DO_FCALL_BY_NAME || execute_data->opline->opcode == ZEND_DO_FCALL) && execute_data->function_state.function->type == ZEND_USER_FUNCTION) { +#if PHP_VERSION_ID < 50500 + zend_execute = execute; +#else + zend_execute_ex = execute_ex; +#endif + } PHPDBG_G(vmret) = execute_data->opline->handler(execute_data TSRMLS_CC); +#if PHP_VERSION_ID < 50500 + zend_execute = phpdbg_execute_ex; +#else + zend_execute_ex = phpdbg_execute_ex; +#endif if (PHPDBG_G(vmret) > 0) { switch (PHPDBG_G(vmret)) { @@ -1333,3 +1544,47 @@ next: } zend_error_noreturn(E_ERROR, "Arrived at end of main loop which shouldn't happen"); } /* }}} */ + +/* only if *not* interactive and while executing */ +void phpdbg_force_interruption(TSRMLS_D) { + zend_execute_data *data = EG(current_execute_data); /* should be always readable if not NULL */ + + PHPDBG_G(flags) |= PHPDBG_IN_SIGNAL_HANDLER; + + if (data) { + if (data->op_array) { + phpdbg_notice("hardinterrupt", "opline=\"%p\" num=\"%lu\" file=\"%s\" line=\"%u\"", "Current opline: %p (op #%lu) in %s:%u", data->opline, (data->opline - data->op_array->opcodes) / sizeof(data->opline), data->op_array->filename, data->opline->lineno); + } else { + phpdbg_notice("hardinterrupt", "opline=\"%p\"", "Current opline: %p (op_array information unavailable)", data->opline); + } + } else { + phpdbg_notice("hardinterrupt", "", "No information available about executing context"); + } + + DO_INTERACTIVE(0); + +next: + PHPDBG_G(flags) &= ~PHPDBG_IN_SIGNAL_HANDLER; + + if (PHPDBG_G(flags) & PHPDBG_IS_QUITTING) { + zend_bailout(); + } +} + +PHPDBG_COMMAND(eol) /* {{{ */ +{ + if (!param || param->type == EMPTY_PARAM) { + phpdbg_notice("eol", "argument required", "argument required"); + } else switch (param->type) { + case STR_PARAM: + if (FAILURE == phpdbg_eol_global_update(param->str TSRMLS_CC)) { + phpdbg_notice("eol", "unknown EOL name '%s', give crlf, lf, cr", "unknown EOL name '%s', give crlf, lf, cr", param->str); + } + break; + + phpdbg_default_switch_case(); + } + + return SUCCESS; +} /* }}} */ + diff --git a/phpdbg_prompt.h b/phpdbg_prompt.h index ef648aabeb0..94e24df8334 100644 --- a/phpdbg_prompt.h +++ b/phpdbg_prompt.h @@ -24,9 +24,11 @@ /* {{{ */ void phpdbg_init(char *init_file, size_t init_file_len, zend_bool use_default TSRMLS_DC); void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_init TSRMLS_DC); -int phpdbg_interactive(TSRMLS_D); +int phpdbg_interactive(zend_bool allow_async_unsafe TSRMLS_DC); int phpdbg_compile(TSRMLS_D); -void phpdbg_clean(zend_bool full TSRMLS_DC); /* }}} */ +void phpdbg_clean(zend_bool full TSRMLS_DC); +void phpdbg_force_interruption(TSRMLS_D); +/* }}} */ /* {{{ phpdbg command handlers */ PHPDBG_COMMAND(exec); @@ -47,12 +49,15 @@ PHPDBG_COMMAND(clean); PHPDBG_COMMAND(clear); PHPDBG_COMMAND(help); PHPDBG_COMMAND(sh); +PHPDBG_COMMAND(dl); PHPDBG_COMMAND(set); PHPDBG_COMMAND(source); PHPDBG_COMMAND(export); PHPDBG_COMMAND(register); PHPDBG_COMMAND(quit); -PHPDBG_COMMAND(watch); /* }}} */ +PHPDBG_COMMAND(watch); +PHPDBG_COMMAND(eol); +PHPDBG_COMMAND(wait); /* }}} */ /* {{{ prompt commands */ extern const phpdbg_command_t phpdbg_prompt_commands[]; /* }}} */ diff --git a/phpdbg_rinit_hook.c b/phpdbg_rinit_hook.c new file mode 100644 index 00000000000..049a782d9dc --- /dev/null +++ b/phpdbg_rinit_hook.c @@ -0,0 +1,101 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#include "phpdbg_rinit_hook.h" +#include "php_ini.h" +#include + +ZEND_DECLARE_MODULE_GLOBALS(phpdbg_webhelper); + +PHP_INI_BEGIN() + STD_PHP_INI_ENTRY("phpdbg.auth", "", PHP_INI_SYSTEM | PHP_INI_PERDIR, OnUpdateString, auth, zend_phpdbg_webhelper_globals, phpdbg_webhelper_globals) + STD_PHP_INI_ENTRY("phpdbg.path", "", PHP_INI_SYSTEM | PHP_INI_PERDIR, OnUpdateString, path, zend_phpdbg_webhelper_globals, phpdbg_webhelper_globals) +PHP_INI_END() + +static inline void php_phpdbg_webhelper_globals_ctor(zend_phpdbg_webhelper_globals *pg) /* {{{ */ +{ +} /* }}} */ + +static PHP_MINIT_FUNCTION(phpdbg_webhelper) /* {{{ */ +{ + if (!strcmp(sapi_module.name, PHPDBG_NAME)) { + return SUCCESS; + } + + ZEND_INIT_MODULE_GLOBALS(phpdbg_webhelper, php_phpdbg_webhelper_globals_ctor, NULL); + REGISTER_INI_ENTRIES(); + + return SUCCESS; +} /* }}} */ + +static PHP_RINIT_FUNCTION(phpdbg_webhelper) /* {{{ */ +{ + zval *cookies = PG(http_globals)[TRACK_VARS_COOKIE]; + zval **auth; + + if (!cookies || zend_hash_find(Z_ARRVAL_P(cookies), PHPDBG_NAME "_AUTH_COOKIE", sizeof(PHPDBG_NAME "_AUTH_COOKIE"), (void **) &auth) == FAILURE || Z_STRLEN_PP(auth) != strlen(PHPDBG_WG(auth)) || strcmp(Z_STRVAL_PP(auth), PHPDBG_WG(auth))) { + return SUCCESS; + } + +#ifndef _WIN32 + { + struct sockaddr_un sock; + int s = socket(AF_UNIX, SOCK_STREAM, 0); + int len = strlen(PHPDBG_WG(path)) + sizeof(sock.sun_family); + char buf[(1 << 8) + 1]; + int buflen; + sock.sun_family = AF_UNIX; + strcpy(sock.sun_path, PHPDBG_WG(path)); + + if (connect(s, (struct sockaddr *)&sock, len) == -1) { + zend_error(E_ERROR, "Unable to connect to UNIX domain socket at %s defined by phpdbg.path ini setting. Reason: %s", PHPDBG_WG(path), strerror(errno)); + } + + char *msg = NULL; + char msglen[5] = {0}; + phpdbg_webdata_compress(&msg, (int *)msglen TSRMLS_CC); + + send(s, msglen, 4, 0); + send(s, msg, *(int *) msglen, 0); + + while ((buflen = recv(s, buf, sizeof(buf) - 1, 0)) > 0) { + php_write(buf, buflen TSRMLS_CC); + } + + close(s); + + php_output_flush_all(TSRMLS_C); + zend_bailout(); + } +#endif + + return SUCCESS; +} /* }}} */ + +zend_module_entry phpdbg_webhelper_module_entry = { + STANDARD_MODULE_HEADER, + "phpdbg_webhelper", + NULL, + PHP_MINIT(phpdbg_webhelper), + NULL, + PHP_RINIT(phpdbg_webhelper), + NULL, + NULL, + PHPDBG_VERSION, + STANDARD_MODULE_PROPERTIES +}; diff --git a/phpdbg_rinit_hook.h b/phpdbg_rinit_hook.h new file mode 100644 index 00000000000..d28be10f8c4 --- /dev/null +++ b/phpdbg_rinit_hook.h @@ -0,0 +1,41 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHPDBG_WEBHELPER_H +#define PHPDBG_WEBHELPER_H + +#include "phpdbg_webdata_transfer.h" + +extern zend_module_entry phpdbg_webhelper_module_entry; +#define phpext_phpdbg_webhelper_ptr &phpdbg_webhelper_module_entry + +#ifdef ZTS +# define PHPDBG_WG(v) TSRMG(phpdbg_webhelper_globals_id, zend_phpdbg_webhelper_globals *, v) +#else +# define PHPDBG_WG(v) (phpdbg_webhelper_globals.v) +#endif + +/* {{{ structs */ +ZEND_BEGIN_MODULE_GLOBALS(phpdbg_webhelper) + char *auth; + char *path; +ZEND_END_MODULE_GLOBALS(phpdbg_webhelper) /* }}} */ + +#endif /* PHPDBG_WEBHELPER_H */ diff --git a/phpdbg_set.c b/phpdbg_set.c index 54269a81931..fc7e788fa03 100644 --- a/phpdbg_set.c +++ b/phpdbg_set.c @@ -27,30 +27,32 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg); -#define PHPDBG_SET_COMMAND_D(f, h, a, m, l, s) \ - PHPDBG_COMMAND_D_EXP(f, h, a, m, l, s, &phpdbg_prompt_commands[18]) +#define PHPDBG_SET_COMMAND_D(f, h, a, m, l, s, flags) \ + PHPDBG_COMMAND_D_EXP(f, h, a, m, l, s, &phpdbg_prompt_commands[18], flags) const phpdbg_command_t phpdbg_set_commands[] = { - PHPDBG_SET_COMMAND_D(prompt, "usage: set prompt []", 'p', set_prompt, NULL, "|s"), + PHPDBG_SET_COMMAND_D(prompt, "usage: set prompt []", 'p', set_prompt, NULL, "|s", 0), #ifndef _WIN32 - PHPDBG_SET_COMMAND_D(color, "usage: set color ", 'c', set_color, NULL, "ss"), - PHPDBG_SET_COMMAND_D(colors, "usage: set colors []", 'C', set_colors, NULL, "|b"), + PHPDBG_SET_COMMAND_D(color, "usage: set color ", 'c', set_color, NULL, "ss", PHPDBG_ASYNC_SAFE), + PHPDBG_SET_COMMAND_D(colors, "usage: set colors []", 'C', set_colors, NULL, "|b", PHPDBG_ASYNC_SAFE), #endif - PHPDBG_SET_COMMAND_D(oplog, "usage: set oplog []", 'O', set_oplog, NULL, "|s"), - PHPDBG_SET_COMMAND_D(break, "usage: set break id []", 'b', set_break, NULL, "l|b"), - PHPDBG_SET_COMMAND_D(breaks, "usage: set breaks []", 'B', set_breaks, NULL, "|b"), - PHPDBG_SET_COMMAND_D(quiet, "usage: set quiet []", 'q', set_quiet, NULL, "|b"), - PHPDBG_SET_COMMAND_D(stepping, "usage: set stepping []", 's', set_stepping, NULL, "|s"), - PHPDBG_SET_COMMAND_D(refcount, "usage: set refcount []", 'r', set_refcount, NULL, "|b"), + PHPDBG_SET_COMMAND_D(oplog, "usage: set oplog []", 'O', set_oplog, NULL, "|s", 0), + PHPDBG_SET_COMMAND_D(break, "usage: set break id []", 'b', set_break, NULL, "l|b", PHPDBG_ASYNC_SAFE), + PHPDBG_SET_COMMAND_D(breaks, "usage: set breaks []", 'B', set_breaks, NULL, "|b", PHPDBG_ASYNC_SAFE), + PHPDBG_SET_COMMAND_D(quiet, "usage: set quiet []", 'q', set_quiet, NULL, "|b", PHPDBG_ASYNC_SAFE), + PHPDBG_SET_COMMAND_D(stepping, "usage: set stepping []", 's', set_stepping, NULL, "|s", PHPDBG_ASYNC_SAFE), + PHPDBG_SET_COMMAND_D(refcount, "usage: set refcount []", 'r', set_refcount, NULL, "|b", PHPDBG_ASYNC_SAFE), PHPDBG_END_COMMAND }; PHPDBG_SET(prompt) /* {{{ */ { if (!param || param->type == EMPTY_PARAM) { - phpdbg_writeln("%s", phpdbg_get_prompt(TSRMLS_C)); - } else phpdbg_set_prompt(param->str TSRMLS_CC); - + phpdbg_writeln("setprompt", "str=\"%s\"", "Current prompt: %s", phpdbg_get_prompt(TSRMLS_C)); + } else { + phpdbg_set_prompt(param->str TSRMLS_CC); + } + return SUCCESS; } /* }}} */ @@ -61,21 +63,21 @@ PHPDBG_SET(break) /* {{{ */ if (param->next) { if (param->next->num) { phpdbg_enable_breakpoint(param->num TSRMLS_CC); - } else phpdbg_disable_breakpoint(param->num TSRMLS_CC); + } else { + phpdbg_disable_breakpoint(param->num TSRMLS_CC); + } } else { phpdbg_breakbase_t *brake = phpdbg_find_breakbase(param->num TSRMLS_CC); if (brake) { - phpdbg_writeln( - "%s", brake->disabled ? "off" : "on"); + phpdbg_writeln("setbreak", "id=\"%ld\" active=\"%s\"", "Breakpoint #%ld %s", param->num, brake->disabled ? "off" : "on"); } else { - phpdbg_error("Failed to find breakpoint #%ld", param->num); + phpdbg_error("setbreak", "type=\"nobreak\" id=\"%ld\"", "Failed to find breakpoint #%ld", param->num); } } } break; default: - phpdbg_error( - "set break used incorrectly: set break [id] "); + phpdbg_error("setbreak", "type=\"wrongargs\"", "set break used incorrectly: set break [id] "); } return SUCCESS; @@ -84,18 +86,18 @@ PHPDBG_SET(break) /* {{{ */ PHPDBG_SET(breaks) /* {{{ */ { if (!param || param->type == EMPTY_PARAM) { - phpdbg_writeln("%s", - PHPDBG_G(flags) & PHPDBG_IS_BP_ENABLED ? "on" : "off"); - } else switch (param->type) { + phpdbg_writeln("setbreaks", "active=\"%s\"", "Breakpoints %s",PHPDBG_G(flags) & PHPDBG_IS_BP_ENABLED ? "on" : "off"); + } else switch (param->type) { case NUMERIC_PARAM: { if (param->num) { phpdbg_enable_breakpoints(TSRMLS_C); - } else phpdbg_disable_breakpoints(TSRMLS_C); + } else { + phpdbg_disable_breakpoints(TSRMLS_C); + } } break; default: - phpdbg_error( - "set break used incorrectly: set break [id] "); + phpdbg_error("setbreaks", "type=\"wrongargs\"", "set breaks used incorrectly: set breaks "); } return SUCCESS; @@ -104,41 +106,35 @@ PHPDBG_SET(breaks) /* {{{ */ #ifndef _WIN32 PHPDBG_SET(color) /* {{{ */ { - const phpdbg_color_t *color = phpdbg_get_color( - param->next->str, param->next->len TSRMLS_CC); - + const phpdbg_color_t *color = phpdbg_get_color(param->next->str, param->next->len TSRMLS_CC); + if (!color) { - phpdbg_error( - "Failed to find the requested color (%s)", param->next->str); + phpdbg_error("setcolor", "type=\"nocolor\"", "Failed to find the requested color (%s)", param->next->str); return SUCCESS; } - + switch (phpdbg_get_element(param->str, param->len TSRMLS_CC)) { case PHPDBG_COLOR_PROMPT: - phpdbg_notice( - "setting prompt color to %s (%s)", color->name, color->code); + phpdbg_notice("setcolor", "type=\"prompt\" color=\"%s\" code=\"%s\"", "setting prompt color to %s (%s)", color->name, color->code); if (PHPDBG_G(prompt)[1]) { free(PHPDBG_G(prompt)[1]); PHPDBG_G(prompt)[1]=NULL; } phpdbg_set_color(PHPDBG_COLOR_PROMPT, color TSRMLS_CC); break; - + case PHPDBG_COLOR_ERROR: - phpdbg_notice( - "setting error color to %s (%s)", color->name, color->code); + phpdbg_notice("setcolor", "type=\"error\" color=\"%s\" code=\"%s\"", "setting error color to %s (%s)", color->name, color->code); phpdbg_set_color(PHPDBG_COLOR_ERROR, color TSRMLS_CC); break; - + case PHPDBG_COLOR_NOTICE: - phpdbg_notice( - "setting notice color to %s (%s)", color->name, color->code); + phpdbg_notice("setcolor", "type=\"notice\" color=\"%s\" code=\"%s\"", "setting notice color to %s (%s)", color->name, color->code); phpdbg_set_color(PHPDBG_COLOR_NOTICE, color TSRMLS_CC); break; - + default: - phpdbg_error( - "Failed to find the requested element (%s)", param->str); + phpdbg_error("setcolor", "type=\"invalidtype\"", "Failed to find the requested element (%s)", param->str); } return SUCCESS; @@ -147,7 +143,7 @@ PHPDBG_SET(color) /* {{{ */ PHPDBG_SET(colors) /* {{{ */ { if (!param || param->type == EMPTY_PARAM) { - phpdbg_writeln("%s", PHPDBG_G(flags) & PHPDBG_IS_COLOURED ? "on" : "off"); + phpdbg_writeln("setcolors", "active=\"%s\"", "Colors %s", PHPDBG_G(flags) & PHPDBG_IS_COLOURED ? "on" : "off"); } else switch (param->type) { case NUMERIC_PARAM: { if (param->num) { @@ -156,10 +152,9 @@ PHPDBG_SET(colors) /* {{{ */ PHPDBG_G(flags) &= ~PHPDBG_IS_COLOURED; } } break; - + default: - phpdbg_error( - "set colors used incorrectly: set colors "); + phpdbg_error("setcolors", "type=\"wrongargs\"", "set colors used incorrectly: set colors "); } return SUCCESS; @@ -169,7 +164,7 @@ PHPDBG_SET(colors) /* {{{ */ PHPDBG_SET(oplog) /* {{{ */ { if (!param || param->type == EMPTY_PARAM) { - phpdbg_notice("Oplog %s", PHPDBG_G(oplog) ? "enabled" : "disabled"); + phpdbg_notice("setoplog", "active=\"%s\"", "Oplog %s", PHPDBG_G(oplog) ? "on" : "off"); } else switch (param->type) { case STR_PARAM: { /* open oplog */ @@ -177,14 +172,15 @@ PHPDBG_SET(oplog) /* {{{ */ PHPDBG_G(oplog) = fopen(param->str, "w+"); if (!PHPDBG_G(oplog)) { - phpdbg_error("Failed to open %s for oplog", param->str); + phpdbg_error("setoplog", "type=\"openfailure\" file=\"%s\"", "Failed to open %s for oplog", param->str); PHPDBG_G(oplog) = old; } else { if (old) { - phpdbg_notice("Closing previously open oplog"); + phpdbg_notice("setoplog", "type=\"closingold\"", "Closing previously open oplog"); fclose(old); } - phpdbg_notice("Successfully opened oplog %s", param->str); + + phpdbg_notice("setoplog", "file=\"%s\"", "Successfully opened oplog %s", param->str); } } break; @@ -197,8 +193,7 @@ PHPDBG_SET(oplog) /* {{{ */ PHPDBG_SET(quiet) /* {{{ */ { if (!param || param->type == EMPTY_PARAM) { - phpdbg_writeln("Quietness %s", - PHPDBG_G(flags) & PHPDBG_IS_QUIET ? "on" : "off"); + phpdbg_writeln("setquiet", "active=\"%s\"", "Quietness %s", PHPDBG_G(flags) & PHPDBG_IS_QUIET ? "on" : "off"); } else switch (param->type) { case NUMERIC_PARAM: { if (param->num) { @@ -217,18 +212,15 @@ PHPDBG_SET(quiet) /* {{{ */ PHPDBG_SET(stepping) /* {{{ */ { if (!param || param->type == EMPTY_PARAM) { - phpdbg_writeln("Stepping %s", - PHPDBG_G(flags) & PHPDBG_STEP_OPCODE ? "opcode" : "line"); + phpdbg_writeln("setstepping", "type=\"%s\"", "Stepping %s", PHPDBG_G(flags) & PHPDBG_STEP_OPCODE ? "opcode" : "line"); } else switch (param->type) { - case STR_PARAM: { - if ((param->len == sizeof("opcode")-1) && - (memcmp(param->str, "opcode", sizeof("opcode")) == SUCCESS)) { + case STR_PARAM: { + if ((param->len == sizeof("opcode") - 1) && memcmp(param->str, "opcode", sizeof("opcode")) == SUCCESS) { PHPDBG_G(flags) |= PHPDBG_STEP_OPCODE; - } else if ((param->len == sizeof("line")-1) && - (memcmp(param->str, "line", sizeof("line")) == SUCCESS)) { + } else if ((param->len == sizeof("line")-1) && memcmp(param->str, "line", sizeof("line")) == SUCCESS) { PHPDBG_G(flags) &= ~PHPDBG_STEP_OPCODE; } else { - phpdbg_error("usage set stepping []"); + phpdbg_error("setstepping", "type=\"wrongargs\"", "usage set stepping []"); } } break; @@ -241,7 +233,7 @@ PHPDBG_SET(stepping) /* {{{ */ PHPDBG_SET(refcount) /* {{{ */ { if (!param || param->type == EMPTY_PARAM) { - phpdbg_writeln("Refcount %s", PHPDBG_G(flags) & PHPDBG_IS_QUIET ? "on" : "off"); + phpdbg_writeln("setrefcount", "active=\"%s\"", "Showing refcounts %s", PHPDBG_G(flags) & PHPDBG_IS_QUIET ? "on" : "off"); } else switch (param->type) { case NUMERIC_PARAM: { if (param->num) { diff --git a/phpdbg_sigio_win32.c b/phpdbg_sigio_win32.c new file mode 100644 index 00000000000..24e9ac0e0aa --- /dev/null +++ b/phpdbg_sigio_win32.c @@ -0,0 +1,120 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 7-4 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Anatol Belski | + +----------------------------------------------------------------------+ +*/ + + +#include + +#include "phpdbg.h" +#include "phpdbg_sigio_win32.h" + + +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); + + +VOID +SigIoWatcherThread(VOID *p) +{ + zend_uchar sig; + struct win32_sigio_watcher_data *swd = (struct win32_sigio_watcher_data *)p; +#ifdef ZTS + void ***tsrm_ls = swd->tsrm_ls; +top: + (void)phpdbg_consume_bytes(swd->fd, &sig, 1, -1, tsrm_ls); +#else +top: + (void)phpdbg_consume_bytes(swd->fd, &sig, 1, -1); +#endif + + + if (3 == sig) { + printf("signaled, got %d", sig); + /* XXX completely not sure it is done right here */ + if (swd->flags & PHPDBG_IS_INTERACTIVE) { + if (raise(sig)) { + /* just out*/ + exit(0); + } + } + if (swd->flags & PHPDBG_IS_SIGNALED) { + phpdbg_set_sigsafe_mem(&sig TSRMLS_CC); + zend_try { + phpdbg_force_interruption(TSRMLS_C); + } zend_end_try(); + phpdbg_clear_sigsafe_mem(TSRMLS_C); + } + /* XXX set signaled flag to the caller thread, question is - whether it's needed */ + ExitThread(sig); + } else { + goto top; + } +} + + +/* Start this only for the time of the run or eval command, +for so long that the main thread is busy serving some debug +session. */ +void +sigio_watcher_start(void) +{ + TSRMLS_FETCH(); + + PHPDBG_G(swd).fd = PHPDBG_G(io)[PHPDBG_STDIN].fd; + PHPDBG_G(swd).running = 1; + PHPDBG_G(swd).flags = PHPDBG_G(flags); +#ifdef ZTS + PHPDBG_G(swd).tsrm_ls = tsrm_ls; +#endif + + PHPDBG_G(sigio_watcher_thread) = CreateThread( + NULL, + 0, + (LPTHREAD_START_ROUTINE)SigIoWatcherThread, + &PHPDBG_G(swd), + 0, + NULL); +} + +void +sigio_watcher_stop(void) +{ + DWORD waited; + TSRMLS_FETCH(); + + if (INVALID_HANDLE_VALUE == PHPDBG_G(sigio_watcher_thread)) { + /* it probably did bail out already */ + return; + } + + waited = WaitForSingleObject(PHPDBG_G(sigio_watcher_thread), 300); + + if (WAIT_OBJECT_0 != waited) { + if (!CancelSynchronousIo(PHPDBG_G(sigio_watcher_thread))) { + /* error out */ + } + + if (!TerminateThread(PHPDBG_G(sigio_watcher_thread), 0)) { + /* error out */ + } + } + + PHPDBG_G(swd).fd = -1; + PHPDBG_G(swd).running = 0; + PHPDBG_G(swd).flags = 0; + PHPDBG_G(sigio_watcher_thread) = INVALID_HANDLE_VALUE; +} + diff --git a/phpdbg_sigio_win32.h b/phpdbg_sigio_win32.h new file mode 100644 index 00000000000..796b477f936 --- /dev/null +++ b/phpdbg_sigio_win32.h @@ -0,0 +1,42 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 7-4 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Anatol Belski | + +----------------------------------------------------------------------+ +*/ + + +#ifndef PHPDBG_SIGIO_WIN32_H +#define PHPDBG_SIGIO_WIN32_H + +#include "phpdbg.h" +#include "phpdbg_prompt.h" +#include "phpdbg_io.h" + +struct win32_sigio_watcher_data { + zend_ulong flags; +#ifdef ZTS + void ***tsrm_ls; +#endif + int fd; + zend_uchar running; +}; + +void +sigio_watcher_start(void); + +void +sigio_watcher_stop(void); + +#endif /* PHPDBG_SIGIO_WIN32_H */ diff --git a/phpdbg_sigsafe.c b/phpdbg_sigsafe.c new file mode 100644 index 00000000000..7238ad102fb --- /dev/null +++ b/phpdbg_sigsafe.c @@ -0,0 +1,111 @@ +#include "phpdbg_sigsafe.h" +#include "phpdbg.h" + +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); + +static inline void zend_mm_init(zend_mm_heap *heap) { + zend_mm_free_block *p; + int i; + + heap->free_bitmap = 0; + heap->large_free_bitmap = 0; +#if ZEND_MM_CACHE + heap->cached = 0; + memset(heap->cache, 0, sizeof(heap->cache)); +#endif +#if ZEND_MM_CACHE_STAT + for (i = 0; i < ZEND_MM_NUM_BUCKETS; i++) { + heap->cache_stat[i].count = 0; + } +#endif + p = ZEND_MM_SMALL_FREE_BUCKET(heap, 0); + for (i = 0; i < ZEND_MM_NUM_BUCKETS; i++) { + p->next_free_block = p; + p->prev_free_block = p; + p = (zend_mm_free_block *)((char *)p + sizeof(zend_mm_free_block *) * 2); + heap->large_free_buckets[i] = NULL; + } + heap->rest_buckets[0] = heap->rest_buckets[1] = ZEND_MM_REST_BUCKET(heap); + heap->rest_count = 0; +} + +static zend_mm_storage* zend_mm_mem_init(void *params) { + TSRMLS_FETCH(); + + return &PHPDBG_G(sigsafe_mem).storage; +} + +static void zend_mm_mem_dummy(zend_mm_storage *storage) { +} + +#define STR(x) #x +#define EXP_STR(x) STR(x) + +static zend_mm_segment* zend_mm_mem_alloc(zend_mm_storage *storage, size_t size) { + TSRMLS_FETCH(); + + if (EXPECTED(size == PHPDBG_SIGSAFE_MEM_SIZE && !PHPDBG_G(sigsafe_mem).allocated)) { + PHPDBG_G(sigsafe_mem).allocated = 1; + return (zend_mm_segment *) PHPDBG_G(sigsafe_mem).mem; + } + + write(PHPDBG_G(io)[PHPDBG_STDERR].fd, ZEND_STRL("Tried to allocate more than " EXP_STR(PHPDBG_SIGSAFE_MEM_SIZE) " bytes from stack memory in signal handler ... bailing out of signal handler\n")); + + if (*EG(bailout)) { + LONGJMP(*EG(bailout), FAILURE); + } + + write(PHPDBG_G(io)[PHPDBG_STDERR].fd, ZEND_STRL("Bailed out without a bailout address in signal handler!\n")); + + return NULL; +} + +static zend_mm_segment* zend_mm_mem_realloc(zend_mm_storage *storage, zend_mm_segment *ptr, size_t size) { + return zend_mm_mem_alloc(storage, size); +} + +static void zend_mm_mem_free(zend_mm_storage *storage, zend_mm_segment *ptr) { +} + +static const zend_mm_mem_handlers phpdbg_handlers_sigsafe_mem = { "stack", zend_mm_mem_init, zend_mm_mem_dummy, zend_mm_mem_dummy, zend_mm_mem_alloc, zend_mm_mem_realloc, zend_mm_mem_free }; + +void phpdbg_set_sigsafe_mem(char *buffer TSRMLS_DC) { + phpdbg_signal_safe_mem *mem = &PHPDBG_G(sigsafe_mem); + mem->old_heap = zend_mm_set_heap(&mem->heap TSRMLS_CC); + mem->mem = buffer; + mem->allocated = 0; + + mem->storage.handlers = &phpdbg_handlers_sigsafe_mem; + mem->heap.storage = &mem->storage; + mem->heap.block_size = PHPDBG_SIGSAFE_MEM_SIZE; + mem->heap.compact_size = 0; + mem->heap.segments_list = NULL; + zend_mm_init(&mem->heap); +#if ZEND_MM_CACHE_STAT + memset(mem->heap.cache_stat, 0, sizeof(mem->heap.cache_stat)); +#endif + mem->heap.use_zend_alloc = 1; + mem->heap.real_size = 0; + mem->heap.overflow = 0; + mem->heap.real_peak = 0; + mem->heap.limit = PHPDBG_SIGSAFE_MEM_SIZE; + mem->heap.size = 0; + mem->heap.peak = 0; + mem->heap.internal = 0; + mem->heap.reserve = NULL; + mem->heap.reserve_size = 0; +} + +zend_mm_heap *phpdbg_original_heap_sigsafe_mem(TSRMLS_D) { + return PHPDBG_G(sigsafe_mem).old_heap; +} + +void phpdbg_clear_sigsafe_mem(TSRMLS_D) { + zend_mm_set_heap(phpdbg_original_heap_sigsafe_mem(TSRMLS_C) TSRMLS_CC); + PHPDBG_G(sigsafe_mem).mem = NULL; +} + +zend_bool phpdbg_active_sigsafe_mem(TSRMLS_D) { + return !!PHPDBG_G(sigsafe_mem).mem; +} + diff --git a/phpdbg_sigsafe.h b/phpdbg_sigsafe.h new file mode 100644 index 00000000000..6ed74f53db9 --- /dev/null +++ b/phpdbg_sigsafe.h @@ -0,0 +1,25 @@ +#ifndef PHPDBG_SIGSAFE_H +#define PHPDBG_SIGSAFE_H + +#include "zend_mm_structs.h" + +#define PHPDBG_SIGSAFE_MEM_SIZE (1 << 20) + +typedef struct { + char *mem; + zend_bool allocated; + zend_mm_heap heap; + zend_mm_heap *old_heap; + zend_mm_storage storage; +} phpdbg_signal_safe_mem; + +#include "phpdbg.h" + +zend_bool phpdbg_active_sigsafe_mem(TSRMLS_D); + +void phpdbg_set_sigsafe_mem(char *mem TSRMLS_DC); +void phpdbg_clear_sigsafe_mem(TSRMLS_D); + +zend_mm_heap *phpdbg_original_heap_sigsafe_mem(TSRMLS_D); + +#endif diff --git a/phpdbg_utils.c b/phpdbg_utils.c index 3ce2fade17d..85b6eeb3b52 100644 --- a/phpdbg_utils.c +++ b/phpdbg_utils.c @@ -18,19 +18,14 @@ +----------------------------------------------------------------------+ */ -#include -#include -#include #include "zend.h" + #include "php.h" -#include "spprintf.h" #include "phpdbg.h" #include "phpdbg_opcode.h" #include "phpdbg_utils.h" -#ifdef _WIN32 -# include "win32/time.h" -#elif defined(HAVE_SYS_IOCTL_H) +#if defined(HAVE_SYS_IOCTL_H) # include "sys/ioctl.h" # ifndef GWINSZ_IN_SYS_IOCTL # include @@ -128,12 +123,12 @@ PHPDBG_API int phpdbg_is_class_method(const char *str, size_t len, char **class, } if (class != NULL) { - + if (str[0] == '\\') { str++; len--; } - + *class = estrndup(str, sep - str); (*class)[sep - str] = 0; } @@ -224,103 +219,6 @@ PHPDBG_API char *phpdbg_trim(const char *str, size_t len, size_t *new_len) /* {{ } /* }}} */ -PHPDBG_API int phpdbg_print(int type TSRMLS_DC, FILE *fp, const char *format, ...) /* {{{ */ -{ - int rc = 0; - char *buffer = NULL; - va_list args; - - if (format != NULL && strlen(format) > 0L) { - va_start(args, format); - vspprintf(&buffer, 0, format, args); - va_end(args); - } - - /* TODO(anyone) colours */ - - switch (type) { - case P_ERROR: - if (PHPDBG_G(flags) & PHPDBG_IS_COLOURED) { - rc = fprintf(fp, - "\033[%sm[%s]\033[0m\n", - PHPDBG_G(colors)[PHPDBG_COLOR_ERROR]->code, buffer); - } else { - rc = fprintf(fp, "[%s]\n", buffer); - } - break; - - case P_NOTICE: - if (PHPDBG_G(flags) & PHPDBG_IS_COLOURED) { - rc = fprintf(fp, - "\033[%sm[%s]\033[0m\n", - PHPDBG_G(colors)[PHPDBG_COLOR_NOTICE]->code, buffer); - } else { - rc = fprintf(fp, "[%s]\n", buffer); - } - break; - - case P_WRITELN: { - if (buffer) { - rc = fprintf(fp, "%s\n", buffer); - } else { - rc = fprintf(fp, "\n"); - } - } break; - - case P_WRITE: - if (buffer) { - rc = fprintf(fp, "%s", buffer); - } - break; - - /* no formatting on logging output */ - case P_LOG: - if (buffer) { - struct timeval tp; - if (gettimeofday(&tp, NULL) == SUCCESS) { - rc = fprintf(fp, "[%ld %.8F]: %s\n", tp.tv_sec, tp.tv_usec / 1000000.00, buffer); - } else { - rc = FAILURE; - } - } - break; - } - - if (buffer) { - efree(buffer); - } - - return rc; -} /* }}} */ - -PHPDBG_API int phpdbg_rlog(FILE *fp, const char *fmt, ...) { /* {{{ */ - int rc = 0; - - va_list args; - struct timeval tp; - - va_start(args, fmt); - if (gettimeofday(&tp, NULL) == SUCCESS) { - char friendly[100]; - char *format = NULL, *buffer = NULL; - const time_t tt = tp.tv_sec; - - strftime(friendly, 100, "%a %b %d %T.%%04d %Y", localtime(&tt)); - asprintf( - &buffer, friendly, tp.tv_usec/1000); - asprintf( - &format, "[%s]: %s\n", buffer, fmt); - rc = vfprintf( - fp, format, args); - - free(format); - free(buffer); - } - va_end(args); - - return rc; -} /* }}} */ - PHPDBG_API const phpdbg_color_t *phpdbg_get_color(const char *name, size_t name_length TSRMLS_DC) /* {{{ */ { const phpdbg_color_t *color = colors; @@ -328,15 +226,13 @@ PHPDBG_API const phpdbg_color_t *phpdbg_get_color(const char *name, size_t name_ while (color && color->name) { if (name_length == color->name_length && memcmp(name, color->name, name_length) == SUCCESS) { - phpdbg_debug( - "phpdbg_get_color(%s, %lu): %s", name, name_length, color->code); + phpdbg_debug("phpdbg_get_color(%s, %lu): %s", name, name_length, color->code); return color; } ++color; } - phpdbg_debug( - "phpdbg_get_color(%s, %lu): failed", name, name_length); + phpdbg_debug("phpdbg_get_color(%s, %lu): failed", name, name_length); return NULL; } /* }}} */ @@ -362,7 +258,7 @@ PHPDBG_API const phpdbg_color_t* phpdbg_get_colors(TSRMLS_D) /* {{{ */ PHPDBG_API int phpdbg_get_element(const char *name, size_t len TSRMLS_DC) { const phpdbg_element_t *element = elements; - + while (element && element->name) { if (len == element->name_length) { if (strncasecmp(name, element->name, len) == SUCCESS) { @@ -371,7 +267,7 @@ PHPDBG_API int phpdbg_get_element(const char *name, size_t len TSRMLS_DC) { } element++; } - + return PHPDBG_COLOR_INVALID; } @@ -420,7 +316,7 @@ PHPDBG_API const char *phpdbg_get_prompt(TSRMLS_D) /* {{{ */ int phpdbg_rebuild_symtable(TSRMLS_D) { if (!EG(active_op_array)) { - phpdbg_error("No active op array!"); + phpdbg_error("inactive", "type=\"op_array\"", "No active op array!"); return FAILURE; } @@ -428,7 +324,7 @@ int phpdbg_rebuild_symtable(TSRMLS_D) { zend_rebuild_symbol_table(TSRMLS_C); if (!EG(active_symbol_table)) { - phpdbg_error("No active symbol table!"); + phpdbg_error("inactive", "type=\"symbol_table\"", "No active symbol table!"); return FAILURE; } } @@ -438,13 +334,13 @@ int phpdbg_rebuild_symtable(TSRMLS_D) { PHPDBG_API int phpdbg_get_terminal_width(TSRMLS_D) /* {{{ */ { - int columns; + int columns; #ifdef _WIN32 CONSOLE_SCREEN_BUFFER_INFO csbi; GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); columns = csbi.srWindow.Right - csbi.srWindow.Left + 1; -#elif defined(HAVE_SYS_IOCTL_H) && defined (TIOCGWINSZ) +#elif defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ) struct winsize w; columns = ioctl(fileno(stdout), TIOCGWINSZ, &w) == 0 ? w.ws_col : 80; @@ -453,3 +349,294 @@ PHPDBG_API int phpdbg_get_terminal_width(TSRMLS_D) /* {{{ */ #endif return columns; } /* }}} */ + +PHPDBG_API void phpdbg_set_async_io(int fd) { +#ifndef _WIN32 + int flags; + fcntl(STDIN_FILENO, F_SETOWN, getpid()); + flags = fcntl(STDIN_FILENO, F_GETFL); + fcntl(STDIN_FILENO, F_SETFL, flags | FASYNC); +#endif +} + +int phpdbg_safe_class_lookup(const char *name, int name_length, zend_class_entry ***ce TSRMLS_DC) { + if (PHPDBG_G(flags) & PHPDBG_IN_SIGNAL_HANDLER) { + char *lc_name, *lc_free; + int lc_length, ret = FAILURE; + + if (name == NULL || !name_length) { + return FAILURE; + } + + lc_free = lc_name = emalloc(name_length + 1); + zend_str_tolower_copy(lc_name, name, name_length); + lc_length = name_length + 1; + + if (lc_name[0] == '\\') { + lc_name += 1; + lc_length -= 1; + } + + phpdbg_try_access { + ret = zend_hash_find(EG(class_table), lc_name, lc_length, (void **) &ce); + } phpdbg_catch_access { + phpdbg_error("signalsegv", "class=\"%.*s\"", "Could not fetch class %.*s, invalid data source", name_length, name); + } phpdbg_end_try_access(); + + efree(lc_free); + return ret; + } else { + return zend_lookup_class(name, name_length, ce TSRMLS_CC); + } +} + +char *phpdbg_get_property_key(char *key) { + if (*key != 0) { + return key; + } + return strchr(key + 1, 0) + 1; +} + +static int phpdbg_parse_variable_arg_wrapper(char *name, size_t len, char *keyname, size_t keylen, HashTable *parent, zval **zv, phpdbg_parse_var_func callback TSRMLS_DC) { + return callback(name, len, keyname, keylen, parent, zv TSRMLS_CC); +} + +PHPDBG_API int phpdbg_parse_variable(char *input, size_t len, HashTable *parent, size_t i, phpdbg_parse_var_func callback, zend_bool silent TSRMLS_DC) { + return phpdbg_parse_variable_with_arg(input, len, parent, i, (phpdbg_parse_var_with_arg_func) phpdbg_parse_variable_arg_wrapper, silent, callback TSRMLS_CC); +} + +PHPDBG_API int phpdbg_parse_variable_with_arg(char *input, size_t len, HashTable *parent, size_t i, phpdbg_parse_var_with_arg_func callback, zend_bool silent, void *arg TSRMLS_DC) { + int ret = FAILURE; + zend_bool new_index = 1; + char *last_index; + size_t index_len = 0; + zval **zv; + + if (len < 2 || *input != '$') { + goto error; + } + + while (i++ < len) { + if (i == len) { + new_index = 1; + } else { + switch (input[i]) { + case '[': + new_index = 1; + break; + case ']': + break; + case '>': + if (last_index[index_len - 1] == '-') { + new_index = 1; + index_len--; + } + break; + + default: + if (new_index) { + last_index = input + i; + new_index = 0; + } + if (input[i - 1] == ']') { + goto error; + } + index_len++; + } + } + + if (new_index && index_len == 0) { + HashPosition position; + for (zend_hash_internal_pointer_reset_ex(parent, &position); + zend_hash_get_current_data_ex(parent, (void **)&zv, &position) == SUCCESS; + zend_hash_move_forward_ex(parent, &position)) { + if (i == len || (i == len - 1 && input[len - 1] == ']')) { + zval *key = emalloc(sizeof(zval)); + size_t namelen; + char *name; + char *keyname = estrndup(last_index, index_len); + zend_hash_get_current_key_zval_ex(parent, key, &position); + convert_to_string(key); + name = emalloc(i + Z_STRLEN_P(key) + 2); + namelen = sprintf(name, "%.*s%s%s", (int)i, input, phpdbg_get_property_key(Z_STRVAL_P(key)), input[len - 1] == ']'?"]":""); + efree(key); + + ret = callback(name, namelen, keyname, index_len, parent, zv, arg TSRMLS_CC) == SUCCESS || ret == SUCCESS?SUCCESS:FAILURE; + } else if (Z_TYPE_PP(zv) == IS_OBJECT) { + phpdbg_parse_variable_with_arg(input, len, Z_OBJPROP_PP(zv), i, callback, silent, arg TSRMLS_CC); + } else if (Z_TYPE_PP(zv) == IS_ARRAY) { + phpdbg_parse_variable_with_arg(input, len, Z_ARRVAL_PP(zv), i, callback, silent, arg TSRMLS_CC); + } else { + /* Ignore silently */ + } + } + return ret; + } else if (new_index) { + char last_chr = last_index[index_len]; + last_index[index_len] = 0; + if (zend_symtable_find(parent, last_index, index_len + 1, (void **)&zv) == FAILURE) { + if (!silent) { + phpdbg_error("variable", "type=\"undefined\" variable=\"%.*s\"", "%.*s is undefined", (int) i, input); + } + return FAILURE; + } + last_index[index_len] = last_chr; + if (i == len) { + char *name = estrndup(input, len); + char *keyname = estrndup(last_index, index_len); + + ret = callback(name, len, keyname, index_len, parent, zv, arg TSRMLS_CC) == SUCCESS || ret == SUCCESS?SUCCESS:FAILURE; + } else if (Z_TYPE_PP(zv) == IS_OBJECT) { + parent = Z_OBJPROP_PP(zv); + } else if (Z_TYPE_PP(zv) == IS_ARRAY) { + parent = Z_ARRVAL_PP(zv); + } else { + phpdbg_error("variable", "type=\"notiterable\" variable=\"%.*s\"", "%.*s is nor an array nor an object", (int) i, input); + return FAILURE; + } + index_len = 0; + } + } + + return ret; + error: + phpdbg_error("variable", "type=\"invalidinput\"", "Malformed input"); + return FAILURE; +} + +static int phpdbg_xml_array_element_dump(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) { + phpdbg_xml("nKeyLength == 0) { /* numeric key */ + phpdbg_xml(" name=\"%ld\"", hash_key->h); + } else { /* string key */ + phpdbg_xml(" name=\"%.*s\"", hash_key->nKeyLength - 1, hash_key->arKey); + } + } phpdbg_catch_access { + phpdbg_xml(" severity=\"error\" >"); + return 0; + } phpdbg_end_try_access(); + + phpdbg_xml(">"); + + phpdbg_xml_var_dump(zv TSRMLS_CC); + + phpdbg_xml(""); + + return 0; +} + +static int phpdbg_xml_object_property_dump(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) { + phpdbg_xml("nKeyLength == 0) { /* numeric key */ + phpdbg_xml(" name=\"%ld\"", hash_key->h); + } else { /* string key */ + const char *prop_name, *class_name; + int unmangle = zend_unmangle_property_name(hash_key->arKey, hash_key->nKeyLength - 1, &class_name, &prop_name); + + if (class_name && unmangle == SUCCESS) { + phpdbg_xml(" name=\"%s\"", prop_name); + if (class_name[0] == '*') { + phpdbg_xml(" protection=\"protected\""); + } else { + phpdbg_xml(" class=\"%s\" protection=\"private\"", class_name); + } + } else { + phpdbg_xml(" name=\"%.*s\" protection=\"public\"", hash_key->nKeyLength - 1, hash_key->arKey); + } + } + } phpdbg_catch_access { + phpdbg_xml(" severity=\"error\" >"); + return 0; + } phpdbg_end_try_access(); + + phpdbg_xml(">"); + + phpdbg_xml_var_dump(zv TSRMLS_CC); + + phpdbg_xml(""); + + return 0; +} + +#define COMMON (Z_ISREF_PP(zv) ? "&" : "") + +PHPDBG_API void phpdbg_xml_var_dump(zval **zv TSRMLS_DC) { + HashTable *myht; + const char *class_name; + zend_uint class_name_len; + int (*element_dump_func)(zval** TSRMLS_DC, int, va_list, zend_hash_key*); + int is_temp; + + phpdbg_try_access { + switch (Z_TYPE_PP(zv)) { + case IS_BOOL: + phpdbg_xml("", COMMON, Z_LVAL_PP(zv) ? "true" : "false"); + break; + case IS_NULL: + phpdbg_xml("", COMMON); + break; + case IS_LONG: + phpdbg_xml("", COMMON, Z_LVAL_PP(zv)); + break; + case IS_DOUBLE: + phpdbg_xml("", COMMON, (int) EG(precision), Z_DVAL_PP(zv)); + break; + case IS_STRING: + phpdbg_xml("", COMMON, Z_STRLEN_PP(zv), Z_STRLEN_PP(zv), Z_STRVAL_PP(zv)); + break; + case IS_ARRAY: + myht = Z_ARRVAL_PP(zv); + if (++myht->nApplyCount > 1) { + phpdbg_xml(""); + --myht->nApplyCount; + break; + } + phpdbg_xml("", COMMON, zend_hash_num_elements(myht)); + element_dump_func = phpdbg_xml_array_element_dump; + is_temp = 0; + goto head_done; + case IS_OBJECT: + myht = Z_OBJDEBUG_PP(zv, is_temp); + if (myht && ++myht->nApplyCount > 1) { + phpdbg_xml(""); + --myht->nApplyCount; + break; + } + + if (Z_OBJ_HANDLER(**zv, get_class_name)) { + Z_OBJ_HANDLER(**zv, get_class_name)(*zv, &class_name, &class_name_len, 0 TSRMLS_CC); + phpdbg_xml("", COMMON, class_name, Z_OBJ_HANDLE_PP(zv), myht ? zend_hash_num_elements(myht) : 0); + efree((char*)class_name); + } else { + phpdbg_xml("", COMMON, Z_OBJ_HANDLE_PP(zv), myht ? zend_hash_num_elements(myht) : 0); + } + element_dump_func = phpdbg_xml_object_property_dump; +head_done: + if (myht) { + zend_hash_apply_with_arguments(myht TSRMLS_CC, (apply_func_args_t) element_dump_func, 0); + --myht->nApplyCount; + if (is_temp) { + zend_hash_destroy(myht); + efree(myht); + } + } + if (Z_TYPE_PP(zv) == IS_ARRAY) { + phpdbg_xml(""); + } else { + phpdbg_xml(""); + } + break; + case IS_RESOURCE: { + const char *type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(zv) TSRMLS_CC); + phpdbg_xml("", COMMON, Z_LVAL_PP(zv), type_name ? type_name : "unknown"); + break; + } + default: + break; + } + } phpdbg_end_try_access(); +} diff --git a/phpdbg_utils.h b/phpdbg_utils.h index 56bacfc4596..d657dc79fd9 100644 --- a/phpdbg_utils.h +++ b/phpdbg_utils.h @@ -33,52 +33,6 @@ PHPDBG_API char *phpdbg_resolve_path(const char* TSRMLS_DC); PHPDBG_API char *phpdbg_trim(const char*, size_t, size_t*); PHPDBG_API const zend_function *phpdbg_get_function(const char*, const char* TSRMLS_DC); -/** - * Error/notice/formatting helpers - */ -enum { - P_ERROR = 1, - P_NOTICE, - P_WRITELN, - P_WRITE, - P_LOG -}; - -#ifdef ZTS -PHPDBG_API int phpdbg_print(int TSRMLS_DC, FILE*, const char*, ...) PHP_ATTRIBUTE_FORMAT(printf, 4, 5); -#else -PHPDBG_API int phpdbg_print(int TSRMLS_DC, FILE*, const char*, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4); -#endif - -PHPDBG_API int phpdbg_rlog(FILE *stream, const char *fmt, ...); - -#define phpdbg_error(fmt, ...) phpdbg_print(P_ERROR TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT], fmt, ##__VA_ARGS__) -#define phpdbg_notice(fmt, ...) phpdbg_print(P_NOTICE TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT], fmt, ##__VA_ARGS__) -#define phpdbg_writeln(fmt, ...) phpdbg_print(P_WRITELN TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT], fmt, ##__VA_ARGS__) -#define phpdbg_write(fmt, ...) phpdbg_print(P_WRITE TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT], fmt, ##__VA_ARGS__) -#define phpdbg_log(fmt, ...) phpdbg_print(P_LOG TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT], fmt, ##__VA_ARGS__) - -#define phpdbg_error_ex(out, fmt, ...) phpdbg_print(P_ERROR TSRMLS_CC, out, fmt, ##__VA_ARGS__) -#define phpdbg_notice_ex(out, fmt, ...) phpdbg_print(P_NOTICE TSRMLS_CC, out, fmt, ##__VA_ARGS__) -#define phpdbg_writeln_ex(out, fmt, ...) phpdbg_print(P_WRITELN TSRMLS_CC, out, fmt, ##__VA_ARGS__) -#define phpdbg_write_ex(out, fmt, ...) phpdbg_print(P_WRITE TSRMLS_CC, out, fmt, ##__VA_ARGS__) -#define phpdbg_log_ex(out, fmt, ...) phpdbg_print(P_LOG TSRMLS_CC, out, fmt, ##__VA_ARGS__) - -#if PHPDBG_DEBUG -# define phpdbg_debug(fmt, ...) phpdbg_print(P_LOG TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDERR], fmt, ##__VA_ARGS__) -#else -# define phpdbg_debug(fmt, ...) -#endif - -/* {{{ For writing blank lines */ -#define EMPTY NULL /* }}} */ - -/* {{{ For prompt lines */ -#define PROMPT "phpdbg>" /* }}} */ - -/* {{{ For separation */ -#define SEPARATE "------------------------------------------------" /* }}} */ - /* {{{ Color Management */ #define PHPDBG_COLOR_LEN 12 #define PHPDBG_COLOR_D(color, code) \ @@ -112,7 +66,7 @@ typedef struct _phpdbg_element_t { PHPDBG_API const phpdbg_color_t *phpdbg_get_color(const char *name, size_t name_length TSRMLS_DC); PHPDBG_API void phpdbg_set_color(int element, const phpdbg_color_t *color TSRMLS_DC); PHPDBG_API void phpdbg_set_color_ex(int element, const char *name, size_t name_length TSRMLS_DC); -PHPDBG_API const phpdbg_color_t* phpdbg_get_colors(TSRMLS_D); +PHPDBG_API const phpdbg_color_t *phpdbg_get_colors(TSRMLS_D); PHPDBG_API int phpdbg_get_element(const char *name, size_t len TSRMLS_DC); /* }}} */ /* {{{ Prompt Management */ @@ -122,6 +76,8 @@ PHPDBG_API const char *phpdbg_get_prompt(TSRMLS_D); /* }}} */ /* {{{ Console Width */ PHPDBG_API int phpdbg_get_terminal_width(TSRMLS_D); /* }}} */ +PHPDBG_API void phpdbg_set_async_io(int fd); + int phpdbg_rebuild_symtable(TSRMLS_D); #if PHP_VERSION_ID < 50500 @@ -144,4 +100,16 @@ static void zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, Ha } #endif +int phpdbg_safe_class_lookup(const char *name, int name_length, zend_class_entry ***ce TSRMLS_DC); + +char *phpdbg_get_property_key(char *key); + +typedef int (*phpdbg_parse_var_func)(char *name, size_t len, char *keyname, size_t keylen, HashTable *parent, zval **zv TSRMLS_DC); +typedef int (*phpdbg_parse_var_with_arg_func)(char *name, size_t len, char *keyname, size_t keylen, HashTable *parent, zval **zv, void *arg TSRMLS_DC); + +PHPDBG_API int phpdbg_parse_variable(char *input, size_t len, HashTable *parent, size_t i, phpdbg_parse_var_func callback, zend_bool silent TSRMLS_DC); +PHPDBG_API int phpdbg_parse_variable_with_arg(char *input, size_t len, HashTable *parent, size_t i, phpdbg_parse_var_with_arg_func callback, zend_bool silent, void *arg TSRMLS_DC); + +PHPDBG_API void phpdbg_xml_var_dump(zval **zv TSRMLS_DC); + #endif /* PHPDBG_UTILS_H */ diff --git a/phpdbg_wait.c b/phpdbg_wait.c new file mode 100644 index 00000000000..ea506a2d932 --- /dev/null +++ b/phpdbg_wait.c @@ -0,0 +1,419 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#include "phpdbg_wait.h" +#include "phpdbg_prompt.h" +#include "ext/json/JSON_parser.h" +#include "ext/standard/basic_functions.h" + +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); +ZEND_EXTERN_MODULE_GLOBALS(json); + +static void phpdbg_rebuild_http_globals_array(int type, const char *name TSRMLS_DC) { + zval **zvpp; + if (PG(http_globals)[type]) { + zval_dtor(PG(http_globals)[type]); + } + if (zend_hash_find(&EG(symbol_table), name, strlen(name) + 1, (void **) &zvpp) == SUCCESS) { + Z_SET_REFCOUNT_PP(zvpp, 2); + PG(http_globals)[type] = *zvpp; + } +} + + +static int phpdbg_dearm_autoglobals(zend_auto_global *auto_global TSRMLS_DC) { + if (auto_global->name_len != sizeof("GLOBALS") - 1 || memcmp(auto_global->name, "GLOBALS", sizeof("GLOBALS") - 1)) { + auto_global->armed = 0; + } + + return ZEND_HASH_APPLY_KEEP; +} + +typedef struct { + HashTable *ht[2]; + HashPosition pos[2]; +} phpdbg_intersect_ptr; + +static int phpdbg_array_data_compare(const void *a, const void *b TSRMLS_DC) { + Bucket *f, *s; + zval result; + zval *first, *second; + + f = *((Bucket **) a); + s = *((Bucket **) b); + + first = *((zval **) f->pData); + second = *((zval **) s->pData); + + if (string_compare_function(&result, first, second TSRMLS_CC) == FAILURE) { + return 0; + } + + if (Z_LVAL(result) < 0) { + return -1; + } else if (Z_LVAL(result) > 0) { + return 1; + } + + return 0; +} + +static void phpdbg_array_intersect_init(phpdbg_intersect_ptr *info, HashTable *ht1, HashTable *ht2 TSRMLS_DC) { + info->ht[0] = ht1; + info->ht[1] = ht2; + + zend_hash_sort(info->ht[0], zend_qsort, (compare_func_t) phpdbg_array_data_compare, 0 TSRMLS_CC); + zend_hash_sort(info->ht[1], zend_qsort, (compare_func_t) phpdbg_array_data_compare, 0 TSRMLS_CC); + + zend_hash_internal_pointer_reset_ex(info->ht[0], &info->pos[0]); + zend_hash_internal_pointer_reset_ex(info->ht[1], &info->pos[1]); +} + +/* -1 => first array, 0 => both arrays equal, 1 => second array */ +static int phpdbg_array_intersect(phpdbg_intersect_ptr *info, zval ***ptr) { + int ret; + zval **zvpp[2]; + int invalid = !info->ht[0] + !info->ht[1]; + + if (invalid > 0) { + invalid = !info->ht[0]; + + if (zend_hash_get_current_data_ex(info->ht[invalid], (void **) ptr, &info->pos[invalid]) == FAILURE) { + *ptr = NULL; + return 0; + } + + zend_hash_move_forward_ex(info->ht[invalid], &info->pos[invalid]); + + return invalid ? 1 : -1; + } + + if (zend_hash_get_current_data_ex(info->ht[0], (void **) &zvpp[0], &info->pos[0]) == FAILURE) { + info->ht[0] = NULL; + return phpdbg_array_intersect(info, ptr); + } + if (zend_hash_get_current_data_ex(info->ht[1], (void **) &zvpp[1], &info->pos[1]) == FAILURE) { + info->ht[1] = NULL; + return phpdbg_array_intersect(info, ptr); + } + + ret = zend_binary_zval_strcmp(*zvpp[0], *zvpp[1]); + + if (ret <= 0) { + *ptr = zvpp[0]; + zend_hash_move_forward_ex(info->ht[0], &info->pos[0]); + } + if (ret >= 0) { + *ptr = zvpp[1]; + zend_hash_move_forward_ex(info->ht[1], &info->pos[1]); + } + + return ret; +} + +void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) { +#ifdef HAVE_JSON + zval *free_zv = NULL; + zval zv, **zvpp; + HashTable *ht; + php_json_decode(&zv, msg, len, 1, 1000 /* enough */ TSRMLS_CC); + + if (JSON_G(error_code) != PHP_JSON_ERROR_NONE) { + phpdbg_error("wait", "type=\"invaliddata\" import=\"fail\"", "Malformed JSON was sent to this socket, arborting"); + return; + } + + ht = Z_ARRVAL(zv); + + /* Reapply symbol table */ + if (zend_hash_find(ht, "GLOBALS", sizeof("GLOBALS"), (void **) &zvpp) == SUCCESS && Z_TYPE_PP(zvpp) == IS_ARRAY) { + { + zval **srv; + if (zend_hash_find(Z_ARRVAL_PP(zvpp), "_SERVER", sizeof("_SERVER"), (void **) &srv) == SUCCESS && Z_TYPE_PP(srv) == IS_ARRAY) { + zval **script; + if (zend_hash_find(Z_ARRVAL_PP(srv), "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME"), (void **) &script) == SUCCESS && Z_TYPE_PP(script) == IS_STRING) { + phpdbg_param_t param; + param.str = Z_STRVAL_PP(script); + PHPDBG_COMMAND_HANDLER(exec)(¶m TSRMLS_CC); + } + } + } + + PG(auto_globals_jit) = 0; + zend_hash_apply(CG(auto_globals), (apply_func_t) phpdbg_dearm_autoglobals TSRMLS_CC); + + zend_hash_clean(&EG(symbol_table)); + EG(symbol_table) = *Z_ARRVAL_PP(zvpp); + + /* Rebuild cookies, env vars etc. from GLOBALS (PG(http_globals)) */ + phpdbg_rebuild_http_globals_array(TRACK_VARS_POST, "_POST" TSRMLS_CC); + phpdbg_rebuild_http_globals_array(TRACK_VARS_GET, "_GET" TSRMLS_CC); + phpdbg_rebuild_http_globals_array(TRACK_VARS_COOKIE, "_COOKIE" TSRMLS_CC); + phpdbg_rebuild_http_globals_array(TRACK_VARS_SERVER, "_SERVER" TSRMLS_CC); + phpdbg_rebuild_http_globals_array(TRACK_VARS_ENV, "_ENV" TSRMLS_CC); + phpdbg_rebuild_http_globals_array(TRACK_VARS_FILES, "_FILES" TSRMLS_CC); + + Z_ADDREF_PP(zvpp); + free_zv = *zvpp; + } + + if (zend_hash_find(ht, "input", sizeof("input"), (void **) &zvpp) == SUCCESS && Z_TYPE_PP(zvpp) == IS_STRING) { + if (SG(request_info).request_body) { + php_stream_close(SG(request_info).request_body); + } + SG(request_info).request_body = php_stream_temp_create_ex(TEMP_STREAM_DEFAULT, SAPI_POST_BLOCK_SIZE, PG(upload_tmp_dir)); + php_stream_truncate_set_size(SG(request_info).request_body, 0); + php_stream_write(SG(request_info).request_body, Z_STRVAL_PP(zvpp), Z_STRLEN_PP(zvpp)); + } + + if (zend_hash_find(ht, "cwd", sizeof("cwd"), (void **) &zvpp) == SUCCESS && Z_TYPE_PP(zvpp) == IS_STRING) { + if (VCWD_CHDIR(Z_STRVAL_PP(zvpp)) == SUCCESS) { + if (BG(CurrentStatFile) && !IS_ABSOLUTE_PATH(BG(CurrentStatFile), strlen(BG(CurrentStatFile)))) { + efree(BG(CurrentStatFile)); + BG(CurrentStatFile) = NULL; + } + if (BG(CurrentLStatFile) && !IS_ABSOLUTE_PATH(BG(CurrentLStatFile), strlen(BG(CurrentLStatFile)))) { + efree(BG(CurrentLStatFile)); + BG(CurrentLStatFile) = NULL; + } + } + } + + if (zend_hash_find(ht, "sapi_name", sizeof("sapi_name"), (void **) &zvpp) == SUCCESS && (Z_TYPE_PP(zvpp) == IS_STRING || Z_TYPE_PP(zvpp) == IS_NULL)) { + if (PHPDBG_G(sapi_name_ptr)) { + free(PHPDBG_G(sapi_name_ptr)); + } + if (Z_TYPE_PP(zvpp) == IS_STRING) { + PHPDBG_G(sapi_name_ptr) = sapi_module.name = strdup(Z_STRVAL_PP(zvpp)); + } else { + PHPDBG_G(sapi_name_ptr) = sapi_module.name = NULL; + } + } + + if (zend_hash_find(ht, "modules", sizeof("modules"), (void **) &zvpp) == SUCCESS && Z_TYPE_PP(zvpp) == IS_ARRAY) { + HashPosition position; + phpdbg_intersect_ptr pos; + zval **module; + zend_module_entry *mod; + HashTable zv_registry; + + /* intersect modules, unregister modules loaded "too much", announce not yet registered modules (phpdbg_notice) */ + + zend_hash_init(&zv_registry, zend_hash_num_elements(&module_registry), 0, ZVAL_PTR_DTOR, 0); + for (zend_hash_internal_pointer_reset_ex(&module_registry, &position); + zend_hash_get_current_data_ex(&module_registry, (void **) &mod, &position) == SUCCESS; + zend_hash_move_forward_ex(&module_registry, &position)) { + if (mod->name) { + zval **value = emalloc(sizeof(zval *)); + MAKE_STD_ZVAL(*value); + ZVAL_STRING(*value, mod->name, 1); + zend_hash_next_index_insert(&zv_registry, value, sizeof(zval *), NULL); + } + } + + phpdbg_array_intersect_init(&pos, &zv_registry, Z_ARRVAL_PP(zvpp) TSRMLS_CC); + do { + int mode = phpdbg_array_intersect(&pos, &module); + if (mode < 0) { + // loaded module, but not needed + if (strcmp(PHPDBG_NAME, Z_STRVAL_PP(module))) { + zend_hash_del(&module_registry, Z_STRVAL_PP(module), Z_STRLEN_PP(module) + 1); + } + } else if (mode > 0) { + // not loaded module + if (!sapi_module.name || strcmp(sapi_module.name, Z_STRVAL_PP(module))) { + phpdbg_notice("wait", "missingmodule=\"%.*s\"", "The module %.*s isn't present in " PHPDBG_NAME ", you still can load via dl /path/to/module/%.*s.so", Z_STRLEN_PP(module), Z_STRVAL_PP(module), Z_STRLEN_PP(module), Z_STRVAL_PP(module)); + } + } + } while (module); + + zend_hash_clean(&zv_registry); + } + + if (zend_hash_find(ht, "extensions", sizeof("extensions"), (void **) &zvpp) == SUCCESS && Z_TYPE_PP(zvpp) == IS_ARRAY) { + zend_extension *extension; + zend_llist_position pos; + HashPosition hpos; + zval **name, key; + + extension = (zend_extension *) zend_llist_get_first_ex(&zend_extensions, &pos); + while (extension) { + extension = (zend_extension *) zend_llist_get_next_ex(&zend_extensions, &pos); + + /* php_serach_array() body should be in some ZEND_API function */ + for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(zvpp), &hpos); + zend_hash_get_current_data_ex(Z_ARRVAL_PP(zvpp), (void **) &name, &hpos) == SUCCESS; + zend_hash_move_forward_ex(Z_ARRVAL_PP(zvpp), &hpos)) { + if (Z_TYPE_PP(name) == IS_STRING && !zend_binary_strcmp(extension->name, strlen(extension->name), Z_STRVAL_PP(name), Z_STRLEN_PP(name))) { + break; + } + } + + if (zend_hash_get_current_data_ex(Z_ARRVAL_PP(zvpp), (void **) &zvpp, &hpos) == FAILURE) { + /* sigh, breaking the encapsulation, there aren't any functions manipulating the llist at the place of the zend_llist_position */ + zend_llist_element *elm = pos; + if (elm->prev) { + elm->prev->next = elm->next; + } else { + zend_extensions.head = elm->next; + } + if (elm->next) { + elm->next->prev = elm->prev; + } else { + zend_extensions.tail = elm->prev; + } +#if ZEND_EXTENSIONS_SUPPORT + if (extension->shutdown) { + extension->shutdown(extension); + } +#endif + if (zend_extensions.dtor) { + zend_extensions.dtor(elm->data); + } + pefree(elm, zend_extensions.persistent); + zend_extensions.count--; + } else { + zend_hash_get_current_key_zval_ex(Z_ARRVAL_PP(zvpp), &key, &hpos); + if (Z_TYPE(key) == IS_LONG) { + zend_hash_index_del(Z_ARRVAL_PP(zvpp), Z_LVAL(key)); + } + } + + for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(zvpp), &hpos); + zend_hash_get_current_data_ex(Z_ARRVAL_PP(zvpp), (void **) &name, &hpos) == SUCCESS; + zend_hash_move_forward_ex(Z_ARRVAL_PP(zvpp), &hpos)) { + phpdbg_notice("wait", "missingextension=\"%.*s\"", "The Zend extension %.*s isn't present in " PHPDBG_NAME ", you still can load via dl /path/to/extension.so", Z_STRLEN_PP(name), Z_STRVAL_PP(name)); + } + } + } + + zend_ini_deactivate(TSRMLS_C); + + if (zend_hash_find(ht, "systemini", sizeof("systemini"), (void **) &zvpp) == SUCCESS && Z_TYPE_PP(zvpp) == IS_ARRAY) { + HashPosition position; + zval **ini_entry; + zend_ini_entry *original_ini; + zval key; + + for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(zvpp), &position); + zend_hash_get_current_data_ex(Z_ARRVAL_PP(zvpp), (void**) &ini_entry, &position) == SUCCESS; + zend_hash_move_forward_ex(Z_ARRVAL_PP(zvpp), &position)) { + zend_hash_get_current_key_zval_ex(Z_ARRVAL_PP(zvpp), &key, &position); + if (Z_TYPE(key) == IS_STRING) { + if (Z_TYPE_PP(ini_entry) == IS_STRING) { + if (zend_hash_find(EG(ini_directives), Z_STRVAL(key), Z_STRLEN(key) + 1, (void **) &original_ini) == SUCCESS) { + if (!original_ini->on_modify || original_ini->on_modify(original_ini, Z_STRVAL_PP(ini_entry), Z_STRLEN_PP(ini_entry), original_ini->mh_arg1, original_ini->mh_arg2, original_ini->mh_arg3, ZEND_INI_STAGE_ACTIVATE TSRMLS_CC) == SUCCESS) { + if (original_ini->modified && original_ini->orig_value != original_ini->value) { + efree(original_ini->value); + } + original_ini->value = Z_STRVAL_PP(ini_entry); + original_ini->value_length = Z_STRLEN_PP(ini_entry); + Z_TYPE_PP(ini_entry) = IS_NULL; /* don't free the value */ + } + } + } + efree(Z_STRVAL(key)); + } + } + } + + if (zend_hash_find(ht, "userini", sizeof("userini"), (void **) &zvpp) == SUCCESS && Z_TYPE_PP(zvpp) == IS_ARRAY) { + HashPosition position; + zval **ini_entry; + zval key; + + for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(zvpp), &position); + zend_hash_get_current_data_ex(Z_ARRVAL_PP(zvpp), (void**) &ini_entry, &position) == SUCCESS; + zend_hash_move_forward_ex(Z_ARRVAL_PP(zvpp), &position)) { + zend_hash_get_current_key_zval_ex(Z_ARRVAL_PP(zvpp), &key, &position); + if (Z_TYPE(key) == IS_STRING) { + if (Z_TYPE_PP(ini_entry) == IS_STRING) { + zend_alter_ini_entry_ex(Z_STRVAL(key), Z_STRLEN(key) + 1, Z_STRVAL_PP(ini_entry), Z_STRLEN_PP(ini_entry), ZEND_INI_PERDIR, ZEND_INI_STAGE_HTACCESS, 1 TSRMLS_CC); + } + efree(Z_STRVAL(key)); + } + } + } + + zval_dtor(&zv); + if (free_zv) { + /* separate freeing to not dtor the symtable too, just the container zval... */ + efree(free_zv); + } + + /* Reapply raw input */ + /* ??? */ +#endif +} + +PHPDBG_COMMAND(wait) /* {{{ */ +{ +#ifdef HAVE_JSON + struct sockaddr_un local, remote; + int rlen, sr, sl; + unlink(PHPDBG_G(socket_path)); + if (PHPDBG_G(socket_server_fd) == -1) { + int len; + PHPDBG_G(socket_server_fd) = sl = socket(AF_UNIX, SOCK_STREAM, 0); + + local.sun_family = AF_UNIX; + strcpy(local.sun_path, PHPDBG_G(socket_path)); + len = strlen(local.sun_path) + sizeof(local.sun_family); + if (bind(sl, (struct sockaddr *)&local, len) == -1) { + phpdbg_error("wait", "type=\"nosocket\" import=\"fail\"", "Unable to connect to UNIX domain socket at %s defined by phpdbg.path ini setting", PHPDBG_G(socket_path)); + return FAILURE; + } + + chmod(PHPDBG_G(socket_path), 0666); + + listen(sl, 2); + } else { + sl = PHPDBG_G(socket_server_fd); + } + + rlen = sizeof(remote); + sr = accept(sl, (struct sockaddr *) &remote, (socklen_t *) &rlen); + + char msglen[5]; + int recvd = 4; + + do { + recvd -= recv(sr, &(msglen[4 - recvd]), recvd, 0); + } while (recvd > 0); + + recvd = *(size_t *) msglen; + char *data = emalloc(recvd); + + do { + recvd -= recv(sr, &(data[(*(int *) msglen) - recvd]), recvd, 0); + } while (recvd > 0); + + phpdbg_webdata_decompress(data, *(int *) msglen TSRMLS_CC); + + if (PHPDBG_G(socket_fd) != -1) { + close(PHPDBG_G(socket_fd)); + } + PHPDBG_G(socket_fd) = sr; + + efree(data); + + phpdbg_notice("wait", "import=\"success\"", "Successfully imported request data, stopped before executing"); + + return SUCCESS; +#endif +} /* }}} */ diff --git a/phpdbg_wait.h b/phpdbg_wait.h new file mode 100644 index 00000000000..7cf95919ccb --- /dev/null +++ b/phpdbg_wait.h @@ -0,0 +1,29 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHPDBG_WAIT_H +#define PHPDBG_WAIT_H + +#include "zend.h" +#include "phpdbg.h" + +PHPDBG_COMMAND(wait); + +void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC); + +#endif /* PHPDBG_WAIT_H */ diff --git a/phpdbg_watch.c b/phpdbg_watch.c index e88622444bf..de6cddf5b3c 100644 --- a/phpdbg_watch.c +++ b/phpdbg_watch.c @@ -30,7 +30,6 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg); - typedef struct { void *page; size_t size; @@ -138,13 +137,6 @@ static int phpdbg_create_array_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_DC) return SUCCESS; } -static char *phpdbg_get_property_key(char *key) { - if (*key != 0) { - return key; - } - return strchr(key + 1, 0) + 1; -} - static int phpdbg_create_recursive_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_DC) { HashTable *ht; @@ -190,7 +182,7 @@ static int phpdbg_create_recursive_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_ } new_watch->str = NULL; - new_watch->str_len = asprintf(&new_watch->str, "%.*s%s%s%s", (int)watch->str_len, watch->str, Z_TYPE_P(watch->addr.zv) == IS_ARRAY?"[":"->", phpdbg_get_property_key(new_watch->name_in_parent), Z_TYPE_P(watch->addr.zv) == IS_ARRAY?"]":""); + new_watch->str_len = asprintf(&new_watch->str, "%.*s%s%s%s", (int) watch->str_len, watch->str, Z_TYPE_P(watch->addr.zv) == IS_ARRAY ? "[" : "->", phpdbg_get_property_key(new_watch->name_in_parent), Z_TYPE_P(watch->addr.zv) == IS_ARRAY ? "]" : ""); phpdbg_create_zval_watchpoint(*zv, new_watch); phpdbg_create_recursive_watchpoint(new_watch TSRMLS_CC); @@ -236,9 +228,9 @@ static int phpdbg_delete_watchpoint_recursive(phpdbg_watchpoint_t *watch, zend_b zend_hash_get_current_key_zval_ex(ht, &key, &position); str = NULL; if (Z_TYPE(key) == IS_STRING) { - str_len = asprintf(&str, "%.*s%s%s%s", (int)watch->parent->str_len, watch->parent->str, Z_TYPE_P(watch->parent->addr.zv) == IS_ARRAY?"[":"->", phpdbg_get_property_key(Z_STRVAL(key)), Z_TYPE_P(watch->parent->addr.zv) == IS_ARRAY?"]":""); + str_len = asprintf(&str, "%.*s%s%s%s", (int) watch->parent->str_len, watch->parent->str, Z_TYPE_P(watch->parent->addr.zv) == IS_ARRAY ? "[" : "->", phpdbg_get_property_key(Z_STRVAL(key)), Z_TYPE_P(watch->parent->addr.zv) == IS_ARRAY ? "]" : ""); } else { - str_len = asprintf(&str, "%.*s%s%li%s", (int)watch->parent->str_len, watch->parent->str, Z_TYPE_P(watch->parent->addr.zv) == IS_ARRAY?"[":"->", Z_LVAL(key), Z_TYPE_P(watch->parent->addr.zv) == IS_ARRAY?"]":""); + str_len = asprintf(&str, "%.*s%s%li%s", (int) watch->parent->str_len, watch->parent->str, Z_TYPE_P(watch->parent->addr.zv) == IS_ARRAY ? "[" : "->", Z_LVAL(key), Z_TYPE_P(watch->parent->addr.zv) == IS_ARRAY ? "]" : ""); } if (zend_hash_find(&PHPDBG_G(watchpoints), str, str_len, (void **) &watchpoint) == SUCCESS) { @@ -281,118 +273,37 @@ static int phpdbg_delete_watchpoint(phpdbg_watchpoint_t *tmp_watch TSRMLS_DC) { ret = zend_hash_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len); } - free(tmp_watch->str); + efree(tmp_watch->str); + efree(tmp_watch->name_in_parent); efree(tmp_watch); return ret; } -static int phpdbg_watchpoint_parse_input(char *input, size_t len, HashTable *parent, size_t i, int (*callback)(phpdbg_watchpoint_t * TSRMLS_DC), zend_bool silent TSRMLS_DC) { - int ret = FAILURE; - zend_bool new_index = 1; - char *last_index; - int index_len = 0; - zval **zv; +static int phpdbg_watchpoint_parse_wrapper(char *name, size_t len, char *keyname, size_t keylen, HashTable *parent, zval **zv, int (*callback)(phpdbg_watchpoint_t * TSRMLS_DC) TSRMLS_DC) { + int ret; + phpdbg_watchpoint_t *watch = emalloc(sizeof(phpdbg_watchpoint_t)); + watch->flags = 0; + watch->str = name; + watch->str_len = len; + watch->name_in_parent = keyname; + watch->name_in_parent_len = keylen; + watch->parent_container = parent; + phpdbg_create_zval_watchpoint(*zv, watch); - if (len < 2 || *input != '$') { - goto error; - } + ret = callback(watch TSRMLS_CC); - while (i++ < len) { - if (i == len) { - new_index = 1; - } else { - switch (input[i]) { - case '[': - new_index = 1; - break; - case ']': - break; - case '>': - if (last_index[index_len - 1] == '-') { - new_index = 1; - index_len--; - } - break; - - default: - if (new_index) { - last_index = input + i; - new_index = 0; - } - if (input[i - 1] == ']') { - goto error; - } - index_len++; - } - } - - if (new_index && index_len == 0) { - HashPosition position; - for (zend_hash_internal_pointer_reset_ex(parent, &position); - zend_hash_get_current_data_ex(parent, (void **)&zv, &position) == SUCCESS; - zend_hash_move_forward_ex(parent, &position)) { - if (i == len || (i == len - 1 && input[len - 1] == ']')) { - zval *key = emalloc(sizeof(zval)); - phpdbg_watchpoint_t *watch = emalloc(sizeof(phpdbg_watchpoint_t)); - watch->flags = 0; - zend_hash_get_current_key_zval_ex(parent, key, &position); - convert_to_string(key); - watch->str = malloc(i + Z_STRLEN_P(key) + 2); - watch->str_len = sprintf(watch->str, "%.*s%s%s", (int)i, input, phpdbg_get_property_key(Z_STRVAL_P(key)), input[len - 1] == ']'?"]":""); - efree(key); - watch->name_in_parent = zend_strndup(last_index, index_len); - watch->name_in_parent_len = index_len; - watch->parent_container = parent; - phpdbg_create_zval_watchpoint(*zv, watch); - - ret = callback(watch TSRMLS_CC) == SUCCESS || ret == SUCCESS?SUCCESS:FAILURE; - } else if (Z_TYPE_PP(zv) == IS_OBJECT) { - phpdbg_watchpoint_parse_input(input, len, Z_OBJPROP_PP(zv), i, callback, silent TSRMLS_CC); - } else if (Z_TYPE_PP(zv) == IS_ARRAY) { - phpdbg_watchpoint_parse_input(input, len, Z_ARRVAL_PP(zv), i, callback, silent TSRMLS_CC); - } else { - /* Ignore silently */ - } - } - return ret; - } else if (new_index) { - char last_chr = last_index[index_len]; - last_index[index_len] = 0; - if (zend_symtable_find(parent, last_index, index_len + 1, (void **)&zv) == FAILURE) { - if (!silent) { - phpdbg_error("%.*s is undefined", (int)i, input); - } - return FAILURE; - } - last_index[index_len] = last_chr; - if (i == len) { - phpdbg_watchpoint_t *watch = emalloc(sizeof(phpdbg_watchpoint_t)); - watch->flags = 0; - watch->str = zend_strndup(input, len); - watch->str_len = len; - watch->name_in_parent = zend_strndup(last_index, index_len); - watch->name_in_parent_len = index_len; - watch->parent_container = parent; - phpdbg_create_zval_watchpoint(*zv, watch); - - ret = callback(watch TSRMLS_CC) == SUCCESS || ret == SUCCESS?SUCCESS:FAILURE; - } else if (Z_TYPE_PP(zv) == IS_OBJECT) { - parent = Z_OBJPROP_PP(zv); - } else if (Z_TYPE_PP(zv) == IS_ARRAY) { - parent = Z_ARRVAL_PP(zv); - } else { - phpdbg_error("%.*s is nor an array nor an object", (int)i, input); - return FAILURE; - } - index_len = 0; - } + if (ret != SUCCESS) { + efree(watch); + efree(name); + efree(keyname); } return ret; - error: - phpdbg_error("Malformed input"); - return FAILURE; +} + +PHPDBG_API int phpdbg_watchpoint_parse_input(char *input, size_t len, HashTable *parent, size_t i, int (*callback)(phpdbg_watchpoint_t * TSRMLS_DC), zend_bool silent TSRMLS_DC) { + return phpdbg_parse_variable_with_arg(input, len, parent, i, (phpdbg_parse_var_with_arg_func) phpdbg_watchpoint_parse_wrapper, 0, callback TSRMLS_CC); } static int phpdbg_watchpoint_parse_symtables(char *input, size_t len, int (*callback)(phpdbg_watchpoint_t * TSRMLS_DC) TSRMLS_DC) { @@ -412,9 +323,9 @@ PHPDBG_WATCH(delete) /* {{{ */ switch (param->type) { case STR_PARAM: if (phpdbg_delete_var_watchpoint(param->str, param->len TSRMLS_CC) == FAILURE) { - phpdbg_error("Nothing was deleted, no corresponding watchpoint found"); + phpdbg_error("watchdelete", "type=\"nowatch\"", "Nothing was deleted, no corresponding watchpoint found"); } else { - phpdbg_notice("Removed watchpoint %.*s", (int)param->len, param->str); + phpdbg_notice("watchdelete", "variable=\"%.*s\"", "Removed watchpoint %.*s", (int) param->len, param->str); } break; @@ -433,7 +344,7 @@ PHPDBG_WATCH(recursive) /* {{{ */ switch (param->type) { case STR_PARAM: if (phpdbg_watchpoint_parse_symtables(param->str, param->len, phpdbg_create_recursive_watchpoint TSRMLS_CC) != FAILURE) { - phpdbg_notice("Set recursive watchpoint on %.*s", (int)param->len, param->str); + phpdbg_notice("watchrecursive", "variable=\"%.*s\"", "Set recursive watchpoint on %.*s", (int)param->len, param->str); } break; @@ -452,7 +363,7 @@ PHPDBG_WATCH(array) /* {{{ */ switch (param->type) { case STR_PARAM: if (phpdbg_watchpoint_parse_symtables(param->str, param->len, phpdbg_create_array_watchpoint TSRMLS_CC) != FAILURE) { - phpdbg_notice("Set array watchpoint on %.*s", (int)param->len, param->str); + phpdbg_notice("watcharray", "variable=\"%.*s\"", "Set array watchpoint on %.*s", (int)param->len, param->str); } break; @@ -473,7 +384,7 @@ void phpdbg_watch_HashTable_dtor(zval **zv) { PHPDBG_G(watchpoint_hit) = 1; - phpdbg_notice("%.*s was removed, removing watchpoint%s", (int)watch->str_len, watch->str, (watch->flags & PHPDBG_WATCH_RECURSIVE)?" recursively":""); + phpdbg_notice("watchdelete", "variable=\"%.*s\" recursive=\"%s\"", "%.*s was removed, removing watchpoint%s", (int)watch->str_len, watch->str, watch->flags & PHPDBG_WATCH_RECURSIVE ? " recursively" : ""); if (watch->flags & PHPDBG_WATCH_RECURSIVE) { phpdbg_delete_watchpoint_recursive(watch, 0 TSRMLS_CC); @@ -550,8 +461,8 @@ static void phpdbg_watch_dtor(void *pDest) { phpdbg_deactivate_watchpoint(watch TSRMLS_CC); phpdbg_remove_watchpoint(watch TSRMLS_CC); - free(watch->str); - free(watch->name_in_parent); + efree(watch->str); + efree(watch->name_in_parent); efree(watch); } @@ -585,7 +496,7 @@ void phpdbg_setup_watchpoints(TSRMLS_D) { static void phpdbg_print_changed_zval(phpdbg_watch_memdump *dump TSRMLS_DC) { /* fetch all changes between dump->page and dump->page + dump->size */ - phpdbg_btree_position pos = phpdbg_btree_find_between(&PHPDBG_G(watchpoint_tree), (zend_ulong)dump->page, (zend_ulong)dump->page + dump->size); + phpdbg_btree_position pos = phpdbg_btree_find_between(&PHPDBG_G(watchpoint_tree), (zend_ulong) dump->page, (zend_ulong) dump->page + dump->size); phpdbg_btree_result *result, *htresult; int elementDiff; void *curTest; @@ -597,7 +508,7 @@ static void phpdbg_print_changed_zval(phpdbg_watch_memdump *dump TSRMLS_DC) { void *oldPtr = (char *)&dump->data + ((size_t)watch->addr.ptr - (size_t)dump->page); char reenable = 1; - if ((size_t)watch->addr.ptr < (size_t)dump->page || (size_t)watch->addr.ptr + watch->size > (size_t)dump->page + dump->size) { + if ((size_t)watch->addr.ptr < (size_t)dump->page || (size_t)watch->addr.ptr + watch->size > (size_t) dump->page + dump->size) { continue; } @@ -629,14 +540,17 @@ static void phpdbg_print_changed_zval(phpdbg_watch_memdump *dump TSRMLS_DC) { /* Show to the user what changed and delete watchpoint upon removal */ if (memcmp(oldPtr, watch->addr.ptr, watch->size) != SUCCESS) { - if (PHPDBG_G(flags) & PHPDBG_SHOW_REFCOUNTS || (watch->type == WATCH_ON_ZVAL && memcmp(oldPtr, watch->addr.zv, sizeof(zvalue_value))) || (watch->type == WATCH_ON_HASHTABLE + zend_bool do_break = PHPDBG_G(flags) & PHPDBG_SHOW_REFCOUNTS || (watch->type == WATCH_ON_ZVAL && memcmp(oldPtr, watch->addr.zv, sizeof(zvalue_value))) || (watch->type == WATCH_ON_HASHTABLE #if ZEND_DEBUG && !watch->addr.ht->inconsistent #endif - && zend_hash_num_elements((HashTable *)oldPtr) != zend_hash_num_elements(watch->addr.ht))) { + && zend_hash_num_elements((HashTable *)oldPtr) != zend_hash_num_elements(watch->addr.ht)); + + if (do_break) { PHPDBG_G(watchpoint_hit) = 1; - phpdbg_notice("Breaking on watchpoint %s", watch->str); + phpdbg_notice("watchhit", "variable=\"%s\"", "Breaking on watchpoint %.*s", (int) watch->str_len, watch->str); + phpdbg_xml(""); } switch (watch->type) { @@ -646,26 +560,28 @@ static void phpdbg_print_changed_zval(phpdbg_watch_memdump *dump TSRMLS_DC) { int show_ref = ((zval *)oldPtr)->refcount__gc != watch->addr.zv->refcount__gc || ((zval *)oldPtr)->is_ref__gc != watch->addr.zv->is_ref__gc; if (removed || show_value) { - phpdbg_write("Old value: "); if ((Z_TYPE_P((zval *)oldPtr) == IS_ARRAY || Z_TYPE_P((zval *)oldPtr) == IS_OBJECT) && removed) { - phpdbg_writeln("Value inaccessible, HashTable already destroyed"); + phpdbg_writeln("watchvalue", "type=\"old\" inaccessible=\"inaccessible\"", "Old value inaccessible, array or object (HashTable) already destroyed"); } else { - zend_print_flat_zval_r((zval *)oldPtr TSRMLS_CC); - phpdbg_writeln(""); + phpdbg_out("Old value: "); + phpdbg_xml(""); + zend_print_flat_zval_r((zval *) oldPtr TSRMLS_CC); + phpdbg_xml(""); + phpdbg_out("\n"); } } if (PHPDBG_G(flags) & PHPDBG_SHOW_REFCOUNTS && (removed || show_ref)) { - phpdbg_writeln("Old refcount: %d; Old is_ref: %d", ((zval *)oldPtr)->refcount__gc, ((zval *)oldPtr)->is_ref__gc); + phpdbg_write("watchrefcount", "type=\"old\" refcount=\"%d\" isref=\"%d\"", "Old refcount: %d; Old is_ref: %d", ((zval *) oldPtr)->refcount__gc, ((zval *) oldPtr)->is_ref__gc); } /* check if zval was removed */ if (removed) { - phpdbg_notice("Watchpoint %s was unset, removing watchpoint", watch->str); + phpdbg_notice("watchdelete", "variable=\"%.*s\"", "Watchpoint %.*s was unset, removing watchpoint", (int) watch->str_len, watch->str); zend_hash_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len); reenable = 0; - if (Z_TYPE_P((zval *)oldPtr) == IS_ARRAY || Z_TYPE_P((zval *)oldPtr) == IS_OBJECT) { + if (Z_TYPE_P((zval *) oldPtr) == IS_ARRAY || Z_TYPE_P((zval *) oldPtr) == IS_OBJECT) { goto remove_ht_watch; } @@ -673,22 +589,24 @@ static void phpdbg_print_changed_zval(phpdbg_watch_memdump *dump TSRMLS_DC) { } if (show_value) { - phpdbg_write("New value: "); + phpdbg_out("New value: "); + phpdbg_xml(""); zend_print_flat_zval_r(watch->addr.zv TSRMLS_CC); - phpdbg_writeln(""); + phpdbg_xml(""); + phpdbg_out("\n"); } if (PHPDBG_G(flags) & PHPDBG_SHOW_REFCOUNTS && show_ref) { - phpdbg_writeln("New refcount: %d; New is_ref: %d", watch->addr.zv->refcount__gc, watch->addr.zv->is_ref__gc); + phpdbg_writeln("watchrefcount", "type=\"new\" refcount=\"%d\" isref=\"%d\"", "New refcount: %d; New is_ref: %d", watch->addr.zv->refcount__gc, watch->addr.zv->is_ref__gc); } - if ((Z_TYPE_P(watch->addr.zv) == IS_ARRAY && Z_ARRVAL_P(watch->addr.zv) != Z_ARRVAL_P((zval *)oldPtr)) || (Z_TYPE_P(watch->addr.zv) != IS_OBJECT && Z_OBJ_HANDLE_P(watch->addr.zv) == Z_OBJ_HANDLE_P((zval *)oldPtr))) { + if ((Z_TYPE_P(watch->addr.zv) == IS_ARRAY && Z_ARRVAL_P(watch->addr.zv) != Z_ARRVAL_P((zval *) oldPtr)) || (Z_TYPE_P(watch->addr.zv) != IS_OBJECT && Z_OBJ_HANDLE_P(watch->addr.zv) == Z_OBJ_HANDLE_P((zval *) oldPtr))) { /* add new watchpoints if necessary */ if (watch->flags & PHPDBG_WATCH_RECURSIVE) { phpdbg_create_recursive_watchpoint(watch TSRMLS_CC); } } - if ((Z_TYPE_P((zval *)oldPtr) != IS_ARRAY || Z_ARRVAL_P(watch->addr.zv) == Z_ARRVAL_P((zval *)oldPtr)) && (Z_TYPE_P((zval *)oldPtr) != IS_OBJECT || Z_OBJ_HANDLE_P(watch->addr.zv) == Z_OBJ_HANDLE_P((zval *)oldPtr))) { + if ((Z_TYPE_P((zval *) oldPtr) != IS_ARRAY || Z_ARRVAL_P(watch->addr.zv) == Z_ARRVAL_P((zval *) oldPtr)) && (Z_TYPE_P((zval *)oldPtr) != IS_OBJECT || Z_OBJ_HANDLE_P(watch->addr.zv) == Z_OBJ_HANDLE_P((zval *) oldPtr))) { break; } @@ -704,7 +622,7 @@ remove_ht_watch: #if ZEND_DEBUG if (watch->addr.ht->inconsistent) { - phpdbg_notice("Watchpoint %s was unset, removing watchpoint", watch->str); + phpdbg_notice("watchdelete", "variable=\"%.*s\"", "Watchpoint %.*s was unset, removing watchpoint", (int) watch->str_len, watch->str); zend_hash_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len); reenable = 0; @@ -713,12 +631,12 @@ remove_ht_watch: } #endif - elementDiff = zend_hash_num_elements((HashTable *)oldPtr) - zend_hash_num_elements(watch->addr.ht); + elementDiff = zend_hash_num_elements((HashTable *) oldPtr) - zend_hash_num_elements(watch->addr.ht); if (elementDiff) { if (elementDiff > 0) { - phpdbg_writeln("%d elements were removed from the array", elementDiff); + phpdbg_writeln("watchsize", "removed=\"%d\"", "%d elements were removed from the array", elementDiff); } else { - phpdbg_writeln("%d elements were added to the array", -elementDiff); + phpdbg_writeln("watchsize", "added=\"%d\"", "%d elements were added to the array", -elementDiff); /* add new watchpoints if necessary */ if (watch->flags & PHPDBG_WATCH_RECURSIVE) { @@ -726,11 +644,15 @@ remove_ht_watch: } } } - if (((HashTable *)oldPtr)->pInternalPointer != watch->addr.ht->pInternalPointer) { - phpdbg_writeln("Internal pointer of array was changed"); + if (((HashTable *) oldPtr)->pInternalPointer != watch->addr.ht->pInternalPointer) { + phpdbg_writeln("watcharrayptr", "", "Internal pointer of array was changed"); } break; } + + if (do_break) { + phpdbg_xml(""); + } } dump->reenable_writing = dump->reenable_writing | reenable; @@ -746,15 +668,15 @@ int phpdbg_print_changed_zvals(TSRMLS_D) { return FAILURE; } - dump = (phpdbg_watch_memdump **)zend_llist_get_last_ex(&PHPDBG_G(watchlist_mem), &pos); + dump = (phpdbg_watch_memdump **) zend_llist_get_last_ex(&PHPDBG_G(watchlist_mem), &pos); do { phpdbg_print_changed_zval(*dump TSRMLS_CC); - } while ((dump = (phpdbg_watch_memdump **)zend_llist_get_prev_ex(&PHPDBG_G(watchlist_mem), &pos))); + } while ((dump = (phpdbg_watch_memdump **) zend_llist_get_prev_ex(&PHPDBG_G(watchlist_mem), &pos))); zend_llist_clean(&PHPDBG_G(watchlist_mem)); - ret = PHPDBG_G(watchpoint_hit)?SUCCESS:FAILURE; + ret = PHPDBG_G(watchpoint_hit) ? SUCCESS : FAILURE; PHPDBG_G(watchpoint_hit) = 0; return ret; @@ -764,23 +686,27 @@ void phpdbg_list_watchpoints(TSRMLS_D) { HashPosition position; phpdbg_watchpoint_t **watch; + phpdbg_xml(""); + for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(watchpoints), &position); zend_hash_get_current_data_ex(&PHPDBG_G(watchpoints), (void**) &watch, &position) == SUCCESS; zend_hash_move_forward_ex(&PHPDBG_G(watchpoints), &position)) { - phpdbg_writeln("%.*s", (int)(*watch)->str_len, (*watch)->str); + phpdbg_writeln("watchvariable", "variable=\"%.*s\" on=\"%s\" type=\"%s\"", "%.*s (%s, %s)", (int) (*watch)->str_len, (*watch)->str, (*watch)->type == WATCH_ON_HASHTABLE ? "array" : "variable", (*watch)->flags == PHPDBG_WATCH_RECURSIVE ? "recursive" : "simple"); } + + phpdbg_xml(""); } void phpdbg_watch_efree(void *ptr) { phpdbg_btree_result *result; TSRMLS_FETCH(); - result = phpdbg_btree_find_closest(&PHPDBG_G(watchpoint_tree), (zend_ulong)ptr); + result = phpdbg_btree_find_closest(&PHPDBG_G(watchpoint_tree), (zend_ulong) ptr); if (result) { phpdbg_watchpoint_t *watch = result->ptr; - if ((size_t)watch->addr.ptr + watch->size > (size_t)ptr) { + if ((size_t)watch->addr.ptr + watch->size > (size_t) ptr) { zend_hash_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len); } } diff --git a/phpdbg_watch.h b/phpdbg_watch.h index d00bcff77e5..5c0079057cf 100644 --- a/phpdbg_watch.h +++ b/phpdbg_watch.h @@ -42,9 +42,9 @@ PHPDBG_WATCH(recursive); */ static const phpdbg_command_t phpdbg_watch_commands[] = { - PHPDBG_COMMAND_D_EX(array, "create watchpoint on an array", 'a', watch_array, NULL, "s"), - PHPDBG_COMMAND_D_EX(delete, "delete watchpoint", 'd', watch_delete, NULL, "s"), - PHPDBG_COMMAND_D_EX(recursive, "create recursive watchpoints", 'r', watch_recursive, NULL, "s"), + PHPDBG_COMMAND_D_EX(array, "create watchpoint on an array", 'a', watch_array, NULL, "s", 0), + PHPDBG_COMMAND_D_EX(delete, "delete watchpoint", 'd', watch_delete, NULL, "s", 0), + PHPDBG_COMMAND_D_EX(recursive, "create recursive watchpoints", 'r', watch_recursive, NULL, "s", 0), PHPDBG_END_COMMAND }; diff --git a/phpdbg_webdata_transfer.c b/phpdbg_webdata_transfer.c new file mode 100644 index 00000000000..e7438ea01ab --- /dev/null +++ b/phpdbg_webdata_transfer.c @@ -0,0 +1,185 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#include "phpdbg_webdata_transfer.h" +#include "ext/json/php_json.h" + +PHPDBG_API void phpdbg_webdata_compress(char **msg, int *len TSRMLS_DC) { +#ifdef HAVE_JSON + smart_str buf = {0}; + zval array; + HashTable *ht; + /* I really need to change that to an array of zvals... */ + zval zv1 = {{0}}, *zvp1 = &zv1; + zval zv2 = {{0}}, *zvp2 = &zv2; + zval zv3 = {{0}}, *zvp3 = &zv3; + zval zv4 = {{0}}, *zvp4 = &zv4; + zval zv5 = {{0}}, *zvp5 = &zv5; + zval zv6 = {{0}}, *zvp6 = &zv6; + zval zv7 = {{0}}, *zvp7 = &zv7; + zval zv8 = {{0}}, *zvp8 = &zv8; + + array_init(&array); + ht = Z_ARRVAL(array); + + /* fetch superglobals */ + { + zend_is_auto_global(ZEND_STRL("GLOBALS") TSRMLS_CC); + /* might be JIT */ + zend_is_auto_global(ZEND_STRL("_ENV") TSRMLS_CC); + zend_is_auto_global(ZEND_STRL("_SERVER") TSRMLS_CC); + zend_is_auto_global(ZEND_STRL("_REQUEST") TSRMLS_CC); + array_init(&zv1); + zend_hash_copy(Z_ARRVAL(zv1), &EG(symbol_table), NULL, (void *) NULL, sizeof(zval *)); + Z_ARRVAL(zv1)->pDestructor = NULL; /* we're operating on a copy! Don't double free zvals */ + zend_hash_del(Z_ARRVAL(zv1), "GLOBALS", sizeof("GLOBALS")); /* do not use the reference to itself in json */ + zend_hash_add(ht, "GLOBALS", sizeof("GLOBALS"), &zvp1, sizeof(zval *), NULL); + } + + /* save php://input */ + { + php_stream *stream; + int len; + char *contents; + + stream = php_stream_temp_create_ex(TEMP_STREAM_DEFAULT, SAPI_POST_BLOCK_SIZE, PG(upload_tmp_dir)); + if ((len = php_stream_copy_to_mem(stream, &contents, PHP_STREAM_COPY_ALL, 0)) > 0) { + ZVAL_STRINGL(&zv2, contents, len, 0); + } else { + ZVAL_EMPTY_STRING(&zv2); + } + Z_SET_REFCOUNT(zv2, 2); + zend_hash_add(ht, "input", sizeof("input"), &zvp2, sizeof(zval *), NULL); + } + + /* change sapi name */ + { + if (sapi_module.name) { + ZVAL_STRING(&zv6, sapi_module.name, 0); + } else { + Z_TYPE(zv6) = IS_NULL; + } + Z_SET_REFCOUNT(zv6, 2); + zend_hash_add(ht, "sapi_name", sizeof("sapi_name"), &zvp6, sizeof(zval *), NULL); + } + + /* handle modules / extensions */ + { + HashPosition position; + zend_module_entry *module; + zend_extension *extension; + zend_llist_position pos; + + array_init(&zv7); + for (zend_hash_internal_pointer_reset_ex(&module_registry, &position); + zend_hash_get_current_data_ex(&module_registry, (void**) &module, &position) == SUCCESS; + zend_hash_move_forward_ex(&module_registry, &position)) { + zval **value = emalloc(sizeof(zval *)); + ALLOC_ZVAL(*value); + ZVAL_STRING(*value, module->name, 1); + zend_hash_next_index_insert(Z_ARRVAL(zv7), value, sizeof(zval *), NULL); + } + zend_hash_add(ht, "modules", sizeof("modules"), &zvp7, sizeof(zval *), NULL); + + array_init(&zv8); + extension = (zend_extension *) zend_llist_get_first_ex(&zend_extensions, &pos); + while (extension) { + zval **value = emalloc(sizeof(zval *)); + ALLOC_ZVAL(*value); + ZVAL_STRING(*value, extension->name, 1); + zend_hash_next_index_insert(Z_ARRVAL(zv8), value, sizeof(zval *), NULL); + extension = (zend_extension *) zend_llist_get_next_ex(&zend_extensions, &pos); + } + zend_hash_add(ht, "extensions", sizeof("extensions"), &zvp8, sizeof(zval *), NULL); + } + + /* switch cwd */ + if (SG(options) & SAPI_OPTION_NO_CHDIR) { + char *ret = NULL; + char path[MAXPATHLEN]; + +#if HAVE_GETCWD + ret = VCWD_GETCWD(path, MAXPATHLEN); +#elif HAVE_GETWD + ret = VCWD_GETWD(path); +#endif + if (ret) { + ZVAL_STRING(&zv5, path, 1); + Z_SET_REFCOUNT(zv5, 1); + zend_hash_add(ht, "cwd", sizeof("cwd"), &zvp5, sizeof(zval *), NULL); + } + } + + /* get system ini entries */ + { + HashPosition position; + zend_ini_entry *ini_entry; + + array_init(&zv3); + for (zend_hash_internal_pointer_reset_ex(EG(ini_directives), &position); + zend_hash_get_current_data_ex(EG(ini_directives), (void**) &ini_entry, &position) == SUCCESS; + zend_hash_move_forward_ex(EG(ini_directives), &position)) { + zval **value = emalloc(sizeof(zval *)); + if (ini_entry->modified) { + if (!ini_entry->orig_value) { + efree(value); + continue; + } + ALLOC_ZVAL(*value); + ZVAL_STRINGL(*value, ini_entry->orig_value, ini_entry->orig_value_length, 1); + } else { + if (!ini_entry->value) { + efree(value); + continue; + } + ALLOC_ZVAL(*value); + ZVAL_STRINGL(*value, ini_entry->value, ini_entry->value_length, 1); + } + zend_hash_add(Z_ARRVAL(zv3), ini_entry->name, ini_entry->name_length, value, sizeof(zval *), NULL); + } + zend_hash_add(ht, "systemini", sizeof("systemini"), &zvp3, sizeof(zval *), NULL); + } + + /* get perdir ini entries */ + if (EG(modified_ini_directives)) { + HashPosition position; + zend_ini_entry *ini_entry; + + array_init(&zv4); + for (zend_hash_internal_pointer_reset_ex(EG(modified_ini_directives), &position); + zend_hash_get_current_data_ex(EG(modified_ini_directives), (void**) &ini_entry, &position) == SUCCESS; + zend_hash_move_forward_ex(EG(modified_ini_directives), &position)) { + zval **value = emalloc(sizeof(zval *)); + if (!ini_entry->value) { + efree(value); + continue; + } + ALLOC_ZVAL(*value); + ZVAL_STRINGL(*value, ini_entry->value, ini_entry->value_length, 1); + zend_hash_add(Z_ARRVAL(zv4), ini_entry->name, ini_entry->name_length, value, sizeof(zval *), NULL); + } + zend_hash_add(ht, "userini", sizeof("userini"), &zvp4, sizeof(zval *), NULL); + } + + /* encode data */ + php_json_encode(&buf, &array, 0 TSRMLS_CC); + *msg = buf.c; + *len = buf.len; + zval_dtor(&array); +#endif +} diff --git a/phpdbg_webdata_transfer.h b/phpdbg_webdata_transfer.h new file mode 100644 index 00000000000..d70175ad99d --- /dev/null +++ b/phpdbg_webdata_transfer.h @@ -0,0 +1,27 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Bob Weinand | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHPDBG_WEBDATA_TRANSFER_H +#define PHPDBG_WEBDATA_TRANSFER_H + +#include "zend.h" +#include "phpdbg.h" + +PHPDBG_API void phpdbg_webdata_compress(char **msg, int *len TSRMLS_DC); + +#endif /* PHPDBG_WEBDATA_TRANSFER_H */ diff --git a/tests/commands/0002_set.test b/tests/commands/0002_set.test index 468ac6d9ea0..6a14a15adc2 100644 --- a/tests/commands/0002_set.test +++ b/tests/commands/0002_set.test @@ -8,7 +8,7 @@ # setting error color # setting notice color # Failed to find breakpoint #0 -# oplog disabled +# [Oplog off] # opened oplog test.log # nothing ################################################# diff --git a/tests/commands/0102_print.test b/tests/commands/0102_print.test index de4acb7651b..c174564e07f 100644 --- a/tests/commands/0102_print.test +++ b/tests/commands/0102_print.test @@ -4,15 +4,14 @@ # expect: TEST::FORMAT # options: -rr ################################################# -#[User Class: test] -#Methods (3): +#[User Class: test (3 methods)] #L%d-%d test::testMethod() %s # L%d %s ZEND_RETURN C%d # L%d-%d test::testPrivateMethod() %s # L%d %s ZEND_RETURN C%d # L%d-%d test::testProtectedMethod() %s # L%d %s ZEND_RETURN C%d -#[User Method testMethod] +#[User Method testMethod (1 ops)] # L%d-%d test::testMethod() %s # L%d %s ZEND_RETURN C%d ################################################# diff --git a/tests/commands/0104_clean.test b/tests/commands/0104_clean.test index c7a579be179..d50903c479e 100644 --- a/tests/commands/0104_clean.test +++ b/tests/commands/0104_clean.test @@ -4,11 +4,11 @@ # expect: TEST::FORMAT # options: -rr ################################################# -#[Cleaning Execution Environment] -#Classes %d -#Functions %d -#Constants %d -#Includes %d +#Cleaning Execution Environment +#Classes %d +#Functions %d +#Constants %d +#Includes %d #[Nothing to execute!] ################################################# clean diff --git a/tests/commands/0105_clear.test b/tests/commands/0105_clear.test index b547b0d6ba1..8ce10024913 100644 --- a/tests/commands/0105_clear.test +++ b/tests/commands/0105_clear.test @@ -4,7 +4,7 @@ # expect: TEST::FORMAT # options: -rr ################################################# -#[Clearing Breakpoints] +#Clearing Breakpoints #File%w%d #Functions%w%d #Methods%w%d diff --git a/tests/commands/0106_compile.test b/tests/commands/0106_compile.test index 7193600ea3d..b4d801670bc 100644 --- a/tests/commands/0106_compile.test +++ b/tests/commands/0106_compile.test @@ -4,9 +4,9 @@ # expect: TEST::FORMAT # options: -rr ################################################# -#[Attempting compilation of %s] -#[Success] +#[Successful compilation of %s] #Hello World +#[Script ended normally] ################################################# <: define('OUT', diff --git a/xml.md b/xml.md new file mode 100644 index 00000000000..0556fb24152 --- /dev/null +++ b/xml.md @@ -0,0 +1,759 @@ +phpdbg XML format +================= + +Common attributes +================= + +severity +-------- + +- indicates the genre of phpdbg system output +- usually one of these values: + - normal + - notice + - error + +msgout +------ + +- text message output related to the xml data (e.g. <intro severity="normal" help="help" msgout="To get help using phpdbg type &quot;help&quot; and press enter" />) + +req +--- + +- the request id, if one was passed to the last command (via -r %d, where %d is the id) (and the output is related to that message) + +file +---- + +- refers to a filename + +method +------ + +- format classname::methodname +- refers to a method + +function +-------- + +- refers to a function + +symbol +------ + +- either function or method (is method if "::" are present) + +opline +------ + +- in hexadecimal format +- refers to a specific pointer to a (zend_)op + +opcode +------ + +- refers to an opcode (ZEND_*) + +type +---- + +- general attribute for most errors, describes the genre of the error + + +General tags +============ + +intro +----- + +- appears on startup if -q flag wasn't provided as command line arg +- before any input possibility +- attributes may be spread over multiple tags +- wrapped in <intros> tag + +### attributes ### + +- version: current phpdbg version (as string) +- help: command name for help +- report: URL for bug reporting + +prompt +------ + +- msg tag contains the text prompt +- indicates that a new command may be accepted + +phpdbg +------ + +- general text message output from phpdbg system + +stream +------ + +- any output by PHP itself (e.g. <stream type="stdout">test</stream>) + +### attributes ### + +- type: stderr or stdout + +php +--- + +- php error output + +### attributes ### + +- msg: the error message + + +General error tags +================== + +command +------- + +- general errors about commands + +### possible attributes ### + +- type + - toomanyargs: more arguments than allowed + - noarg: argument missing + - wrongarg: wrong type of argument (e.g. letters instead of integer) + - toofewargs: not enough arguments + - notfound: command (or subcommand) doesn't exist + - ambiguous: command was ambiguous + - invalidcommand: command input is totally invalid + - (nostack: should not happen: is an internal error) + - (emptystack: should not happen: is an internal error) +- command: passed command +- subcommand: passed subcommand (present if the error is related to the subcommand) +- expected: count of expected arguments +- got: type of argument for type "wrongarg" +- num: if possible, information about which parameter had a wrong argument + +inactive +-------- + +- by type + - op_array: nothing was yet compiled (probably because no execution context set) + - symbol_table: no symbol table present (not yet initiailized or already destructed) + - noexec: not in execution + - memory_manager: using the native memory manager (malloc, free, realloc) instead of e.g. the Zend MM + - notfound: file not found + - nocontext: execution context was not set (or compilation had failed) + - isrunning: command requires no running script + + +Commands +======== + +export +------ + +- tag: <exportbreakpoint /> +- usually triggered by successful export command +- may appear when cleaning to temporary store breakpoints +- errors by type + - openfailure: could not create file + +### attributes ### + +- count: number of exported breakpoints + +break / info break +------------------ + +- General tag for breakpoint creation, deletion and hits is "<breakpoint />" + +### possible attributes ### + +- id: the breakpoint id (if the leave command was executed, the id has the value "leave") +- num: the nth opline of a function/method/file +- add: has value "success"/"fail": a brekpoint was successfully/not added +- pending: the breakpoint is waiting for resolving (e.g. a file opline on a not yet loaded file) +- deleted: has value "success"/"fail": a breakpoint was successfully/not deleted +- eval: the condition on conditional breakpoints +- file +- opline +- opcode +- symbol +- function +- method +- line + + +- listing breakpoints always in a container element "<breakpoints>" + - Child nodes: + - function + - method + - file + - opline + - methodopline + - functionopline + - fileopline + - evalfunction + - evalfunctionopline + - evalmethod + - evalmethodopline + - evalfile + - evalopline + - eval + - opcode + - attributes: + - name: name of the symbol (function/method/file/opcode) + - disabled: empty value if enabled, non-empty if enabled + +- errors (by type) + - exists: the breakpoint already exists + - maxoplines: tries to break at an opline (usedoplinenum) higher than the number of present oplines (in maxoplinenum) + - nomethod: method doesn't exist + - internalfunction: one cannot break on an opline of an internal function + - notregular: tries to set a breakpoint in not a regular file + - (invalidparameter: should not happen: is an internal error) + +frame +----- + +- General tag for frames is "<frame>" +- always has id attribute; if it only has id attribute, it just indicates current frame number, no other elements follow +- may contain other elements (of type <arg>) when contained in <backtrace> tag +- <arg> always contains a <stream> element, the value of the variable + +### possible attributes ### + +- id: the frame id, current frame has id 0 (frames with internal function calls have the same id than their called frame) +- symbol ("{main}" is root frame) +- file +- line +- internal: has value "internal" when being an internal function call (one cannot inspect that frame) + +- being an error: (by type) + - maxnum: tried to access a frame with a number heigher than existing (or < 0) + +### attributes on <arg> ### + +- variadic: has a non-empty value if the argument is variadic +- name: variable name of parameter + +info (subcommands) +------------------ + +### break ### + +- See above ("break / info break") + +### files ### + +- lists included files +- <includedfileinfo num="" /> with num having an integer value, indicating the number of included files +- <includedfile name=""/>: one per file, with name being the file path of the included file + +### error ### + +- gets last error +- <lasterror error="" (file="" line="") /> +- error attribute contains the last error as a string, is empty if there's no last error + +### constants ### + +- <constantinfo num="" /> with num having an integer value, indicating the number of (local or superglobal) variables +- if info vars was used it'll have also one of these attributes: + - method + - function + - file + - opline +- for each variable there is a <constant> element +- <constant address="" refcount="" type="" name="" /> + - address: pointer to zval (hexadecimal) + - refcount: refcount of zval + - type: the variable type (long, string, ...). If the value is "unknown", the other attributes are meaningless + - name: the name of the variable + - value: the value of primitive types (scalars) => string/int/bool/double + - length: if string, then the length of that string + +### vars / globals ### + +- <variableinfo num="" /> with num having an integer value, indicating the number of (local or superglobal) variables +- if info vars was used it'll have also one of these attributes: + - method + - function + - file + - opline +- for each variable there is a <variable> element +- <variable address="" refcount="" type="" name="" /> + - address: pointer to zval (hexadecimal) + - refcount: refcount of zval + - type: the variable type (long, string, ...). If the value is "unknown", the other attributes are meaningless + - name: the name of the variable + - refstatus: empty if the zval is not a reference + - class: the class the object in the zval is an instance of + - resource: the type of the resource in the zval + - value: the value of primitive types (scalars) => string/int/bool/double + - length: if string, then the length of that string + +### literal ### + +- <literalinfo num="" /> with num having an integer value, indicating the number of literals, optional arguments are: + - method + - function + - file + - opline +- for each literal there is a <literal> followed by a <stream type="stdout"> which prints the value of the literal +- <literal id="" />: where id is the internal identifier of the literal + +### memory ### + +- Format: + + <meminfo /> + <current /> + <used mem="" /> + <real mem="" /> + <peak /> + <used mem="" /> + <real mem="" /> + +- mem is an attribute whose value is a float. The memory is given in kilobytes (1 kB == 1024 bytes) + +### classes ### + +- <classinfo num="" /> with num having an integer value, indicating the number of loaded user-defined classes +- Each class is enumerated with first a <class>, then an optional <parents> container and then a <classsource> element +- The <parents> container contains the <class> elements of the parent of the last <class> element. +- <class type="" flags="" name="" methodcount="" /> + - type: either "User" or "Internal" + - flags: either "Interface", "Class" or "Abstract Class" +- <classsource /> where the class was defined, if there are no attributes, location is unknown, usually defined by + - file + - line + +### funcs ### + +- <functioninfo num="" /> with num having an integer value, indicating the number of loaded user-defined functions +- Each class is enumerated with first a <function> and then a <functionsource> element +- <function name="" /> +- <functionsource /> where the function was defined, if there are no attributes, location is unknown, usually defined by + - file + - line + +list +---- + +- consists of <line> elements wrapped in a <list> container +- <list file=""> is the container element with file being the filename +- <line line="" code="" /> with value of code being the whole line of code in the line specified in the line attribute + - current: this attribute is set to "current" if that line is the line where the executor currently is + +print +----- + +### without a subcommand ### + +- <print> elements are wrapped in a <printinfo> element +- there may be a variable number of <print> elements with a variable count of args inside the <printinfo> element +- possible args are: + - readline: yes/no - readline enabled or disabled + - libedit: yes/no - libedit enabled or disabled + - context: current executing context + - compiled: yes/no - are there actual compiled ops? + - stepping: @@ TODO (meaningless for now) @@ + - quiet: on/off - should it always print the opline being currently executed? + - oplog: on/off - are oplines logged in a file? + - ops: number of opcodes in current executing context + - vars: number of compiled variables (CV) + - executing: yes/no - in executor? + - vmret: the return value of the last executed opcode + - default: continue + - 1: return from vm + - 2: enter stack frame + - 3: leave stack frame + - classes: number of classes + - functions: number of functions + - constants: number of constants + - includes: number of included files + +### with a subcommand ### + +- introduced by <printinfo num="" /> (except for print opline) with num being the number of opcodes and one of these args: + - file + - method + - function + - class (then also type and flags attributes, see info classes command for their meanings) + - symbol (also type and flags attributes; here the value of flags is either "Method" or "Function") +- if there is a class method, the methods are all wrapped in a <printmethods> container +- then comes a <printoplineinfo type="" /> where type is either "User" or "Internal" +- the <printoplineinfo> has either a method or a function attribute +- if the type is "Internal" + - there are no oplines, it's an internal method or function +- if the type is "User" + - it has these attributes + - startline: the first line of code where the method or function is defined + - endline: the lastt line of code where the method or function is defined + - file: the file of code where the method or function is defined + - is followed by the oplines of that method or function (<print> elements) +- <print line="%u" opline="%p" opcode="%s" op="%s" /> +- in case of print opline it emits a single <opline line="" opline="" opcode="" op="" file="" /> + +exec +---- + +- command executing and compiling a given file + - <exec type="unset" context="" />: indicates unsetting of the old context + - <exec type="unsetops" />: indicates unsetting of the old compiled opcodes + - <exec type="unchanged" />: same execution context choosen again + - <exec type="set" context="" />: indicates setting of the new context +- errors by tag + - <compile> + - openfailure: couldn't open file + - compilefailure: The file indicated in context couldn't be compiled + - <exec> + - invalid: given context (attribute) is not matching a valid file or symlink + - notfound: given context (attribute) does not exist + +run / <stop> tag +------------------- + +- runs the script (set via exec command) +- <stop type="end" />: script execution ended normally +- (error) <stop type="bailout" /> the VM bailed out (usually because there was some error) +- compile failures see under exec, errors, <compile> + +step +---- + +- steps by one line or opcode (as defined via set stepping) default is one line +- returns back to the executor + +continue +-------- + +- returns back to the executor + +until +----- + +- temporarily disables all the breakpoints on that line until that line was left once +- returns back to the executor + +finish +------ + +- temporarily disables all the breakpoints until the end of the current frame +- returns back to the executor + +leave +------ + +- temporarily disables all the breakpoints past the end of the current frame and then stops +- returns back to the executor + +back +---- + +- prints backtrace +- see frame command + +ev +-- + +- eval()uates some code +- output wrapped in <eval> tags +- output is here first a dump of xml tags (see "Variable Dump" section), then a dump wrapped in tags +- if there's an error, the tag will be , instead of the usual tag + +sh +-- + +- executes shell command +- still pipes to stdout ... without wrapping <stream> !!! (@@ TODO @@) + +source +------ + +- executes a file in .phpdbginit format +- errors by type + - notfound: file not found + +register +-------- + +- registers a function to be used like a command +- <register function="" />: successfully registered function +- errors by type + - notfound: no such function + - inuse: function already registered + +quit +---- + +- quits phpdbg +- if successful connection will be closed... + +clean +----- + +- cleans environment (basically a shutdown + new startup) +- <clean> tags wrapped in a <cleaninfo> container +- possible attributes of <clean> tag + - classes: number of classes + - functions: number of functions + - constants: number of constants + - includes: number of included files + +clear +----- + +- removes all breakpoints +- <clear> tags wrapped in a <clearinfo> container +- possible attributes of <clear> tag (value is always the number of defined breakpoints of that type) + - files + - functions + - methods + - oplines + - fileoplines + - functionoplines + - methodoplines + - eval + +watch +----- + +- watchpoints generally are identified by a variable (one may need to switch frames first...) +- <watch variable="" />, <watchrecursive variable="" /> and <watcharray variable="" /> (normal, array, recursive) +- <watch> if error, by type: + - undefined: tried to set a watchpoint on a not (yet) defined variable + - notiterable: element which is tried to be accessed as an object or array is nor array nor object + - invalidinput: generally malformed input +- <watchdelete variable="" />: when "watch delete" was used on a watchpoint +- (error) <watchdelete type="nowatch" />: that watchpoint doesn't exist, so couldn't be deleted +- for hit watchpoints etc., see Other tags, <watch*> +- when using watch list, <watchvariable> elements are wrapped in a <watchlist> container + - <watchvariable variable="" on="" type="" /> + - variable: watched variable (may be a variable of another scope!) + - on: values are array or variable, depending on what is watched + - type: values are recursive or simple, depending on whether the watchpoint is checked recursively or not + +set +--- + +- a general error is type="wrongargs" where a wrong argument was passed to a subcommand; tag is then <set*> + +### prompt ### + +- without other args, a <setpromt str="" /> tag is emitted where the value of the str attribue is the value of the prompt +- when there is another arg, the prompt is changed to that arg, no further xml answer + +### break ### + +- enables / disables a given breakpoint silently with no further xml answer +- if the boolean switch is omitted, it emits current state in a <setbreak id="" active="" /> where active is on or off +- error with type="nobreak", when no breakpoint with the given id exists + +### breaks ### + +- generally enables / disables breakpoint functionality silently with no futher xml answer +- if the boolean switch is omitted, it emits current state in a <setbreaks active="" /> where active is on or off + +### color ### + +- sets the color on prompt, error or notices +- <setcolor type="" color="" code="" />: code is the color code of color, type is either: + - prompt + - error + - notice +- errors by type: + - nocolor: color doesn't exist + - invalidtype: type wasn't one of the three allowed types + +### colors ### + +- generally enables / disables colors silently with no further xml answer +- if the boolean switch is omitted, it emits current state in a <setcolors active="" /> where active is on or off + +### oplog ### + +- sets oplog +- (error) <setoplog type="openfailure" file="" /> when it couldn't open the passed file path +- <setoplog type="closingold" /> is emitted when there was a previous open oplog (and a file is passed) +- if no further argument is passed, it emits current state in a <setoplog active="" /> where active is on or off + +### quiet ### + +- generally enables / disables quietness silently with no further xml answer +- if the boolean switch is omitted, it emits current state in a <setquiet active="" /> where active is on or off + +### setpping ### + +- sets stepping to either opcode or line (so a step command will either advance one op or one line) +- if no further argument is passed, it emits current state in a <setoplog type="" /> where active is opcode or line + +### refcount ### + +- generally enables / disables showing of refcount in watchpoint breaks silently with no further xml answer +- if the boolean switch is omitted, it emits current state in a <setrefcount active="" /> where active is on or off + +wait +---- + +- internally executes exec, so exec will output first (if binding to socket worked) + +### attributes ### + +- import: has value "success"/"fail" +- missingmodule/missingextension: modules/extensions loaded in the target SAPI, but not in phpdbg + +### errors (by type) ### + +- nosocket: couldn't establish socket +- invaliddata: invalid JSON passed to socket + +dl +-- + +- loads a module or Zend extension at a given path +- if a relative path is passed, it's relative to the extension_dir ini setting + +### attributes ### + +- extensiontype: "Zend extension" or "module" +- name: the extension name +- path: the path where it was loaded + +### errors (by type) ### + +- unsupported: dynamic extension loading is unsupported +- relpath: relative path given, but no extension_dir defined +- unknown: general error with internal DL_LOAD() (for message see msg attribute) +- wrongapi: wrong Zend engine version (apineeded / apiinstalled attributes give information about the API versions) +- wrongbuild: unmatched build versions (buildneeded / buildinstalled attributes give information about the build versions) +- registerfailure: registering module failed +- startupfailure: couldn't startup Zend extension / module +- initfailure: couldn't initialize module +- nophpso: passed shared object is not a valid Zend extension nor module + +- errors may have the module or extension attribute when their name is already known at the point of failure + + +Other tags +========== + +<signal> +----------- + +- received caught signal + +### attributes ### + +- type: type of signal (e.g. SIGINT) + +### by type ### + +- SIGINT: interactive mode is entered... + +<watch*> +----------- + +- generally emitted on hit watchpoint +- <watchdelete variable="" />: when a variable was unset, the watchpoint is removed too +- <watchhit variable="" />: when ever a watched variable is changed, followed by a <watchdata> container +- <watchdata> may contain + - for watchpoints on variables: + - each of these <watch*> tags conatins a type attribute whose value is either "old" or "new") + - <watchvalue type="" inaccessible="inaccessible" />: old value is inaccessible + - <watchvalue type=""> may contain a <stream> element which indicates the old/new (type attribute) value of the variable + - <watchrefcount type="" refcount="" isref="" />: old/new (type attribute) refcount and isref, both numbers + - isref: if the value is 0, it's not a reference, else it is one + - for watchpoints on arrays: + - <watchsize> inspects size variations of an array (the sum): + - removed: number of elements removed + - added: number of elements added + - <watcharrayptr>: if this tag appears, the internal pointer of the array way changed + +<signalsegv> +--------------- + +- generally emitted when data couldn't be fetched (e.g. by accessing inconsistent data); only used in hard interrupt mode +- it might mean that data couldn't be fetched at all, or that only incomplete data was fetched (e.g. when a fixed number of following attributes are fetched, this tag will mark a stop of fetching if none or not all tags were printed) + + +Variable Dump +============= + +- all except property and element tags have a refstatus attribute, is set to non-empty if it's a reference + +object properties +----------------- + +- wrapped in a property tag <property name="" protection=""> + - name: name of key + - protection: one of these three values: public / protected / private + - class: only present if protection attribute is set to "private", contains the name of the class to which the property belongs +- if the property tag contains any serverity="error" attribute, there was some crucial error to read it, just skip it + +array elements +-------------- +- wrapped in an element tag <property name="" protection=""> + - name: name of key +- if the element tag contains any serverity="error" attribute, there was some crucial error to read it, jsut skip it + +int +--- + +- <int refstatus="" value="" /> + - value is the integer + +float +----- + +- <float refstatus="" value="" /> + - value is the float + +bool +---- + +- <bool refstatus="" value="" /> + -value: true or false + +string +------ + +- <string refstatus="" length="" value="" /> + - length: length or string + - value: the string + +null +---- + +- <null refstatus="" /> + +array +----- + +- <array refstatus="" num=""> + - num: number of elements + - contains <element> tags + +object +------ + +- <object refstatus="" class="" id="" num=""> + - class: name of the class the object is an instance of (may be empty if unknown) + - id: id of the object + - num: number of properties + - contains <property> tags + +resource +-------- + +- <resource refstatus="" id="" type="" /> + - id: resource id + - type: type of resource + +recursion +--------- + +- <recursion /> +- if that tag appears, there's a recursive reference inside the value to be printed diff --git a/zend_mm_structs.h b/zend_mm_structs.h new file mode 100644 index 00000000000..ca64069e0f8 --- /dev/null +++ b/zend_mm_structs.h @@ -0,0 +1,102 @@ +#ifndef ZEND_MM_STRUCTS_H +#define ZEND_MM_STRUCTS_H + +/* structs and macros defined in Zend/zend_alloc.c + Needed for realizing watchpoints and sigsafe memory */ + +#include "zend.h" + +#ifndef ZEND_MM_COOKIES +# define ZEND_MM_COOKIES ZEND_DEBUG +#endif + +#define ZEND_MM_CACHE 1 +#ifndef ZEND_MM_CACHE_STAT +# define ZEND_MM_CACHE_STAT 0 +#endif + +typedef struct _zend_mm_block_info { +#if ZEND_MM_COOKIES + size_t _cookie; +#endif + size_t _size; + size_t _prev; +} zend_mm_block_info; + +typedef struct _zend_mm_small_free_block { + zend_mm_block_info info; +#if ZEND_DEBUG + unsigned int magic; +#ifdef ZTS + THREAD_T thread_id; +#endif +#endif + struct _zend_mm_free_block *prev_free_block; + struct _zend_mm_free_block *next_free_block; +} zend_mm_small_free_block; + +typedef struct _zend_mm_free_block { + zend_mm_block_info info; +#if ZEND_DEBUG + unsigned int magic; +#ifdef ZTS + THREAD_T thread_id; +#endif +#endif + struct _zend_mm_free_block *prev_free_block; + struct _zend_mm_free_block *next_free_block; + + struct _zend_mm_free_block **parent; + struct _zend_mm_free_block *child[2]; +} zend_mm_free_block; + +#define ZEND_MM_SMALL_FREE_BUCKET(heap, index) \ + (zend_mm_free_block *) ((char *)&heap->free_buckets[index * 2] + \ + sizeof(zend_mm_free_block *) * 2 - \ + sizeof(zend_mm_small_free_block)) + +#define ZEND_MM_REST_BUCKET(heap) \ + (zend_mm_free_block *)((char *)&heap->rest_buckets[0] + \ + sizeof(zend_mm_free_block *) * 2 - \ + sizeof(zend_mm_small_free_block)) + +#define ZEND_MM_NUM_BUCKETS (sizeof(size_t) << 3) +struct _zend_mm_heap { + int use_zend_alloc; + void *(*_malloc)(size_t); + void (*_free)(void *); + void *(*_realloc)(void *, size_t); + size_t free_bitmap; + size_t large_free_bitmap; + size_t block_size; + size_t compact_size; + zend_mm_segment *segments_list; + zend_mm_storage *storage; + size_t real_size; + size_t real_peak; + size_t limit; + size_t size; + size_t peak; + size_t reserve_size; + void *reserve; + int overflow; + int internal; +#if ZEND_MM_CACHE + unsigned int cached; + zend_mm_free_block *cache[ZEND_MM_NUM_BUCKETS]; +#endif + zend_mm_free_block *free_buckets[ZEND_MM_NUM_BUCKETS*2]; + zend_mm_free_block *large_free_buckets[ZEND_MM_NUM_BUCKETS]; + zend_mm_free_block *rest_buckets[2]; + int rest_count; +#if ZEND_MM_CACHE_STAT + struct { + int count; + int max_count; + int hit; + int miss; + } cache_stat[ZEND_MM_NUM_BUCKETS+1]; +#endif +}; + +#endif From a1a18fca6e2a1690ea113dc2ebe0e7d22fdc71a0 Mon Sep 17 00:00:00 2001 From: STANLEY SUFFICOOL Date: Fri, 24 Oct 2014 20:10:04 -0700 Subject: [PATCH 048/398] Fixed Bug #52885 - PDO_DBLIB: Binary data may be truncated Data containing characters in conflict with the server codepage or containing null char will throw an error. Implement binary quoting to allow binding of binary values. --- ext/pdo_dblib/dblib_driver.c | 71 +++++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 22 deletions(-) diff --git a/ext/pdo_dblib/dblib_driver.c b/ext/pdo_dblib/dblib_driver.c index 323c805fca7..a433e8652c3 100644 --- a/ext/pdo_dblib/dblib_driver.c +++ b/ext/pdo_dblib/dblib_driver.c @@ -144,30 +144,58 @@ static zend_long dblib_handle_doer(pdo_dbh_t *dbh, const char *sql, zend_long sq static int dblib_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, char **quoted, int *quotedlen, enum pdo_param_type paramtype TSRMLS_DC) { - - /* pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data; */ - - char *q; - int l = 1; - - *quoted = q = safe_emalloc(2, unquotedlen, 3); - *q++ = '\''; - while (unquotedlen--) { - if (*unquoted == '\'') { - *q++ = '\''; - *q++ = '\''; - l += 2; - } else { - *q++ = *unquoted; - ++l; + int useBinaryEncoding = 0; + const char * hex = "0123456789abcdef"; + int i; + char * q; + *quotedlen = 0; + + /* + * Detect quoted length and if we should use binary encoding + */ + for(i=0;i unquoted[i] || 127 < unquoted[i] ) { + useBinaryEncoding = 1; + break; } - unquoted++; + if(unquoted[i] == '\'') ++*quotedlen; + ++*quotedlen; + } + + if(useBinaryEncoding) { + /* + * Binary safe quoting + * Will implicitly convert for all data types except Text, DateTime & SmallDateTime + * + */ + *quotedlen = (unquotedlen * 2) + 2; /* 2 chars per byte +2 for "0x" prefix */ + q = *quoted = emalloc(*quotedlen); + + *q++ = '0'; + *q++ = 'x'; + for (i=0;i>4)&0xF]; + *q++ = hex[ (*unquoted++)&0xF]; + } + } else { + /* Alpha/Numeric Quoting */ + *quotedlen += 2; /* +2 for opening, closing quotes */ + q = *quoted = emalloc(*quotedlen); + *q++ = '\''; + + for (i=0;ilink, 1)) , (dbdata(H->link, 1)) , (dbdatlen(H->link, 1)), SQLCHAR, id, (DBINT)-1); + *len = dbconvert(NULL, (dbcoltype(H->link, 1)) , (dbdata(H->link, 1)) , (dbdatlen(H->link, 1)), SQLCHAR, (BYTE *)id, (DBINT)-1); dbcancel(H->link); return id; @@ -285,7 +313,6 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_ { pdo_dblib_db_handle *H; int i, nvars, nvers, ret = 0; - int *val; const pdo_dblib_keyval tdsver[] = { {"4.2",DBVERSION_42} From f35e6a839463b2aa98bf6f6036ebfcc9ff465c3d Mon Sep 17 00:00:00 2001 From: STANLEY SUFFICOOL Date: Fri, 24 Oct 2014 20:30:18 -0700 Subject: [PATCH 049/398] Update PDO_DBLIB README file --- ext/pdo_dblib/README | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/ext/pdo_dblib/README b/ext/pdo_dblib/README index 888ffb676f1..15f8d147a01 100644 --- a/ext/pdo_dblib/README +++ b/ext/pdo_dblib/README @@ -1,25 +1,12 @@ This is the unified Sybase-DB style driver for PDO. -There are three implementations of this library that are known to me: - -- The Sybase DB lib itself -- MSSQL DB lib -- FreeTDS DB lib - -This extension will compile and register itself as 'mssql' when built against -the mssql libraries (and be named php_pdo_mssql.dll), or 'sybase' otherwise -(php_pdo_sybase.dll) - -If you want to try out the free "desktop" version of SQL Server, known as the MSDE, google to obtain the appropriate download link. Here are some short tips on getting it running: - -- Download it and run it to extract it -- Open up a command prompt -- cd \MSDERelA -- setup.exe SQLSECURITY=1 SAPWD=yoursecretpassword -- cd \Program Files\Microsoft SQL Server\80\Tools\Binn -- SVRNETCN.exe -- enable TCP (you MUST do this if you want to access it via FreeTDS/Sybase libs) -- net start mssqlserver - -Consult the MS docs for more information about all this stuff. +This extension register itself as: + - 'mssql' when built against the Microsoft DBLIB library + - 'sybase' when built against Sybase ct-lib + - 'dblib' when built against FreeTDS +The following database products are free for testing: + - Microsoft SQL Server Express (Windows Only) + - Sybase Adaptive Server (Windows, Linux, *NIX) + - Microsoft SQL Server Azure (One Month Trial Cloud Service) + From 5b295bf19161b14d6c81151fd89c2f17bd50525c Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 22 Oct 2014 15:37:04 +0200 Subject: [PATCH 050/398] Fix bug #68283: fileinfo: out-of-bounds read in elf note headers Upstream commit https://github.com/file/file/commit/39c7ac1106be844a5296d3eb5971946cc09ffda0 CVE -2014-3710 (cherry picked from commit 1803228597e82218a8c105e67975bc50e6f5bf0d) --- ext/fileinfo/libmagic/readelf.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ext/fileinfo/libmagic/readelf.c b/ext/fileinfo/libmagic/readelf.c index 1c3845fc6b1..bb6f70fb8b7 100644 --- a/ext/fileinfo/libmagic/readelf.c +++ b/ext/fileinfo/libmagic/readelf.c @@ -372,6 +372,13 @@ donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size, uint32_t namesz, descsz; unsigned char *nbuf = CAST(unsigned char *, vbuf); + if (xnh_sizeof + offset > size) { + /* + * We're out of note headers. + */ + return xnh_sizeof + offset; + } + (void)memcpy(xnh_addr, &nbuf[offset], xnh_sizeof); offset += xnh_sizeof; From ec3d25fcbda6109c4ae353b768d59e25af854712 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Sat, 25 Oct 2014 11:29:53 +0200 Subject: [PATCH 051/398] NEWS --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index e111df21670..abcaa7b461e 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,8 @@ PHP NEWS - Fileinfo: . Fixed bug #66242 (libmagic: don't assume char is signed). (ArdB) + . Fixed bug #68283 (fileinfo: out-of-bounds read in elf note headers). + (CVE-2014-3710) (Remi) - GD: . Fixed bug #65171 (imagescale() fails without height param). (Remi) From e75e003ae44bd501e05508128b8a52d364196918 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Sat, 25 Oct 2014 11:30:53 +0200 Subject: [PATCH 052/398] NEWS --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index b1d56ac0f5b..2b68ac14933 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,8 @@ PHP NEWS . Fixed bug #66242 (libmagic: don't assume char is signed). (ArdB) . Fixed bug #68224 (buffer-overflow in libmagic/readcdf.c caught by AddressSanitizer). (Remi) + . Fixed bug #68283 (fileinfo: out-of-bounds read in elf note headers). + (CVE-2014-3710) (Remi) - FPM: . Fixed bug #65641 (PHP-FPM incorrectly defines the SCRIPT_NAME variable From 270df3ffd6c29296a32899690dcb6dbf29cba693 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sat, 25 Oct 2014 12:01:58 +0200 Subject: [PATCH 053/398] updated libmagic.patch in 5.5 --- ext/fileinfo/libmagic.patch | 204 +++++++++++++++++++++++++++--------- 1 file changed, 156 insertions(+), 48 deletions(-) diff --git a/ext/fileinfo/libmagic.patch b/ext/fileinfo/libmagic.patch index a91a6583975..14409852bfd 100644 --- a/ext/fileinfo/libmagic.patch +++ b/ext/fileinfo/libmagic.patch @@ -1,6 +1,6 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c --- libmagic.orig/apprentice.c Thu Mar 21 18:45:14 2013 -+++ libmagic/apprentice.c Mon Apr 14 23:42:51 2014 ++++ libmagic/apprentice.c Mon Sep 29 10:53:07 2014 @@ -29,6 +29,8 @@ * apprentice - make one pass through /etc/magic, learning its secrets. */ @@ -479,6 +479,15 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c return NULL; } return map; +@@ -1233,7 +1269,7 @@ + * the sign extension must have happened. + */ + case FILE_BYTE: +- v = (char) v; ++ v = (signed char) v; + break; + case FILE_SHORT: + case FILE_BESHORT: @@ -1500,7 +1536,7 @@ if (me->cont_count == me->max_count) { struct magic *nm; @@ -833,7 +842,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c } diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c --- libmagic.orig/ascmagic.c Wed Oct 31 18:03:01 2012 -+++ libmagic/ascmagic.c Mon Apr 14 23:42:51 2014 ++++ libmagic/ascmagic.c Mon Mar 10 16:40:55 2014 @@ -139,7 +139,7 @@ /* malloc size is a conservative overestimate; could be improved, or at least realloced after conversion. */ @@ -872,7 +881,7 @@ diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c } diff -u libmagic.orig/cdf.c libmagic/cdf.c --- libmagic.orig/cdf.c Thu Mar 21 18:45:14 2013 -+++ libmagic/cdf.c Tue Jul 1 09:00:09 2014 ++++ libmagic/cdf.c Wed Aug 20 21:20:34 2014 @@ -43,7 +43,17 @@ #include #endif @@ -955,7 +964,7 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c errno = EFTYPE; return (size_t)-1; } -@@ -796,7 +812,11 @@ +@@ -796,11 +812,15 @@ if (cdf_check_stream_offset(sst, h, e, 0, __LINE__) == -1) goto out; for (i = 0; i < sh.sh_properties; i++) { @@ -968,6 +977,11 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c q = (const uint8_t *)(const void *) ((const char *)(const void *)p + ofs - 2 * sizeof(uint32_t)); +- if (q > e) { ++ if (q < p || q > e) { + DPRINTF(("Ran of the end %p > %p\n", q, e)); + goto out; + } @@ -810,6 +830,10 @@ i, inp[i].pi_id, inp[i].pi_type, q - p, offs)); if (inp[i].pi_type & CDF_VECTOR) { @@ -1056,7 +1070,7 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c } else { diff -u libmagic.orig/cdf.h libmagic/cdf.h --- libmagic.orig/cdf.h Wed Oct 31 18:03:01 2012 -+++ libmagic/cdf.h Mon Apr 14 23:32:55 2014 ++++ libmagic/cdf.h Mon Dec 2 15:25:29 2013 @@ -35,10 +35,12 @@ #ifndef _H_CDF_ #define _H_CDF_ @@ -1099,7 +1113,7 @@ diff -u libmagic.orig/cdf.h libmagic/cdf.h void cdf_unpack_header(cdf_header_t *, char *); diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c --- libmagic.orig/cdf_time.c Wed Oct 31 18:03:01 2012 -+++ libmagic/cdf_time.c Mon Apr 14 23:32:55 2014 ++++ libmagic/cdf_time.c Mon Dec 2 15:25:29 2013 @@ -96,7 +96,7 @@ } @@ -1159,7 +1173,7 @@ diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c static const char *ref = "Sat Apr 23 01:30:00 1977"; diff -u libmagic.orig/compress.c libmagic/compress.c --- libmagic.orig/compress.c Sun Jan 6 21:35:43 2013 -+++ libmagic/compress.c Mon Apr 14 23:42:51 2014 ++++ libmagic/compress.c Mon Dec 2 15:25:29 2013 @@ -32,6 +32,7 @@ * uncompress(method, old, n, newch) - uncompress old into new, * using method, return sizeof new @@ -1322,7 +1336,7 @@ diff -u libmagic.orig/compress.c libmagic/compress.c +#endif /* if PHP_FILEINFO_UNCOMPRESS */ diff -u libmagic.orig/file.h libmagic/file.h --- libmagic.orig/file.h Mon Feb 18 16:40:59 2013 -+++ libmagic/file.h Mon Apr 14 23:42:51 2014 ++++ libmagic/file.h Mon Mar 10 16:40:55 2014 @@ -33,11 +33,9 @@ #ifndef __file_h__ #define __file_h__ @@ -1532,7 +1546,7 @@ diff -u libmagic.orig/file.h libmagic/file.h #endif /* __file_h__ */ diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c --- libmagic.orig/fsmagic.c Thu Mar 21 18:45:14 2013 -+++ libmagic/fsmagic.c Mon Apr 14 23:42:51 2014 ++++ libmagic/fsmagic.c Mon Dec 2 15:25:29 2013 @@ -59,27 +59,21 @@ # define minor(dev) ((dev) & 0xff) #endif @@ -1899,7 +1913,7 @@ diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c } diff -u libmagic.orig/funcs.c libmagic/funcs.c --- libmagic.orig/funcs.c Wed Oct 31 18:03:01 2012 -+++ libmagic/funcs.c Mon Apr 14 23:42:51 2014 ++++ libmagic/funcs.c Mon Mar 10 16:40:55 2014 @@ -41,52 +41,42 @@ #if defined(HAVE_WCTYPE_H) #include @@ -2193,7 +2207,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c + diff -u libmagic.orig/magic.c libmagic/magic.c --- libmagic.orig/magic.c Fri Jan 11 17:43:09 2013 -+++ libmagic/magic.c Mon Apr 14 23:42:51 2014 ++++ libmagic/magic.c Mon Dec 2 15:29:02 2013 @@ -25,11 +25,6 @@ * SUCH DAMAGE. */ @@ -2537,7 +2551,7 @@ diff -u libmagic.orig/magic.c libmagic/magic.c magic_error(struct magic_set *ms) diff -u libmagic.orig/magic.h libmagic/magic.h --- libmagic.orig/magic.h Thu Mar 21 18:52:42 2013 -+++ libmagic/magic.h Mon Apr 14 23:42:51 2014 ++++ libmagic/magic.h Mon Dec 2 15:25:29 2013 @@ -87,6 +87,7 @@ const char *magic_getpath(const char *, int); @@ -2556,14 +2570,14 @@ diff -u libmagic.orig/magic.h libmagic/magic.h diff -u libmagic.orig/print.c libmagic/print.c --- libmagic.orig/print.c Thu Mar 21 18:45:14 2013 -+++ libmagic/print.c Mon Apr 14 23:42:51 2014 -@@ -29,12 +29,17 @@ ++++ libmagic/print.c Mon Dec 2 15:29:02 2013 +@@ -28,13 +28,17 @@ + /* * print.c - debugging printout routines */ - +#define _GNU_SOURCE +#include "php.h" -+ + #include "file.h" +#include "cdf.h" @@ -2575,7 +2589,7 @@ diff -u libmagic.orig/print.c libmagic/print.c #include #include #include -@@ -43,188 +48,28 @@ +@@ -43,188 +47,28 @@ #endif #include @@ -2776,7 +2790,7 @@ diff -u libmagic.orig/print.c libmagic/print.c } protected const char * -@@ -235,7 +80,7 @@ +@@ -235,7 +79,7 @@ struct tm *tm; if (flags & FILE_T_WINDOWS) { @@ -2787,7 +2801,7 @@ diff -u libmagic.orig/print.c libmagic/print.c } diff -u libmagic.orig/readcdf.c libmagic/readcdf.c --- libmagic.orig/readcdf.c Wed Oct 31 18:03:01 2012 -+++ libmagic/readcdf.c Tue May 27 22:17:37 2014 ++++ libmagic/readcdf.c Thu Apr 24 19:54:40 2014 @@ -30,7 +30,11 @@ #endif @@ -2863,7 +2877,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c return -1; diff -u libmagic.orig/readelf.c libmagic/readelf.c --- libmagic.orig/readelf.c Thu Mar 21 18:45:14 2013 -+++ libmagic/readelf.c Mon Apr 14 23:42:51 2014 ++++ libmagic/readelf.c Sat Oct 25 11:50:05 2014 @@ -48,8 +48,8 @@ private int dophn_exec(struct magic_set *, int, int, int, off_t, int, size_t, off_t, int *, int); @@ -2956,7 +2970,21 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c file_badread(ms); return -1; } -@@ -852,24 +867,12 @@ +@@ -357,6 +372,13 @@ + uint32_t namesz, descsz; + unsigned char *nbuf = CAST(unsigned char *, vbuf); + ++ if (xnh_sizeof + offset > size) { ++ /* ++ * We're out of note headers. ++ */ ++ return xnh_sizeof + offset; ++ } ++ + (void)memcpy(xnh_addr, &nbuf[offset], xnh_sizeof); + offset += xnh_sizeof; + +@@ -852,24 +874,12 @@ return 0; } @@ -2984,7 +3012,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c file_badread(ms); return -1; } -@@ -894,14 +897,17 @@ +@@ -894,14 +904,17 @@ /* Things we can determine when we seek */ switch (xsh_type) { case SHT_NOTE: @@ -3007,7 +3035,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c return -1; } -@@ -910,25 +916,16 @@ +@@ -910,25 +923,16 @@ if (noff >= (off_t)xsh_size) break; noff = donote(ms, nbuf, (size_t)noff, @@ -3038,7 +3066,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c file_badseek(ms); return -1; } -@@ -940,7 +937,7 @@ +@@ -940,7 +944,7 @@ MAX(sizeof cap32, sizeof cap64)]; if ((coff += xcap_sizeof) > (off_t)xsh_size) break; @@ -3047,7 +3075,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c (ssize_t)xcap_sizeof) { file_badread(ms); return -1; -@@ -966,13 +963,12 @@ +@@ -966,13 +970,12 @@ break; } } @@ -3063,7 +3091,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c if (file_printf(ms, ", %sstripped", stripped ? "" : "not ") == -1) return -1; if (cap_hw1) { -@@ -1051,7 +1047,7 @@ +@@ -1051,7 +1054,7 @@ const char *shared_libraries = ""; unsigned char nbuf[BUFSIZ]; ssize_t bufsize; @@ -3072,7 +3100,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c if (size != xph_sizeof) { if (file_printf(ms, ", corrupted program header size") == -1) -@@ -1060,8 +1056,13 @@ +@@ -1060,8 +1063,13 @@ } for ( ; num; num--) { @@ -3088,7 +3116,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c return -1; } -@@ -1099,9 +1100,12 @@ +@@ -1099,9 +1107,12 @@ * This is a PT_NOTE section; loop through all the notes * in the section. */ @@ -3104,7 +3132,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c if (bufsize == -1) { file_badread(ms); return -1; -@@ -1162,7 +1166,7 @@ +@@ -1162,7 +1173,7 @@ /* * If we cannot seek, it must be a pipe, socket or fifo. */ @@ -3115,7 +3143,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c if (fstat(fd, &st) == -1) { diff -u libmagic.orig/readelf.h libmagic/readelf.h --- libmagic.orig/readelf.h Thu Mar 21 18:45:14 2013 -+++ libmagic/readelf.h Mon Apr 14 23:42:51 2014 ++++ libmagic/readelf.h Mon Dec 2 15:25:29 2013 @@ -44,9 +44,17 @@ typedef uint32_t Elf32_Word; typedef uint8_t Elf32_Char; @@ -3136,7 +3164,7 @@ diff -u libmagic.orig/readelf.h libmagic/readelf.h typedef uint8_t Elf64_Char; diff -u libmagic.orig/softmagic.c libmagic/softmagic.c --- libmagic.orig/softmagic.c Thu Mar 21 18:45:14 2013 -+++ libmagic/softmagic.c Tue Jul 1 09:00:09 2014 ++++ libmagic/softmagic.c Wed Aug 20 21:20:34 2014 @@ -41,6 +41,11 @@ #include #include @@ -3149,6 +3177,15 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c private int match(struct magic_set *, struct magic *, uint32_t, const unsigned char *, size_t, size_t, int, int, int, int, int *, int *, +@@ -53,7 +58,7 @@ + private int32_t moffset(struct magic_set *, struct magic *); + private void mdebug(uint32_t, const char *, size_t); + private int mcopy(struct magic_set *, union VALUETYPE *, int, int, +- const unsigned char *, uint32_t, size_t, size_t); ++ const unsigned char *, uint32_t, size_t, struct magic *); + private int mconvert(struct magic_set *, struct magic *, int); + private int print_sep(struct magic_set *, int); + private int handle_annotation(struct magic_set *, struct magic *); @@ -62,6 +67,8 @@ private void cvt_32(union VALUETYPE *, const struct magic *); private void cvt_64(union VALUETYPE *, const struct magic *); @@ -3308,9 +3345,72 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c while (len--) *ptr1++ = *ptr2++; *ptr1 = '\0'; -@@ -1145,9 +1138,6 @@ - "nbytes=%zu, count=%u)\n", m->type, m->flag, offset, o, - nbytes, count); +@@ -1010,7 +1003,7 @@ + + private int + mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir, +- const unsigned char *s, uint32_t offset, size_t nbytes, size_t linecnt) ++ const unsigned char *s, uint32_t offset, size_t nbytes, struct magic *m) + { + /* + * Note: FILE_SEARCH and FILE_REGEX do not actually copy +@@ -1030,15 +1023,24 @@ + const char *last; /* end of search region */ + const char *buf; /* start of search region */ + const char *end; +- size_t lines; ++ size_t lines, linecnt, bytecnt; ++ ++ linecnt = m->str_range; ++ bytecnt = linecnt * 80; + ++ if (bytecnt == 0) { ++ bytecnt = 8192; ++ } ++ if (bytecnt > nbytes) { ++ bytecnt = nbytes; ++ } + if (s == NULL) { + ms->search.s_len = 0; + ms->search.s = NULL; + return 0; + } + buf = RCAST(const char *, s) + offset; +- end = last = RCAST(const char *, s) + nbytes; ++ end = last = RCAST(const char *, s) + bytecnt; + /* mget() guarantees buf <= last */ + for (lines = linecnt, b = buf; lines && b < end && + ((b = CAST(const char *, +@@ -1051,7 +1053,7 @@ + b++; + } + if (lines) +- last = RCAST(const char *, s) + nbytes; ++ last = RCAST(const char *, s) + bytecnt; + + ms->search.s = buf; + ms->search.s_len = last - buf; +@@ -1125,7 +1127,6 @@ + int *need_separator, int *returnval) + { + uint32_t soffset, offset = ms->offset; +- uint32_t count = m->str_range; + int rv, oneed_separator; + char *sbuf, *rbuf; + union VALUETYPE *p = &ms->ms_value; +@@ -1137,17 +1138,13 @@ + } + + if (mcopy(ms, p, m->type, m->flag & INDIR, s, (uint32_t)(offset + o), +- (uint32_t)nbytes, count) == -1) ++ (uint32_t)nbytes, m) == -1) + return -1; + + if ((ms->flags & MAGIC_DEBUG) != 0) { + fprintf(stderr, "mget(type=%d, flag=%x, offset=%u, o=%zu, " +- "nbytes=%zu, count=%u)\n", m->type, m->flag, offset, o, +- nbytes, count); ++ "nbytes=%zu)\n", m->type, m->flag, offset, o, nbytes); mdebug(offset, (char *)(void *)p, sizeof(union VALUETYPE)); -#ifndef COMPILE_ONLY - file_mdump(m); @@ -3318,7 +3418,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c } if (m->flag & INDIR) { -@@ -1191,7 +1181,7 @@ +@@ -1191,7 +1188,7 @@ } switch (cvt_flip(m->in_type, flip)) { case FILE_BYTE: @@ -3327,7 +3427,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c return 0; if (off) { switch (m->in_op & FILE_OPS_MASK) { -@@ -1226,7 +1216,7 @@ +@@ -1226,7 +1223,7 @@ offset = ~offset; break; case FILE_BESHORT: @@ -3336,7 +3436,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c return 0; if (off) { switch (m->in_op & FILE_OPS_MASK) { -@@ -1278,7 +1268,7 @@ +@@ -1278,7 +1275,7 @@ offset = ~offset; break; case FILE_LESHORT: @@ -3345,7 +3445,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c return 0; if (off) { switch (m->in_op & FILE_OPS_MASK) { -@@ -1330,7 +1320,7 @@ +@@ -1330,7 +1327,7 @@ offset = ~offset; break; case FILE_SHORT: @@ -3354,7 +3454,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c return 0; if (off) { switch (m->in_op & FILE_OPS_MASK) { -@@ -1367,7 +1357,7 @@ +@@ -1367,7 +1364,7 @@ break; case FILE_BELONG: case FILE_BEID3: @@ -3363,7 +3463,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c return 0; if (off) { switch (m->in_op & FILE_OPS_MASK) { -@@ -1438,7 +1428,7 @@ +@@ -1438,7 +1435,7 @@ break; case FILE_LELONG: case FILE_LEID3: @@ -3372,7 +3472,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c return 0; if (off) { switch (m->in_op & FILE_OPS_MASK) { -@@ -1508,7 +1498,7 @@ +@@ -1508,7 +1505,7 @@ offset = ~offset; break; case FILE_MELONG: @@ -3381,7 +3481,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c return 0; if (off) { switch (m->in_op & FILE_OPS_MASK) { -@@ -1578,7 +1568,7 @@ +@@ -1578,7 +1575,7 @@ offset = ~offset; break; case FILE_LONG: @@ -3390,7 +3490,15 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c return 0; if (off) { switch (m->in_op & FILE_OPS_MASK) { -@@ -1644,23 +1634,20 @@ +@@ -1637,30 +1634,27 @@ + if ((ms->flags & MAGIC_DEBUG) != 0) + fprintf(stderr, "indirect +offs=%u\n", offset); + } +- if (mcopy(ms, p, m->type, 0, s, offset, nbytes, count) == -1) ++ if (mcopy(ms, p, m->type, 0, s, offset, nbytes, m) == -1) + return -1; + ms->offset = offset; + if ((ms->flags & MAGIC_DEBUG) != 0) { mdebug(offset, (char *)(void *)p, sizeof(union VALUETYPE)); @@ -3416,7 +3524,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c return 0; break; -@@ -1679,38 +1666,40 @@ +@@ -1679,38 +1673,40 @@ case FILE_FLOAT: case FILE_BEFLOAT: case FILE_LEFLOAT: @@ -3463,7 +3571,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c if ((ms->flags & MAGIC_DEBUG) != 0) fprintf(stderr, "indirect @offs=%u[%d]\n", offset, rv); rbuf = ms->o.buf; -@@ -1718,16 +1707,26 @@ +@@ -1718,16 +1714,26 @@ ms->offset = soffset; if (rv == 1) { if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 && @@ -3494,7 +3602,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c return 0; sbuf = m->value.s; if (*sbuf == '^') { -@@ -1837,6 +1836,42 @@ +@@ -1837,6 +1843,42 @@ return file_strncmp(a, b, len, flags); } @@ -3537,7 +3645,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c private int magiccheck(struct magic_set *ms, struct magic *m) { -@@ -1996,69 +2031,157 @@ +@@ -1996,69 +2038,157 @@ break; } case FILE_REGEX: { @@ -3608,7 +3716,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c + zval *retval; + zval *subpats; + char *haystack; -+ ++ + MAKE_STD_ZVAL(retval); + ALLOC_INIT_ZVAL(subpats); + From 7e5bd4ec69b5c026afc95d17009b91b0f08064a9 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sat, 25 Oct 2014 12:03:49 +0200 Subject: [PATCH 054/398] updated libmagic.patch in 5.6 --- ext/fileinfo/libmagic.patch | 237 +++++++++++++++++++++++++++++------- 1 file changed, 194 insertions(+), 43 deletions(-) diff --git a/ext/fileinfo/libmagic.patch b/ext/fileinfo/libmagic.patch index 8b0b9a89110..2d987e45734 100644 --- a/ext/fileinfo/libmagic.patch +++ b/ext/fileinfo/libmagic.patch @@ -1,6 +1,6 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c --- libmagic.orig/apprentice.c Tue Nov 19 22:01:12 2013 -+++ libmagic/apprentice.c Mon Mar 31 17:15:53 2014 ++++ libmagic/apprentice.c Fri Oct 3 22:48:34 2014 @@ -29,6 +29,8 @@ * apprentice - make one pass through /etc/magic, learning its secrets. */ @@ -454,6 +454,15 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c return NULL; } return map; +@@ -1248,7 +1272,7 @@ + * the sign extension must have happened. + */ + case FILE_BYTE: +- v = (char) v; ++ v = (signed char) v; + break; + case FILE_SHORT: + case FILE_BESHORT: @@ -1516,7 +1540,7 @@ if (me->cont_count == me->max_count) { struct magic *nm; @@ -822,7 +831,7 @@ diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c } diff -u libmagic.orig/cdf.c libmagic/cdf.c --- libmagic.orig/cdf.c Tue Feb 26 17:20:42 2013 -+++ libmagic/cdf.c Tue Jul 1 08:57:25 2014 ++++ libmagic/cdf.c Fri Oct 3 22:48:34 2014 @@ -35,7 +35,7 @@ #include "file.h" @@ -937,7 +946,7 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c /* If the it is not there, just fake it; some docs don't have it */ if (d->d_stream_first_sector < 0) -@@ -796,7 +815,11 @@ +@@ -796,11 +815,15 @@ if (cdf_check_stream_offset(sst, h, e, 0, __LINE__) == -1) goto out; for (i = 0; i < sh.sh_properties; i++) { @@ -950,6 +959,11 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c q = (const uint8_t *)(const void *) ((const char *)(const void *)p + ofs - 2 * sizeof(uint32_t)); +- if (q > e) { ++ if (q < p || q > e) { + DPRINTF(("Ran of the end %p > %p\n", q, e)); + goto out; + } @@ -810,6 +833,10 @@ i, inp[i].pi_id, inp[i].pi_type, q - p, offs)); if (inp[i].pi_type & CDF_VECTOR) { @@ -1814,7 +1828,16 @@ diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c } diff -u libmagic.orig/funcs.c libmagic/funcs.c --- libmagic.orig/funcs.c Thu Feb 13 00:20:53 2014 -+++ libmagic/funcs.c Wed Mar 19 13:28:34 2014 ++++ libmagic/funcs.c Fri Oct 3 22:48:34 2014 +@@ -27,7 +27,7 @@ + #include "file.h" + + #ifndef lint +-FILE_RCSID("@(#)$File: funcs.c,v 1.67 2014/02/12 23:20:53 christos Exp $") ++FILE_RCSID("@(#)$File: funcs.c,v 1.68 2014/02/18 11:09:31 kim Exp $") + #endif /* lint */ + + #include "magic.h" @@ -41,79 +41,79 @@ #if defined(HAVE_WCTYPE_H) #include @@ -1947,7 +1970,26 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c { int m = 0, rv = 0, looks_text = 0; int mime = ms->flags & MAGIC_MIME; -@@ -203,10 +202,10 @@ +@@ -174,8 +173,7 @@ + const char *code_mime = "binary"; + const char *type = "application/octet-stream"; + const char *def = "data"; +- +- ++ const char *ftype = NULL; + + if (nb == 0) { + def = "empty"; +@@ -188,7 +186,7 @@ + + if ((ms->flags & MAGIC_NO_CHECK_ENCODING) == 0) { + looks_text = file_encoding(ms, ubuf, nb, &u8buf, &ulen, +- &code, &code_mime, &type); ++ &code, &code_mime, &ftype); + } + + #ifdef __EMX__ +@@ -203,10 +201,10 @@ } } #endif @@ -1961,7 +2003,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c if ((ms->flags & MAGIC_DEBUG) != 0) (void)fprintf(stderr, "zmagic %d\n", m); goto done_encoding; -@@ -221,12 +220,17 @@ +@@ -221,12 +219,17 @@ } /* Check if we have a CDF file */ @@ -1984,7 +2026,16 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c /* try soft magic tests */ if ((ms->flags & MAGIC_NO_CHECK_SOFT) == 0) -@@ -300,7 +304,6 @@ +@@ -268,7 +271,7 @@ + if ((ms->flags & MAGIC_NO_CHECK_ENCODING) == 0) { + if (looks_text == 0) + if ((m = file_ascmagic_with_encoding( ms, ubuf, +- nb, u8buf, ulen, code, type, looks_text)) ++ nb, u8buf, ulen, code, ftype, looks_text)) + != 0) { + if ((ms->flags & MAGIC_DEBUG) != 0) + (void)fprintf(stderr, +@@ -300,7 +303,6 @@ return m; } @@ -1992,7 +2043,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c protected int file_reset(struct magic_set *ms) -@@ -310,11 +313,11 @@ +@@ -310,11 +312,11 @@ return -1; } if (ms->o.buf) { @@ -2006,7 +2057,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c ms->o.pbuf = NULL; } ms->event_flags &= ~EVENT_HAD_ERR; -@@ -333,7 +336,7 @@ +@@ -333,7 +335,7 @@ protected const char * file_getbuffer(struct magic_set *ms) { @@ -2015,7 +2066,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c size_t psize, len; if (ms->event_flags & EVENT_HAD_ERR) -@@ -348,15 +351,13 @@ +@@ -348,15 +350,13 @@ /* * 4 is for octal representation, + 1 is for NUL */ len = strlen(ms->o.buf); if (len > (SIZE_MAX - 1) / 4) { @@ -2032,7 +2083,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c #if defined(HAVE_WCHAR_H) && defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH) { -@@ -416,8 +417,8 @@ +@@ -416,8 +416,8 @@ if (level >= ms->c.len) { len = (ms->c.len += 20) * sizeof(*ms->c.li); ms->c.li = CAST(struct level_info *, (ms->c.li == NULL) ? @@ -2043,7 +2094,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c if (ms->c.li == NULL) { file_oomem(ms, len); return -1; -@@ -437,32 +438,50 @@ +@@ -437,32 +437,50 @@ return ms->o.buf == NULL ? 0 : strlen(ms->o.buf); } @@ -2706,7 +2757,7 @@ diff -u libmagic.orig/print.c libmagic/print.c } diff -u libmagic.orig/readcdf.c libmagic/readcdf.c --- libmagic.orig/readcdf.c Tue Jan 7 04:13:42 2014 -+++ libmagic/readcdf.c Thu Jun 5 18:05:33 2014 ++++ libmagic/readcdf.c Sat Oct 25 11:50:04 2014 @@ -26,11 +26,15 @@ #include "file.h" @@ -2724,7 +2775,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c #include #include #include -@@ -69,6 +73,44 @@ +@@ -69,6 +73,50 @@ { NULL, NULL, }, }; @@ -2743,6 +2794,9 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c + { 0x00000000000c1084LLU, 0x46000000000000c0LLU }, +#endif + "x-msi", ++ }, ++ { { 0, 0 }, ++ NULL, + } +}, clsid2desc[] = { + { @@ -2753,6 +2807,9 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c +#endif + "MSI Installer", + }, ++ { { 0, 0 }, ++ NULL, ++ } +}; + +private const char * @@ -2769,7 +2826,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c private const char * cdf_app_to_mime(const char *vbuf, const struct nv *nv) { -@@ -87,16 +129,21 @@ +@@ -87,16 +135,21 @@ private int cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info, @@ -2793,7 +2850,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c for (i = 0; i < count; i++) { cdf_print_property_name(buf, sizeof(buf), info[i].pi_id); switch (info[i].pi_type) { -@@ -153,7 +200,7 @@ +@@ -153,7 +206,7 @@ buf, vbuf) == -1) return -1; } @@ -2802,7 +2859,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c CDF_PROPERTY_NAME_OF_APPLICATION) { str = cdf_app_to_mime(vbuf, app2mime); } -@@ -162,8 +209,12 @@ +@@ -162,8 +215,12 @@ case CDF_FILETIME: tp = info[i].pi_tp; if (tp != 0) { @@ -2817,7 +2874,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c cdf_print_elapsed_time(tbuf, sizeof(tbuf), tp); if (NOTMIME(ms) && file_printf(ms, -@@ -171,8 +222,11 @@ +@@ -171,8 +228,11 @@ return -1; } else { char *c, *ec; @@ -2831,7 +2888,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c if (c != NULL && (ec = strchr(c, '\n')) != NULL) *ec = '\0'; -@@ -200,7 +254,7 @@ +@@ -200,7 +260,7 @@ private int cdf_file_summary_info(struct magic_set *ms, const cdf_header_t *h, @@ -2840,7 +2897,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c { cdf_summary_info_header_t si; cdf_property_info_t *info; -@@ -211,6 +265,8 @@ +@@ -211,6 +271,8 @@ return -1; if (NOTMIME(ms)) { @@ -2849,7 +2906,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c if (file_printf(ms, "Composite Document File V2 Document") == -1) return -1; -@@ -238,9 +294,15 @@ +@@ -238,9 +300,15 @@ return -2; break; } @@ -2867,7 +2924,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c free(info); return m == -1 ? -2 : m; -@@ -258,6 +320,7 @@ +@@ -258,6 +326,7 @@ int i; const char *expn = ""; const char *corrupt = "corrupt: "; @@ -2875,7 +2932,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c info.i_fd = fd; info.i_buf = buf; -@@ -291,7 +354,8 @@ +@@ -291,7 +360,8 @@ goto out2; } @@ -2885,7 +2942,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c expn = "Cannot read short stream"; goto out3; } -@@ -312,23 +376,21 @@ +@@ -312,23 +382,21 @@ #ifdef CDF_DEBUG cdf_dump_summary_info(&h, &scn); #endif @@ -2918,7 +2975,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c if (str != NULL) { diff -u libmagic.orig/readelf.c libmagic/readelf.c --- libmagic.orig/readelf.c Tue Nov 5 16:44:01 2013 -+++ libmagic/readelf.c Fri Feb 21 00:21:27 2014 ++++ libmagic/readelf.c Sat Oct 25 11:50:04 2014 @@ -48,8 +48,8 @@ private int dophn_exec(struct magic_set *, int, int, int, off_t, int, size_t, off_t, int *, int); @@ -2983,7 +3040,21 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c file_badread(ms); return -1; } -@@ -913,24 +928,12 @@ +@@ -477,6 +492,13 @@ + uint32_t namesz, descsz; + unsigned char *nbuf = CAST(unsigned char *, vbuf); + ++ if (xnh_sizeof + offset > size) { ++ /* ++ * We're out of note headers. ++ */ ++ return xnh_sizeof + offset; ++ } ++ + (void)memcpy(xnh_addr, &nbuf[offset], xnh_sizeof); + offset += xnh_sizeof; + +@@ -913,24 +935,12 @@ return 0; } @@ -3011,7 +3082,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c file_badread(ms); return -1; } -@@ -955,14 +958,17 @@ +@@ -955,14 +965,17 @@ /* Things we can determine when we seek */ switch (xsh_type) { case SHT_NOTE: @@ -3034,7 +3105,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c return -1; } -@@ -971,25 +977,16 @@ +@@ -971,25 +984,16 @@ if (noff >= (off_t)xsh_size) break; noff = donote(ms, nbuf, (size_t)noff, @@ -3065,7 +3136,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c file_badseek(ms); return -1; } -@@ -1001,7 +998,7 @@ +@@ -1001,7 +1005,7 @@ MAX(sizeof cap32, sizeof cap64)]; if ((coff += xcap_sizeof) > (off_t)xsh_size) break; @@ -3074,7 +3145,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c (ssize_t)xcap_sizeof) { file_badread(ms); return -1; -@@ -1027,13 +1024,12 @@ +@@ -1027,13 +1031,12 @@ break; } } @@ -3090,7 +3161,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c if (file_printf(ms, ", %sstripped", stripped ? "" : "not ") == -1) return -1; if (cap_hw1) { -@@ -1112,7 +1108,7 @@ +@@ -1112,7 +1115,7 @@ const char *shared_libraries = ""; unsigned char nbuf[BUFSIZ]; ssize_t bufsize; @@ -3099,7 +3170,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c if (size != xph_sizeof) { if (file_printf(ms, ", corrupted program header size") == -1) -@@ -1121,8 +1117,13 @@ +@@ -1121,8 +1124,13 @@ } for ( ; num; num--) { @@ -3115,7 +3186,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c return -1; } -@@ -1160,9 +1161,12 @@ +@@ -1160,9 +1168,12 @@ * This is a PT_NOTE section; loop through all the notes * in the section. */ @@ -3131,7 +3202,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c if (bufsize == -1) { file_badread(ms); return -1; -@@ -1223,7 +1227,7 @@ +@@ -1223,7 +1234,7 @@ /* * If we cannot seek, it must be a pipe, socket or fifo. */ @@ -3163,7 +3234,7 @@ diff -u libmagic.orig/readelf.h libmagic/readelf.h typedef uint8_t Elf64_Char; diff -u libmagic.orig/softmagic.c libmagic/softmagic.c --- libmagic.orig/softmagic.c Thu Feb 13 00:20:53 2014 -+++ libmagic/softmagic.c Tue Jul 1 08:57:25 2014 ++++ libmagic/softmagic.c Mon Aug 4 14:58:55 2014 @@ -50,6 +50,11 @@ #include #endif @@ -3176,6 +3247,15 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c private int match(struct magic_set *, struct magic *, uint32_t, const unsigned char *, size_t, size_t, int, int, int, int, int *, int *, +@@ -62,7 +67,7 @@ + private int32_t moffset(struct magic_set *, struct magic *); + private void mdebug(uint32_t, const char *, size_t); + private int mcopy(struct magic_set *, union VALUETYPE *, int, int, +- const unsigned char *, uint32_t, size_t, size_t); ++ const unsigned char *, uint32_t, size_t, struct magic *); + private int mconvert(struct magic_set *, struct magic *, int); + private int print_sep(struct magic_set *, int); + private int handle_annotation(struct magic_set *, struct magic *); @@ -71,7 +76,8 @@ private void cvt_32(union VALUETYPE *, const struct magic *); private void cvt_64(union VALUETYPE *, const struct magic *); @@ -3320,9 +3400,72 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c while (len--) *ptr1++ = *ptr2++; *ptr1 = '\0'; -@@ -1178,9 +1170,6 @@ - "nbytes=%zu, count=%u)\n", m->type, m->flag, offset, o, - nbytes, count); +@@ -1046,7 +1038,7 @@ + + private int + mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir, +- const unsigned char *s, uint32_t offset, size_t nbytes, size_t linecnt) ++ const unsigned char *s, uint32_t offset, size_t nbytes, struct magic *m) + { + /* + * Note: FILE_SEARCH and FILE_REGEX do not actually copy +@@ -1066,15 +1058,24 @@ + const char *last; /* end of search region */ + const char *buf; /* start of search region */ + const char *end; +- size_t lines; ++ size_t lines, linecnt, bytecnt; + ++ linecnt = m->str_range; ++ bytecnt = linecnt * 80; ++ ++ if (bytecnt == 0) { ++ bytecnt = 8192; ++ } ++ if (bytecnt > nbytes) { ++ bytecnt = nbytes; ++ } + if (s == NULL) { + ms->search.s_len = 0; + ms->search.s = NULL; + return 0; + } + buf = RCAST(const char *, s) + offset; +- end = last = RCAST(const char *, s) + nbytes; ++ end = last = RCAST(const char *, s) + bytecnt; + /* mget() guarantees buf <= last */ + for (lines = linecnt, b = buf; lines && b < end && + ((b = CAST(const char *, +@@ -1087,7 +1088,7 @@ + b++; + } + if (lines) +- last = RCAST(const char *, s) + nbytes; ++ last = RCAST(const char *, s) + bytecnt; + + ms->search.s = buf; + ms->search.s_len = last - buf; +@@ -1158,7 +1159,6 @@ + int *need_separator, int *returnval) + { + uint32_t soffset, offset = ms->offset; +- uint32_t count = m->str_range; + int rv, oneed_separator, in_type; + char *sbuf, *rbuf; + union VALUETYPE *p = &ms->ms_value; +@@ -1170,17 +1170,13 @@ + } + + if (mcopy(ms, p, m->type, m->flag & INDIR, s, (uint32_t)(offset + o), +- (uint32_t)nbytes, count) == -1) ++ (uint32_t)nbytes, m) == -1) + return -1; + + if ((ms->flags & MAGIC_DEBUG) != 0) { + fprintf(stderr, "mget(type=%d, flag=%x, offset=%u, o=%zu, " +- "nbytes=%zu, count=%u)\n", m->type, m->flag, offset, o, +- nbytes, count); ++ "nbytes=%zu)\n", m->type, m->flag, offset, o, nbytes); mdebug(offset, (char *)(void *)p, sizeof(union VALUETYPE)); -#ifndef COMPILE_ONLY - file_mdump(m); @@ -3330,7 +3473,15 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c } if (m->flag & INDIR) { -@@ -1679,9 +1668,6 @@ +@@ -1672,16 +1668,13 @@ + if ((ms->flags & MAGIC_DEBUG) != 0) + fprintf(stderr, "indirect +offs=%u\n", offset); + } +- if (mcopy(ms, p, m->type, 0, s, offset, nbytes, count) == -1) ++ if (mcopy(ms, p, m->type, 0, s, offset, nbytes, m) == -1) + return -1; + ms->offset = offset; + if ((ms->flags & MAGIC_DEBUG) != 0) { mdebug(offset, (char *)(void *)p, sizeof(union VALUETYPE)); @@ -3340,7 +3491,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c } } -@@ -1755,11 +1741,21 @@ +@@ -1755,11 +1748,21 @@ ms->offset = soffset; if (rv == 1) { if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 && @@ -3365,7 +3516,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c } return rv; -@@ -1875,6 +1871,42 @@ +@@ -1875,6 +1878,42 @@ return file_strncmp(a, b, len, flags); } @@ -3408,7 +3559,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c private int magiccheck(struct magic_set *ms, struct magic *m) { -@@ -2035,63 +2067,151 @@ +@@ -2035,63 +2074,151 @@ break; } case FILE_REGEX: { @@ -3444,7 +3595,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c + zval *retval; + zval *subpats; + char *haystack; -+ ++ + MAKE_STD_ZVAL(retval); + ALLOC_INIT_ZVAL(subpats); + From 71a653452f4c6b95b940972a00674f7a3e386f75 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sat, 25 Oct 2014 12:06:17 +0200 Subject: [PATCH 055/398] updated libmagic.patch in master --- ext/fileinfo/libmagic.patch | 765 ++++++++++++++++++++++++------------ 1 file changed, 510 insertions(+), 255 deletions(-) diff --git a/ext/fileinfo/libmagic.patch b/ext/fileinfo/libmagic.patch index 8b0b9a89110..30f1e9b4504 100644 --- a/ext/fileinfo/libmagic.patch +++ b/ext/fileinfo/libmagic.patch @@ -1,6 +1,6 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c --- libmagic.orig/apprentice.c Tue Nov 19 22:01:12 2013 -+++ libmagic/apprentice.c Mon Mar 31 17:15:53 2014 ++++ libmagic/apprentice.c Sun Sep 21 18:30:39 2014 @@ -29,6 +29,8 @@ * apprentice - make one pass through /etc/magic, learning its secrets. */ @@ -357,8 +357,9 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c uint32_t i, j; size_t files = 0, maxfiles = 0; - char **filearr = NULL, *mfn; +- struct stat st; + char **filearr = NULL; - struct stat st; ++ zend_stat_t st; struct magic_map *map; struct magic_entry_set mset[MAGIC_SETS]; - DIR *dir; @@ -406,8 +407,9 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c + php_stream_closedir(dir); goto out; } - if (stat(mfn, &st) == -1 || !S_ISREG(st.st_mode)) { +- if (stat(mfn, &st) == -1 || !S_ISREG(st.st_mode)) { - free(mfn); ++ if (zend_stat(mfn, &st) == -1 || !S_ISREG(st.st_mode)) { continue; } if (files >= maxfiles) { @@ -454,6 +456,15 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c return NULL; } return map; +@@ -1248,7 +1272,7 @@ + * the sign extension must have happened. + */ + case FILE_BYTE: +- v = (char) v; ++ v = (signed char) v; + break; + case FILE_SHORT: + case FILE_BESHORT: @@ -1516,7 +1540,7 @@ if (me->cont_count == me->max_count) { struct magic *nm; @@ -536,12 +547,12 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c size_t i; + php_stream *stream = NULL; + php_stream_statbuf st; -+ -+ -+ TSRMLS_FETCH(); - fd = -1; - if ((map = CAST(struct magic_map *, calloc(1, sizeof(*map)))) == NULL) { ++ ++ TSRMLS_FETCH(); ++ + if ((map = CAST(struct magic_map *, ecalloc(1, sizeof(*map)))) == NULL) { file_oomem(ms, sizeof(*map)); + efree(map); @@ -649,7 +660,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c + if (NULL != fn) { + nentries = (uint32_t)(st.sb.st_size / sizeof(struct magic)); + entries = (uint32_t)(st.sb.st_size / sizeof(struct magic)); -+ if ((off_t)(entries * sizeof(struct magic)) != st.sb.st_size) { ++ if ((zend_off_t)(entries * sizeof(struct magic)) != st.sb.st_size) { + file_error(ms, 0, "Size of `%s' %llu is not a multiple of %zu", + dbname, (unsigned long long)st.sb.st_size, + sizeof(struct magic)); @@ -729,7 +740,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c assert(nm + sizeof(ar) < m); - if (lseek(fd, (off_t)m, SEEK_SET) != (off_t)m) { -+ if (php_stream_seek(stream,(off_t)sizeof(struct magic), SEEK_SET) != sizeof(struct magic)) { ++ if (php_stream_seek(stream,(zend_off_t)sizeof(struct magic), SEEK_SET) != sizeof(struct magic)) { file_error(ms, errno, "error seeking `%s'", dbname); goto out; } @@ -800,7 +811,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c } diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c --- libmagic.orig/ascmagic.c Thu Feb 13 00:20:53 2014 -+++ libmagic/ascmagic.c Fri Feb 21 00:21:27 2014 ++++ libmagic/ascmagic.c Wed Aug 27 12:35:45 2014 @@ -139,7 +139,7 @@ /* malloc size is a conservative overestimate; could be improved, or at least realloced after conversion. */ @@ -822,7 +833,7 @@ diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c } diff -u libmagic.orig/cdf.c libmagic/cdf.c --- libmagic.orig/cdf.c Tue Feb 26 17:20:42 2013 -+++ libmagic/cdf.c Tue Jul 1 08:57:25 2014 ++++ libmagic/cdf.c Wed Aug 27 12:35:45 2014 @@ -35,7 +35,7 @@ #include "file.h" @@ -850,7 +861,7 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c #include #include #include -@@ -267,13 +277,15 @@ +@@ -267,23 +277,25 @@ { const char *b = (const char *)sst->sst_tab; const char *e = ((const char *)p) + tail; @@ -868,18 +879,48 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c errno = EFTYPE; return -1; } + + static ssize_t +-cdf_read(const cdf_info_t *info, off_t off, void *buf, size_t len) ++cdf_read(const cdf_info_t *info, zend_off_t off, void *buf, size_t len) + { + size_t siz = (size_t)off + len; + +- if ((off_t)(off + len) != (off_t)siz) { ++ if ((zend_off_t)(off + len) != (zend_off_t)siz) { + errno = EINVAL; + return -1; + } @@ -296,7 +308,10 @@ if (info->i_fd == -1) return -1; - if (pread(info->i_fd, buf, len, off) != (ssize_t)len) -+ if (FINFO_LSEEK_FUNC(info->i_fd, off, SEEK_SET) == (off_t)-1) ++ if (FINFO_LSEEK_FUNC(info->i_fd, off, SEEK_SET) == (zend_off_t)-1) + return -1; + + if (FINFO_READ_FUNC(info->i_fd, buf, len) != (ssize_t)len) return -1; return (ssize_t)len; +@@ -308,7 +323,7 @@ + char buf[512]; + + (void)memcpy(cdf_bo.s, "\01\02\03\04", 4); +- if (cdf_read(info, (off_t)0, buf, sizeof(buf)) == -1) ++ if (cdf_read(info, (zend_off_t)0, buf, sizeof(buf)) == -1) + return -1; + cdf_unpack_header(h, buf); + cdf_swap_header(h); +@@ -342,7 +357,7 @@ + size_t ss = CDF_SEC_SIZE(h); + size_t pos = CDF_SEC_POS(h, id); + assert(ss == len); +- return cdf_read(info, (off_t)pos, ((char *)buf) + offs, len); ++ return cdf_read(info, (zend_off_t)pos, ((char *)buf) + offs, len); + } + + ssize_t @@ -352,10 +367,10 @@ size_t ss = CDF_SHORT_SEC_SIZE(h); size_t pos = CDF_SHORT_SEC_POS(h, id); @@ -937,7 +978,7 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c /* If the it is not there, just fake it; some docs don't have it */ if (d->d_stream_first_sector < 0) -@@ -796,7 +815,11 @@ +@@ -796,11 +815,15 @@ if (cdf_check_stream_offset(sst, h, e, 0, __LINE__) == -1) goto out; for (i = 0; i < sh.sh_properties; i++) { @@ -950,6 +991,11 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c q = (const uint8_t *)(const void *) ((const char *)(const void *)p + ofs - 2 * sizeof(uint32_t)); +- if (q > e) { ++ if (q < p || q > e) { + DPRINTF(("Ran of the end %p > %p\n", q, e)); + goto out; + } @@ -810,6 +833,10 @@ i, inp[i].pi_id, inp[i].pi_type, q - p, offs)); if (inp[i].pi_type & CDF_VECTOR) { @@ -1038,7 +1084,7 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c } else { diff -u libmagic.orig/cdf.h libmagic/cdf.h --- libmagic.orig/cdf.h Thu Jun 21 00:19:55 2012 -+++ libmagic/cdf.h Thu Jun 5 18:05:33 2014 ++++ libmagic/cdf.h Wed Aug 27 12:35:45 2014 @@ -35,10 +35,12 @@ #ifndef _H_CDF_ #define _H_CDF_ @@ -1091,7 +1137,7 @@ diff -u libmagic.orig/cdf.h libmagic/cdf.h int cdf_read_summary_info(const cdf_info_t *, const cdf_header_t *, diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c --- libmagic.orig/cdf_time.c Thu Jun 21 00:18:33 2012 -+++ libmagic/cdf_time.c Fri Feb 21 00:21:27 2014 ++++ libmagic/cdf_time.c Wed Aug 27 12:35:45 2014 @@ -96,7 +96,7 @@ } @@ -1151,7 +1197,7 @@ diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c static const char *ref = "Sat Apr 23 01:30:00 1977"; diff -u libmagic.orig/compress.c libmagic/compress.c --- libmagic.orig/compress.c Sun Jan 5 16:55:21 2014 -+++ libmagic/compress.c Fri Feb 21 00:21:27 2014 ++++ libmagic/compress.c Wed Aug 27 12:35:45 2014 @@ -32,6 +32,7 @@ * uncompress(method, old, n, newch) - uncompress old into new, * using method, return sizeof new @@ -1237,7 +1283,7 @@ diff -u libmagic.orig/compress.c libmagic/compress.c } (void)close(tfd); - if (lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) { -+ if (FINFO_LSEEK_FUNC(fd, (off_t)0, SEEK_SET) == (off_t)-1) { ++ if (FINFO_LSEEK_FUNC(fd, (zend_off_t)0, SEEK_SET) == (zend_off_t)-1) { file_badseek(ms); return -1; } @@ -1266,7 +1312,7 @@ diff -u libmagic.orig/compress.c libmagic/compress.c - _exit(1); - (void) lseek(0, (off_t)0, SEEK_SET); + (void) dup(fd); -+ (void) FINFO_LSEEK_FUNC(0, (off_t)0, SEEK_SET); ++ (void) FINFO_LSEEK_FUNC(0, (zend_off_t)0, SEEK_SET); } else { - if (dup(fdin[0]) == -1) - _exit(1); @@ -1312,9 +1358,39 @@ diff -u libmagic.orig/compress.c libmagic/compress.c } -#endif +#endif /* if PHP_FILEINFO_UNCOMPRESS */ +diff -u libmagic.orig/elfclass.h libmagic/elfclass.h +--- libmagic.orig/elfclass.h Mon Feb 18 19:33:14 2013 ++++ libmagic/elfclass.h Wed Aug 27 12:35:45 2014 +@@ -37,7 +37,7 @@ + case ET_CORE: + flags |= FLAGS_IS_CORE; + if (dophn_core(ms, clazz, swap, fd, +- (off_t)elf_getu(swap, elfhdr.e_phoff), ++ (zend_off_t)elf_getu(swap, elfhdr.e_phoff), + elf_getu16(swap, elfhdr.e_phnum), + (size_t)elf_getu16(swap, elfhdr.e_phentsize), + fsize, &flags) == -1) +@@ -47,7 +47,7 @@ + case ET_EXEC: + case ET_DYN: + if (dophn_exec(ms, clazz, swap, fd, +- (off_t)elf_getu(swap, elfhdr.e_phoff), ++ (zend_off_t)elf_getu(swap, elfhdr.e_phoff), + elf_getu16(swap, elfhdr.e_phnum), + (size_t)elf_getu16(swap, elfhdr.e_phentsize), + fsize, &flags, elf_getu16(swap, elfhdr.e_shnum)) +@@ -56,7 +56,7 @@ + /*FALLTHROUGH*/ + case ET_REL: + if (doshn(ms, clazz, swap, fd, +- (off_t)elf_getu(swap, elfhdr.e_shoff), ++ (zend_off_t)elf_getu(swap, elfhdr.e_shoff), + elf_getu16(swap, elfhdr.e_shnum), + (size_t)elf_getu16(swap, elfhdr.e_shentsize), + fsize, &flags, elf_getu16(swap, elfhdr.e_machine), diff -u libmagic.orig/file.h libmagic/file.h --- libmagic.orig/file.h Thu Feb 13 00:20:53 2014 -+++ libmagic/file.h Fri Feb 21 00:21:27 2014 ++++ libmagic/file.h Wed Aug 27 12:35:45 2014 @@ -33,11 +33,9 @@ #ifndef __file_h__ #define __file_h__ @@ -1383,7 +1459,13 @@ diff -u libmagic.orig/file.h libmagic/file.h ((t) == FILE_STRING || \ (t) == FILE_PSTRING || \ (t) == FILE_BESTRING16 || \ -@@ -411,22 +413,18 @@ +@@ -405,28 +407,23 @@ + /* Type for Unicode characters */ + typedef unsigned long unichar; + +-struct stat; + #define FILE_T_LOCAL 1 + #define FILE_T_WINDOWS 2 protected const char *file_fmttime(uint64_t, int, char *); protected struct magic_set *file_ms_alloc(int); protected void file_ms_free(struct magic_set *); @@ -1391,7 +1473,7 @@ diff -u libmagic.orig/file.h libmagic/file.h +protected int file_buffer(struct magic_set *, php_stream *, const char *, const void *, size_t); -protected int file_fsmagic(struct magic_set *, const char *, struct stat *); -+protected int file_fsmagic(struct magic_set *, const char *, struct stat *, php_stream *); ++protected int file_fsmagic(struct magic_set *, const char *, zend_stat_t *, php_stream *); protected int file_pipe2file(struct magic_set *, int, const void *, size_t); -protected int file_vprintf(struct magic_set *, const char *, va_list) - __attribute__((__format__(__printf__, 2, 0))); @@ -1410,7 +1492,7 @@ diff -u libmagic.orig/file.h libmagic/file.h protected int file_zmagic(struct magic_set *, int, const char *, const unsigned char *, size_t); #endif -@@ -444,16 +442,13 @@ +@@ -444,16 +441,13 @@ protected int file_magicfind(struct magic_set *, const char *, struct mlist *); protected uint64_t file_signextend(struct magic_set *, struct magic *, uint64_t); @@ -1431,7 +1513,7 @@ diff -u libmagic.orig/file.h libmagic/file.h protected void file_showstr(FILE *, const char *, size_t); protected size_t file_mbswidth(const char *); protected const char *file_getbuffer(struct magic_set *); -@@ -463,16 +458,14 @@ +@@ -463,16 +457,14 @@ size_t *); protected size_t file_pstring_length_size(const struct magic *); protected size_t file_pstring_get_length(const struct magic *, const char *); @@ -1449,7 +1531,7 @@ diff -u libmagic.orig/file.h libmagic/file.h #ifndef HAVE_STRERROR extern int sys_nerr; -@@ -485,20 +478,10 @@ +@@ -485,20 +477,10 @@ #define strtoul(a, b, c) strtol(a, b, c) #endif @@ -1472,7 +1554,7 @@ diff -u libmagic.orig/file.h libmagic/file.h size_t strlcat(char *, const char *, size_t); #endif #ifndef HAVE_STRCASESTR -@@ -535,6 +518,14 @@ +@@ -535,6 +517,14 @@ #endif #else #define FILE_RCSID(id) @@ -1489,7 +1571,7 @@ diff -u libmagic.orig/file.h libmagic/file.h #endif /* __file_h__ */ diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c --- libmagic.orig/fsmagic.c Sun Dec 1 20:22:13 2013 -+++ libmagic/fsmagic.c Fri Feb 21 00:21:27 2014 ++++ libmagic/fsmagic.c Wed Aug 27 12:35:45 2014 @@ -59,27 +59,21 @@ # define minor(dev) ((dev) & 0xff) #endif @@ -1537,7 +1619,7 @@ diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c protected int -file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb) -+file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb, php_stream *stream) ++file_fsmagic(struct magic_set *ms, const char *fn, zend_stat_t *sb, php_stream *stream) { int ret, did = 0; int mime = ms->flags & MAGIC_MIME; @@ -1814,7 +1896,16 @@ diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c } diff -u libmagic.orig/funcs.c libmagic/funcs.c --- libmagic.orig/funcs.c Thu Feb 13 00:20:53 2014 -+++ libmagic/funcs.c Wed Mar 19 13:28:34 2014 ++++ libmagic/funcs.c Sat Aug 30 10:39:10 2014 +@@ -27,7 +27,7 @@ + #include "file.h" + + #ifndef lint +-FILE_RCSID("@(#)$File: funcs.c,v 1.67 2014/02/12 23:20:53 christos Exp $") ++FILE_RCSID("@(#)$File: funcs.c,v 1.68 2014/02/18 11:09:31 kim Exp $") + #endif /* lint */ + + #include "magic.h" @@ -41,79 +41,79 @@ #if defined(HAVE_WCTYPE_H) #include @@ -1865,7 +1956,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c - file_error(ms, errno, "vasprintf failed"); - return -1; -} -+extern public void convert_libmagic_pattern(zval *pattern, int options); ++extern public void convert_libmagic_pattern(zval *pattern, char *val, int len, int options); protected int file_printf(struct magic_set *ms, const char *fmt, ...) @@ -1947,7 +2038,26 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c { int m = 0, rv = 0, looks_text = 0; int mime = ms->flags & MAGIC_MIME; -@@ -203,10 +202,10 @@ +@@ -174,8 +173,7 @@ + const char *code_mime = "binary"; + const char *type = "application/octet-stream"; + const char *def = "data"; +- +- ++ const char *ftype = NULL; + + if (nb == 0) { + def = "empty"; +@@ -188,7 +186,7 @@ + + if ((ms->flags & MAGIC_NO_CHECK_ENCODING) == 0) { + looks_text = file_encoding(ms, ubuf, nb, &u8buf, &ulen, +- &code, &code_mime, &type); ++ &code, &code_mime, &ftype); + } + + #ifdef __EMX__ +@@ -203,10 +201,10 @@ } } #endif @@ -1961,7 +2071,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c if ((ms->flags & MAGIC_DEBUG) != 0) (void)fprintf(stderr, "zmagic %d\n", m); goto done_encoding; -@@ -221,12 +220,17 @@ +@@ -221,12 +219,17 @@ } /* Check if we have a CDF file */ @@ -1984,7 +2094,16 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c /* try soft magic tests */ if ((ms->flags & MAGIC_NO_CHECK_SOFT) == 0) -@@ -300,7 +304,6 @@ +@@ -268,7 +271,7 @@ + if ((ms->flags & MAGIC_NO_CHECK_ENCODING) == 0) { + if (looks_text == 0) + if ((m = file_ascmagic_with_encoding( ms, ubuf, +- nb, u8buf, ulen, code, type, looks_text)) ++ nb, u8buf, ulen, code, ftype, looks_text)) + != 0) { + if ((ms->flags & MAGIC_DEBUG) != 0) + (void)fprintf(stderr, +@@ -300,7 +303,6 @@ return m; } @@ -1992,7 +2111,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c protected int file_reset(struct magic_set *ms) -@@ -310,11 +313,11 @@ +@@ -310,11 +312,11 @@ return -1; } if (ms->o.buf) { @@ -2006,7 +2125,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c ms->o.pbuf = NULL; } ms->event_flags &= ~EVENT_HAD_ERR; -@@ -333,7 +336,7 @@ +@@ -333,7 +335,7 @@ protected const char * file_getbuffer(struct magic_set *ms) { @@ -2015,7 +2134,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c size_t psize, len; if (ms->event_flags & EVENT_HAD_ERR) -@@ -348,15 +351,13 @@ +@@ -348,15 +350,13 @@ /* * 4 is for octal representation, + 1 is for NUL */ len = strlen(ms->o.buf); if (len > (SIZE_MAX - 1) / 4) { @@ -2032,7 +2151,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c #if defined(HAVE_WCHAR_H) && defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH) { -@@ -416,8 +417,8 @@ +@@ -416,8 +416,8 @@ if (level >= ms->c.len) { len = (ms->c.len += 20) * sizeof(*ms->c.li); ms->c.li = CAST(struct level_info *, (ms->c.li == NULL) ? @@ -2043,7 +2162,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c if (ms->c.li == NULL) { file_oomem(ms, len); return -1; -@@ -437,32 +438,50 @@ +@@ -437,32 +437,42 @@ return ms->o.buf == NULL ? 0 : strlen(ms->o.buf); } @@ -2052,12 +2171,12 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c { - regex_t rx; - int rc, rv = -1; -+ zval *patt; ++ zval patt; + int opts = 0; + pcre_cache_entry *pce; -+ char *res; -+ zval *repl; -+ int res_len, rep_cnt = 0; ++ zend_string *res; ++ zval repl; ++ int rep_cnt = 0; + TSRMLS_FETCH(); (void)setlocale(LC_CTYPE, "C"); @@ -2079,36 +2198,28 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c - regfree(&rx); - rv = nm; + -+ MAKE_STD_ZVAL(patt); -+ ZVAL_STRINGL(patt, pat, strlen(pat), 0); + opts |= PCRE_MULTILINE; -+ convert_libmagic_pattern(patt, opts); -+ if ((pce = pcre_get_compiled_regex_cache(Z_STRVAL_P(patt), Z_STRLEN_P(patt) TSRMLS_CC)) == NULL) { -+ zval_dtor(patt); -+ FREE_ZVAL(patt); ++ convert_libmagic_pattern(&patt, pat, strlen(pat), opts); ++ if ((pce = pcre_get_compiled_regex_cache(Z_STR(patt) TSRMLS_CC)) == NULL) { ++ zval_ptr_dtor(&patt); + rep_cnt = -1; + goto out; } ++ zval_ptr_dtor(&patt); + -+ MAKE_STD_ZVAL(repl); -+ ZVAL_STRINGL(repl, rep, strlen(rep), 0); -+ -+ res = php_pcre_replace_impl(pce, ms->o.buf, strlen(ms->o.buf), repl, -+ 0, &res_len, -1, &rep_cnt TSRMLS_CC); -+ -+ FREE_ZVAL(repl); -+ zval_dtor(patt); -+ FREE_ZVAL(patt); ++ ZVAL_STRING(&repl, rep); ++ res = php_pcre_replace_impl(pce, ms->o.buf, strlen(ms->o.buf), &repl, 0, -1, &rep_cnt TSRMLS_CC); + ++ zval_ptr_dtor(&repl); + if (NULL == res) { + rep_cnt = -1; + goto out; + } + -+ strncpy(ms->o.buf, res, res_len); -+ ms->o.buf[res_len] = '\0'; ++ strncpy(ms->o.buf, res->val, res->len); ++ ms->o.buf[res->len] = '\0'; + -+ efree(res); ++ zend_string_release(res); + out: (void)setlocale(LC_CTYPE, ""); @@ -2117,7 +2228,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c } diff -u libmagic.orig/magic.c libmagic/magic.c --- libmagic.orig/magic.c Sun Dec 1 20:22:13 2013 -+++ libmagic/magic.c Fri Feb 21 00:21:27 2014 ++++ libmagic/magic.c Wed Aug 27 20:49:37 2014 @@ -25,11 +25,6 @@ * SUCH DAMAGE. */ @@ -2169,7 +2280,8 @@ diff -u libmagic.orig/magic.c libmagic/magic.c +#endif + private void close_and_restore(const struct magic_set *, const char *, int, - const struct stat *); +- const struct stat *); ++ const zend_stat_t *); private int unreadable_info(struct magic_set *, mode_t, const char *); +#if 0 private const char* get_default_magic(void); @@ -2262,9 +2374,12 @@ diff -u libmagic.orig/magic.c libmagic/magic.c public int magic_list(struct magic_set *ms, const char *magicfile) -@@ -282,9 +288,6 @@ +@@ -280,11 +286,8 @@ + + private void close_and_restore(const struct magic_set *ms, const char *name, int fd, - const struct stat *sb) +- const struct stat *sb) ++ const zend_stat_t *sb) { - if (fd == STDIN_FILENO || name == NULL) - return; @@ -2311,7 +2426,8 @@ diff -u libmagic.orig/magic.c libmagic/magic.c { int rv = -1; unsigned char *buf; - struct stat sb; +- struct stat sb; ++ zend_stat_t sb; ssize_t nbytes = 0; /* number of bytes read from a datafile */ - int ispipe = 0; - off_t pos = (off_t)-1; @@ -2456,7 +2572,7 @@ diff -u libmagic.orig/magic.c libmagic/magic.c magic_error(struct magic_set *ms) diff -u libmagic.orig/magic.h libmagic/magic.h --- libmagic.orig/magic.h Wed Feb 19 10:53:11 2014 -+++ libmagic/magic.h Fri Feb 21 00:21:27 2014 ++++ libmagic/magic.h Wed Aug 27 12:35:45 2014 @@ -88,6 +88,7 @@ const char *magic_getpath(const char *, int); @@ -2475,7 +2591,7 @@ diff -u libmagic.orig/magic.h libmagic/magic.h diff -u libmagic.orig/print.c libmagic/print.c --- libmagic.orig/print.c Tue Feb 26 19:25:00 2013 -+++ libmagic/print.c Fri Feb 21 00:21:27 2014 ++++ libmagic/print.c Wed Aug 27 12:35:45 2014 @@ -28,13 +28,17 @@ /* * print.c - debugging printout routines @@ -2706,7 +2822,7 @@ diff -u libmagic.orig/print.c libmagic/print.c } diff -u libmagic.orig/readcdf.c libmagic/readcdf.c --- libmagic.orig/readcdf.c Tue Jan 7 04:13:42 2014 -+++ libmagic/readcdf.c Thu Jun 5 18:05:33 2014 ++++ libmagic/readcdf.c Wed Oct 22 17:56:13 2014 @@ -26,11 +26,15 @@ #include "file.h" @@ -2724,7 +2840,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c #include #include #include -@@ -69,6 +73,44 @@ +@@ -69,6 +73,50 @@ { NULL, NULL, }, }; @@ -2743,6 +2859,9 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c + { 0x00000000000c1084LLU, 0x46000000000000c0LLU }, +#endif + "x-msi", ++ }, ++ { { 0, 0 }, ++ NULL, + } +}, clsid2desc[] = { + { @@ -2753,6 +2872,9 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c +#endif + "MSI Installer", + }, ++ { { 0, 0 }, ++ NULL, ++ } +}; + +private const char * @@ -2769,7 +2891,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c private const char * cdf_app_to_mime(const char *vbuf, const struct nv *nv) { -@@ -87,16 +129,21 @@ +@@ -87,16 +135,21 @@ private int cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info, @@ -2793,7 +2915,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c for (i = 0; i < count; i++) { cdf_print_property_name(buf, sizeof(buf), info[i].pi_id); switch (info[i].pi_type) { -@@ -153,7 +200,7 @@ +@@ -153,7 +206,7 @@ buf, vbuf) == -1) return -1; } @@ -2802,7 +2924,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c CDF_PROPERTY_NAME_OF_APPLICATION) { str = cdf_app_to_mime(vbuf, app2mime); } -@@ -162,8 +209,12 @@ +@@ -162,8 +215,12 @@ case CDF_FILETIME: tp = info[i].pi_tp; if (tp != 0) { @@ -2817,7 +2939,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c cdf_print_elapsed_time(tbuf, sizeof(tbuf), tp); if (NOTMIME(ms) && file_printf(ms, -@@ -171,8 +222,11 @@ +@@ -171,8 +228,11 @@ return -1; } else { char *c, *ec; @@ -2831,7 +2953,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c if (c != NULL && (ec = strchr(c, '\n')) != NULL) *ec = '\0'; -@@ -200,7 +254,7 @@ +@@ -200,7 +260,7 @@ private int cdf_file_summary_info(struct magic_set *ms, const cdf_header_t *h, @@ -2840,7 +2962,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c { cdf_summary_info_header_t si; cdf_property_info_t *info; -@@ -211,6 +265,8 @@ +@@ -211,6 +271,8 @@ return -1; if (NOTMIME(ms)) { @@ -2849,7 +2971,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c if (file_printf(ms, "Composite Document File V2 Document") == -1) return -1; -@@ -238,9 +294,15 @@ +@@ -238,9 +300,15 @@ return -2; break; } @@ -2867,7 +2989,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c free(info); return m == -1 ? -2 : m; -@@ -258,6 +320,7 @@ +@@ -258,6 +326,7 @@ int i; const char *expn = ""; const char *corrupt = "corrupt: "; @@ -2875,7 +2997,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c info.i_fd = fd; info.i_buf = buf; -@@ -291,7 +354,8 @@ +@@ -291,7 +360,8 @@ goto out2; } @@ -2885,7 +3007,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c expn = "Cannot read short stream"; goto out3; } -@@ -312,23 +376,21 @@ +@@ -312,23 +382,21 @@ #ifdef CDF_DEBUG cdf_dump_summary_info(&h, &scn); #endif @@ -2918,14 +3040,23 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c if (str != NULL) { diff -u libmagic.orig/readelf.c libmagic/readelf.c --- libmagic.orig/readelf.c Tue Nov 5 16:44:01 2013 -+++ libmagic/readelf.c Fri Feb 21 00:21:27 2014 -@@ -48,8 +48,8 @@ ++++ libmagic/readelf.c Sat Oct 25 11:42:59 2014 +@@ -42,14 +42,14 @@ + #include "magic.h" + + #ifdef ELFCORE +-private int dophn_core(struct magic_set *, int, int, int, off_t, int, size_t, +- off_t, int *); ++private int dophn_core(struct magic_set *, int, int, int, zend_off_t, int, size_t, ++ zend_off_t, int *); + #endif private int dophn_exec(struct magic_set *, int, int, int, off_t, int, size_t, - off_t, int *, int); +- off_t, int *, int); ++ zend_off_t, int *, int); private int doshn(struct magic_set *, int, int, int, off_t, int, size_t, - off_t, int *, int, int); -private size_t donote(struct magic_set *, void *, size_t, size_t, int, -+ off_t, int *, int); ++ zend_off_t, int *, int); +private size_t donote(struct magic_set *, unsigned char *, size_t, size_t, int, int, size_t, int *); @@ -2945,7 +3076,40 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c #define xsh_addr (clazz == ELFCLASS32 \ ? (void *)&sh32 \ -@@ -292,7 +298,7 @@ +@@ -138,7 +144,7 @@ + #define xsh_size (size_t)(clazz == ELFCLASS32 \ + ? elf_getu32(swap, sh32.sh_size) \ + : elf_getu64(swap, sh64.sh_size)) +-#define xsh_offset (off_t)(clazz == ELFCLASS32 \ ++#define xsh_offset (zend_off_t)(clazz == ELFCLASS32 \ + ? elf_getu32(swap, sh32.sh_offset) \ + : elf_getu64(swap, sh64.sh_offset)) + #define xsh_type (clazz == ELFCLASS32 \ +@@ -156,13 +162,13 @@ + #define xph_type (clazz == ELFCLASS32 \ + ? elf_getu32(swap, ph32.p_type) \ + : elf_getu32(swap, ph64.p_type)) +-#define xph_offset (off_t)(clazz == ELFCLASS32 \ ++#define xph_offset (zend_off_t)(clazz == ELFCLASS32 \ + ? elf_getu32(swap, ph32.p_offset) \ + : elf_getu64(swap, ph64.p_offset)) + #define xph_align (size_t)((clazz == ELFCLASS32 \ +- ? (off_t) (ph32.p_align ? \ ++ ? (zend_off_t) (ph32.p_align ? \ + elf_getu32(swap, ph32.p_align) : 4) \ +- : (off_t) (ph64.p_align ? \ ++ : (zend_off_t) (ph64.p_align ? \ + elf_getu64(swap, ph64.p_align) : 4))) + #define xph_filesz (size_t)((clazz == ELFCLASS32 \ + ? elf_getu32(swap, ph32.p_filesz) \ +@@ -287,12 +293,12 @@ + #define FLAGS_IS_CORE 0x10 + + private int +-dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off, +- int num, size_t size, off_t fsize, int *flags) ++dophn_core(struct magic_set *ms, int clazz, int swap, int fd, zend_off_t off, ++ int num, size_t size, zend_off_t fsize, int *flags) { Elf32_Phdr ph32; Elf64_Phdr ph64; @@ -2959,7 +3123,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c */ for ( ; num; num--) { - if (pread(fd, xph_addr, xph_sizeof, off) == -1) { -+ if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (off_t)-1) { ++ if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (zend_off_t)-1) { + file_badseek(ms); + return -1; + } @@ -2973,7 +3137,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c */ - len = xph_filesz < sizeof(nbuf) ? xph_filesz : sizeof(nbuf); - if ((bufsize = pread(fd, nbuf, len, xph_offset)) == -1) { -+ if (FINFO_LSEEK_FUNC(fd, xph_offset, SEEK_SET) == (off_t)-1) { ++ if (FINFO_LSEEK_FUNC(fd, xph_offset, SEEK_SET) == (zend_off_t)-1) { + file_badseek(ms); + return -1; + } @@ -2983,7 +3147,30 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c file_badread(ms); return -1; } -@@ -913,24 +928,12 @@ +@@ -477,6 +492,13 @@ + uint32_t namesz, descsz; + unsigned char *nbuf = CAST(unsigned char *, vbuf); + ++ if (xnh_sizeof + offset > size) { ++ /* ++ * We're out of note headers. ++ */ ++ return xnh_sizeof + offset; ++ } ++ + (void)memcpy(xnh_addr, &nbuf[offset], xnh_sizeof); + offset += xnh_sizeof; + +@@ -902,7 +924,7 @@ + Elf64_Shdr sh64; + int stripped = 1; + void *nbuf; +- off_t noff, coff, name_off; ++ zend_off_t noff, coff, name_off; + uint64_t cap_hw1 = 0; /* SunOS 5.x hardware capabilites */ + uint64_t cap_sf1 = 0; /* SunOS 5.x software capabilites */ + char name[50]; +@@ -913,24 +935,12 @@ return 0; } @@ -2998,7 +3185,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c - /* Read the name of this section. */ - if (pread(fd, name, sizeof(name), name_off + xsh_name) == -1) { - file_badread(ms); -+ if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (off_t)-1) { ++ if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (zend_off_t)-1) { + file_badseek(ms); return -1; } @@ -3011,7 +3198,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c file_badread(ms); return -1; } -@@ -955,14 +958,17 @@ +@@ -955,41 +965,35 @@ /* Things we can determine when we seek */ switch (xsh_type) { case SHT_NOTE: @@ -3019,8 +3206,8 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c - file_error(ms, errno, "Cannot allocate memory" - " for note"); + nbuf = emalloc((size_t)xsh_size); -+ if ((noff = FINFO_LSEEK_FUNC(fd, (off_t)xsh_offset, SEEK_SET)) == -+ (off_t)-1) { ++ if ((noff = FINFO_LSEEK_FUNC(fd, (zend_off_t)xsh_offset, SEEK_SET)) == ++ (zend_off_t)-1) { + file_badread(ms); + efree(nbuf); return -1; @@ -3034,8 +3221,10 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c return -1; } -@@ -971,25 +977,16 @@ - if (noff >= (off_t)xsh_size) + noff = 0; + for (;;) { +- if (noff >= (off_t)xsh_size) ++ if (noff >= (zend_off_t)xsh_size) break; noff = donote(ms, nbuf, (size_t)noff, - xsh_size, clazz, swap, 4, flags); @@ -3060,21 +3249,24 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c - } - - if (lseek(fd, xsh_offset, SEEK_SET) == (off_t)-1) { -+ if (FINFO_LSEEK_FUNC(fd, (off_t)xsh_offset, SEEK_SET) == -+ (off_t)-1) { ++ if (FINFO_LSEEK_FUNC(fd, (zend_off_t)xsh_offset, SEEK_SET) == ++ (zend_off_t)-1) { file_badseek(ms); return -1; } -@@ -1001,7 +998,7 @@ +@@ -999,9 +1003,9 @@ + Elf64_Cap cap64; + char cbuf[/*CONSTCOND*/ MAX(sizeof cap32, sizeof cap64)]; - if ((coff += xcap_sizeof) > (off_t)xsh_size) +- if ((coff += xcap_sizeof) > (off_t)xsh_size) ++ if ((coff += xcap_sizeof) > (zend_off_t)xsh_size) break; - if (read(fd, cbuf, (size_t)xcap_sizeof) != + if (FINFO_READ_FUNC(fd, cbuf, (size_t)xcap_sizeof) != (ssize_t)xcap_sizeof) { file_badread(ms); return -1; -@@ -1027,13 +1024,12 @@ +@@ -1027,13 +1031,12 @@ break; } } @@ -3090,7 +3282,18 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c if (file_printf(ms, ", %sstripped", stripped ? "" : "not ") == -1) return -1; if (cap_hw1) { -@@ -1112,7 +1108,7 @@ +@@ -1103,8 +1106,8 @@ + * otherwise it's statically linked. + */ + private int +-dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off, +- int num, size_t size, off_t fsize, int *flags, int sh_num) ++dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, zend_off_t off, ++ int num, size_t size, zend_off_t fsize, int *flags, int sh_num) + { + Elf32_Phdr ph32; + Elf64_Phdr ph64; +@@ -1112,7 +1115,7 @@ const char *shared_libraries = ""; unsigned char nbuf[BUFSIZ]; ssize_t bufsize; @@ -3099,13 +3302,13 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c if (size != xph_sizeof) { if (file_printf(ms, ", corrupted program header size") == -1) -@@ -1121,8 +1117,13 @@ +@@ -1121,8 +1124,13 @@ } for ( ; num; num--) { - if (pread(fd, xph_addr, xph_sizeof, off) == -1) { - file_badread(ms); -+ if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (off_t)-1) { ++ if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (zend_off_t)-1) { + file_badseek(ms); + return -1; + } @@ -3115,14 +3318,14 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c return -1; } -@@ -1160,9 +1161,12 @@ +@@ -1160,9 +1168,12 @@ * This is a PT_NOTE section; loop through all the notes * in the section. */ - len = xph_filesz < sizeof(nbuf) ? xph_filesz - : sizeof(nbuf); - bufsize = pread(fd, nbuf, len, xph_offset); -+ if (FINFO_LSEEK_FUNC(fd, xph_offset, SEEK_SET) == (off_t)-1) { ++ if (FINFO_LSEEK_FUNC(fd, xph_offset, SEEK_SET) == (zend_off_t)-1) { + file_badseek(ms); + return -1; + } @@ -3131,18 +3334,27 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c if (bufsize == -1) { file_badread(ms); return -1; -@@ -1223,7 +1227,7 @@ +@@ -1200,7 +1211,7 @@ + int clazz; + int swap; + struct stat st; +- off_t fsize; ++ zend_off_t fsize; + int flags = 0; + Elf32_Ehdr elf32hdr; + Elf64_Ehdr elf64hdr; +@@ -1223,7 +1234,7 @@ /* * If we cannot seek, it must be a pipe, socket or fifo. */ - if((lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) && (errno == ESPIPE)) -+ if((FINFO_LSEEK_FUNC(fd, (off_t)0, SEEK_SET) == (off_t)-1) && (errno == ESPIPE)) ++ if((FINFO_LSEEK_FUNC(fd, (zend_off_t)0, SEEK_SET) == (zend_off_t)-1) && (errno == ESPIPE)) fd = file_pipe2file(ms, fd, buf, nbytes); if (fstat(fd, &st) == -1) { diff -u libmagic.orig/readelf.h libmagic/readelf.h --- libmagic.orig/readelf.h Tue Nov 5 16:41:56 2013 -+++ libmagic/readelf.h Fri Feb 21 00:21:27 2014 ++++ libmagic/readelf.h Wed Aug 27 12:35:45 2014 @@ -44,9 +44,17 @@ typedef uint32_t Elf32_Word; typedef uint8_t Elf32_Char; @@ -3163,7 +3375,7 @@ diff -u libmagic.orig/readelf.h libmagic/readelf.h typedef uint8_t Elf64_Char; diff -u libmagic.orig/softmagic.c libmagic/softmagic.c --- libmagic.orig/softmagic.c Thu Feb 13 00:20:53 2014 -+++ libmagic/softmagic.c Tue Jul 1 08:57:25 2014 ++++ libmagic/softmagic.c Fri Sep 19 16:29:55 2014 @@ -50,6 +50,11 @@ #include #endif @@ -3176,6 +3388,15 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c private int match(struct magic_set *, struct magic *, uint32_t, const unsigned char *, size_t, size_t, int, int, int, int, int *, int *, +@@ -62,7 +67,7 @@ + private int32_t moffset(struct magic_set *, struct magic *); + private void mdebug(uint32_t, const char *, size_t); + private int mcopy(struct magic_set *, union VALUETYPE *, int, int, +- const unsigned char *, uint32_t, size_t, size_t); ++ const unsigned char *, uint32_t, size_t, struct magic *); + private int mconvert(struct magic_set *, struct magic *, int); + private int print_sep(struct magic_set *, int); + private int handle_annotation(struct magic_set *, struct magic *); @@ -71,7 +76,8 @@ private void cvt_32(union VALUETYPE *, const struct magic *); private void cvt_64(union VALUETYPE *, const struct magic *); @@ -3206,7 +3427,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c m = &magic[magindex]; ms->line = m->lineno; /* for messages */ -@@ -350,46 +356,24 @@ +@@ -350,46 +356,27 @@ private int check_fmt(struct magic_set *ms, struct magic *m) { @@ -3216,6 +3437,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c + pcre *pce; + int re_options, rv = -1; + pcre_extra *re_extra; ++ zend_string *pattern; + TSRMLS_FETCH(); + if (strchr(m->desc, '%') == NULL) @@ -3227,7 +3449,8 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c - char errmsg[512]; - (void)regerror(rc, &rx, errmsg, sizeof(errmsg)); - file_magerror(ms, "regex error %d, (%s)", rc, errmsg); -+ if ((pce = pcre_get_compiled_regex("~%[-0-9.]*s~", &re_extra, &re_options TSRMLS_CC)) == NULL) { ++ pattern = zend_string_init("~%[-0-9.]*s~", sizeof("~%[-0-9.]*s~") - 1, 0); ++ if ((pce = pcre_get_compiled_regex(pattern, &re_extra, &re_options TSRMLS_CC)) == NULL) { + rv = -1; } else { - rc = regexec(&rx, m->desc, 0, 0, 0); @@ -3235,6 +3458,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c - rv = !rc; + rv = !pcre_exec(pce, re_extra, m->desc, strlen(m->desc), 0, re_options, NULL, 0); } ++ zend_string_release(pattern); (void)setlocale(LC_CTYPE, ""); return rv; } @@ -3261,7 +3485,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c private int32_t mprint(struct magic_set *ms, struct magic *m) { -@@ -618,13 +602,13 @@ +@@ -618,13 +605,13 @@ char *cp; int rval; @@ -3277,7 +3501,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c if (rval == -1) return -1; -@@ -870,16 +854,16 @@ +@@ -870,16 +857,16 @@ if (m->num_mask) \ switch (m->mask_op & FILE_OPS_MASK) { \ case FILE_OPADD: \ @@ -3298,7 +3522,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c break; \ } \ -@@ -931,10 +915,18 @@ +@@ -931,10 +918,18 @@ return 1; } case FILE_PSTRING: { @@ -3320,9 +3544,72 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c while (len--) *ptr1++ = *ptr2++; *ptr1 = '\0'; -@@ -1178,9 +1170,6 @@ - "nbytes=%zu, count=%u)\n", m->type, m->flag, offset, o, - nbytes, count); +@@ -1046,7 +1041,7 @@ + + private int + mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir, +- const unsigned char *s, uint32_t offset, size_t nbytes, size_t linecnt) ++ const unsigned char *s, uint32_t offset, size_t nbytes, struct magic *m) + { + /* + * Note: FILE_SEARCH and FILE_REGEX do not actually copy +@@ -1066,15 +1061,24 @@ + const char *last; /* end of search region */ + const char *buf; /* start of search region */ + const char *end; +- size_t lines; ++ size_t lines, linecnt, bytecnt; ++ ++ linecnt = m->str_range; ++ bytecnt = linecnt * 80; + ++ if (bytecnt == 0) { ++ bytecnt = 8192; ++ } ++ if (bytecnt > nbytes) { ++ bytecnt = nbytes; ++ } + if (s == NULL) { + ms->search.s_len = 0; + ms->search.s = NULL; + return 0; + } + buf = RCAST(const char *, s) + offset; +- end = last = RCAST(const char *, s) + nbytes; ++ end = last = RCAST(const char *, s) + bytecnt; + /* mget() guarantees buf <= last */ + for (lines = linecnt, b = buf; lines && b < end && + ((b = CAST(const char *, +@@ -1087,7 +1091,7 @@ + b++; + } + if (lines) +- last = RCAST(const char *, s) + nbytes; ++ last = RCAST(const char *, s) + bytecnt; + + ms->search.s = buf; + ms->search.s_len = last - buf; +@@ -1158,7 +1162,6 @@ + int *need_separator, int *returnval) + { + uint32_t soffset, offset = ms->offset; +- uint32_t count = m->str_range; + int rv, oneed_separator, in_type; + char *sbuf, *rbuf; + union VALUETYPE *p = &ms->ms_value; +@@ -1170,17 +1173,13 @@ + } + + if (mcopy(ms, p, m->type, m->flag & INDIR, s, (uint32_t)(offset + o), +- (uint32_t)nbytes, count) == -1) ++ (uint32_t)nbytes, m) == -1) + return -1; + + if ((ms->flags & MAGIC_DEBUG) != 0) { + fprintf(stderr, "mget(type=%d, flag=%x, offset=%u, o=%zu, " +- "nbytes=%zu, count=%u)\n", m->type, m->flag, offset, o, +- nbytes, count); ++ "nbytes=%zu)\n", m->type, m->flag, offset, o, nbytes); mdebug(offset, (char *)(void *)p, sizeof(union VALUETYPE)); -#ifndef COMPILE_ONLY - file_mdump(m); @@ -3330,7 +3617,15 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c } if (m->flag & INDIR) { -@@ -1679,9 +1668,6 @@ +@@ -1672,16 +1671,13 @@ + if ((ms->flags & MAGIC_DEBUG) != 0) + fprintf(stderr, "indirect +offs=%u\n", offset); + } +- if (mcopy(ms, p, m->type, 0, s, offset, nbytes, count) == -1) ++ if (mcopy(ms, p, m->type, 0, s, offset, nbytes, m) == -1) + return -1; + ms->offset = offset; + if ((ms->flags & MAGIC_DEBUG) != 0) { mdebug(offset, (char *)(void *)p, sizeof(union VALUETYPE)); @@ -3340,7 +3635,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c } } -@@ -1755,11 +1741,21 @@ +@@ -1755,11 +1751,21 @@ ms->offset = soffset; if (rv == 1) { if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 && @@ -3365,50 +3660,49 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c } return rv; -@@ -1875,6 +1871,42 @@ +@@ -1875,6 +1881,41 @@ return file_strncmp(a, b, len, flags); } +public void -+convert_libmagic_pattern(zval *pattern, int options) ++convert_libmagic_pattern(zval *pattern, char *val, int len, int options) +{ -+ int i, j=0; -+ char *t; ++ int i, j=0; ++ zend_string *t; + -+ t = (char *) safe_emalloc(Z_STRLEN_P(pattern), 2, 5); -+ -+ t[j++] = '~'; -+ -+ for (i=0; ival[j++] = '~'; ++ ++ for (i = 0; i < len; i++, j++) { ++ switch (val[i]) { ++ case '~': ++ t->val[j++] = '\\'; ++ t->val[j] = '~'; ++ break; ++ default: ++ t->val[j] = val[i]; ++ break; + } -+ t[j++] = '~'; -+ -+ if (options & PCRE_CASELESS) -+ t[j++] = 'i'; -+ -+ if (options & PCRE_MULTILINE) -+ t[j++] = 'm'; ++ } ++ t->val[j++] = '~'; + -+ t[j]='\0'; -+ -+ Z_STRVAL_P(pattern) = t; -+ Z_STRLEN_P(pattern) = j; ++ if (options & PCRE_CASELESS) ++ t->val[j++] = 'i'; + ++ if (options & PCRE_MULTILINE) ++ t->val[j++] = 'm'; ++ ++ t->val[j]='\0'; ++ t->len = j; ++ ++ ZVAL_NEW_STR(pattern, t); +} + private int magiccheck(struct magic_set *ms, struct magic *m) { -@@ -2035,63 +2067,151 @@ +@@ -2035,63 +2076,112 @@ break; } case FILE_REGEX: { @@ -3418,141 +3712,61 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c - - if (ms->search.s == NULL) - return 0; -+ zval *pattern; ++ zval pattern; + int options = 0; + pcre_cache_entry *pce; + TSRMLS_FETCH(); + -+ MAKE_STD_ZVAL(pattern); -+ ZVAL_STRINGL(pattern, (char *)m->value.s, m->vallen, 0); -+ + options |= PCRE_MULTILINE; + + if (m->str_flags & STRING_IGNORE_CASE) { + options |= PCRE_CASELESS; + } + -+ convert_libmagic_pattern(pattern, options); ++ convert_libmagic_pattern(&pattern, (char *)m->value.s, m->vallen, options); + + l = v = 0; -+ if ((pce = pcre_get_compiled_regex_cache(Z_STRVAL_P(pattern), Z_STRLEN_P(pattern) TSRMLS_CC)) == NULL) { -+ zval_dtor(pattern); -+ FREE_ZVAL(pattern); ++ if ((pce = pcre_get_compiled_regex_cache(Z_STR(pattern) TSRMLS_CC)) == NULL) { ++ zval_ptr_dtor(&pattern); + return -1; + } else { + /* pce now contains the compiled regex */ -+ zval *retval; -+ zval *subpats; ++ zval retval; ++ zval subpats; + char *haystack; + -+ MAKE_STD_ZVAL(retval); -+ ALLOC_INIT_ZVAL(subpats); -+ ++ ZVAL_NULL(&retval); ++ ZVAL_NULL(&subpats); ++ + /* Cut the search len from haystack, equals to REG_STARTEND */ + haystack = estrndup(ms->search.s, ms->search.s_len); + + /* match v = 0, no match v = 1 */ -+ php_pcre_match_impl(pce, haystack, ms->search.s_len, retval, subpats, 1, 1, PREG_OFFSET_CAPTURE, 0 TSRMLS_CC); ++ php_pcre_match_impl(pce, haystack, ms->search.s_len, &retval, &subpats, 1, 1, PREG_OFFSET_CAPTURE, 0 TSRMLS_CC); + /* Free haystack */ + efree(haystack); + -+ if (Z_LVAL_P(retval) < 0) { ++ if (Z_LVAL(retval) < 0) { + zval_ptr_dtor(&subpats); -+ FREE_ZVAL(retval); -+ zval_dtor(pattern); -+ FREE_ZVAL(pattern); ++ zval_ptr_dtor(&pattern); + return -1; -+ } else if ((Z_LVAL_P(retval) > 0) && (Z_TYPE_P(subpats) == IS_ARRAY)) { -+ ++ } else if ((Z_LVAL(retval) > 0) && (Z_TYPE(subpats) == IS_ARRAY)) { + /* Need to fetch global match which equals pmatch[0] */ -+ HashTable *ht = Z_ARRVAL_P(subpats); -+ HashPosition outer_pos; ++ zval *pzval; ++ HashTable *ht = Z_ARRVAL(subpats); + zval *pattern_match = NULL, *pattern_offset = NULL; -+ -+ zend_hash_internal_pointer_reset_ex(ht, &outer_pos); -+ -+ if (zend_hash_has_more_elements_ex(ht, &outer_pos) == SUCCESS && -+ zend_hash_move_forward_ex(ht, &outer_pos)) { -+ -+ zval **ppzval; -+ -+ /* The first element (should be) is the global match -+ Need to move to the inner array to get the global match */ -+ -+ if (zend_hash_get_current_data_ex(ht, (void**)&ppzval, &outer_pos) != FAILURE) { -+ -+ HashTable *inner_ht; -+ HashPosition inner_pos; -+ zval **match, **offset; -+ zval tmpcopy = **ppzval, matchcopy, offsetcopy; -+ -+ zval_copy_ctor(&tmpcopy); -+ INIT_PZVAL(&tmpcopy); -+ -+ inner_ht = Z_ARRVAL(tmpcopy); -+ -+ /* If everything goes according to the master plan -+ tmpcopy now contains two elements: -+ 0 = the match -+ 1 = starting position of the match */ -+ zend_hash_internal_pointer_reset_ex(inner_ht, &inner_pos); -+ -+ if (zend_hash_has_more_elements_ex(inner_ht, &inner_pos) == SUCCESS && -+ zend_hash_move_forward_ex(inner_ht, &inner_pos)) { -+ -+ if (zend_hash_get_current_data_ex(inner_ht, (void**)&match, &inner_pos) != FAILURE) { -+ -+ matchcopy = **match; -+ zval_copy_ctor(&matchcopy); -+ INIT_PZVAL(&matchcopy); -+ convert_to_string(&matchcopy); -+ -+ MAKE_STD_ZVAL(pattern_match); -+ Z_STRVAL_P(pattern_match) = (char *)Z_STRVAL(matchcopy); -+ Z_STRLEN_P(pattern_match) = Z_STRLEN(matchcopy); -+ Z_TYPE_P(pattern_match) = IS_STRING; ++ int first = 1, inner_first; + -+ zval_dtor(&matchcopy); -+ } -+ } -+ -+ if (zend_hash_has_more_elements_ex(inner_ht, &inner_pos) == SUCCESS && -+ zend_hash_move_forward_ex(inner_ht, &inner_pos)) { -+ -+ if (zend_hash_get_current_data_ex(inner_ht, (void**)&offset, &inner_pos) != FAILURE) { -+ -+ offsetcopy = **offset; -+ zval_copy_ctor(&offsetcopy); -+ INIT_PZVAL(&offsetcopy); -+ convert_to_long(&offsetcopy); -+ -+ MAKE_STD_ZVAL(pattern_offset); -+ Z_LVAL_P(pattern_offset) = Z_LVAL(offsetcopy); -+ Z_TYPE_P(pattern_offset) = IS_LONG; -+ -+ zval_dtor(&offsetcopy); -+ } -+ } -+ zval_dtor(&tmpcopy); ++ ZEND_HASH_FOREACH_VAL(ht, pzval) { ++ HashTable *inner_ht; ++ zval *match, *offset; ++ zval tmpcopy, matchcopy, offsetcopy; ++ ++ if (first) { ++ first = 0; ++ continue; + } -+ -+ if ((pattern_match != NULL) && (pattern_offset != NULL)) { -+ ms->search.s += (int)Z_LVAL_P(pattern_offset); /* this is where the match starts */ -+ ms->search.offset += (size_t)Z_LVAL_P(pattern_offset); /* this is where the match starts as size_t */ -+ ms->search.rm_len = Z_STRLEN_P(pattern_match) /* This is the length of the matched pattern */; -+ v = 0; -+ -+ efree(pattern_match); -+ efree(pattern_offset); -+ -+ } else { -+ zval_ptr_dtor(&subpats); -+ FREE_ZVAL(retval); -+ zval_dtor(pattern); -+ FREE_ZVAL(pattern); -+ return -1; -+ } -+ } ++ ZVAL_DUP(&tmpcopy, pzval); - l = 0; - rc = regcomp(&rx, m->value.s, @@ -3588,8 +3802,51 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c - (size_t)(pmatch[0].rm_eo - pmatch[0].rm_so); - v = 0; - break; ++ inner_ht = Z_ARRVAL(tmpcopy); - case REG_NOMATCH: ++ /* If everything goes according to the master plan ++ tmpcopy now contains two elements: ++ 0 = the match ++ 1 = starting position of the match */ ++ inner_first = 1; ++ ZEND_HASH_FOREACH_VAL(inner_ht, match) { ++ if (inner_first) { ++ inner_first = 0; ++ continue; ++ } ++ ZVAL_DUP(&matchcopy, match); ++ convert_to_string(&matchcopy); ++ pattern_match = &matchcopy; ++ } ZEND_HASH_FOREACH_END(); ++ ++ inner_first = 1; ++ ZEND_HASH_FOREACH_VAL(inner_ht, offset) { ++ if (inner_first) { ++ inner_first = 0; ++ continue; ++ } ++ ZVAL_DUP(&offsetcopy, offset); ++ convert_to_long(&offsetcopy); ++ pattern_offset = &offsetcopy; ++ } ZEND_HASH_FOREACH_END(); ++ ++ zval_dtor(&tmpcopy); ++ ++ if ((pattern_match != NULL) && (pattern_offset != NULL)) { ++ ms->search.s += Z_LVAL_P(pattern_offset); /* this is where the match starts */ ++ ms->search.offset += Z_LVAL_P(pattern_offset); /* this is where the match starts as size_t */ ++ ms->search.rm_len = Z_STRLEN_P(pattern_match) /* This is the length of the matched pattern */; ++ v = 0; ++ ++ zval_ptr_dtor(pattern_match); ++ zval_ptr_dtor(pattern_offset); ++ } else { ++ zval_ptr_dtor(&subpats); ++ zval_ptr_dtor(&pattern); ++ return -1; ++ } ++ } ZEND_HASH_FOREACH_END(); + } else { v = 1; - break; @@ -3603,18 +3860,16 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c } - regfree(&rx); + zval_ptr_dtor(&subpats); -+ FREE_ZVAL(retval); ++ zval_ptr_dtor(&pattern); } - if (v == (uint64_t)-1) - return -1; -+ zval_dtor(pattern); -+ FREE_ZVAL(pattern); break; } case FILE_INDIRECT: diff -u libmagic.orig/strcasestr.c libmagic/strcasestr.c --- libmagic.orig/strcasestr.c Thu Dec 5 17:57:50 2013 -+++ libmagic/strcasestr.c Sun May 4 21:29:20 2014 ++++ libmagic/strcasestr.c Wed Aug 27 12:35:45 2014 @@ -37,6 +37,8 @@ __RCSID("$NetBSD: strncasecmp.c,v 1.2 2007/06/04 18:19:27 christos Exp $"); #endif /* LIBC_SCCS and not lint */ From c1639b3e527e89e8199fafebfd4ff8e55b7f092c Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sat, 25 Oct 2014 13:01:17 +0200 Subject: [PATCH 056/398] stdint will be included in the win32 variant, so don't do it twice --- phpdbg.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/phpdbg.h b/phpdbg.h index 8c0dbb4afa0..4147198b3dc 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -29,8 +29,12 @@ # define PHPDBG_API #endif -#include -#include +#ifndef PHP_WIN32 +# include +# include +#else +# include "win32/php_stdint.h" +#endif #include "php.h" #include "php_globals.h" #include "php_variables.h" @@ -50,7 +54,6 @@ #if defined(_WIN32) && !defined(__MINGW32__) # include # include "config.w32.h" -# include "win32/php_stdint.h" # undef strcasecmp # undef strncasecmp # define strcasecmp _stricmp From b79e9044f90c4335c2a16f65bb31218a22ab282c Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sat, 25 Oct 2014 15:06:34 +0200 Subject: [PATCH 057/398] Fix listing of files with no absolute path --- phpdbg_list.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/phpdbg_list.c b/phpdbg_list.c index 80b5d2b1892..7aa8c4f9e08 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;) { From e995ad1131781db91fb58002e06d9c638122df3c Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sat, 25 Oct 2014 15:28:41 +0200 Subject: [PATCH 058/398] Fix eventual stack overflow after clean cmd --- phpdbg.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpdbg.c b/phpdbg.c index f09dc4ee13d..91133b3efb8 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -1532,6 +1532,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)); From be5242e0fedcf23bdf56a4b1a73f8a84c5b216ce Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sat, 25 Oct 2014 15:29:54 +0200 Subject: [PATCH 059/398] Set engine back to initial state after fatal-ed ev command --- phpdbg_prompt.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 82444fbf1d3..47d8f20154d 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -689,6 +689,16 @@ 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); + 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); @@ -716,6 +726,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; From 73a34fed93e6c7c9679518c43244b7a78b678cef Mon Sep 17 00:00:00 2001 From: Andrea Faulds Date: Sat, 25 Oct 2014 17:05:52 +0100 Subject: [PATCH 060/398] Fixed Closure::call() NEWS/UPGRADING --- NEWS | 2 +- UPGRADING | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 52af8e247ca..1c9fd616efa 100644 --- a/NEWS +++ b/NEWS @@ -12,7 +12,7 @@ PHP NEWS - Core: . Added PHP_INT_MIN constant. (Andrea) - . Added Closure::apply() method. (Andrea) + . Added Closure::call() method. (Andrea) . Implemented FR #38409 (parse_ini_file() looses the type of booleans). (Tjerk) . Fixed #67959 (Segfault when calling phpversion('spl')). (Florian) . Implemented the RFC `Catchable "Call to a member function bar() on a diff --git a/UPGRADING b/UPGRADING index 5e2c33c7c6f..6cc31732e84 100644 --- a/UPGRADING +++ b/UPGRADING @@ -52,7 +52,7 @@ PHP X.Y UPGRADE NOTES - Core . Support for strings with length >= 2^31 bytes in 64 bit builds - . Closure::apply() method added + . Closure::call() method added - Standard . intdiv() function for integer division added. From bbcee18b4b6d9220d4fdcb0d69a33979a5fa84a4 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sat, 25 Oct 2014 18:48:43 +0200 Subject: [PATCH 061/398] Fix phpdbg output when outputting via php with active output handlers --- phpdbg.c | 10 +--------- phpdbg_frame.c | 7 +++++++ phpdbg_prompt.c | 7 +++++++ phpdbg_utils.h | 25 +++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index 91133b3efb8..aaf1e5f4060 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)) { diff --git a/phpdbg_frame.c b/phpdbg_frame.c index df304e35411..437e6d474a8 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(""); zval_dtor(&zbacktrace); + + PHPDBG_OUTPUT_BACKUP_RESTORE(); } /* }}} */ diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 47d8f20154d..2e0c698f050 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 @@ -699,12 +700,16 @@ PHPDBG_COMMAND(ev) /* {{{ */ 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; } @@ -746,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 d657dc79fd9..9038aa74579 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 */ From e4e39d852a9dac3e2ee8dc46656ffefa41b6ce25 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sat, 25 Oct 2014 18:59:48 +0200 Subject: [PATCH 062/398] Merge phpdbg into PHP-5.6 --- phpdbg.c | 15 ++++++--------- phpdbg_frame.c | 7 +++++++ phpdbg_list.c | 9 +++++++++ phpdbg_prompt.c | 27 +++++++++++++++++++++++++++ phpdbg_utils.h | 25 +++++++++++++++++++++++++ 5 files changed, 74 insertions(+), 9 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index f09dc4ee13d..aaf1e5f4060 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 df304e35411..437e6d474a8 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(""); zval_dtor(&zbacktrace); + + PHPDBG_OUTPUT_BACKUP_RESTORE(); } /* }}} */ diff --git a/phpdbg_list.c b/phpdbg_list.c index 80b5d2b1892..7aa8c4f9e08 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 82444fbf1d3..2e0c698f050 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 d657dc79fd9..9038aa74579 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 */ From 918466c262d4118de2164a62a96ffcccadc587bd Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sun, 26 Oct 2014 03:50:28 +0100 Subject: [PATCH 063/398] Add question to reset execution in run/exec/clean --- phpdbg.c | 44 ++++++++--------- phpdbg.h | 7 +-- phpdbg_cmd.c | 82 ++++++++++-------------------- phpdbg_cmd.h | 1 + phpdbg_io.c | 49 ++++++++++++++++++ phpdbg_io.h | 2 + phpdbg_prompt.c | 129 ++++++++++++++++++++++++++---------------------- 7 files changed, 173 insertions(+), 141 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index aaf1e5f4060..ff03c670d06 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -45,6 +45,8 @@ #endif /* }}} */ ZEND_DECLARE_MODULE_GLOBALS(phpdbg); +int phpdbg_startup_run = 0; +char *phpdbg_exec = NULL; static PHP_INI_MH(OnUpdateEol) { @@ -487,7 +489,7 @@ static void php_sapi_phpdbg_log_message(char *message TSRMLS_DC) /* {{{ */ case PHPDBG_NEXT: return; } - } while (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)); + } while (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)); } } else fprintf(stdout, "%s\n", message); @@ -752,7 +754,7 @@ static void phpdbg_welcome(zend_bool cleaning TSRMLS_DC) /* {{{ */ phpdbg_writeln("intro", "help=\"help\"", "To get help using phpdbg type \"help\" and press enter"); phpdbg_notice("intro", "report=\"%s\"", "Please report bugs to <%s>", PHPDBG_ISSUES); phpdbg_xml(""); - } else { + } else if (phpdbg_startup_run == 0) { if (!(PHPDBG_G(flags) & PHPDBG_WRITE_XML)) { phpdbg_notice(NULL, NULL, "Clean Execution Environment"); } @@ -776,7 +778,7 @@ static inline void phpdbg_sigint_handler(int signo) /* {{{ */ if (PHPDBG_G(flags) & PHPDBG_IS_INTERACTIVE) { /* we quit remote consoles on recv SIGINT */ if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) { - PHPDBG_G(flags) |= PHPDBG_IS_QUITTING; + PHPDBG_G(flags) |= PHPDBG_IS_STOPPING; zend_bailout(); } } else { @@ -961,8 +963,6 @@ int main(int argc, char **argv) /* {{{ */ zend_ulong zend_extensions_len = 0L; zend_bool ini_ignore; char *ini_override; - char *exec; - size_t exec_len; char *init_file; size_t init_file_len; zend_bool init_file_default; @@ -973,7 +973,6 @@ int main(int argc, char **argv) /* {{{ */ int php_optind, opt, show_banner = 1; long cleaning = 0; zend_bool remote = 0; - int run = 0; int step = 0; #ifdef _WIN32 @@ -1046,8 +1045,6 @@ phpdbg_main: ini_override = NULL; zend_extensions = NULL; zend_extensions_len = 0L; - exec = NULL; - exec_len = 0; init_file = NULL; init_file_len = 0; init_file_default = 1; @@ -1057,14 +1054,13 @@ phpdbg_main: php_optarg = NULL; php_optind = 1; opt = 0; - run = 0; step = 0; sapi_name = NULL; while ((opt = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) { switch (opt) { case 'r': - run++; + phpdbg_startup_run++; break; case 'n': ini_ignore = 1; @@ -1201,14 +1197,12 @@ phpdbg_main: } /* set exec if present on command line */ - if ((argc > php_optind) && (strcmp(argv[php_optind-1],"--") != SUCCESS)) - { - exec_len = strlen(argv[php_optind]); - if (exec_len) { - if (exec) { - free(exec); + if (!phpdbg_exec && (argc > php_optind) && (strcmp(argv[php_optind-1],"--") != SUCCESS)) { + if (strlen(argv[php_optind])) { + if (phpdbg_exec) { + free(phpdbg_exec); } - exec = strdup(argv[php_optind]); + phpdbg_exec = strdup(argv[php_optind]); } php_optind++; } @@ -1331,7 +1325,7 @@ phpdbg_main: for (i = SG(request_info).argc; --i;) { SG(request_info).argv[i] = estrdup(argv[php_optind - 1 + i]); } - SG(request_info).argv[i] = exec ? estrndup(exec, exec_len) : estrdup(""); + SG(request_info).argv[i] = phpdbg_exec ? estrdup(phpdbg_exec) : estrdup(""); php_hash_environment(TSRMLS_C); } @@ -1394,11 +1388,12 @@ phpdbg_main: php_stream_stdio_ops.write = phpdbg_stdiop_write; #endif - if (exec) { /* set execution context */ - PHPDBG_G(exec) = phpdbg_resolve_path(exec TSRMLS_CC); + if (phpdbg_exec) { /* set execution context */ + PHPDBG_G(exec) = phpdbg_resolve_path(phpdbg_exec TSRMLS_CC); PHPDBG_G(exec_len) = strlen(PHPDBG_G(exec)); - free(exec); + free(phpdbg_exec); + phpdbg_exec = NULL; } if (oplog_file) { /* open oplog */ @@ -1448,13 +1443,14 @@ phpdbg_main: PHPDBG_G(flags) |= PHPDBG_IS_STEPPING; } - if (run) { + if (phpdbg_startup_run) { /* no need to try{}, run does it ... */ PHPDBG_COMMAND_HANDLER(run)(NULL TSRMLS_CC); - if (run > 1) { + if (phpdbg_startup_run > 1) { /* if -r is on the command line more than once just quit */ goto phpdbg_out; } + phpdbg_startup_run = 0; } phpdbg_interact: @@ -1494,7 +1490,7 @@ phpdbg_interact: } } } zend_end_try(); - } while(!cleaning && !(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)); + } while (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)); /* this must be forced */ CG(unclean_shutdown) = 0; diff --git a/phpdbg.h b/phpdbg.h index 8c0dbb4afa0..688ba7cdfcb 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -187,9 +187,10 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC); #define PHPDBG_IN_SIGNAL_HANDLER (1<<30) -#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_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) #ifndef _WIN32 # define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_COLOURED|PHPDBG_IS_BP_ENABLED) diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index 30ea48cfbe4..ab0755454ec 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -796,80 +796,30 @@ PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack, zend_bool allow_async PHPDBG_API char *phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */ { + char buf[PHPDBG_MAX_CMD]; char *cmd = NULL; char *buffer = NULL; - if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { + if (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && (buffered == NULL) && !phpdbg_active_sigsafe_mem(TSRMLS_C)) { fflush(PHPDBG_G(io)[PHPDBG_STDOUT].ptr); } if (buffered == NULL) { - if (0) { -disconnect: - PHPDBG_G(flags) |= (PHPDBG_IS_QUITTING|PHPDBG_IS_DISCONNECTED); - zend_bailout(); - return NULL; - } - #define USE_LIB_STAR (defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT)) - /* note: EOF makes readline write prompt again in local console mode - and ignored if compiled without readline */ - /* strongly assuming to be in blocking mode... */ #if USE_LIB_STAR readline: if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) #endif { - char buf[PHPDBG_MAX_CMD]; - int bytes = PHPDBG_G(input_buflen), len = 0; - if (PHPDBG_G(input_buflen)) { - memcpy(buf, PHPDBG_G(input_buffer), bytes); - } - phpdbg_write("prompt", "", "%s", phpdbg_get_prompt(TSRMLS_C)); - PHPDBG_G(last_was_newline) = 1; - - do { - int i; - if (bytes <= 0) { - continue; - } - - for (i = len; i < len + bytes; i++) { - if (buf[i] == '\x03') { - if (i != len + bytes - 1) { - memmove(buf + i, buf + i + 1, len + bytes - i - 1); - } - len--; - i--; - continue; - } - if (buf[i] == '\n') { - PHPDBG_G(input_buflen) = len + bytes - 1 - i; - if (PHPDBG_G(input_buflen)) { - memcpy(PHPDBG_G(input_buffer), buf + i + 1, PHPDBG_G(input_buflen)); - } - if (i != PHPDBG_MAX_CMD - 1) { - buf[i + 1] = 0; - } - cmd = buf; - goto end; - } - } - len += bytes; - /* XXX export the timeout through INI??*/ - } while ((bytes = phpdbg_mixed_read(PHPDBG_G(io)[PHPDBG_STDIN].fd, buf + len, PHPDBG_MAX_CMD - len, -1 TSRMLS_CC)) > 0); - - if (bytes <= 0) { - goto disconnect; - } - - cmd = buf; + phpdbg_consume_stdin_line(cmd = buf TSRMLS_CC); } #if USE_LIB_STAR else { cmd = readline(phpdbg_get_prompt(TSRMLS_C)); + PHPDBG_G(last_was_newline) = 1; } if (!cmd) { @@ -883,8 +833,7 @@ readline: } else { cmd = buffered; } -end: - PHPDBG_G(last_was_newline) = 1; + buffer = estrdup(cmd); #if USE_LIB_STAR @@ -922,3 +871,24 @@ PHPDBG_API void phpdbg_destroy_input(char **input TSRMLS_DC) /*{{{ */ { efree(*input); } /* }}} */ + +PHPDBG_API int phpdbg_ask_user_permission(const char *question TSRMLS_DC) { + if (!(PHPDBG_G(flags) & PHPDBG_WRITE_XML)) { + char buf[PHPDBG_MAX_CMD]; + phpdbg_out("%s", question); + phpdbg_out(" (type y or n): "); + + while (1) { + phpdbg_consume_stdin_line(buf TSRMLS_CC); + if (buf[1] == '\n' && (buf[0] == 'y' || buf[0] == 'n')) { + if (buf[0] == 'y') { + return SUCCESS; + } + return FAILURE; + } + phpdbg_out("Please enter either y (yes) or n (no): "); + } + } + + return SUCCESS; +} diff --git a/phpdbg_cmd.h b/phpdbg_cmd.h index 3896551c9a2..4c9e5383d82 100644 --- a/phpdbg_cmd.h +++ b/phpdbg_cmd.h @@ -131,6 +131,7 @@ typedef struct { */ PHPDBG_API char* phpdbg_read_input(char *buffered TSRMLS_DC); PHPDBG_API void phpdbg_destroy_input(char** TSRMLS_DC); +PHPDBG_API int phpdbg_ask_user_permission(const char *question TSRMLS_DC); /** * Stack Management diff --git a/phpdbg_io.c b/phpdbg_io.c index 97f0356285c..a2a5c5969f4 100644 --- a/phpdbg_io.c +++ b/phpdbg_io.c @@ -47,6 +47,55 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg); +/* is easy to generalize ... but not needed for now */ +PHPDBG_API int phpdbg_consume_stdin_line(char *buf TSRMLS_DC) { + int bytes = PHPDBG_G(input_buflen), len = 0; + + if (PHPDBG_G(input_buflen)) { + memcpy(buf, PHPDBG_G(input_buffer), bytes); + } + + PHPDBG_G(last_was_newline) = 1; + + do { + int i; + if (bytes <= 0) { + continue; + } + + for (i = len; i < len + bytes; i++) { + if (buf[i] == '\x03') { + if (i != len + bytes - 1) { + memmove(buf + i, buf + i + 1, len + bytes - i - 1); + } + len--; + i--; + continue; + } + if (buf[i] == '\n') { + PHPDBG_G(input_buflen) = len + bytes - 1 - i; + if (PHPDBG_G(input_buflen)) { + memcpy(PHPDBG_G(input_buffer), buf + i + 1, PHPDBG_G(input_buflen)); + } + if (i != PHPDBG_MAX_CMD - 1) { + buf[i + 1] = 0; + } + return i; + } + } + + len += bytes; + } while ((bytes = phpdbg_mixed_read(PHPDBG_G(io)[PHPDBG_STDIN].fd, buf + len, PHPDBG_MAX_CMD - len, -1 TSRMLS_CC)) > 0); + + if (bytes <= 0) { + PHPDBG_G(flags) |= PHPDBG_IS_QUITTING | PHPDBG_IS_DISCONNECTED; + zend_bailout(); + return 0; + } + + return bytes; +} + PHPDBG_API int phpdbg_consume_bytes(int sock, char *ptr, int len, int tmo TSRMLS_DC) { int got_now, i = len, j; char *p = ptr; diff --git a/phpdbg_io.h b/phpdbg_io.h index 3ac8f4112d0..a5659e88c65 100644 --- a/phpdbg_io.h +++ b/phpdbg_io.h @@ -21,6 +21,8 @@ #include "phpdbg.h" +PHPDBG_API int phpdbg_consume_stdin_line(char *buf TSRMLS_DC); + PHPDBG_API int phpdbg_consume_bytes(int sock, char *ptr, int len, int tmo TSRMLS_DC); PHPDBG_API int phpdbg_send_bytes(int sock, const char *ptr, int len); PHPDBG_API int phpdbg_mixed_read(int sock, char *ptr, int len, int tmo TSRMLS_DC); diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 2e0c698f050..29c75c583c0 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -43,6 +43,8 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg); ZEND_EXTERN_MODULE_GLOBALS(output); +extern int phpdbg_startup_run; +extern char *phpdbg_exec; #ifdef HAVE_LIBDL #ifdef PHP_WIN32 @@ -355,6 +357,11 @@ PHPDBG_COMMAND(exec) /* {{{ */ size_t res_len = strlen(res); if ((res_len != PHPDBG_G(exec_len)) || (memcmp(res, PHPDBG_G(exec), res_len) != SUCCESS)) { + if (EG(in_execution)) { + if (phpdbg_ask_user_permission("Do you really want to stop execution to set a new execution context?" TSRMLS_CC) == FAILURE) { + return FAILURE; + } + } if (PHPDBG_G(exec)) { phpdbg_notice("exec", "type=\"unset\" context=\"%s\"", "Unsetting old execution context: %s", PHPDBG_G(exec)); @@ -378,9 +385,11 @@ PHPDBG_COMMAND(exec) /* {{{ */ phpdbg_notice("exec", "type=\"set\" context=\"%s\"", "Set execution context: %s", PHPDBG_G(exec)); - if (phpdbg_compile(TSRMLS_C) == FAILURE) { - phpdbg_error("compile", "type=\"compilefailure\" context=\"%s\"", "Failed to compile %s", PHPDBG_G(exec)); + if (EG(in_execution)) { + phpdbg_clean(1 TSRMLS_CC); } + + phpdbg_compile(TSRMLS_C); } else { phpdbg_notice("exec", "type=\"unchanged\"", "Execution context not changed"); } @@ -399,20 +408,15 @@ int phpdbg_compile(TSRMLS_D) /* {{{ */ if (!PHPDBG_G(exec)) { phpdbg_error("inactive", "type=\"nocontext\"", "No execution context"); - return SUCCESS; - } - - if (EG(in_execution)) { - phpdbg_error("inactive", "type=\"isrunning\"", "Cannot compile while in execution"); return FAILURE; } if (php_stream_open_for_zend_ex(PHPDBG_G(exec), &fh, USE_PATH|STREAM_OPEN_FOR_INCLUDE TSRMLS_CC) == SUCCESS) { - PHPDBG_G(ops) = zend_compile_file(&fh, ZEND_INCLUDE TSRMLS_CC); zend_destroy_file_handle(&fh TSRMLS_CC); phpdbg_notice("compile", "context=\"%s\"", "Successful compilation of %s", PHPDBG_G(exec)); + return SUCCESS; } else { phpdbg_error("compile", "type=\"openfailure\" context=\"%s\"", "Could not open file %s", PHPDBG_G(exec)); @@ -570,11 +574,6 @@ static inline void phpdbg_handle_exception(TSRMLS_D) /* }}} */ PHPDBG_COMMAND(run) /* {{{ */ { - if (EG(in_execution)) { - phpdbg_error("inactive", "type=\"isrunning\"", "Cannot start another execution while one is in progress"); - return SUCCESS; - } - if (PHPDBG_G(ops) || PHPDBG_G(exec)) { zend_op **orig_opline = EG(opline_ptr); zend_op_array *orig_op_array = EG(active_op_array); @@ -582,6 +581,14 @@ PHPDBG_COMMAND(run) /* {{{ */ zend_bool restore = 1; zend_execute_data *ex = EG(current_execute_data); + if (EG(in_execution)) { + if (phpdbg_ask_user_permission("Do you really want to restart execution?" TSRMLS_CC) == SUCCESS) { + phpdbg_startup_run++; + phpdbg_clean(1 TSRMLS_CC); + } + return SUCCESS; + } + if (!PHPDBG_G(ops)) { if (phpdbg_compile(TSRMLS_C) == FAILURE) { phpdbg_error("compile", "type=\"compilefailure\" context=\"%s\"", "Failed to compile %s, cannot run", PHPDBG_G(exec)); @@ -643,7 +650,7 @@ PHPDBG_COMMAND(run) /* {{{ */ EG(opline_ptr) = orig_opline; EG(return_value_ptr_ptr) = orig_retval_ptr; - if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { + if (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { phpdbg_error("stop", "type=\"bailout\"", "Caught exit/error from VM"); restore = 0; } @@ -1127,7 +1134,7 @@ PHPDBG_COMMAND(register) /* {{{ */ PHPDBG_COMMAND(quit) /* {{{ */ { /* don't allow this to loop, ever ... */ - if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { + if (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { PHPDBG_G(flags) |= PHPDBG_IS_QUITTING; zend_bailout(); } @@ -1138,8 +1145,9 @@ PHPDBG_COMMAND(quit) /* {{{ */ PHPDBG_COMMAND(clean) /* {{{ */ { if (EG(in_execution)) { - phpdbg_error("inactive", "type=\"isrunning\"", "Cannot clean environment while executing"); - return SUCCESS; + if (phpdbg_ask_user_permission("Do you really want to clean your current environment?" TSRMLS_CC) == FAILURE) { + return SUCCESS; + } } phpdbg_out("Cleaning Execution Environment\n"); @@ -1227,60 +1235,64 @@ int phpdbg_interactive(zend_bool allow_async_unsafe TSRMLS_DC) /* {{{ */ PHPDBG_G(flags) |= PHPDBG_IS_INTERACTIVE; - input = phpdbg_read_input(NULL TSRMLS_CC); + while (1) { + if (PHPDBG_G(flags) & PHPDBG_IS_STOPPING) { + zend_bailout(); + } - if (input) { - do { - phpdbg_init_param(&stack, STACK_PARAM); + if (!(input = phpdbg_read_input(NULL TSRMLS_CC))) { + break; + } - if (phpdbg_do_parse(&stack, input TSRMLS_CC) <= 0) { - phpdbg_activate_err_buf(1 TSRMLS_CC); + + phpdbg_init_param(&stack, STACK_PARAM); + + if (phpdbg_do_parse(&stack, input TSRMLS_CC) <= 0) { + phpdbg_activate_err_buf(1 TSRMLS_CC); #ifdef PHP_WIN32 #define PARA ((phpdbg_param_t *)stack.next)->type - if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE && (RUN_PARAM == PARA || EVAL_PARAM == PARA)) { - sigio_watcher_start(); - } + if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE && (RUN_PARAM == PARA || EVAL_PARAM == PARA)) { + sigio_watcher_start(); + } #endif - switch (ret = phpdbg_stack_execute(&stack, allow_async_unsafe TSRMLS_CC)) { - case FAILURE: - if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { - if (!allow_async_unsafe || phpdbg_call_register(&stack TSRMLS_CC) == FAILURE) { - phpdbg_output_err_buf(NULL, "%b", "%b" TSRMLS_CC); - } + switch (ret = phpdbg_stack_execute(&stack, allow_async_unsafe TSRMLS_CC)) { + case FAILURE: + if (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { + if (!allow_async_unsafe || phpdbg_call_register(&stack TSRMLS_CC) == FAILURE) { + phpdbg_output_err_buf(NULL, "%b", "%b" TSRMLS_CC); } - break; - - case PHPDBG_LEAVE: - case PHPDBG_FINISH: - case PHPDBG_UNTIL: - case PHPDBG_NEXT: { - phpdbg_activate_err_buf(0 TSRMLS_CC); - phpdbg_free_err_buf(TSRMLS_C); - if (!EG(in_execution) && !(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { - phpdbg_error("command", "type=\"noexec\"", "Not running"); - } - goto out; } - } + break; - phpdbg_activate_err_buf(0 TSRMLS_CC); - phpdbg_free_err_buf(TSRMLS_C); -#ifdef PHP_WIN32 - if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE && (RUN_PARAM == PARA || EVAL_PARAM == PARA)) { - sigio_watcher_stop(); + case PHPDBG_LEAVE: + case PHPDBG_FINISH: + case PHPDBG_UNTIL: + case PHPDBG_NEXT: { + phpdbg_activate_err_buf(0 TSRMLS_CC); + phpdbg_free_err_buf(TSRMLS_C); + if (!EG(in_execution) && !(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { + phpdbg_error("command", "type=\"noexec\"", "Not running"); + } + break; } -#undef PARA -#endif } - phpdbg_stack_free(&stack); - phpdbg_destroy_input(&input TSRMLS_CC); - PHPDBG_G(req_id) = 0; - } while ((input = phpdbg_read_input(NULL TSRMLS_CC))); + phpdbg_activate_err_buf(0 TSRMLS_CC); + phpdbg_free_err_buf(TSRMLS_C); +#ifdef PHP_WIN32 + if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE && (RUN_PARAM == PARA || EVAL_PARAM == PARA)) { + sigio_watcher_stop(); + } +#undef PARA +#endif + } + + phpdbg_stack_free(&stack); + phpdbg_destroy_input(&input TSRMLS_CC); + PHPDBG_G(req_id) = 0; } -out: if (input) { phpdbg_stack_free(&stack); phpdbg_destroy_input(&input TSRMLS_CC); @@ -1308,6 +1320,7 @@ void phpdbg_clean(zend_bool full TSRMLS_DC) /* {{{ */ } if (full) { + phpdbg_exec = strdup(PHPDBG_G(exec)); /* preserve exec, don't reparse that from cmd */ PHPDBG_G(flags) |= PHPDBG_IS_CLEANING; zend_bailout(); @@ -1593,7 +1606,7 @@ void phpdbg_force_interruption(TSRMLS_D) { next: PHPDBG_G(flags) &= ~PHPDBG_IN_SIGNAL_HANDLER; - if (PHPDBG_G(flags) & PHPDBG_IS_QUITTING) { + if (PHPDBG_G(flags) & PHPDBG_IS_STOPPING) { zend_bailout(); } } From 29446f2f043fd3eeb6fbb800389348a1418c148d Mon Sep 17 00:00:00 2001 From: krakjoe Date: Sun, 26 Oct 2014 07:02:15 +0000 Subject: [PATCH 064/398] disable output buffering, better breakpoint api for userland, remove hand parsing of params --- sapi/phpdbg/phpdbg.c | 89 +++++++++++++++++++++++++++++++++----------- 1 file changed, 68 insertions(+), 21 deletions(-) diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 3de0cc45241..052ead7d0b8 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -297,26 +297,57 @@ static PHP_FUNCTION(phpdbg_exec) } } /* }}} */ -/* {{{ proto void phpdbg_break([integer type, string expression]) +/* {{{ proto void phpdbg_break() instructs phpdbg to insert a breakpoint at the next opcode */ -static PHP_FUNCTION(phpdbg_break) +static PHP_FUNCTION(phpdbg_break_next) { - if (ZEND_NUM_ARGS() > 0) { - long type = 0; - char *expr = NULL; - int expr_len = 0; - phpdbg_param_t param; + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + phpdbg_set_breakpoint_opline_ex((phpdbg_opline_ptr_t) EG(current_execute_data)->opline + 1 TSRMLS_CC); +} /* }}} */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &type, &expr, &expr_len) == FAILURE) { - return; - } - - phpdbg_parse_param(expr, expr_len, ¶m TSRMLS_CC); - phpdbg_do_break(¶m TSRMLS_CC); - phpdbg_clear_param(¶m TSRMLS_CC); - } else if (EG(current_execute_data) && EG(current_execute_data)->func->type != ZEND_INTERNAL_FUNCTION) { - phpdbg_set_breakpoint_opline_ex((phpdbg_opline_ptr_t) EG(current_execute_data)->opline + 1 TSRMLS_CC); +/* {{{ proto void phpdbg_break_file(string file, integer line) */ +static PHP_FUNCTION(phpdbg_break_file) +{ + char *file = NULL; + size_t flen = 0; + long line; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &file, &flen, &line) == FAILURE) { + return; } + + phpdbg_set_breakpoint_file(file, line TSRMLS_CC); +} /* }}} */ + +/* {{{ proto void phpdbg_break_method(string class, string method) */ +static PHP_FUNCTION(phpdbg_break_method) +{ + char *class = NULL, + *method = NULL; + size_t clen = 0, + mlen = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &class, &clen, &method, &mlen) == FAILURE) { + return; + } + + phpdbg_set_breakpoint_method(class, method TSRMLS_CC); +} /* }}} */ + +/* {{{ proto void phpdbg_break_function(string function) */ +static PHP_FUNCTION(phpdbg_break_function) +{ + char *function = NULL; + size_t function_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &function, &function_len) == FAILURE) { + return; + } + + phpdbg_set_breakpoint_symbol(function, function_len TSRMLS_CC); } /* }}} */ /* {{{ proto void phpdbg_clear(void) @@ -368,9 +399,21 @@ static PHP_FUNCTION(phpdbg_prompt) phpdbg_set_prompt(prompt TSRMLS_CC); } /* }}} */ -ZEND_BEGIN_ARG_INFO_EX(phpdbg_break_arginfo, 0, 0, 0) - ZEND_ARG_INFO(0, type) - ZEND_ARG_INFO(0, expression) +ZEND_BEGIN_ARG_INFO_EX(phpdbg_break_next_arginfo, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(phpdbg_break_file_arginfo, 0, 0, 2) + ZEND_ARG_INFO(0, file) + ZEND_ARG_INFO(0, line) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(phpdbg_break_method_arginfo, 0, 0, 2) + ZEND_ARG_INFO(0, class) + ZEND_ARG_INFO(0, method) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(phpdbg_break_function_arginfo, 0, 0, 1) + ZEND_ARG_INFO(0, function) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(phpdbg_color_arginfo, 0, 0, 0) @@ -391,7 +434,10 @@ ZEND_END_ARG_INFO() zend_function_entry phpdbg_user_functions[] = { PHP_FE(phpdbg_clear, phpdbg_clear_arginfo) - PHP_FE(phpdbg_break, phpdbg_break_arginfo) + PHP_FE(phpdbg_break_next, phpdbg_break_next_arginfo) + PHP_FE(phpdbg_break_file, phpdbg_break_file_arginfo) + PHP_FE(phpdbg_break_method, phpdbg_break_method_arginfo) + PHP_FE(phpdbg_break_function, phpdbg_break_function_arginfo) PHP_FE(phpdbg_exec, phpdbg_exec_arginfo) PHP_FE(phpdbg_color, phpdbg_color_arginfo) PHP_FE(phpdbg_prompt, phpdbg_prompt_arginfo) @@ -704,7 +750,8 @@ const char phpdbg_ini_hardcoded[] = "log_errors=On\n" "max_execution_time=0\n" "max_input_time=-1\n" -"error_log=\n\0"; +"error_log=\n" +"output_buffering=off\n\0"; /* overwriteable ini defaults must be set in phpdbg_ini_defaults() */ #define INI_DEFAULT(name, value) \ From 8ba69820f7858b63b00ad39d69cd09f4560fe260 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Sun, 26 Oct 2014 07:05:55 +0000 Subject: [PATCH 065/398] actually remove this --- sapi/phpdbg/phpdbg_cmd.c | 73 ---------------------------------------- sapi/phpdbg/phpdbg_cmd.h | 1 - 2 files changed, 74 deletions(-) diff --git a/sapi/phpdbg/phpdbg_cmd.c b/sapi/phpdbg/phpdbg_cmd.c index 729babefca9..d91acb1d17c 100644 --- a/sapi/phpdbg/phpdbg_cmd.c +++ b/sapi/phpdbg/phpdbg_cmd.c @@ -70,79 +70,6 @@ PHPDBG_API const char *phpdbg_get_param_type(const phpdbg_param_t *param TSRMLS_ } } -PHPDBG_API phpdbg_param_type phpdbg_parse_param(const char *str, size_t len, phpdbg_param_t *param TSRMLS_DC) /* {{{ */ -{ - char *class_name, *func_name; - - if (len == 0) { - param->type = EMPTY_PARAM; - goto parsed; - } - - if (phpdbg_is_addr(str)) { - param->addr = strtoul(str, 0, 16); - param->type = ADDR_PARAM; - goto parsed; - - } else if (phpdbg_is_numeric(str)) { - param->num = strtol(str, NULL, 0); - param->type = NUMERIC_PARAM; - goto parsed; - - } else if (phpdbg_is_class_method(str, len+1, &class_name, &func_name)) { - param->method.class = class_name; - param->method.name = func_name; - param->type = METHOD_PARAM; - goto parsed; - } else { - char *line_pos = strrchr(str, ':'); - - if (line_pos && phpdbg_is_numeric(line_pos+1)) { - if (strchr(str, ':') == line_pos) { - char path[MAXPATHLEN]; - - memcpy(path, str, line_pos - str); - path[line_pos - str] = 0; - *line_pos = 0; - param->file.name = phpdbg_resolve_path(path TSRMLS_CC); - param->file.line = strtol(line_pos+1, NULL, 0); - param->type = FILE_PARAM; - - goto parsed; - } - } - - line_pos = strrchr(str, '#'); - - if (line_pos && phpdbg_is_numeric(line_pos+1)) { - if (strchr(str, '#') == line_pos) { - param->num = strtol(line_pos + 1, NULL, 0); - - if (phpdbg_is_class_method(str, line_pos - str, &class_name, &func_name)) { - param->method.class = class_name; - param->method.name = func_name; - param->type = NUMERIC_METHOD_PARAM; - } else { - param->len = line_pos - str; - param->str = estrndup(str, param->len); - param->type = NUMERIC_FUNCTION_PARAM; - } - - goto parsed; - } - } - } - - param->str = estrndup(str, len); - param->len = len; - param->type = STR_PARAM; - -parsed: - phpdbg_debug("phpdbg_parse_param(\"%s\", %lu): %s", - str, len, phpdbg_get_param_type(param TSRMLS_CC)); - return param->type; -} /* }}} */ - PHPDBG_API void phpdbg_clear_param(phpdbg_param_t *param TSRMLS_DC) /* {{{ */ { if (param) { diff --git a/sapi/phpdbg/phpdbg_cmd.h b/sapi/phpdbg/phpdbg_cmd.h index 3896551c9a2..4049cd92957 100644 --- a/sapi/phpdbg/phpdbg_cmd.h +++ b/sapi/phpdbg/phpdbg_cmd.h @@ -144,7 +144,6 @@ PHPDBG_API void phpdbg_stack_free(phpdbg_param_t *stack); /* * Parameter Management */ -PHPDBG_API phpdbg_param_type phpdbg_parse_param(const char*, size_t, phpdbg_param_t* TSRMLS_DC); PHPDBG_API void phpdbg_clear_param(phpdbg_param_t* TSRMLS_DC); PHPDBG_API void phpdbg_copy_param(const phpdbg_param_t*, phpdbg_param_t* TSRMLS_DC); PHPDBG_API zend_bool phpdbg_match_param(const phpdbg_param_t *, const phpdbg_param_t * TSRMLS_DC); From 5feb96520aa20416ef751806b9a5fc3d86186b4d Mon Sep 17 00:00:00 2001 From: krakjoe Date: Sun, 26 Oct 2014 07:08:29 +0000 Subject: [PATCH 066/398] disable output buffering by default --- phpdbg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpdbg.c b/phpdbg.c index ff03c670d06..f8879d77abb 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -730,7 +730,8 @@ const char phpdbg_ini_hardcoded[] = "log_errors=On\n" "max_execution_time=0\n" "max_input_time=-1\n" -"error_log=\n\0"; +"error_log=\n" +"output_buffering=off\0"; /* overwriteable ini defaults must be set in phpdbg_ini_defaults() */ #define INI_DEFAULT(name, value) \ From 65eaab52b6cb241ca0bac7d8abe691be37d122bb Mon Sep 17 00:00:00 2001 From: krakjoe Date: Sun, 26 Oct 2014 07:24:35 +0000 Subject: [PATCH 067/398] remove dodgy param parser, bring userland breakpoint api inline with PHP7 --- phpdbg.c | 85 ++++++++--- phpdbg_cmd.c | 73 --------- phpdbg_cmd.h | 1 - phpdbg_parser.c | 396 ++++++++++++++++++++++-------------------------- phpdbg_parser.h | 39 +++-- 5 files changed, 278 insertions(+), 316 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index f8879d77abb..493d8ec20c9 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -301,24 +301,12 @@ static PHP_FUNCTION(phpdbg_exec) } } /* }}} */ -/* {{{ proto void phpdbg_break([integer type, string expression]) +/* {{{ proto void phpdbg_break_next() instructs phpdbg to insert a breakpoint at the next opcode */ -static PHP_FUNCTION(phpdbg_break) +static PHP_FUNCTION(phpdbg_break_next) { - if (ZEND_NUM_ARGS() > 0) { - long type = 0; - char *expr = NULL; - int expr_len = 0; - phpdbg_param_t param; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &type, &expr, &expr_len) == FAILURE) { - return; - } - - phpdbg_parse_param(expr, expr_len, ¶m TSRMLS_CC); - phpdbg_do_break(¶m TSRMLS_CC); - phpdbg_clear_param(¶m TSRMLS_CC); - + if (zend_parse_parameters_none() != SUCCESS) { + return; } else if (EG(current_execute_data) && EG(active_op_array)) { zend_ulong opline_num = (EG(current_execute_data)->opline - EG(active_op_array)->opcodes); @@ -328,6 +316,48 @@ static PHP_FUNCTION(phpdbg_break) } } /* }}} */ +/* {{{ proto void phpdbg_break_file(string file, integer line) */ +static PHP_FUNCTION(phpdbg_break_file) +{ + char *file = NULL; + int flen = 0; + long line; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &file, &flen, &line) == FAILURE) { + return; + } + + phpdbg_set_breakpoint_file(file, line TSRMLS_CC); +} /* }}} */ + +/* {{{ proto void phpdbg_break_method(string class, string method) */ +static PHP_FUNCTION(phpdbg_break_method) +{ + char *class = NULL, + *method = NULL; + int clen = 0, + mlen = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &class, &clen, &method, &mlen) == FAILURE) { + return; + } + + phpdbg_set_breakpoint_method(class, method TSRMLS_CC); +} /* }}} */ + +/* {{{ proto void phpdbg_break_function(string function) */ +static PHP_FUNCTION(phpdbg_break_function) +{ + char *function = NULL; + int function_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &function, &function_len) == FAILURE) { + return; + } + + phpdbg_set_breakpoint_symbol(function, function_len TSRMLS_CC); +} /* }}} */ + /* {{{ proto void phpdbg_clear(void) instructs phpdbg to clear breakpoints */ static PHP_FUNCTION(phpdbg_clear) @@ -377,9 +407,21 @@ static PHP_FUNCTION(phpdbg_prompt) phpdbg_set_prompt(prompt TSRMLS_CC); } /* }}} */ -ZEND_BEGIN_ARG_INFO_EX(phpdbg_break_arginfo, 0, 0, 0) - ZEND_ARG_INFO(0, type) - ZEND_ARG_INFO(0, expression) +ZEND_BEGIN_ARG_INFO_EX(phpdbg_break_next_arginfo, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(phpdbg_break_file_arginfo, 0, 0, 2) + ZEND_ARG_INFO(0, file) + ZEND_ARG_INFO(0, line) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(phpdbg_break_method_arginfo, 0, 0, 2) + ZEND_ARG_INFO(0, class) + ZEND_ARG_INFO(0, method) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(phpdbg_break_function_arginfo, 0, 0, 1) + ZEND_ARG_INFO(0, function) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(phpdbg_color_arginfo, 0, 0, 0) @@ -400,7 +442,10 @@ ZEND_END_ARG_INFO() zend_function_entry phpdbg_user_functions[] = { PHP_FE(phpdbg_clear, phpdbg_clear_arginfo) - PHP_FE(phpdbg_break, phpdbg_break_arginfo) + PHP_FE(phpdbg_break_next, phpdbg_break_next_arginfo) + PHP_FE(phpdbg_break_file, phpdbg_break_file_arginfo) + PHP_FE(phpdbg_break_method, phpdbg_break_method_arginfo) + PHP_FE(phpdbg_break_function, phpdbg_break_function_arginfo) PHP_FE(phpdbg_exec, phpdbg_exec_arginfo) PHP_FE(phpdbg_color, phpdbg_color_arginfo) PHP_FE(phpdbg_prompt, phpdbg_prompt_arginfo) diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index ab0755454ec..13d5a0d6340 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -70,79 +70,6 @@ PHPDBG_API const char *phpdbg_get_param_type(const phpdbg_param_t *param TSRMLS_ } } -PHPDBG_API phpdbg_param_type phpdbg_parse_param(const char *str, size_t len, phpdbg_param_t *param TSRMLS_DC) /* {{{ */ -{ - char *class_name, *func_name; - - if (len == 0) { - param->type = EMPTY_PARAM; - goto parsed; - } - - if (phpdbg_is_addr(str)) { - param->addr = strtoul(str, 0, 16); - param->type = ADDR_PARAM; - goto parsed; - - } else if (phpdbg_is_numeric(str)) { - param->num = strtol(str, NULL, 0); - param->type = NUMERIC_PARAM; - goto parsed; - - } else if (phpdbg_is_class_method(str, len+1, &class_name, &func_name)) { - param->method.class = class_name; - param->method.name = func_name; - param->type = METHOD_PARAM; - goto parsed; - } else { - char *line_pos = strrchr(str, ':'); - - if (line_pos && phpdbg_is_numeric(line_pos+1)) { - if (strchr(str, ':') == line_pos) { - char path[MAXPATHLEN]; - - memcpy(path, str, line_pos - str); - path[line_pos - str] = 0; - *line_pos = 0; - param->file.name = phpdbg_resolve_path(path TSRMLS_CC); - param->file.line = strtol(line_pos+1, NULL, 0); - param->type = FILE_PARAM; - - goto parsed; - } - } - - line_pos = strrchr(str, '#'); - - if (line_pos && phpdbg_is_numeric(line_pos+1)) { - if (strchr(str, '#') == line_pos) { - param->num = strtol(line_pos + 1, NULL, 0); - - if (phpdbg_is_class_method(str, line_pos - str, &class_name, &func_name)) { - param->method.class = class_name; - param->method.name = func_name; - param->type = NUMERIC_METHOD_PARAM; - } else { - param->len = line_pos - str; - param->str = estrndup(str, param->len); - param->type = NUMERIC_FUNCTION_PARAM; - } - - goto parsed; - } - } - } - - param->str = estrndup(str, len); - param->len = len; - param->type = STR_PARAM; - -parsed: - phpdbg_debug("phpdbg_parse_param(\"%s\", %lu): %s", - str, len, phpdbg_get_param_type(param TSRMLS_CC)); - return param->type; -} /* }}} */ - PHPDBG_API void phpdbg_clear_param(phpdbg_param_t *param TSRMLS_DC) /* {{{ */ { if (param) { diff --git a/phpdbg_cmd.h b/phpdbg_cmd.h index 4c9e5383d82..a79641c0800 100644 --- a/phpdbg_cmd.h +++ b/phpdbg_cmd.h @@ -145,7 +145,6 @@ PHPDBG_API void phpdbg_stack_free(phpdbg_param_t *stack); /* * Parameter Management */ -PHPDBG_API phpdbg_param_type phpdbg_parse_param(const char*, size_t, phpdbg_param_t* TSRMLS_DC); PHPDBG_API void phpdbg_clear_param(phpdbg_param_t* TSRMLS_DC); PHPDBG_API void phpdbg_copy_param(const phpdbg_param_t*, phpdbg_param_t* TSRMLS_DC); PHPDBG_API zend_bool phpdbg_match_param(const phpdbg_param_t *, const phpdbg_param_t * TSRMLS_DC); diff --git a/phpdbg_parser.c b/phpdbg_parser.c index c7668683699..433423db872 100644 --- a/phpdbg_parser.c +++ b/phpdbg_parser.c @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.5. */ +/* A Bison parser, made by GNU Bison 2.7. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.5" +#define YYBISON_VERSION "2.7" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -58,8 +58,6 @@ /* Pull parsers. */ #define YYPULL 1 -/* Using locations. */ -#define YYLSP_NEEDED 0 /* Substitute the variable and function names. */ #define yyparse phpdbg_parse @@ -70,11 +68,9 @@ #define yydebug phpdbg_debug #define yynerrs phpdbg_nerrs - /* Copy the first part of user declarations. */ - -/* Line 268 of yacc.c */ -#line 1 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 371 of yacc.c */ +#line 1 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" /* @@ -101,14 +97,16 @@ static int yyerror(void ***tsrm_ls, const char *msg); ZEND_EXTERN_MODULE_GLOBALS(phpdbg); +/* Line 371 of yacc.c */ +#line 102 "sapi/phpdbg/phpdbg_parser.c" -/* Line 268 of yacc.c */ -#line 107 "sapi/phpdbg/phpdbg_parser.c" - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif +# ifndef YY_NULL +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULL nullptr +# else +# define YY_NULL 0 +# endif +# endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE @@ -118,15 +116,20 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg); # define YYERROR_VERBOSE 1 #endif -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 0 +/* In a future release of Bison, this section will be replaced + by #include "phpdbg_parser.h". */ +#ifndef YY_PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED +# define YY_PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int phpdbg_debug; #endif - /* "%code requires" blocks. */ - -/* Line 288 of yacc.c */ -#line 31 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 387 of yacc.c */ +#line 31 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" #include "phpdbg.h" #ifndef YY_TYPEDEF_YY_SCANNER_T @@ -135,9 +138,8 @@ typedef void* yyscan_t; #endif - -/* Line 288 of yacc.c */ -#line 141 "sapi/phpdbg/phpdbg_parser.c" +/* Line 387 of yacc.c */ +#line 143 "sapi/phpdbg/phpdbg_parser.c" /* Tokens. */ #ifndef YYTOKENTYPE @@ -189,7 +191,6 @@ typedef void* yyscan_t; - #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 @@ -198,11 +199,26 @@ typedef int YYSTYPE; #endif +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int phpdbg_parse (void *YYPARSE_PARAM); +#else +int phpdbg_parse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int phpdbg_parse (void *tsrm_ls); +#else +int phpdbg_parse (); +#endif +#endif /* ! YYPARSE_PARAM */ + +#endif /* !YY_PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED */ + /* Copy the second part of user declarations. */ - -/* Line 343 of yacc.c */ -#line 206 "sapi/phpdbg/phpdbg_parser.c" +/* Line 390 of yacc.c */ +#line 222 "sapi/phpdbg/phpdbg_parser.c" #ifdef short # undef short @@ -255,24 +271,24 @@ typedef short int yytype_int16; # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) # endif # endif # ifndef YY_ -# define YY_(msgid) msgid +# define YY_(Msgid) Msgid # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ -# define YYUSE(e) ((void) (e)) +# define YYUSE(E) ((void) (E)) #else -# define YYUSE(e) /* empty */ +# define YYUSE(E) /* empty */ #endif /* Identity function, used to suppress warnings about constant conditions. */ #ifndef lint -# define YYID(n) (n) +# define YYID(N) (N) #else #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) @@ -308,6 +324,7 @@ YYID (yyi) # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ + /* Use EXIT_SUCCESS as a witness for stdlib.h. */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif @@ -399,20 +416,20 @@ union yyalloc #endif #if defined YYCOPY_NEEDED && YYCOPY_NEEDED -/* Copy COUNT objects from FROM to TO. The source and destination do +/* Copy COUNT objects from SRC to DST. The source and destination do not overlap. */ # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# define YYCOPY(Dst, Src, Count) \ + __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) # else -# define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ +# define YYCOPY(Dst, Src, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (Dst)[yyi] = (Src)[yyi]; \ + } \ while (YYID (0)) # endif # endif @@ -505,7 +522,7 @@ static const yytype_uint8 yyrline[] = }; #endif -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +#if YYDEBUG || YYERROR_VERBOSE || 1 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = @@ -519,7 +536,7 @@ static const char *const yytname[] = "\"opcode\"", "\"identifier (command or function name)\"", "\"input (input string or data)\"", "\"input\"", "\"request id (-r %d)\"", "$accept", "input", "parameters", "parameter", - "req_id", "full_expression", 0 + "req_id", "full_expression", YY_NULL }; #endif @@ -599,10 +616,10 @@ static const yytype_uint8 yytable[] = 32, 36, 39, 40, 0, 0, 41, 42, 27 }; -#define yypact_value_is_default(yystate) \ - ((yystate) == (-16)) +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-16))) -#define yytable_value_is_error(yytable_value) \ +#define yytable_value_is_error(Yytable_value) \ YYID (0) static const yytype_int8 yycheck[] = @@ -652,62 +669,35 @@ static const yytype_uint8 yystos[] = #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (1); \ - goto yybackup; \ - } \ - else \ - { \ +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ yyerror (tsrm_ls, YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (YYID (0)) - +/* Error token number */ #define YYTERROR 1 #define YYERRCODE 256 -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (YYID (N)) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC (Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC (Rhs, 0).last_column; \ - } \ - while (YYID (0)) -#endif - - /* This macro is provided for backward compatibility. */ - #ifndef YY_LOCATION_PRINT # define YY_LOCATION_PRINT(File, Loc) ((void) 0) #endif /* YYLEX -- calling `yylex' with the right arguments. */ - #ifdef YYLEX_PARAM # define YYLEX yylex (&yylval, YYLEX_PARAM) #else @@ -758,6 +748,8 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, tsrm_ls) void *tsrm_ls; #endif { + FILE *yyo = yyoutput; + YYUSE (yyo); if (!yyvaluep) return; YYUSE (tsrm_ls); @@ -770,7 +762,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, tsrm_ls) switch (yytype) { default: - break; + break; } } @@ -1012,12 +1004,11 @@ static int yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken) { - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); + YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ - const char *yyformat = 0; + const char *yyformat = YY_NULL; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per @@ -1077,11 +1068,13 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, break; } yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; + { + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } } } } @@ -1101,10 +1094,12 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, # undef YYCASE_ } - yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; + { + YYSIZE_T yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } if (*yymsg_alloc < yysize) { @@ -1166,25 +1161,11 @@ yydestruct (yymsg, yytype, yyvaluep, tsrm_ls) { default: - break; + break; } } -/* Prevent warnings from -Wmissing-prototypes. */ -#ifdef YYPARSE_PARAM -#if defined __STDC__ || defined __cplusplus -int yyparse (void *YYPARSE_PARAM); -#else -int yyparse (); -#endif -#else /* ! YYPARSE_PARAM */ -#if defined __STDC__ || defined __cplusplus -int yyparse (void *tsrm_ls); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ /*----------. @@ -1216,8 +1197,31 @@ yyparse (tsrm_ls) /* The lookahead symbol. */ int yychar; + +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") +#else +/* Default value used for initialization, for pacifying older GCCs + or non-GCC compilers. */ +static YYSTYPE yyval_default; +# define YY_INITIAL_VALUE(Value) = Value +#endif +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ +#endif + /* The semantic value of the lookahead symbol. */ -YYSTYPE yylval; +YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); /* Number of syntax errors so far. */ int yynerrs; @@ -1230,7 +1234,7 @@ YYSTYPE yylval; `yyss': related to states. `yyvs': related to semantic values. - Refer to the stacks thru separate pointers, to allow yyoverflow + Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ @@ -1248,7 +1252,7 @@ YYSTYPE yylval; int yyn; int yyresult; /* Lookahead token as an internal (translated) token number. */ - int yytoken; + int yytoken = 0; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; @@ -1266,9 +1270,8 @@ YYSTYPE yylval; Keep to zero when no symbol should be popped. */ int yylen = 0; - yytoken = 0; - yyss = yyssa; - yyvs = yyvsa; + yyssp = yyss = yyssa; + yyvsp = yyvs = yyvsa; yystacksize = YYINITDEPTH; YYDPRINTF ((stderr, "Starting parse\n")); @@ -1277,14 +1280,6 @@ YYSTYPE yylval; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - yyssp = yyss; - yyvsp = yyvs; - goto yysetstate; /*------------------------------------------------------------. @@ -1425,7 +1420,9 @@ yybackup: yychar = YYEMPTY; yystate = yyn; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END goto yynewstate; @@ -1462,37 +1459,32 @@ yyreduce: switch (yyn) { case 3: - -/* Line 1806 of yacc.c */ -#line 68 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 68 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { phpdbg_stack_push(PHPDBG_G(parser_stack), &(yyvsp[(1) - (1)])); } break; case 5: - -/* Line 1806 of yacc.c */ -#line 73 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 73 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { phpdbg_stack_push(PHPDBG_G(parser_stack), &(yyvsp[(1) - (1)])); } break; case 6: - -/* Line 1806 of yacc.c */ -#line 74 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 74 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { phpdbg_stack_push(PHPDBG_G(parser_stack), &(yyvsp[(2) - (2)])); } break; case 7: - -/* Line 1806 of yacc.c */ -#line 75 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 75 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (2)]); } break; case 8: - -/* Line 1806 of yacc.c */ -#line 79 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 79 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = FILE_PARAM; (yyval).file.name = (yyvsp[(2) - (3)]).str; @@ -1501,9 +1493,8 @@ yyreduce: break; case 9: - -/* Line 1806 of yacc.c */ -#line 84 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 84 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = NUMERIC_FILE_PARAM; (yyval).file.name = (yyvsp[(1) - (4)]).str; @@ -1512,9 +1503,8 @@ yyreduce: break; case 10: - -/* Line 1806 of yacc.c */ -#line 89 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 89 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = FILE_PARAM; (yyval).file.name = malloc((yyvsp[(1) - (4)]).len + (yyvsp[(2) - (4)]).len + 1); @@ -1528,9 +1518,8 @@ yyreduce: break; case 11: - -/* Line 1806 of yacc.c */ -#line 99 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 99 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = NUMERIC_FILE_PARAM; (yyval).file.name = malloc((yyvsp[(1) - (5)]).len + (yyvsp[(2) - (5)]).len + 1); @@ -1544,9 +1533,8 @@ yyreduce: break; case 12: - -/* Line 1806 of yacc.c */ -#line 109 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 109 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = METHOD_PARAM; (yyval).method.class = (yyvsp[(1) - (3)]).str; @@ -1555,9 +1543,8 @@ yyreduce: break; case 13: - -/* Line 1806 of yacc.c */ -#line 114 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 114 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = NUMERIC_METHOD_PARAM; (yyval).method.class = (yyvsp[(1) - (5)]).str; @@ -1567,9 +1554,8 @@ yyreduce: break; case 14: - -/* Line 1806 of yacc.c */ -#line 120 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 120 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = NUMERIC_FUNCTION_PARAM; (yyval).str = (yyvsp[(1) - (3)]).str; @@ -1579,9 +1565,8 @@ yyreduce: break; case 15: - -/* Line 1806 of yacc.c */ -#line 126 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 126 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = COND_PARAM; (yyval).str = (yyvsp[(2) - (2)]).str; @@ -1590,65 +1575,56 @@ yyreduce: break; case 16: - -/* Line 1806 of yacc.c */ -#line 131 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 131 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 17: - -/* Line 1806 of yacc.c */ -#line 132 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 132 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 18: - -/* Line 1806 of yacc.c */ -#line 133 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 133 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 19: - -/* Line 1806 of yacc.c */ -#line 134 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 134 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 20: - -/* Line 1806 of yacc.c */ -#line 135 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 135 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 21: - -/* Line 1806 of yacc.c */ -#line 136 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 136 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 22: - -/* Line 1806 of yacc.c */ -#line 137 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 137 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 23: - -/* Line 1806 of yacc.c */ -#line 141 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 141 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { PHPDBG_G(req_id) = (yyvsp[(1) - (1)]).num; } break; case 25: - -/* Line 1806 of yacc.c */ -#line 146 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 146 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = EVAL_PARAM; (yyval).str = (yyvsp[(3) - (3)]).str; @@ -1657,9 +1633,8 @@ yyreduce: break; case 26: - -/* Line 1806 of yacc.c */ -#line 151 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 151 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = SHELL_PARAM; (yyval).str = (yyvsp[(3) - (3)]).str; @@ -1668,9 +1643,8 @@ yyreduce: break; case 27: - -/* Line 1806 of yacc.c */ -#line 156 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 156 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = RUN_PARAM; (yyval).len = 0; @@ -1678,9 +1652,8 @@ yyreduce: break; case 28: - -/* Line 1806 of yacc.c */ -#line 160 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 160 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = RUN_PARAM; (yyval).str = (yyvsp[(3) - (3)]).str; @@ -1689,9 +1662,8 @@ yyreduce: break; - -/* Line 1806 of yacc.c */ -#line 1695 "sapi/phpdbg/phpdbg_parser.c" +/* Line 1792 of yacc.c */ +#line 1667 "sapi/phpdbg/phpdbg_parser.c" default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -1854,7 +1826,9 @@ yyerrlab1: YY_STACK_PRINT (yyss, yyssp); } + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END /* Shift the error token. */ @@ -1878,7 +1852,7 @@ yyabortlab: yyresult = 1; goto yyreturn; -#if !defined(yyoverflow) || YYERROR_VERBOSE +#if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -1920,9 +1894,8 @@ yyreturn: } - -/* Line 2067 of yacc.c */ -#line 167 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 2055 of yacc.c */ +#line 167 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" static int yyerror(void ***tsrm_ls, const char *msg) { @@ -1948,4 +1921,3 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC) { return yyparse(NULL); #endif } - diff --git a/phpdbg_parser.h b/phpdbg_parser.h index dfa155d7184..4cd8ed6d008 100644 --- a/phpdbg_parser.h +++ b/phpdbg_parser.h @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.5. */ +/* A Bison parser, made by GNU Bison 2.7. */ /* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,10 +30,18 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ +#ifndef YY_PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED +# define YY_PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int phpdbg_debug; +#endif /* "%code requires" blocks. */ - -/* Line 2068 of yacc.c */ -#line 31 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 2058 of yacc.c */ +#line 31 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" #include "phpdbg.h" #ifndef YY_TYPEDEF_YY_SCANNER_T @@ -42,9 +50,8 @@ typedef void* yyscan_t; #endif - -/* Line 2068 of yacc.c */ -#line 48 "sapi/phpdbg/phpdbg_parser.h" +/* Line 2058 of yacc.c */ +#line 55 "sapi/phpdbg/phpdbg_parser.h" /* Tokens. */ #ifndef YYTOKENTYPE @@ -96,7 +103,6 @@ typedef void* yyscan_t; - #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 @@ -105,5 +111,18 @@ typedef int YYSTYPE; #endif +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int phpdbg_parse (void *YYPARSE_PARAM); +#else +int phpdbg_parse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int phpdbg_parse (void *tsrm_ls); +#else +int phpdbg_parse (); +#endif +#endif /* ! YYPARSE_PARAM */ - +#endif /* !YY_PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED */ From 1ff04117c3937de6af116a229c0b43c8ca969b70 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sun, 26 Oct 2014 10:48:45 +0100 Subject: [PATCH 068/398] Fix nullptr dereference in clean without exec context --- phpdbg_prompt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 29c75c583c0..eca4c6ac2ba 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -1320,7 +1320,10 @@ void phpdbg_clean(zend_bool full TSRMLS_DC) /* {{{ */ } if (full) { - phpdbg_exec = strdup(PHPDBG_G(exec)); /* preserve exec, don't reparse that from cmd */ + if (PHPDBG_G(exec)) { + phpdbg_exec = strdup(PHPDBG_G(exec)); /* preserve exec, don't reparse that from cmd */ + } + PHPDBG_G(flags) |= PHPDBG_IS_CLEANING; zend_bailout(); From 22b9f16e9ad0f500b73fd6814feb6c00ce749f34 Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Sun, 26 Oct 2014 10:54:07 -0400 Subject: [PATCH 069/398] - Updated to version 2014.9 (2014i) --- ext/date/lib/timezonedb.h | 773 +++++++++++++++++++------------------- 1 file changed, 394 insertions(+), 379 deletions(-) diff --git a/ext/date/lib/timezonedb.h b/ext/date/lib/timezonedb.h index 98e7b2292cb..0fd9bfbe10c 100644 --- a/ext/date/lib/timezonedb.h +++ b/ext/date/lib/timezonedb.h @@ -1,4 +1,4 @@ -const timelib_tzdb_index_entry timezonedb_idx_builtin[582] = { +const timelib_tzdb_index_entry timezonedb_idx_builtin[583] = { { "Africa/Abidjan" , 0x000000 }, { "Africa/Accra" , 0x000055 }, { "Africa/Addis_Ababa" , 0x00019D }, @@ -261,329 +261,330 @@ const timelib_tzdb_index_entry timezonedb_idx_builtin[582] = { { "Asia/Harbin" , 0x01B474 }, { "Asia/Hebron" , 0x01B514 }, { "Asia/Ho_Chi_Minh" , 0x01B870 }, - { "Asia/Hong_Kong" , 0x01B8E8 }, - { "Asia/Hovd" , 0x01BAAA }, - { "Asia/Irkutsk" , 0x01BC22 }, - { "Asia/Istanbul" , 0x01BE0D }, - { "Asia/Jakarta" , 0x01C1FA }, - { "Asia/Jayapura" , 0x01C2A4 }, - { "Asia/Jerusalem" , 0x01C341 }, - { "Asia/Kabul" , 0x01C670 }, - { "Asia/Kamchatka" , 0x01C6C1 }, - { "Asia/Karachi" , 0x01C8BA }, - { "Asia/Kashgar" , 0x01C96F }, - { "Asia/Kathmandu" , 0x01C9C4 }, - { "Asia/Katmandu" , 0x01CA2A }, - { "Asia/Khandyga" , 0x01CA90 }, - { "Asia/Kolkata" , 0x01CCBA }, - { "Asia/Krasnoyarsk" , 0x01CD33 }, - { "Asia/Kuala_Lumpur" , 0x01CF20 }, - { "Asia/Kuching" , 0x01CFDD }, - { "Asia/Kuwait" , 0x01D0CB }, - { "Asia/Macao" , 0x01D120 }, - { "Asia/Macau" , 0x01D25B }, - { "Asia/Magadan" , 0x01D396 }, - { "Asia/Makassar" , 0x01D59A }, - { "Asia/Manila" , 0x01D65F }, - { "Asia/Muscat" , 0x01D6E4 }, - { "Asia/Nicosia" , 0x01D739 }, - { "Asia/Novokuznetsk" , 0x01DA21 }, - { "Asia/Novosibirsk" , 0x01DC41 }, - { "Asia/Omsk" , 0x01DE31 }, - { "Asia/Oral" , 0x01E01D }, - { "Asia/Phnom_Penh" , 0x01E1ED }, - { "Asia/Pontianak" , 0x01E265 }, - { "Asia/Pyongyang" , 0x01E327 }, - { "Asia/Qatar" , 0x01E3B7 }, - { "Asia/Qyzylorda" , 0x01E41D }, - { "Asia/Rangoon" , 0x01E5F3 }, - { "Asia/Riyadh" , 0x01E66B }, - { "Asia/Saigon" , 0x01E6C0 }, - { "Asia/Sakhalin" , 0x01E738 }, - { "Asia/Samarkand" , 0x01E935 }, - { "Asia/Seoul" , 0x01EA6B }, - { "Asia/Shanghai" , 0x01EB32 }, - { "Asia/Singapore" , 0x01EBDE }, - { "Asia/Srednekolymsk" , 0x01EC95 }, - { "Asia/Taipei" , 0x01EE95 }, - { "Asia/Tashkent" , 0x01EFC6 }, - { "Asia/Tbilisi" , 0x01F0F7 }, - { "Asia/Tehran" , 0x01F2B1 }, - { "Asia/Tel_Aviv" , 0x01F51F }, - { "Asia/Thimbu" , 0x01F84E }, - { "Asia/Thimphu" , 0x01F8B4 }, - { "Asia/Tokyo" , 0x01F91A }, - { "Asia/Ujung_Pandang" , 0x01F9A4 }, - { "Asia/Ulaanbaatar" , 0x01FA21 }, - { "Asia/Ulan_Bator" , 0x01FB7C }, - { "Asia/Urumqi" , 0x01FCC9 }, - { "Asia/Ust-Nera" , 0x01FD2B }, - { "Asia/Vientiane" , 0x01FF3D }, - { "Asia/Vladivostok" , 0x01FFB5 }, - { "Asia/Yakutsk" , 0x02019F }, - { "Asia/Yekaterinburg" , 0x020389 }, - { "Asia/Yerevan" , 0x0205AA }, - { "Atlantic/Azores" , 0x0207AA }, - { "Atlantic/Bermuda" , 0x020CAD }, - { "Atlantic/Canary" , 0x020F8E }, - { "Atlantic/Cape_Verde" , 0x021264 }, - { "Atlantic/Faeroe" , 0x0212DD }, - { "Atlantic/Faroe" , 0x021581 }, - { "Atlantic/Jan_Mayen" , 0x021825 }, - { "Atlantic/Madeira" , 0x021B57 }, - { "Atlantic/Reykjavik" , 0x022060 }, - { "Atlantic/South_Georgia" , 0x022219 }, - { "Atlantic/St_Helena" , 0x02242B }, - { "Atlantic/Stanley" , 0x02225D }, - { "Australia/ACT" , 0x022480 }, - { "Australia/Adelaide" , 0x0227A3 }, - { "Australia/Brisbane" , 0x022AD5 }, - { "Australia/Broken_Hill" , 0x022BA2 }, - { "Australia/Canberra" , 0x022EE6 }, - { "Australia/Currie" , 0x023209 }, - { "Australia/Darwin" , 0x023542 }, - { "Australia/Eucla" , 0x0235CE }, - { "Australia/Hobart" , 0x0236AA }, - { "Australia/LHI" , 0x023A0E }, - { "Australia/Lindeman" , 0x023CAF }, - { "Australia/Lord_Howe" , 0x023D96 }, - { "Australia/Melbourne" , 0x024047 }, - { "Australia/North" , 0x024372 }, - { "Australia/NSW" , 0x0243EC }, - { "Australia/Perth" , 0x02470F }, - { "Australia/Queensland" , 0x0247ED }, - { "Australia/South" , 0x02489F }, - { "Australia/Sydney" , 0x024BC2 }, - { "Australia/Tasmania" , 0x024F05 }, - { "Australia/Victoria" , 0x025250 }, - { "Australia/West" , 0x025573 }, - { "Australia/Yancowinna" , 0x02562F }, - { "Brazil/Acre" , 0x025957 }, - { "Brazil/DeNoronha" , 0x025A5B }, - { "Brazil/East" , 0x025B7B }, - { "Brazil/West" , 0x025E58 }, - { "Canada/Atlantic" , 0x025F50 }, - { "Canada/Central" , 0x026438 }, - { "Canada/East-Saskatchewan" , 0x026D42 }, - { "Canada/Eastern" , 0x026852 }, - { "Canada/Mountain" , 0x026ECB }, - { "Canada/Newfoundland" , 0x027241 }, - { "Canada/Pacific" , 0x02776C }, - { "Canada/Saskatchewan" , 0x027B85 }, - { "Canada/Yukon" , 0x027D0E }, - { "CET" , 0x028011 }, - { "Chile/Continental" , 0x02831A }, - { "Chile/EasterIsland" , 0x0286B5 }, - { "CST6CDT" , 0x0289F7 }, - { "Cuba" , 0x028D48 }, - { "EET" , 0x0290BB }, - { "Egypt" , 0x02936E }, - { "Eire" , 0x029755 }, - { "EST" , 0x029C66 }, - { "EST5EDT" , 0x029CAA }, - { "Etc/GMT" , 0x029FFB }, - { "Etc/GMT+0" , 0x02A0C7 }, - { "Etc/GMT+1" , 0x02A151 }, - { "Etc/GMT+10" , 0x02A1DE }, - { "Etc/GMT+11" , 0x02A26C }, - { "Etc/GMT+12" , 0x02A2FA }, - { "Etc/GMT+2" , 0x02A415 }, - { "Etc/GMT+3" , 0x02A4A1 }, - { "Etc/GMT+4" , 0x02A52D }, - { "Etc/GMT+5" , 0x02A5B9 }, - { "Etc/GMT+6" , 0x02A645 }, - { "Etc/GMT+7" , 0x02A6D1 }, - { "Etc/GMT+8" , 0x02A75D }, - { "Etc/GMT+9" , 0x02A7E9 }, - { "Etc/GMT-0" , 0x02A083 }, - { "Etc/GMT-1" , 0x02A10B }, - { "Etc/GMT-10" , 0x02A197 }, - { "Etc/GMT-11" , 0x02A225 }, - { "Etc/GMT-12" , 0x02A2B3 }, - { "Etc/GMT-13" , 0x02A341 }, - { "Etc/GMT-14" , 0x02A388 }, - { "Etc/GMT-2" , 0x02A3CF }, - { "Etc/GMT-3" , 0x02A45B }, - { "Etc/GMT-4" , 0x02A4E7 }, - { "Etc/GMT-5" , 0x02A573 }, - { "Etc/GMT-6" , 0x02A5FF }, - { "Etc/GMT-7" , 0x02A68B }, - { "Etc/GMT-8" , 0x02A717 }, - { "Etc/GMT-9" , 0x02A7A3 }, - { "Etc/GMT0" , 0x02A03F }, - { "Etc/Greenwich" , 0x02A82F }, - { "Etc/UCT" , 0x02A873 }, - { "Etc/Universal" , 0x02A8B7 }, - { "Etc/UTC" , 0x02A8FB }, - { "Etc/Zulu" , 0x02A93F }, - { "Europe/Amsterdam" , 0x02A983 }, - { "Europe/Andorra" , 0x02ADC1 }, - { "Europe/Athens" , 0x02B03D }, - { "Europe/Belfast" , 0x02B380 }, - { "Europe/Belgrade" , 0x02B8B7 }, - { "Europe/Berlin" , 0x02BB80 }, - { "Europe/Bratislava" , 0x02BEE4 }, - { "Europe/Brussels" , 0x02C216 }, - { "Europe/Bucharest" , 0x02C64D }, - { "Europe/Budapest" , 0x02C977 }, - { "Europe/Busingen" , 0x02CCE0 }, - { "Europe/Chisinau" , 0x02CF97 }, - { "Europe/Copenhagen" , 0x02D325 }, - { "Europe/Dublin" , 0x02D62F }, - { "Europe/Gibraltar" , 0x02DB40 }, - { "Europe/Guernsey" , 0x02DF97 }, - { "Europe/Helsinki" , 0x02E4CE }, - { "Europe/Isle_of_Man" , 0x02E784 }, - { "Europe/Istanbul" , 0x02ECBB }, - { "Europe/Jersey" , 0x02F0A8 }, - { "Europe/Kaliningrad" , 0x02F5DF }, - { "Europe/Kiev" , 0x02F84A }, - { "Europe/Lisbon" , 0x02FB66 }, - { "Europe/Ljubljana" , 0x03006A }, - { "Europe/London" , 0x030333 }, - { "Europe/Luxembourg" , 0x03086A }, - { "Europe/Madrid" , 0x030CC0 }, - { "Europe/Malta" , 0x031086 }, - { "Europe/Mariehamn" , 0x03143F }, - { "Europe/Minsk" , 0x0316F5 }, - { "Europe/Monaco" , 0x031903 }, - { "Europe/Moscow" , 0x031D3E }, - { "Europe/Nicosia" , 0x031F98 }, - { "Europe/Oslo" , 0x032280 }, - { "Europe/Paris" , 0x0325B2 }, - { "Europe/Podgorica" , 0x0329F8 }, - { "Europe/Prague" , 0x032CC1 }, - { "Europe/Riga" , 0x032FF3 }, - { "Europe/Rome" , 0x033338 }, - { "Europe/Samara" , 0x0336FB }, - { "Europe/San_Marino" , 0x033964 }, - { "Europe/Sarajevo" , 0x033D27 }, - { "Europe/Simferopol" , 0x033FF0 }, - { "Europe/Skopje" , 0x034241 }, - { "Europe/Sofia" , 0x03450A }, - { "Europe/Stockholm" , 0x034812 }, - { "Europe/Tallinn" , 0x034AC1 }, - { "Europe/Tirane" , 0x034DFB }, - { "Europe/Tiraspol" , 0x035101 }, - { "Europe/Uzhgorod" , 0x03548F }, - { "Europe/Vaduz" , 0x0357A6 }, - { "Europe/Vatican" , 0x035A55 }, - { "Europe/Vienna" , 0x035E18 }, - { "Europe/Vilnius" , 0x036145 }, - { "Europe/Volgograd" , 0x036484 }, - { "Europe/Warsaw" , 0x0366A5 }, - { "Europe/Zagreb" , 0x036A86 }, - { "Europe/Zaporozhye" , 0x036D4F }, - { "Europe/Zurich" , 0x037090 }, - { "Factory" , 0x03733F }, - { "GB" , 0x0373B0 }, - { "GB-Eire" , 0x0378E7 }, - { "GMT" , 0x037E1E }, - { "GMT+0" , 0x037EEA }, - { "GMT-0" , 0x037EA6 }, - { "GMT0" , 0x037E62 }, - { "Greenwich" , 0x037F2E }, - { "Hongkong" , 0x037F72 }, - { "HST" , 0x038134 }, - { "Iceland" , 0x038178 }, - { "Indian/Antananarivo" , 0x038331 }, - { "Indian/Chagos" , 0x0383A5 }, - { "Indian/Christmas" , 0x038407 }, - { "Indian/Cocos" , 0x03844B }, - { "Indian/Comoro" , 0x03848F }, - { "Indian/Kerguelen" , 0x0384E4 }, - { "Indian/Mahe" , 0x038539 }, - { "Indian/Maldives" , 0x03858E }, - { "Indian/Mauritius" , 0x0385E3 }, - { "Indian/Mayotte" , 0x038659 }, - { "Indian/Reunion" , 0x0386AE }, - { "Iran" , 0x038703 }, - { "Israel" , 0x038971 }, - { "Jamaica" , 0x038CA0 }, - { "Japan" , 0x038D65 }, - { "Kwajalein" , 0x038DEF }, - { "Libya" , 0x038E52 }, - { "MET" , 0x038F5B }, - { "Mexico/BajaNorte" , 0x039264 }, - { "Mexico/BajaSur" , 0x0395CD }, - { "Mexico/General" , 0x039812 }, - { "MST" , 0x039A70 }, - { "MST7MDT" , 0x039AB4 }, - { "Navajo" , 0x039E05 }, - { "NZ" , 0x03A17E }, - { "NZ-CHAT" , 0x03A4FC }, - { "Pacific/Apia" , 0x03A7E0 }, - { "Pacific/Auckland" , 0x03A97C }, - { "Pacific/Chatham" , 0x03AD08 }, - { "Pacific/Chuuk" , 0x03AFFB }, - { "Pacific/Easter" , 0x03B054 }, - { "Pacific/Efate" , 0x03B3A3 }, - { "Pacific/Enderbury" , 0x03B469 }, - { "Pacific/Fakaofo" , 0x03B4D7 }, - { "Pacific/Fiji" , 0x03B528 }, - { "Pacific/Funafuti" , 0x03B6BB }, - { "Pacific/Galapagos" , 0x03B6FF }, - { "Pacific/Gambier" , 0x03B777 }, - { "Pacific/Guadalcanal" , 0x03B7DC }, - { "Pacific/Guam" , 0x03B831 }, - { "Pacific/Honolulu" , 0x03B887 }, - { "Pacific/Johnston" , 0x03B8FE }, - { "Pacific/Kiritimati" , 0x03B97D }, - { "Pacific/Kosrae" , 0x03B9E8 }, - { "Pacific/Kwajalein" , 0x03BA45 }, - { "Pacific/Majuro" , 0x03BAB1 }, - { "Pacific/Marquesas" , 0x03BB10 }, - { "Pacific/Midway" , 0x03BB77 }, - { "Pacific/Nauru" , 0x03BC01 }, - { "Pacific/Niue" , 0x03BC79 }, - { "Pacific/Norfolk" , 0x03BCD7 }, - { "Pacific/Noumea" , 0x03BD2C }, - { "Pacific/Pago_Pago" , 0x03BDBC }, - { "Pacific/Palau" , 0x03BE33 }, - { "Pacific/Pitcairn" , 0x03BE77 }, - { "Pacific/Pohnpei" , 0x03BECC }, - { "Pacific/Ponape" , 0x03BF21 }, - { "Pacific/Port_Moresby" , 0x03BF66 }, - { "Pacific/Rarotonga" , 0x03BFAA }, - { "Pacific/Saipan" , 0x03C086 }, - { "Pacific/Samoa" , 0x03C0E9 }, - { "Pacific/Tahiti" , 0x03C160 }, - { "Pacific/Tarawa" , 0x03C1C5 }, - { "Pacific/Tongatapu" , 0x03C219 }, - { "Pacific/Truk" , 0x03C2A5 }, - { "Pacific/Wake" , 0x03C2EA }, - { "Pacific/Wallis" , 0x03C33A }, - { "Pacific/Yap" , 0x03C37E }, - { "Poland" , 0x03C3C3 }, - { "Portugal" , 0x03C7A4 }, - { "PRC" , 0x03CCA0 }, - { "PST8PDT" , 0x03CD40 }, - { "ROC" , 0x03D091 }, - { "ROK" , 0x03D1C2 }, - { "Singapore" , 0x03D289 }, - { "Turkey" , 0x03D340 }, - { "UCT" , 0x03D72D }, - { "Universal" , 0x03D771 }, - { "US/Alaska" , 0x03D7B5 }, - { "US/Aleutian" , 0x03DB1E }, - { "US/Arizona" , 0x03DE84 }, - { "US/Central" , 0x03DF12 }, - { "US/East-Indiana" , 0x03E91C }, - { "US/Eastern" , 0x03E41D }, - { "US/Hawaii" , 0x03EB86 }, - { "US/Indiana-Starke" , 0x03EBF7 }, - { "US/Michigan" , 0x03EF68 }, - { "US/Mountain" , 0x03F29F }, - { "US/Pacific" , 0x03F618 }, - { "US/Pacific-New" , 0x03FA1D }, - { "US/Samoa" , 0x03FE22 }, - { "UTC" , 0x03FE99 }, - { "W-SU" , 0x040190 }, - { "WET" , 0x03FEDD }, - { "Zulu" , 0x0403D3 }, + { "Asia/Hong_Kong" , 0x01B912 }, + { "Asia/Hovd" , 0x01BAD4 }, + { "Asia/Irkutsk" , 0x01BC4C }, + { "Asia/Istanbul" , 0x01BE37 }, + { "Asia/Jakarta" , 0x01C224 }, + { "Asia/Jayapura" , 0x01C2CE }, + { "Asia/Jerusalem" , 0x01C36B }, + { "Asia/Kabul" , 0x01C69A }, + { "Asia/Kamchatka" , 0x01C6EB }, + { "Asia/Karachi" , 0x01C8E4 }, + { "Asia/Kashgar" , 0x01C999 }, + { "Asia/Kathmandu" , 0x01C9EE }, + { "Asia/Katmandu" , 0x01CA54 }, + { "Asia/Khandyga" , 0x01CABA }, + { "Asia/Kolkata" , 0x01CCE4 }, + { "Asia/Krasnoyarsk" , 0x01CD5D }, + { "Asia/Kuala_Lumpur" , 0x01CF4A }, + { "Asia/Kuching" , 0x01D007 }, + { "Asia/Kuwait" , 0x01D0F5 }, + { "Asia/Macao" , 0x01D14A }, + { "Asia/Macau" , 0x01D285 }, + { "Asia/Magadan" , 0x01D3C0 }, + { "Asia/Makassar" , 0x01D5C4 }, + { "Asia/Manila" , 0x01D689 }, + { "Asia/Muscat" , 0x01D70E }, + { "Asia/Nicosia" , 0x01D763 }, + { "Asia/Novokuznetsk" , 0x01DA4B }, + { "Asia/Novosibirsk" , 0x01DC6B }, + { "Asia/Omsk" , 0x01DE5B }, + { "Asia/Oral" , 0x01E047 }, + { "Asia/Phnom_Penh" , 0x01E217 }, + { "Asia/Pontianak" , 0x01E26C }, + { "Asia/Pyongyang" , 0x01E32E }, + { "Asia/Qatar" , 0x01E3BE }, + { "Asia/Qyzylorda" , 0x01E424 }, + { "Asia/Rangoon" , 0x01E5FA }, + { "Asia/Riyadh" , 0x01E672 }, + { "Asia/Saigon" , 0x01E6C7 }, + { "Asia/Sakhalin" , 0x01E769 }, + { "Asia/Samarkand" , 0x01E966 }, + { "Asia/Seoul" , 0x01EA9C }, + { "Asia/Shanghai" , 0x01EB63 }, + { "Asia/Singapore" , 0x01EC0F }, + { "Asia/Srednekolymsk" , 0x01ECC6 }, + { "Asia/Taipei" , 0x01EEC6 }, + { "Asia/Tashkent" , 0x01EFF7 }, + { "Asia/Tbilisi" , 0x01F128 }, + { "Asia/Tehran" , 0x01F2E2 }, + { "Asia/Tel_Aviv" , 0x01F550 }, + { "Asia/Thimbu" , 0x01F87F }, + { "Asia/Thimphu" , 0x01F8E5 }, + { "Asia/Tokyo" , 0x01F94B }, + { "Asia/Ujung_Pandang" , 0x01F9D5 }, + { "Asia/Ulaanbaatar" , 0x01FA52 }, + { "Asia/Ulan_Bator" , 0x01FBAD }, + { "Asia/Urumqi" , 0x01FCFA }, + { "Asia/Ust-Nera" , 0x01FD5C }, + { "Asia/Vientiane" , 0x01FF6E }, + { "Asia/Vladivostok" , 0x01FFC3 }, + { "Asia/Yakutsk" , 0x0201AD }, + { "Asia/Yekaterinburg" , 0x020397 }, + { "Asia/Yerevan" , 0x0205B8 }, + { "Atlantic/Azores" , 0x0207B8 }, + { "Atlantic/Bermuda" , 0x020CBB }, + { "Atlantic/Canary" , 0x020F9C }, + { "Atlantic/Cape_Verde" , 0x021272 }, + { "Atlantic/Faeroe" , 0x0212EB }, + { "Atlantic/Faroe" , 0x02158F }, + { "Atlantic/Jan_Mayen" , 0x021833 }, + { "Atlantic/Madeira" , 0x021B65 }, + { "Atlantic/Reykjavik" , 0x02206E }, + { "Atlantic/South_Georgia" , 0x022227 }, + { "Atlantic/St_Helena" , 0x022439 }, + { "Atlantic/Stanley" , 0x02226B }, + { "Australia/ACT" , 0x02248E }, + { "Australia/Adelaide" , 0x0227B1 }, + { "Australia/Brisbane" , 0x022AE3 }, + { "Australia/Broken_Hill" , 0x022BB0 }, + { "Australia/Canberra" , 0x022EF4 }, + { "Australia/Currie" , 0x023217 }, + { "Australia/Darwin" , 0x023550 }, + { "Australia/Eucla" , 0x0235DC }, + { "Australia/Hobart" , 0x0236B8 }, + { "Australia/LHI" , 0x023A1C }, + { "Australia/Lindeman" , 0x023CBD }, + { "Australia/Lord_Howe" , 0x023DA4 }, + { "Australia/Melbourne" , 0x024055 }, + { "Australia/North" , 0x024380 }, + { "Australia/NSW" , 0x0243FA }, + { "Australia/Perth" , 0x02471D }, + { "Australia/Queensland" , 0x0247FB }, + { "Australia/South" , 0x0248AD }, + { "Australia/Sydney" , 0x024BD0 }, + { "Australia/Tasmania" , 0x024F13 }, + { "Australia/Victoria" , 0x02525E }, + { "Australia/West" , 0x025581 }, + { "Australia/Yancowinna" , 0x02563D }, + { "Brazil/Acre" , 0x025965 }, + { "Brazil/DeNoronha" , 0x025A69 }, + { "Brazil/East" , 0x025B89 }, + { "Brazil/West" , 0x025E66 }, + { "Canada/Atlantic" , 0x025F5E }, + { "Canada/Central" , 0x026446 }, + { "Canada/East-Saskatchewan" , 0x026D50 }, + { "Canada/Eastern" , 0x026860 }, + { "Canada/Mountain" , 0x026ED9 }, + { "Canada/Newfoundland" , 0x02724F }, + { "Canada/Pacific" , 0x02777A }, + { "Canada/Saskatchewan" , 0x027B93 }, + { "Canada/Yukon" , 0x027D1C }, + { "CET" , 0x02801F }, + { "Chile/Continental" , 0x028328 }, + { "Chile/EasterIsland" , 0x0286C3 }, + { "CST6CDT" , 0x028A05 }, + { "Cuba" , 0x028D56 }, + { "EET" , 0x0290C9 }, + { "Egypt" , 0x02937C }, + { "Eire" , 0x029763 }, + { "EST" , 0x029C74 }, + { "EST5EDT" , 0x029CB8 }, + { "Etc/GMT" , 0x02A009 }, + { "Etc/GMT+0" , 0x02A0D5 }, + { "Etc/GMT+1" , 0x02A15F }, + { "Etc/GMT+10" , 0x02A1EC }, + { "Etc/GMT+11" , 0x02A27A }, + { "Etc/GMT+12" , 0x02A308 }, + { "Etc/GMT+2" , 0x02A423 }, + { "Etc/GMT+3" , 0x02A4AF }, + { "Etc/GMT+4" , 0x02A53B }, + { "Etc/GMT+5" , 0x02A5C7 }, + { "Etc/GMT+6" , 0x02A653 }, + { "Etc/GMT+7" , 0x02A6DF }, + { "Etc/GMT+8" , 0x02A76B }, + { "Etc/GMT+9" , 0x02A7F7 }, + { "Etc/GMT-0" , 0x02A091 }, + { "Etc/GMT-1" , 0x02A119 }, + { "Etc/GMT-10" , 0x02A1A5 }, + { "Etc/GMT-11" , 0x02A233 }, + { "Etc/GMT-12" , 0x02A2C1 }, + { "Etc/GMT-13" , 0x02A34F }, + { "Etc/GMT-14" , 0x02A396 }, + { "Etc/GMT-2" , 0x02A3DD }, + { "Etc/GMT-3" , 0x02A469 }, + { "Etc/GMT-4" , 0x02A4F5 }, + { "Etc/GMT-5" , 0x02A581 }, + { "Etc/GMT-6" , 0x02A60D }, + { "Etc/GMT-7" , 0x02A699 }, + { "Etc/GMT-8" , 0x02A725 }, + { "Etc/GMT-9" , 0x02A7B1 }, + { "Etc/GMT0" , 0x02A04D }, + { "Etc/Greenwich" , 0x02A83D }, + { "Etc/UCT" , 0x02A881 }, + { "Etc/Universal" , 0x02A8C5 }, + { "Etc/UTC" , 0x02A909 }, + { "Etc/Zulu" , 0x02A94D }, + { "Europe/Amsterdam" , 0x02A991 }, + { "Europe/Andorra" , 0x02ADCF }, + { "Europe/Athens" , 0x02B04B }, + { "Europe/Belfast" , 0x02B38E }, + { "Europe/Belgrade" , 0x02B8C5 }, + { "Europe/Berlin" , 0x02BB8E }, + { "Europe/Bratislava" , 0x02BEF2 }, + { "Europe/Brussels" , 0x02C224 }, + { "Europe/Bucharest" , 0x02C65B }, + { "Europe/Budapest" , 0x02C985 }, + { "Europe/Busingen" , 0x02CCEE }, + { "Europe/Chisinau" , 0x02CFA5 }, + { "Europe/Copenhagen" , 0x02D333 }, + { "Europe/Dublin" , 0x02D63D }, + { "Europe/Gibraltar" , 0x02DB4E }, + { "Europe/Guernsey" , 0x02DFA5 }, + { "Europe/Helsinki" , 0x02E4DC }, + { "Europe/Isle_of_Man" , 0x02E792 }, + { "Europe/Istanbul" , 0x02ECC9 }, + { "Europe/Jersey" , 0x02F0B6 }, + { "Europe/Kaliningrad" , 0x02F5ED }, + { "Europe/Kiev" , 0x02F858 }, + { "Europe/Lisbon" , 0x02FB74 }, + { "Europe/Ljubljana" , 0x030078 }, + { "Europe/London" , 0x030341 }, + { "Europe/Luxembourg" , 0x030878 }, + { "Europe/Madrid" , 0x030CCE }, + { "Europe/Malta" , 0x031094 }, + { "Europe/Mariehamn" , 0x03144D }, + { "Europe/Minsk" , 0x031703 }, + { "Europe/Monaco" , 0x031916 }, + { "Europe/Moscow" , 0x031D51 }, + { "Europe/Nicosia" , 0x031FAB }, + { "Europe/Oslo" , 0x032293 }, + { "Europe/Paris" , 0x0325C5 }, + { "Europe/Podgorica" , 0x032A0B }, + { "Europe/Prague" , 0x032CD4 }, + { "Europe/Riga" , 0x033006 }, + { "Europe/Rome" , 0x03334B }, + { "Europe/Samara" , 0x03370E }, + { "Europe/San_Marino" , 0x033977 }, + { "Europe/Sarajevo" , 0x033D3A }, + { "Europe/Simferopol" , 0x034003 }, + { "Europe/Skopje" , 0x034254 }, + { "Europe/Sofia" , 0x03451D }, + { "Europe/Stockholm" , 0x034825 }, + { "Europe/Tallinn" , 0x034AD4 }, + { "Europe/Tirane" , 0x034E0E }, + { "Europe/Tiraspol" , 0x035114 }, + { "Europe/Uzhgorod" , 0x0354A2 }, + { "Europe/Vaduz" , 0x0357B9 }, + { "Europe/Vatican" , 0x035A68 }, + { "Europe/Vienna" , 0x035E2B }, + { "Europe/Vilnius" , 0x036158 }, + { "Europe/Volgograd" , 0x036497 }, + { "Europe/Warsaw" , 0x0366B8 }, + { "Europe/Zagreb" , 0x036A99 }, + { "Europe/Zaporozhye" , 0x036D62 }, + { "Europe/Zurich" , 0x0370A3 }, + { "Factory" , 0x037352 }, + { "GB" , 0x0373C3 }, + { "GB-Eire" , 0x0378FA }, + { "GMT" , 0x037E31 }, + { "GMT+0" , 0x037EFD }, + { "GMT-0" , 0x037EB9 }, + { "GMT0" , 0x037E75 }, + { "Greenwich" , 0x037F41 }, + { "Hongkong" , 0x037F85 }, + { "HST" , 0x038147 }, + { "Iceland" , 0x03818B }, + { "Indian/Antananarivo" , 0x038344 }, + { "Indian/Chagos" , 0x0383B8 }, + { "Indian/Christmas" , 0x03841A }, + { "Indian/Cocos" , 0x03845E }, + { "Indian/Comoro" , 0x0384A2 }, + { "Indian/Kerguelen" , 0x0384F7 }, + { "Indian/Mahe" , 0x03854C }, + { "Indian/Maldives" , 0x0385A1 }, + { "Indian/Mauritius" , 0x0385F6 }, + { "Indian/Mayotte" , 0x03866C }, + { "Indian/Reunion" , 0x0386C1 }, + { "Iran" , 0x038716 }, + { "Israel" , 0x038984 }, + { "Jamaica" , 0x038CB3 }, + { "Japan" , 0x038D78 }, + { "Kwajalein" , 0x038E02 }, + { "Libya" , 0x038E65 }, + { "MET" , 0x038F6E }, + { "Mexico/BajaNorte" , 0x039277 }, + { "Mexico/BajaSur" , 0x0395E0 }, + { "Mexico/General" , 0x039825 }, + { "MST" , 0x039A83 }, + { "MST7MDT" , 0x039AC7 }, + { "Navajo" , 0x039E18 }, + { "NZ" , 0x03A191 }, + { "NZ-CHAT" , 0x03A50F }, + { "Pacific/Apia" , 0x03A7F3 }, + { "Pacific/Auckland" , 0x03A98F }, + { "Pacific/Bougainville" , 0x03AD1B }, + { "Pacific/Chatham" , 0x03AD92 }, + { "Pacific/Chuuk" , 0x03B085 }, + { "Pacific/Easter" , 0x03B0DE }, + { "Pacific/Efate" , 0x03B42D }, + { "Pacific/Enderbury" , 0x03B4F3 }, + { "Pacific/Fakaofo" , 0x03B561 }, + { "Pacific/Fiji" , 0x03B5B2 }, + { "Pacific/Funafuti" , 0x03B745 }, + { "Pacific/Galapagos" , 0x03B789 }, + { "Pacific/Gambier" , 0x03B801 }, + { "Pacific/Guadalcanal" , 0x03B866 }, + { "Pacific/Guam" , 0x03B8BB }, + { "Pacific/Honolulu" , 0x03B911 }, + { "Pacific/Johnston" , 0x03B988 }, + { "Pacific/Kiritimati" , 0x03BA07 }, + { "Pacific/Kosrae" , 0x03BA72 }, + { "Pacific/Kwajalein" , 0x03BACF }, + { "Pacific/Majuro" , 0x03BB3B }, + { "Pacific/Marquesas" , 0x03BB9A }, + { "Pacific/Midway" , 0x03BC01 }, + { "Pacific/Nauru" , 0x03BC8B }, + { "Pacific/Niue" , 0x03BD03 }, + { "Pacific/Norfolk" , 0x03BD61 }, + { "Pacific/Noumea" , 0x03BDB6 }, + { "Pacific/Pago_Pago" , 0x03BE46 }, + { "Pacific/Palau" , 0x03BEBD }, + { "Pacific/Pitcairn" , 0x03BF01 }, + { "Pacific/Pohnpei" , 0x03BF56 }, + { "Pacific/Ponape" , 0x03BFAB }, + { "Pacific/Port_Moresby" , 0x03BFF0 }, + { "Pacific/Rarotonga" , 0x03C042 }, + { "Pacific/Saipan" , 0x03C11E }, + { "Pacific/Samoa" , 0x03C181 }, + { "Pacific/Tahiti" , 0x03C1F8 }, + { "Pacific/Tarawa" , 0x03C25D }, + { "Pacific/Tongatapu" , 0x03C2B1 }, + { "Pacific/Truk" , 0x03C33D }, + { "Pacific/Wake" , 0x03C382 }, + { "Pacific/Wallis" , 0x03C3D2 }, + { "Pacific/Yap" , 0x03C416 }, + { "Poland" , 0x03C45B }, + { "Portugal" , 0x03C83C }, + { "PRC" , 0x03CD38 }, + { "PST8PDT" , 0x03CDD8 }, + { "ROC" , 0x03D129 }, + { "ROK" , 0x03D25A }, + { "Singapore" , 0x03D321 }, + { "Turkey" , 0x03D3D8 }, + { "UCT" , 0x03D7C5 }, + { "Universal" , 0x03D809 }, + { "US/Alaska" , 0x03D84D }, + { "US/Aleutian" , 0x03DBB6 }, + { "US/Arizona" , 0x03DF1C }, + { "US/Central" , 0x03DFAA }, + { "US/East-Indiana" , 0x03E9B4 }, + { "US/Eastern" , 0x03E4B5 }, + { "US/Hawaii" , 0x03EC1E }, + { "US/Indiana-Starke" , 0x03EC8F }, + { "US/Michigan" , 0x03F000 }, + { "US/Mountain" , 0x03F337 }, + { "US/Pacific" , 0x03F6B0 }, + { "US/Pacific-New" , 0x03FAB5 }, + { "US/Samoa" , 0x03FEBA }, + { "UTC" , 0x03FF31 }, + { "W-SU" , 0x040228 }, + { "WET" , 0x03FF75 }, + { "Zulu" , 0x04046B }, }; /* This is a generated file, do not modify */ -const unsigned char timelib_timezone_db_data_builtin[263191] = { +const unsigned char timelib_timezone_db_data_builtin[263343] = { /* Africa/Abidjan */ @@ -8304,13 +8305,16 @@ const unsigned char timelib_timezone_db_data_builtin[263191] = { /* Asia/Ho_Chi_Minh */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x56, 0x4E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0C, 0x88, 0x6F, 0x42, 0x80, -0x91, 0x5F, 0xEE, 0xD0, 0x93, 0x85, 0xB1, 0x90, 0xB7, 0x41, 0xBC, 0x00, 0x01, 0x02, 0x03, 0x02, -0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0xEC, 0x00, 0x04, 0x00, 0x00, 0x62, 0x70, -0x00, 0x08, 0x00, 0x00, 0x70, 0x80, 0x00, 0x08, 0x4C, 0x4D, 0x54, 0x00, 0x53, 0x4D, 0x54, 0x00, -0x49, 0x43, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99, 0xBB, 0x78, -0x01, 0xB5, 0x6B, 0x2A, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x15, 0x88, 0x8C, 0x43, 0x80, +0x91, 0xA3, 0x2B, 0x0A, 0xCD, 0x35, 0xE6, 0x80, 0xD1, 0x59, 0xCE, 0x70, 0xD2, 0x3B, 0x3E, 0xF0, +0xD5, 0x32, 0xBB, 0x10, 0xE4, 0xB6, 0xE4, 0x80, 0xED, 0x2F, 0x98, 0x00, 0x0A, 0x3D, 0xC7, 0x00, +0x01, 0x02, 0x03, 0x04, 0x02, 0x03, 0x02, 0x03, 0x02, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, +0x00, 0x63, 0xF6, 0x00, 0x04, 0x00, 0x00, 0x62, 0x70, 0x00, 0x09, 0x00, 0x00, 0x70, 0x80, 0x00, +0x0D, 0x00, 0x00, 0x7E, 0x90, 0x00, 0x11, 0x4C, 0x4D, 0x54, 0x00, 0x50, 0x4C, 0x4D, 0x54, 0x00, +0x49, 0x43, 0x54, 0x00, 0x49, 0x44, 0x54, 0x00, 0x4A, 0x53, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99, 0xBB, 0x78, 0x01, 0xB5, 0x6B, 0x2A, 0x00, 0x00, +0x00, 0x00, /* Asia/Hong_Kong */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x48, 0x4B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -9046,13 +9050,11 @@ const unsigned char timelib_timezone_db_data_builtin[263191] = { /* Asia/Phnom_Penh */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x4B, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0C, 0x88, 0x6F, 0x44, 0x24, -0x91, 0x5F, 0xEE, 0xD0, 0x93, 0x85, 0xB1, 0x90, 0xB7, 0x41, 0xBC, 0x00, 0x01, 0x02, 0x03, 0x02, -0x00, 0x00, 0x62, 0x5C, 0x00, 0x00, 0x00, 0x00, 0x63, 0xEC, 0x00, 0x04, 0x00, 0x00, 0x62, 0x70, -0x00, 0x08, 0x00, 0x00, 0x70, 0x80, 0x00, 0x08, 0x4C, 0x4D, 0x54, 0x00, 0x53, 0x4D, 0x54, 0x00, -0x49, 0x43, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9A, 0xF3, 0xF8, -0x01, 0xB2, 0xBF, 0x92, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0xA2, 0x6A, 0x67, 0xC4, +0x01, 0x00, 0x00, 0x5E, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x62, 0x70, 0x00, 0x04, 0x42, 0x4D, 0x54, +0x00, 0x49, 0x43, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9A, 0xF3, 0xF8, 0x01, 0xB2, 0xBF, +0x92, 0x00, 0x00, 0x00, 0x00, /* Asia/Pontianak */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x49, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -9142,13 +9144,16 @@ const unsigned char timelib_timezone_db_data_builtin[263191] = { /* Asia/Saigon */ 0x50, 0x48, 0x50, 0x31, 0x00, 0x3F, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0C, 0x88, 0x6F, 0x42, 0x80, -0x91, 0x5F, 0xEE, 0xD0, 0x93, 0x85, 0xB1, 0x90, 0xB7, 0x41, 0xBC, 0x00, 0x01, 0x02, 0x03, 0x02, -0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0xEC, 0x00, 0x04, 0x00, 0x00, 0x62, 0x70, -0x00, 0x08, 0x00, 0x00, 0x70, 0x80, 0x00, 0x08, 0x4C, 0x4D, 0x54, 0x00, 0x53, 0x4D, 0x54, 0x00, -0x49, 0x43, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x89, 0x54, 0x40, -0x01, 0x12, 0xA8, 0x80, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x15, 0x88, 0x8C, 0x43, 0x80, +0x91, 0xA3, 0x2B, 0x0A, 0xCD, 0x35, 0xE6, 0x80, 0xD1, 0x59, 0xCE, 0x70, 0xD2, 0x3B, 0x3E, 0xF0, +0xD5, 0x32, 0xBB, 0x10, 0xE4, 0xB6, 0xE4, 0x80, 0xED, 0x2F, 0x98, 0x00, 0x0A, 0x3D, 0xC7, 0x00, +0x01, 0x02, 0x03, 0x04, 0x02, 0x03, 0x02, 0x03, 0x02, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, +0x00, 0x63, 0xF6, 0x00, 0x04, 0x00, 0x00, 0x62, 0x70, 0x00, 0x09, 0x00, 0x00, 0x70, 0x80, 0x00, +0x0D, 0x00, 0x00, 0x7E, 0x90, 0x00, 0x11, 0x4C, 0x4D, 0x54, 0x00, 0x50, 0x4C, 0x4D, 0x54, 0x00, +0x49, 0x43, 0x54, 0x00, 0x49, 0x44, 0x54, 0x00, 0x4A, 0x53, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x89, 0x54, 0x40, 0x01, 0x12, 0xA8, 0x80, 0x00, 0x00, +0x00, 0x00, /* Asia/Sakhalin */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x52, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -9584,13 +9589,11 @@ const unsigned char timelib_timezone_db_data_builtin[263191] = { /* Asia/Vientiane */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x4C, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0C, 0x88, 0x6F, 0x46, 0x50, -0x91, 0x5F, 0xEE, 0xD0, 0x93, 0x85, 0xB1, 0x90, 0xB7, 0x41, 0xBC, 0x00, 0x01, 0x02, 0x03, 0x02, -0x00, 0x00, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0x63, 0xEC, 0x00, 0x04, 0x00, 0x00, 0x62, 0x70, -0x00, 0x08, 0x00, 0x00, 0x70, 0x80, 0x00, 0x08, 0x4C, 0x4D, 0x54, 0x00, 0x53, 0x4D, 0x54, 0x00, -0x49, 0x43, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA4, 0xBE, 0x7A, -0x01, 0xAF, 0x36, 0xA0, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0xA2, 0x6A, 0x67, 0xC4, +0x01, 0x00, 0x00, 0x5E, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x62, 0x70, 0x00, 0x04, 0x42, 0x4D, 0x54, +0x00, 0x49, 0x43, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA4, 0xBE, 0x7A, 0x01, 0xAF, 0x36, +0xA0, 0x00, 0x00, 0x00, 0x00, /* Asia/Vladivostok */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x52, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -14391,7 +14394,7 @@ const unsigned char timelib_timezone_db_data_builtin[263191] = { /* Europe/Minsk */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x42, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x22, 0xAA, 0x19, 0xAA, 0x38, +0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x22, 0xAA, 0x19, 0xAA, 0x38, 0xB5, 0xA4, 0x19, 0x60, 0xCA, 0x5E, 0x70, 0xD0, 0xCC, 0xE7, 0x4B, 0x10, 0xCD, 0xA9, 0x17, 0x90, 0xCE, 0xA2, 0x43, 0x10, 0xCF, 0x92, 0x34, 0x10, 0xD0, 0x0A, 0x02, 0x60, 0x15, 0x27, 0xA7, 0xD0, 0x16, 0x18, 0xDC, 0x40, 0x17, 0x08, 0xDB, 0x50, 0x17, 0xFA, 0x0F, 0xC0, 0x18, 0xEA, 0x0E, 0xD0, @@ -14408,20 +14411,21 @@ const unsigned char timelib_timezone_db_data_builtin[263191] = { 0x40, 0x66, 0x15, 0x80, 0x41, 0x84, 0x2B, 0x00, 0x42, 0x45, 0xF7, 0x80, 0x43, 0x64, 0x0D, 0x00, 0x44, 0x25, 0xD9, 0x80, 0x45, 0x43, 0xEF, 0x00, 0x46, 0x05, 0xBB, 0x80, 0x47, 0x23, 0xD1, 0x00, 0x47, 0xEE, 0xD8, 0x00, 0x49, 0x03, 0xB3, 0x00, 0x49, 0xCE, 0xBA, 0x00, 0x4A, 0xE3, 0x95, 0x00, -0x4B, 0xAE, 0x9C, 0x00, 0x4C, 0xCC, 0xB1, 0x80, 0x4D, 0x8E, 0x7E, 0x00, 0x01, 0x02, 0x05, 0x03, -0x04, 0x03, 0x04, 0x02, 0x06, 0x02, 0x06, 0x02, 0x06, 0x02, 0x06, 0x07, 0x08, 0x07, 0x08, 0x07, -0x08, 0x07, 0x08, 0x07, 0x08, 0x07, 0x02, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, +0x4B, 0xAE, 0x9C, 0x00, 0x4C, 0xCC, 0xB1, 0x80, 0x4D, 0x8E, 0x7E, 0x00, 0x54, 0x4C, 0x1D, 0x60, +0x01, 0x02, 0x05, 0x03, 0x04, 0x03, 0x04, 0x02, 0x06, 0x02, 0x06, 0x02, 0x06, 0x02, 0x06, 0x07, +0x08, 0x07, 0x08, 0x07, 0x08, 0x07, 0x08, 0x07, 0x08, 0x07, 0x02, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, -0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x0B, -0x00, 0x00, 0x19, 0xC8, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x20, 0x00, 0x04, 0x00, 0x00, 0x2A, 0x30, -0x00, 0x08, 0x00, 0x00, 0x0E, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x1C, 0x20, 0x01, 0x10, 0x00, 0x00, -0x1C, 0x20, 0x01, 0x10, 0x00, 0x00, 0x38, 0x40, 0x01, 0x15, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x08, -0x00, 0x00, 0x38, 0x40, 0x01, 0x15, 0x00, 0x00, 0x2A, 0x30, 0x01, 0x19, 0x00, 0x00, 0x1C, 0x20, -0x00, 0x04, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x1E, 0x4D, 0x4D, 0x54, 0x00, 0x45, 0x45, 0x54, 0x00, -0x4D, 0x53, 0x4B, 0x00, 0x43, 0x45, 0x54, 0x00, 0x43, 0x45, 0x53, 0x54, 0x00, 0x4D, 0x53, 0x44, -0x00, 0x45, 0x45, 0x53, 0x54, 0x00, 0x46, 0x45, 0x54, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, -0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xDB, 0x92, 0xF0, 0x01, 0x3C, 0xB8, 0xBA, 0x00, 0x00, 0x00, 0x00, +0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, +0x0A, 0x09, 0x0A, 0x0B, 0x07, 0x00, 0x00, 0x19, 0xC8, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x20, 0x00, +0x04, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x08, 0x00, 0x00, 0x0E, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x1C, +0x20, 0x01, 0x10, 0x00, 0x00, 0x1C, 0x20, 0x01, 0x10, 0x00, 0x00, 0x38, 0x40, 0x01, 0x15, 0x00, +0x00, 0x2A, 0x30, 0x00, 0x08, 0x00, 0x00, 0x38, 0x40, 0x01, 0x15, 0x00, 0x00, 0x2A, 0x30, 0x01, +0x19, 0x00, 0x00, 0x1C, 0x20, 0x00, 0x04, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x1E, 0x4D, 0x4D, 0x54, +0x00, 0x45, 0x45, 0x54, 0x00, 0x4D, 0x53, 0x4B, 0x00, 0x43, 0x45, 0x54, 0x00, 0x43, 0x45, 0x53, +0x54, 0x00, 0x4D, 0x53, 0x44, 0x00, 0x45, 0x45, 0x53, 0x54, 0x00, 0x46, 0x45, 0x54, 0x00, 0x00, +0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDB, 0x92, 0xF0, 0x01, 0x3C, 0xB8, 0xBA, 0x00, +0x00, 0x00, 0x00, /* Europe/Monaco */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x4D, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -16966,6 +16970,16 @@ const unsigned char timelib_timezone_db_data_builtin[263191] = { 0x00, 0x00, 0x00, 0x51, 0x13, 0x35, 0x02, 0x1D, 0x54, 0xBA, 0x00, 0x00, 0x00, 0x0E, 0x6D, 0x6F, 0x73, 0x74, 0x20, 0x6C, 0x6F, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x73, +/* Pacific/Bougainville */ +0x50, 0x48, 0x50, 0x31, 0x01, 0x50, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0C, 0xCC, 0x43, 0x36, 0x60, +0xD2, 0x2B, 0x6C, 0xF0, 0x54, 0x9E, 0xD7, 0x80, 0x01, 0x00, 0x02, 0x00, 0x00, 0x8C, 0xA0, 0x00, +0x00, 0x00, 0x00, 0x7E, 0x90, 0x00, 0x04, 0x00, 0x00, 0x9A, 0xB0, 0x00, 0x08, 0x50, 0x47, 0x54, +0x00, 0x4A, 0x53, 0x54, 0x00, 0x42, 0x53, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x7F, 0xD7, 0xDD, 0x02, 0x00, 0x08, 0xBA, 0x00, 0x00, 0x00, 0x0C, 0x42, 0x6F, 0x75, 0x67, 0x61, +0x69, 0x6E, 0x76, 0x69, 0x6C, 0x6C, 0x65, + /* Pacific/Chatham */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x4E, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, @@ -17118,19 +17132,19 @@ const unsigned char timelib_timezone_db_data_builtin[263191] = { 0x36, 0x3B, 0x17, 0xE0, 0x36, 0xD7, 0xFA, 0x60, 0x38, 0x24, 0x34, 0x60, 0x38, 0xB7, 0xDC, 0x60, 0x4B, 0x11, 0x2C, 0xE0, 0x4B, 0xAE, 0x0F, 0x60, 0x4C, 0xC2, 0xEA, 0x60, 0x4D, 0x72, 0x41, 0xE0, 0x4E, 0xA2, 0xCC, 0x60, 0x4F, 0x1A, 0xC4, 0xE0, 0x50, 0x82, 0xAE, 0x60, 0x50, 0xFA, 0xA6, 0xE0, -0x52, 0x6B, 0xCA, 0xE0, 0x52, 0xDA, 0x7A, 0xD0, 0x54, 0x4B, 0xAC, 0xE0, 0x54, 0xBA, 0x5C, 0xD0, -0x56, 0x2B, 0x8E, 0xE0, 0x56, 0xA3, 0x79, 0x50, 0x58, 0x0B, 0x70, 0xE0, 0x58, 0x83, 0x5B, 0x50, -0x59, 0xEB, 0x52, 0xE0, 0x5A, 0x63, 0x3D, 0x50, 0x5B, 0xCB, 0x34, 0xE0, 0x5C, 0x43, 0x1F, 0x50, -0x5D, 0xB4, 0x51, 0x60, 0x5E, 0x23, 0x01, 0x50, 0x5F, 0x94, 0x33, 0x60, 0x60, 0x0C, 0x1D, 0xD0, -0x61, 0x74, 0x15, 0x60, 0x61, 0xEB, 0xFF, 0xD0, 0x63, 0x53, 0xF7, 0x60, 0x63, 0xCB, 0xE1, 0xD0, -0x65, 0x33, 0xD9, 0x60, 0x65, 0xAB, 0xC3, 0xD0, 0x67, 0x1C, 0xF5, 0xE0, 0x67, 0x8B, 0xA5, 0xD0, -0x68, 0xFC, 0xD7, 0xE0, 0x69, 0x6B, 0x87, 0xD0, 0x6A, 0xDC, 0xB9, 0xE0, 0x6B, 0x54, 0xA4, 0x50, -0x6C, 0xBC, 0x9B, 0xE0, 0x6D, 0x34, 0x86, 0x50, 0x6E, 0x9C, 0x7D, 0xE0, 0x6F, 0x14, 0x68, 0x50, -0x70, 0x7C, 0x5F, 0xE0, 0x70, 0xF4, 0x4A, 0x50, 0x72, 0x65, 0x7C, 0x60, 0x72, 0xD4, 0x2C, 0x50, -0x74, 0x45, 0x5E, 0x60, 0x74, 0xB4, 0x0E, 0x50, 0x76, 0x25, 0x40, 0x60, 0x76, 0x9D, 0x2A, 0xD0, -0x78, 0x05, 0x22, 0x60, 0x78, 0x7D, 0x0C, 0xD0, 0x79, 0xE5, 0x04, 0x60, 0x7A, 0x5C, 0xEE, 0xD0, -0x7B, 0xC4, 0xE6, 0x60, 0x7C, 0x3C, 0xD0, 0xD0, 0x7D, 0xAE, 0x02, 0xE0, 0x7E, 0x1C, 0xB2, 0xD0, -0x7F, 0x8D, 0xE4, 0xE0, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, +0x52, 0x6B, 0xCA, 0xE0, 0x52, 0xDA, 0x7A, 0xD0, 0x54, 0x54, 0xE7, 0x60, 0x54, 0xBA, 0x6A, 0xE0, +0x56, 0x34, 0xC9, 0x60, 0x56, 0xA3, 0x87, 0x60, 0x58, 0x1D, 0xE5, 0xE0, 0x58, 0x83, 0x69, 0x60, +0x59, 0xFD, 0xC7, 0xE0, 0x5A, 0x63, 0x4B, 0x60, 0x5B, 0xDD, 0xA9, 0xE0, 0x5C, 0x43, 0x2D, 0x60, +0x5D, 0xBD, 0x8B, 0xE0, 0x5E, 0x23, 0x0F, 0x60, 0x5F, 0x9D, 0x6D, 0xE0, 0x60, 0x0C, 0x2B, 0xE0, +0x61, 0x86, 0x8A, 0x60, 0x61, 0xEC, 0x0D, 0xE0, 0x63, 0x66, 0x6C, 0x60, 0x63, 0xCB, 0xEF, 0xE0, +0x65, 0x46, 0x4E, 0x60, 0x65, 0xAB, 0xD1, 0xE0, 0x67, 0x26, 0x30, 0x60, 0x67, 0x8B, 0xB3, 0xE0, +0x69, 0x06, 0x12, 0x60, 0x69, 0x6B, 0x95, 0xE0, 0x6A, 0xE5, 0xF4, 0x60, 0x6B, 0x54, 0xB2, 0x60, +0x6C, 0xCF, 0x10, 0xE0, 0x6D, 0x34, 0x94, 0x60, 0x6E, 0xAE, 0xF2, 0xE0, 0x6F, 0x14, 0x76, 0x60, +0x70, 0x8E, 0xD4, 0xE0, 0x70, 0xF4, 0x58, 0x60, 0x72, 0x6E, 0xB6, 0xE0, 0x72, 0xD4, 0x3A, 0x60, +0x74, 0x4E, 0x98, 0xE0, 0x74, 0xB4, 0x1C, 0x60, 0x76, 0x37, 0xB5, 0x60, 0x76, 0x9D, 0x38, 0xE0, +0x78, 0x17, 0x97, 0x60, 0x78, 0x7D, 0x1A, 0xE0, 0x79, 0xF7, 0x79, 0x60, 0x7A, 0x5C, 0xFC, 0xE0, +0x7B, 0xD7, 0x5B, 0x60, 0x7C, 0x3C, 0xDE, 0xE0, 0x7D, 0xB7, 0x3D, 0x60, 0x7E, 0x1C, 0xC0, 0xE0, +0x7F, 0x97, 0x1F, 0x60, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, @@ -17338,7 +17352,8 @@ const unsigned char timelib_timezone_db_data_builtin[263191] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x8C, 0xA0, 0x00, 0x00, 0x50, 0x47, 0x54, 0x00, 0x00, 0x00, 0x00, 0x7A, 0xD5, 0x50, 0x01, 0xF3, 0x37, 0x7A, -0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x0E, 0x6D, 0x6F, 0x73, 0x74, 0x20, 0x6C, 0x6F, 0x63, 0x61, 0x74, 0x69, 0x6F, +0x6E, 0x73, /* Pacific/Rarotonga */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x43, 0x4B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -18532,4 +18547,4 @@ const unsigned char timelib_timezone_db_data_builtin[263191] = { 0x00, 0x00, 0x55, 0x54, 0x43, 0x00, 0x00, 0x00, 0x00, 0x89, 0x54, 0x40, 0x01, 0x12, 0xA8, 0x80, 0x00, 0x00, 0x00, 0x00, }; -const timelib_tzdb timezonedb_builtin = { "2014.8", 582, timezonedb_idx_builtin, timelib_timezone_db_data_builtin }; +const timelib_tzdb timezonedb_builtin = { "2014.9", 583, timezonedb_idx_builtin, timelib_timezone_db_data_builtin }; From 05711d996185b969fcd533fbce64494ff31eaca1 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sun, 26 Oct 2014 20:43:49 +0100 Subject: [PATCH 070/398] Stabilize execution, always run destructors and extended file breakpoints --- phpdbg.c | 104 ++++++++++++++++++++++-------- phpdbg.h | 92 +++++++++++++-------------- phpdbg_bp.c | 164 +++++++++++++++++++++++++++++++++++++----------- phpdbg_bp.h | 26 ++++---- phpdbg_cmd.c | 2 +- phpdbg_list.c | 2 + phpdbg_out.c | 2 + phpdbg_prompt.c | 21 +++---- 8 files changed, 276 insertions(+), 137 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index 493d8ec20c9..3e31f76898a 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -46,7 +46,6 @@ ZEND_DECLARE_MODULE_GLOBALS(phpdbg); int phpdbg_startup_run = 0; -char *phpdbg_exec = NULL; static PHP_INI_MH(OnUpdateEol) { @@ -186,7 +185,8 @@ static void php_phpdbg_destroy_registered(void *data) /* {{{ */ static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */ { - zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], 8, NULL, php_phpdbg_destroy_bp_file, 0); + zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], 8, NULL, php_phpdbg_destroy_bp_file, 0); + zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], 8, NULL, php_phpdbg_destroy_bp_file, 0); zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], 8, NULL, php_phpdbg_destroy_bp_symbol, 0); zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], 8, NULL, php_phpdbg_destroy_bp_methods, 0); zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], 8, NULL, php_phpdbg_destroy_bp_methods, 0); @@ -216,8 +216,8 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */ zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_COND]); zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP]); zend_hash_destroy(&PHPDBG_G(seek)); - zend_hash_destroy(&PHPDBG_G(registered)); zend_hash_destroy(&PHPDBG_G(file_sources)); + zend_hash_destroy(&PHPDBG_G(registered)); zend_hash_destroy(&PHPDBG_G(watchpoints)); zend_llist_destroy(&PHPDBG_G(watchlist_mem)); @@ -363,6 +363,7 @@ static PHP_FUNCTION(phpdbg_break_function) static PHP_FUNCTION(phpdbg_clear) { zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING]); zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM]); zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE]); zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE]); @@ -543,11 +544,27 @@ static void php_sapi_phpdbg_log_message(char *message TSRMLS_DC) /* {{{ */ static int php_sapi_phpdbg_deactivate(TSRMLS_D) /* {{{ */ { + if ((PHPDBG_G(flags) & (PHPDBG_IS_CLEANING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_CLEANING) { + zend_phpdbg_globals *pg = PHPDBG_G(backup) = calloc(1, sizeof(zend_phpdbg_globals)); + + php_phpdbg_globals_ctor(pg); + + pg->exec = strndup(PHPDBG_G(exec), PHPDBG_G(exec_len)); + pg->exec_len = PHPDBG_G(exec_len); + 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)); + pg->eol = PHPDBG_G(eol); + pg->flags = PHPDBG_G(flags) & PHPDBG_PRESERVE_FLAGS_MASK; + } + fflush(stdout); if(SG(request_info).argv0) { free(SG(request_info).argv0); SG(request_info).argv0 = NULL; } + return SUCCESS; } /* }}} */ @@ -1009,6 +1026,7 @@ int main(int argc, char **argv) /* {{{ */ zend_ulong zend_extensions_len = 0L; zend_bool ini_ignore; char *ini_override; + char *exec = NULL; char *init_file; size_t init_file_len; zend_bool init_file_default; @@ -1020,6 +1038,7 @@ int main(int argc, char **argv) /* {{{ */ long cleaning = 0; zend_bool remote = 0; int step = 0; + zend_phpdbg_globals *settings = NULL; #ifdef _WIN32 char *bp_tmp_file = NULL; @@ -1102,6 +1121,9 @@ phpdbg_main: opt = 0; step = 0; sapi_name = NULL; + if (settings) { + exec = settings->exec; + } while ((opt = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) { switch (opt) { @@ -1243,12 +1265,12 @@ phpdbg_main: } /* set exec if present on command line */ - if (!phpdbg_exec && (argc > php_optind) && (strcmp(argv[php_optind-1],"--") != SUCCESS)) { + if (!exec && (argc > php_optind) && (strcmp(argv[php_optind-1], "--") != SUCCESS)) { if (strlen(argv[php_optind])) { - if (phpdbg_exec) { - free(phpdbg_exec); + if (exec) { + free(exec); } - phpdbg_exec = strdup(argv[php_optind]); + exec = strdup(argv[php_optind]); } php_optind++; } @@ -1309,20 +1331,31 @@ phpdbg_main: #endif zend_mm_heap *mm_heap; - /* setup remote server if necessary */ - if (!cleaning && listen > 0) { - server = phpdbg_open_socket(address, listen TSRMLS_CC); - if (-1 > server || phpdbg_remote_init(address, listen, server, &socket, &stream TSRMLS_CC) == FAILURE) { - exit(0); + /* set flags from command line */ + PHPDBG_G(flags) = flags; + + if (settings) { +#ifdef ZTS + *((zend_phpdbg_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(phpdbg_globals_id)]) = *settings; +#else + phpdbg_globals = *settings; +#endif } + /* setup remote server if necessary */ + if (!cleaning && listen > 0) { + server = phpdbg_open_socket(address, listen TSRMLS_CC); + if (-1 > server || phpdbg_remote_init(address, listen, server, &socket, &stream TSRMLS_CC) == FAILURE) { + exit(0); + } + #ifndef _WIN32 - sigaction(SIGIO, &sigio_struct, NULL); + sigaction(SIGIO, &sigio_struct, NULL); #endif - /* set remote flag to stop service shutting down upon quit */ - remote = 1; - } + /* set remote flag to stop service shutting down upon quit */ + remote = 1; + } mm_heap = phpdbg_mm_get_heap(); @@ -1371,7 +1404,7 @@ phpdbg_main: for (i = SG(request_info).argc; --i;) { SG(request_info).argv[i] = estrdup(argv[php_optind - 1 + i]); } - SG(request_info).argv[i] = phpdbg_exec ? estrdup(phpdbg_exec) : estrdup(""); + SG(request_info).argv[i] = exec ? estrdup(exec) : estrdup(""); php_hash_environment(TSRMLS_C); } @@ -1392,9 +1425,6 @@ phpdbg_main: PG(modules_activated) = 0; - /* set flags from command line */ - PHPDBG_G(flags) = flags; - /* setup io here */ if (remote) { PHPDBG_G(flags) |= PHPDBG_IS_REMOTE; @@ -1434,12 +1464,12 @@ phpdbg_main: php_stream_stdio_ops.write = phpdbg_stdiop_write; #endif - if (phpdbg_exec) { /* set execution context */ - PHPDBG_G(exec) = phpdbg_resolve_path(phpdbg_exec TSRMLS_CC); + if (exec) { /* set execution context */ + PHPDBG_G(exec) = phpdbg_resolve_path(exec TSRMLS_CC); PHPDBG_G(exec_len) = strlen(PHPDBG_G(exec)); - free(phpdbg_exec); - phpdbg_exec = NULL; + free(exec); + exec = NULL; } if (oplog_file) { /* open oplog */ @@ -1537,7 +1567,12 @@ phpdbg_interact: } } zend_end_try(); } while (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)); - + + + if (PHPDBG_G(exec) && (PHPDBG_G(flags) & PHPDBG_IS_CLEANING)) { + exec = strdup(PHPDBG_G(exec)); /* preserve exec, don't reparse that from cmd */ + } + /* this must be forced */ CG(unclean_shutdown) = 0; @@ -1590,7 +1625,24 @@ phpdbg_out: /* this is just helpful */ PG(report_memleaks) = 0; - php_request_shutdown((void*)0); + if ((PHPDBG_G(flags) & (PHPDBG_IS_CLEANING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_CLEANING) { + php_free_shutdown_functions(TSRMLS_C); + zend_objects_store_mark_destructed(&EG(objects_store) TSRMLS_CC); + } + + /* sapi_module.deactivate is where to backup things, last chance before mm_shutdown... */ + + zend_try { + php_request_shutdown(NULL); + } zend_end_try(); + + if ((PHPDBG_G(flags) & (PHPDBG_IS_QUITTING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_RUNNING) { + phpdbg_notice("stop", "type=\"normal\"", "Script ended normally"); + } + + if ((PHPDBG_G(flags) & (PHPDBG_IS_CLEANING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_CLEANING) { + settings = PHPDBG_G(backup); + } php_output_deactivate(TSRMLS_C); diff --git a/phpdbg.h b/phpdbg.h index 688ba7cdfcb..57ea7ee570f 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -116,6 +116,7 @@ #include "phpdbg_utils.h" #include "phpdbg_btree.h" #include "phpdbg_watch.h" +#include "phpdbg_bp.h" #ifdef PHP_WIN32 # include "phpdbg_sigio_win32.h" #endif @@ -131,71 +132,62 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC); BEGIN: DO NOT CHANGE DO NOT CHANGE DO NOT CHANGE */ -/* {{{ tables */ -#define PHPDBG_BREAK_FILE 0 -#define PHPDBG_BREAK_SYM 1 -#define PHPDBG_BREAK_OPLINE 2 -#define PHPDBG_BREAK_METHOD 3 -#define PHPDBG_BREAK_COND 4 -#define PHPDBG_BREAK_OPCODE 5 -#define PHPDBG_BREAK_FUNCTION_OPLINE 6 -#define PHPDBG_BREAK_METHOD_OPLINE 7 -#define PHPDBG_BREAK_FILE_OPLINE 8 -#define PHPDBG_BREAK_MAP 9 -#define PHPDBG_BREAK_TABLES 10 /* }}} */ - /* {{{ flags */ -#define PHPDBG_HAS_FILE_BP (1<<1) -#define PHPDBG_HAS_SYM_BP (1<<2) -#define PHPDBG_HAS_OPLINE_BP (1<<3) -#define PHPDBG_HAS_METHOD_BP (1<<4) -#define PHPDBG_HAS_COND_BP (1<<5) -#define PHPDBG_HAS_OPCODE_BP (1<<6) -#define PHPDBG_HAS_FUNCTION_OPLINE_BP (1<<7) -#define PHPDBG_HAS_METHOD_OPLINE_BP (1<<8) -#define PHPDBG_HAS_FILE_OPLINE_BP (1<<9) /* }}} */ +#define PHPDBG_HAS_FILE_BP (1ULL<<1) +#define PHPDBG_HAS_PENDING_FILE_BP (1ULL<<2) +#define PHPDBG_HAS_SYM_BP (1ULL<<3) +#define PHPDBG_HAS_OPLINE_BP (1ULL<<4) +#define PHPDBG_HAS_METHOD_BP (1ULL<<5) +#define PHPDBG_HAS_COND_BP (1ULL<<6) +#define PHPDBG_HAS_OPCODE_BP (1ULL<<7) +#define PHPDBG_HAS_FUNCTION_OPLINE_BP (1ULL<<8) +#define PHPDBG_HAS_METHOD_OPLINE_BP (1ULL<<9) +#define PHPDBG_HAS_FILE_OPLINE_BP (1ULL<<10) /* }}} */ /* END: DO NOT CHANGE DO NOT CHANGE DO NOT CHANGE */ -#define PHPDBG_IN_COND_BP (1<<10) -#define PHPDBG_IN_EVAL (1<<11) +#define PHPDBG_IN_COND_BP (1ULL<<11) +#define PHPDBG_IN_EVAL (1ULL<<12) -#define PHPDBG_IS_STEPPING (1<<12) -#define PHPDBG_STEP_OPCODE (1<<13) -#define PHPDBG_IS_QUIET (1<<14) -#define PHPDBG_IS_QUITTING (1<<15) -#define PHPDBG_IS_COLOURED (1<<16) -#define PHPDBG_IS_CLEANING (1<<17) +#define PHPDBG_IS_STEPPING (1ULL<<13) +#define PHPDBG_STEP_OPCODE (1ULL<<14) +#define PHPDBG_IS_QUIET (1ULL<<15) +#define PHPDBG_IS_QUITTING (1ULL<<16) +#define PHPDBG_IS_COLOURED (1ULL<<17) +#define PHPDBG_IS_CLEANING (1ULL<<18) +#define PHPDBG_IS_RUNNING (1ULL<<19) -#define PHPDBG_IN_UNTIL (1<<18) -#define PHPDBG_IN_FINISH (1<<19) -#define PHPDBG_IN_LEAVE (1<<20) +#define PHPDBG_IN_UNTIL (1ULL<<20) +#define PHPDBG_IN_FINISH (1ULL<<21) +#define PHPDBG_IN_LEAVE (1ULL<<22) -#define PHPDBG_IS_REGISTERED (1<<21) -#define PHPDBG_IS_STEPONEVAL (1<<22) -#define PHPDBG_IS_INITIALIZING (1<<23) -#define PHPDBG_IS_SIGNALED (1<<24) -#define PHPDBG_IS_INTERACTIVE (1<<25) -#define PHPDBG_IS_BP_ENABLED (1<<26) -#define PHPDBG_IS_REMOTE (1<<27) -#define PHPDBG_IS_DISCONNECTED (1<<28) -#define PHPDBG_WRITE_XML (1<<29) +#define PHPDBG_IS_REGISTERED (1ULL<<23) +#define PHPDBG_IS_STEPONEVAL (1ULL<<24) +#define PHPDBG_IS_INITIALIZING (1ULL<<25) +#define PHPDBG_IS_SIGNALED (1ULL<<26) +#define PHPDBG_IS_INTERACTIVE (1ULL<<27) +#define PHPDBG_IS_BP_ENABLED (1ULL<<28) +#define PHPDBG_IS_REMOTE (1ULL<<29) +#define PHPDBG_IS_DISCONNECTED (1ULL<<30) +#define PHPDBG_WRITE_XML (1ULL<<31) -#define PHPDBG_SHOW_REFCOUNTS (1<<30) +#define PHPDBG_SHOW_REFCOUNTS (1ULL<<32) -#define PHPDBG_IN_SIGNAL_HANDLER (1<<30) +#define PHPDBG_IN_SIGNAL_HANDLER (1ULL<<33) #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) + #ifndef _WIN32 -# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_COLOURED|PHPDBG_IS_BP_ENABLED) +# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET | PHPDBG_IS_COLOURED | PHPDBG_IS_BP_ENABLED) #else -# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_BP_ENABLED) +# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET | PHPDBG_IS_BP_ENABLED) #endif /* }}} */ /* {{{ output descriptors */ @@ -256,6 +248,7 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg) FILE *ptr; int fd; } io[PHPDBG_IO_FDS]; /* io */ + int eol; /* type of line ending to use */ size_t (*php_stdiop_write)(php_stream *, const char *, size_t TSRMLS_DC); int in_script_xml; /* in output mode */ struct { @@ -281,17 +274,18 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg) JMP_BUF *sigsegv_bailout; /* bailout address for accesibility probing */ - zend_ulong flags; /* phpdbg flags */ + uint64_t flags; /* phpdbg flags */ char *socket_path; /* phpdbg.path ini setting */ char *sapi_name_ptr; /* store sapi name to free it if necessary to not leak memory */ int socket_fd; /* file descriptor to socket (wait command) (-1 if unused) */ int socket_server_fd; /* file descriptor to master socket (wait command) (-1 if unused) */ #ifdef PHP_WIN32 - HANDLE sigio_watcher_thread; /* sigio watcher thread handle */ + HANDLE sigio_watcher_thread; /* sigio watcher thread handle */ struct win32_sigio_watcher_data swd; #endif - int8_t eol; + + struct _zend_phpdbg_globals *backup; /* backup of data to store */ ZEND_END_MODULE_GLOBALS(phpdbg) /* }}} */ #endif diff --git a/phpdbg_bp.c b/phpdbg_bp.c index 81674a0daf1..9333b353ce6 100644 --- a/phpdbg_bp.c +++ b/phpdbg_bp.c @@ -220,51 +220,119 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRML { php_stream_statbuf ssb; char realpath[MAXPATHLEN]; + const char *original_path = path; + zend_bool pending; - if (php_stream_stat_path(path, &ssb) != FAILURE) { - if (ssb.sb.st_mode & (S_IFREG|S_IFLNK)) { - HashTable *broken; - phpdbg_breakfile_t new_break; - size_t path_len = 0L; + HashTable *broken, *file_breaks = &PHPDBG_G(bp)[PHPDBG_BREAK_FILE]; + phpdbg_breakfile_t new_break; + size_t path_len = 0L; - if (VCWD_REALPATH(path, realpath)) { - path = realpath; + if (VCWD_REALPATH(path, realpath)) { + path = realpath; + } + path_len = strlen(path); + + if (!zend_hash_exists(&PHPDBG_G(file_sources), path, path_len)) { + if (php_stream_stat_path(path, &ssb) == FAILURE) { + if (original_path[0] == '/') { + phpdbg_error("breakpoint", "type=\"nofile\" add=\"fail\" file=\"%s\"", "Cannot stat %s, it does not exist", original_path); + return; } + + file_breaks = &PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING]; + path = original_path; path_len = strlen(path); - - if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], - path, path_len, (void**)&broken) == FAILURE) { - HashTable breaks; - - zend_hash_init(&breaks, 8, NULL, phpdbg_file_breaks_dtor, 0); - - zend_hash_update(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], - path, path_len, &breaks, sizeof(HashTable), - (void**)&broken); - } - - if (!zend_hash_index_exists(broken, line_num)) { - PHPDBG_G(flags) |= PHPDBG_HAS_FILE_BP; - - PHPDBG_BREAK_INIT(new_break, PHPDBG_BREAK_FILE); - new_break.filename = estrndup(path, path_len); - new_break.line = line_num; - - zend_hash_index_update( broken, line_num, (void**)&new_break, sizeof(phpdbg_breakfile_t), NULL); - - phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" file=\"%s\" line=\"%ld\"", "Breakpoint #%d added at %s:%ld", - new_break.id, new_break.filename, new_break.line); - - PHPDBG_BREAK_MAPPING(new_break.id, broken); - } else { - phpdbg_error("breakpoint", "type=\"exists\" add=\"fail\" file=\"%s\" line=\"%ld\"", "Breakpoint at %s:%ld exists", path, line_num); - } - - } else { + pending = 1; + } else if (!(ssb.sb.st_mode & (S_IFREG|S_IFLNK))) { phpdbg_error("breakpoint", "type=\"notregular\" add=\"fail\" file=\"%s\"", "Cannot set breakpoint in %s, it is not a regular file", path); + return; } + } + + if (zend_hash_find(file_breaks, path, path_len, (void **) &broken) == FAILURE) { + HashTable breaks; + zend_hash_init(&breaks, 8, NULL, phpdbg_file_breaks_dtor, 0); + + zend_hash_add(file_breaks, path, path_len, &breaks, sizeof(HashTable), (void **) &broken); + } + + if (!zend_hash_index_exists(broken, line_num)) { + PHPDBG_BREAK_INIT(new_break, PHPDBG_BREAK_FILE); + new_break.filename = estrndup(path, path_len); + new_break.line = line_num; + + zend_hash_index_update(broken, line_num, (void **) &new_break, sizeof(phpdbg_breakfile_t), NULL); + + if (pending) { + PHPDBG_G(flags) |= PHPDBG_HAS_PENDING_FILE_BP; + + phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" file=\"%s\" line=\"%ld\" pending=\"pending\"", "Pending breakpoint #%d added at %s:%ld", new_break.id, new_break.filename, new_break.line); + } else { + PHPDBG_G(flags) |= PHPDBG_HAS_FILE_BP; + + phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" file=\"%s\" line=\"%ld\"", "Breakpoint #%d added at %s:%ld", new_break.id, new_break.filename, new_break.line); + } + + PHPDBG_BREAK_MAPPING(new_break.id, broken); } else { - phpdbg_error("breakpoint", "type=\"nofile\" add=\"fail\" file=\"%s\"", "Cannot stat %s, it does not exist", path); + phpdbg_error("breakpoint", "type=\"exists\" add=\"fail\" file=\"%s\" line=\"%ld\"", "Breakpoint at %s:%ld exists", path, line_num); + } +} /* }}} */ + +PHPDBG_API void phpdbg_resolve_pending_file_break(const char *file TSRMLS_DC) /* {{{ */ +{ + HashPosition position[2]; + HashTable *fileht; + uint filelen = strlen(file); + + zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position[0]); + while (zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], (void**) &fileht, &position[0]) == SUCCESS) { + const char *cur; + uint curlen; + + zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], (char **) &cur, &curlen, NULL, 0, &position[0]); + zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position[0]); + + if (curlen < filelen && file[filelen - curlen - 1] == '/' && !memcmp(file + filelen - curlen, cur, curlen)) { + phpdbg_breakfile_t *brake, new_brake; + HashTable *master = NULL; + dtor_func_t dtor; + + PHPDBG_G(flags) |= PHPDBG_HAS_FILE_BP; + + if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, (void **) &master) == FAILURE) { + dtor = PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor; + PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor = NULL; + zend_hash_add(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, fileht, sizeof(HashTable), (void **) &fileht); + } + + for (zend_hash_internal_pointer_reset_ex(fileht, &position[1]); + zend_hash_get_current_data_ex(fileht, (void**)&brake, &position[1]) == SUCCESS; + zend_hash_move_forward_ex(fileht, &position[1])) { + new_brake = *brake; + new_brake.filename = estrndup(file, filelen); + PHPDBG_BREAK_UNMAPPING(brake->id); + + if (master) { + zend_hash_index_update(master, brake->line, (void **) &new_brake, sizeof(phpdbg_breakfile_t), NULL); + PHPDBG_BREAK_MAPPING(brake->id, master); + } else { + efree((char *) brake->filename); + *brake = new_brake; + PHPDBG_BREAK_MAPPING(brake->id, fileht); + } + } + + zend_hash_del(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], cur, curlen); + + if (!master) { + PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor = dtor; + } + + if (!zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING])) { + PHPDBG_G(flags) &= ~PHPDBG_HAS_PENDING_FILE_BP; + } + } } } /* }}} */ @@ -1141,6 +1209,7 @@ PHPDBG_API void phpdbg_delete_breakpoint(zend_ulong num TSRMLS_DC) /* {{{ */ PHPDBG_API void phpdbg_clear_breakpoints(TSRMLS_D) /* {{{ */ { zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING]); zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM]); zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]); zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE]); @@ -1398,6 +1467,25 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); } } + } if ((PHPDBG_G(flags) & PHPDBG_HAS_PENDING_FILE_BP)) { + HashPosition position[2]; + HashTable *points; + + phpdbg_out(SEPARATE "\n"); + phpdbg_out("Pending File Breakpoints:\n"); + for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position[0]); + zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], (void**) &points, &position[0]) == SUCCESS; + zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position[0])) { + phpdbg_breakfile_t *brake; + + for (zend_hash_internal_pointer_reset_ex(points, &position[1]); + zend_hash_get_current_data_ex(points, (void**)&brake, &position[1]) == SUCCESS; + zend_hash_move_forward_ex(points, &position[1])) { + phpdbg_writeln("file", "id=\"%d\" name=\"%s\" line=\"%lu\" disabled=\"%s\" pending=\"pending\"", "#%d\t\t%s:%lu%s", + brake->id, brake->filename, brake->line, + ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); + } + } } break; diff --git a/phpdbg_bp.h b/phpdbg_bp.h index a6227cba6c9..606085ddcfc 100644 --- a/phpdbg_bp.h +++ b/phpdbg_bp.h @@ -23,16 +23,17 @@ /* {{{ defines */ #define PHPDBG_BREAK_FILE 0 -#define PHPDBG_BREAK_SYM 1 -#define PHPDBG_BREAK_OPLINE 2 -#define PHPDBG_BREAK_METHOD 3 -#define PHPDBG_BREAK_COND 4 -#define PHPDBG_BREAK_OPCODE 5 -#define PHPDBG_BREAK_FUNCTION_OPLINE 6 -#define PHPDBG_BREAK_METHOD_OPLINE 7 -#define PHPDBG_BREAK_FILE_OPLINE 8 -#define PHPDBG_BREAK_MAP 9 -#define PHPDBG_BREAK_TABLES 10 /* }}} */ +#define PHPDBG_BREAK_FILE_PENDING 1 +#define PHPDBG_BREAK_SYM 2 +#define PHPDBG_BREAK_OPLINE 3 +#define PHPDBG_BREAK_METHOD 4 +#define PHPDBG_BREAK_COND 5 +#define PHPDBG_BREAK_OPCODE 6 +#define PHPDBG_BREAK_FUNCTION_OPLINE 7 +#define PHPDBG_BREAK_METHOD_OPLINE 8 +#define PHPDBG_BREAK_FILE_OPLINE 9 +#define PHPDBG_BREAK_MAP 10 +#define PHPDBG_BREAK_TABLES 11 /* }}} */ /* {{{ */ typedef struct _zend_op *phpdbg_opline_ptr_t; /* }}} */ @@ -116,10 +117,11 @@ typedef struct _phpdbg_breakcond_t { zend_op_array *ops; } phpdbg_breakcond_t; -/* {{{ Opline breaks API */ +/* {{{ Resolving breaks API */ PHPDBG_API void phpdbg_resolve_op_array_breaks(zend_op_array *op_array TSRMLS_DC); PHPDBG_API int phpdbg_resolve_op_array_break(phpdbg_breakopline_t *brake, zend_op_array *op_array TSRMLS_DC); -PHPDBG_API int phpdbg_resolve_opline_break(phpdbg_breakopline_t *new_break TSRMLS_DC); /* }}} */ +PHPDBG_API int phpdbg_resolve_opline_break(phpdbg_breakopline_t *new_break TSRMLS_DC); +PHPDBG_API void phpdbg_resolve_pending_file_break(const char *file TSRMLS_DC); /* }}} */ /* {{{ Breakpoint Creation API */ PHPDBG_API void phpdbg_set_breakpoint_file(const char* filename, long lineno TSRMLS_DC); diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index 13d5a0d6340..a170d529555 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -727,7 +727,7 @@ PHPDBG_API char *phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */ char *cmd = NULL; char *buffer = NULL; - if (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { + if ((PHPDBG_G(flags) & (PHPDBG_IS_STOPPING | PHPDBG_IS_RUNNING)) != PHPDBG_IS_STOPPING) { if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && (buffered == NULL) && !phpdbg_active_sigsafe_mem(TSRMLS_C)) { fflush(PHPDBG_G(io)[PHPDBG_STDOUT].ptr); } diff --git a/phpdbg_list.c b/phpdbg_list.c index 7aa8c4f9e08..8ab4c8922a8 100644 --- a/phpdbg_list.c +++ b/phpdbg_list.c @@ -278,6 +278,8 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type TSRMLS_DC) { dataptr->line[line] = endptr - data.buf; dataptr = erealloc(dataptr, sizeof(phpdbg_file_source) + sizeof(uint) * line); + phpdbg_resolve_pending_file_break(filename TSRMLS_CC); + ret = PHPDBG_G(compile_file)(&fake, type TSRMLS_CC); fake.opened_path = NULL; diff --git a/phpdbg_out.c b/phpdbg_out.c index a4793f144f6..365708c71ed 100644 --- a/phpdbg_out.c +++ b/phpdbg_out.c @@ -1117,6 +1117,8 @@ PHPDBG_API int phpdbg_vprint(int type TSRMLS_DC, int fd, const char *tag, const } if (PHPDBG_G(err_buf).active && type != P_STDOUT && type != P_STDERR) { + phpdbg_free_err_buf(TSRMLS_C); + PHPDBG_G(err_buf).type = type; PHPDBG_G(err_buf).fd = fd; PHPDBG_G(err_buf).tag = estrdup(tag); diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index eca4c6ac2ba..a2e4d41042d 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -28,7 +28,6 @@ #include "phpdbg_print.h" #include "phpdbg_info.h" #include "phpdbg_break.h" -#include "phpdbg_bp.h" #include "phpdbg_opcode.h" #include "phpdbg_list.h" #include "phpdbg_utils.h" @@ -44,7 +43,6 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg); ZEND_EXTERN_MODULE_GLOBALS(output); extern int phpdbg_startup_run; -extern char *phpdbg_exec; #ifdef HAVE_LIBDL #ifdef PHP_WIN32 @@ -641,10 +639,10 @@ PHPDBG_COMMAND(run) /* {{{ */ } zend_try { - PHPDBG_G(flags) ^= PHPDBG_IS_INTERACTIVE; + PHPDBG_G(flags) &= ~PHPDBG_IS_INTERACTIVE; + PHPDBG_G(flags) |= PHPDBG_IS_RUNNING; zend_execute(EG(active_op_array) TSRMLS_CC); - PHPDBG_G(flags) ^= PHPDBG_IS_INTERACTIVE; - phpdbg_notice("stop", "type=\"normal\"", "Script ended normally"); + PHPDBG_G(flags) |= PHPDBG_IS_INTERACTIVE; } zend_catch { EG(active_op_array) = orig_op_array; EG(opline_ptr) = orig_opline; @@ -669,7 +667,11 @@ PHPDBG_COMMAND(run) /* {{{ */ EG(active_op_array) = orig_op_array; EG(opline_ptr) = orig_opline; EG(return_value_ptr_ptr) = orig_retval_ptr; + + phpdbg_clean(1 TSRMLS_CC); } + + PHPDBG_G(flags) &= ~PHPDBG_IS_RUNNING; } else { phpdbg_error("inactive", "type=\"nocontext\"", "Nothing to execute!"); } @@ -1235,8 +1237,8 @@ int phpdbg_interactive(zend_bool allow_async_unsafe TSRMLS_DC) /* {{{ */ PHPDBG_G(flags) |= PHPDBG_IS_INTERACTIVE; - while (1) { - if (PHPDBG_G(flags) & PHPDBG_IS_STOPPING) { + while (ret == SUCCESS || ret == FAILURE) { + if ((PHPDBG_G(flags) & (PHPDBG_IS_STOPPING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_STOPPING) { zend_bailout(); } @@ -1291,6 +1293,7 @@ int phpdbg_interactive(zend_bool allow_async_unsafe TSRMLS_DC) /* {{{ */ phpdbg_stack_free(&stack); phpdbg_destroy_input(&input TSRMLS_CC); PHPDBG_G(req_id) = 0; + input = NULL; } if (input) { @@ -1320,10 +1323,6 @@ void phpdbg_clean(zend_bool full TSRMLS_DC) /* {{{ */ } if (full) { - if (PHPDBG_G(exec)) { - phpdbg_exec = strdup(PHPDBG_G(exec)); /* preserve exec, don't reparse that from cmd */ - } - PHPDBG_G(flags) |= PHPDBG_IS_CLEANING; zend_bailout(); From 29edee4e70f3802101d2dd28f9e8240299629e28 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sun, 26 Oct 2014 22:21:18 +0100 Subject: [PATCH 071/398] Fix last commit, and do not output unnecessary information --- phpdbg.c | 44 +++++++++++++++++++++++----------- phpdbg.h | 4 +++- phpdbg_io.c | 4 ++++ phpdbg_prompt.c | 11 +++++++-- tests/commands/0104_clean.test | 1 - 5 files changed, 46 insertions(+), 18 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index 3e31f76898a..b7fb5e5afc4 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -544,7 +544,7 @@ static void php_sapi_phpdbg_log_message(char *message TSRMLS_DC) /* {{{ */ 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); @@ -554,7 +554,7 @@ static int php_sapi_phpdbg_deactivate(TSRMLS_D) /* {{{ */ 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; } @@ -1035,7 +1035,7 @@ int main(int argc, char **argv) /* {{{ */ 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; @@ -1491,21 +1491,20 @@ phpdbg_main: /* 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; @@ -1514,14 +1513,24 @@ phpdbg_main: 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; @@ -1537,7 +1546,9 @@ phpdbg_interact: } 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 { @@ -1589,9 +1600,13 @@ phpdbg_out: } __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 */ @@ -1638,9 +1653,10 @@ phpdbg_out: 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); } @@ -1654,7 +1670,7 @@ phpdbg_out: } - if (cleaning || remote) { + if (cleaning > 0 || remote) { goto phpdbg_main; } diff --git a/phpdbg.h b/phpdbg.h index 57ea7ee570f..65bdcd0d6f3 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -177,12 +177,14 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC); #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) diff --git a/phpdbg_io.c b/phpdbg_io.c index a2a5c5969f4..6908a687d7e 100644 --- a/phpdbg_io.c +++ b/phpdbg_io.c @@ -187,6 +187,10 @@ PHPDBG_API int phpdbg_mixed_read(int sock, char *ptr, int len, int tmo TSRMLS_DC PHPDBG_API int phpdbg_mixed_write(int sock, const char *ptr, int len TSRMLS_DC) { + if (PHPDBG_G(flags) & PHPDBG_DISCARD_OUTPUT) { + return 0; + } + if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) { return phpdbg_send_bytes(sock, ptr, len); } diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index a2e4d41042d..fd4af2c3cd7 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -263,7 +263,7 @@ void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_ goto next_line; } - { + zend_try { char *input = phpdbg_read_input(cmd TSRMLS_CC); phpdbg_param_t stack; @@ -287,7 +287,12 @@ void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_ 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++; @@ -1160,6 +1165,8 @@ PHPDBG_COMMAND(clean) /* {{{ */ 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(""); diff --git a/tests/commands/0104_clean.test b/tests/commands/0104_clean.test index d50903c479e..2c7660ad60e 100644 --- a/tests/commands/0104_clean.test +++ b/tests/commands/0104_clean.test @@ -9,7 +9,6 @@ #Functions %d #Constants %d #Includes %d -#[Nothing to execute!] ################################################# clean quit From f4748ff9fff3147276e4d37ff5cdfd4ca9dc1fa5 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sun, 26 Oct 2014 23:33:54 +0100 Subject: [PATCH 072/398] Do not execute anything after quit or clean command --- phpdbg_prompt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index fd4af2c3cd7..5e2cc03d502 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -1438,6 +1438,10 @@ void phpdbg_execute_ex(zend_op_array *op_array TSRMLS_DC) /* {{{ */ } #endif + if ((PHPDBG_G(flags) & (PHPDBG_IS_STOPPING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_STOPPING) { + zend_bailout(); + } + EG(in_execution) = 1; #if PHP_VERSION_ID >= 50500 From 2bcc8d83940408c4a0ff8a55cdc30590bf15f663 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sun, 26 Oct 2014 03:50:28 +0100 Subject: [PATCH 073/398] Add question to reset execution in run/exec/clean --- phpdbg.c | 44 ++++++++--------- phpdbg.h | 7 +-- phpdbg_cmd.c | 82 ++++++++++-------------------- phpdbg_cmd.h | 1 + phpdbg_io.c | 49 ++++++++++++++++++ phpdbg_io.h | 2 + phpdbg_prompt.c | 129 ++++++++++++++++++++++++++---------------------- 7 files changed, 173 insertions(+), 141 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index aaf1e5f4060..ff03c670d06 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -45,6 +45,8 @@ #endif /* }}} */ ZEND_DECLARE_MODULE_GLOBALS(phpdbg); +int phpdbg_startup_run = 0; +char *phpdbg_exec = NULL; static PHP_INI_MH(OnUpdateEol) { @@ -487,7 +489,7 @@ static void php_sapi_phpdbg_log_message(char *message TSRMLS_DC) /* {{{ */ case PHPDBG_NEXT: return; } - } while (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)); + } while (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)); } } else fprintf(stdout, "%s\n", message); @@ -752,7 +754,7 @@ static void phpdbg_welcome(zend_bool cleaning TSRMLS_DC) /* {{{ */ phpdbg_writeln("intro", "help=\"help\"", "To get help using phpdbg type \"help\" and press enter"); phpdbg_notice("intro", "report=\"%s\"", "Please report bugs to <%s>", PHPDBG_ISSUES); phpdbg_xml(""); - } else { + } else if (phpdbg_startup_run == 0) { if (!(PHPDBG_G(flags) & PHPDBG_WRITE_XML)) { phpdbg_notice(NULL, NULL, "Clean Execution Environment"); } @@ -776,7 +778,7 @@ static inline void phpdbg_sigint_handler(int signo) /* {{{ */ if (PHPDBG_G(flags) & PHPDBG_IS_INTERACTIVE) { /* we quit remote consoles on recv SIGINT */ if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) { - PHPDBG_G(flags) |= PHPDBG_IS_QUITTING; + PHPDBG_G(flags) |= PHPDBG_IS_STOPPING; zend_bailout(); } } else { @@ -961,8 +963,6 @@ int main(int argc, char **argv) /* {{{ */ zend_ulong zend_extensions_len = 0L; zend_bool ini_ignore; char *ini_override; - char *exec; - size_t exec_len; char *init_file; size_t init_file_len; zend_bool init_file_default; @@ -973,7 +973,6 @@ int main(int argc, char **argv) /* {{{ */ int php_optind, opt, show_banner = 1; long cleaning = 0; zend_bool remote = 0; - int run = 0; int step = 0; #ifdef _WIN32 @@ -1046,8 +1045,6 @@ phpdbg_main: ini_override = NULL; zend_extensions = NULL; zend_extensions_len = 0L; - exec = NULL; - exec_len = 0; init_file = NULL; init_file_len = 0; init_file_default = 1; @@ -1057,14 +1054,13 @@ phpdbg_main: php_optarg = NULL; php_optind = 1; opt = 0; - run = 0; step = 0; sapi_name = NULL; while ((opt = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) { switch (opt) { case 'r': - run++; + phpdbg_startup_run++; break; case 'n': ini_ignore = 1; @@ -1201,14 +1197,12 @@ phpdbg_main: } /* set exec if present on command line */ - if ((argc > php_optind) && (strcmp(argv[php_optind-1],"--") != SUCCESS)) - { - exec_len = strlen(argv[php_optind]); - if (exec_len) { - if (exec) { - free(exec); + if (!phpdbg_exec && (argc > php_optind) && (strcmp(argv[php_optind-1],"--") != SUCCESS)) { + if (strlen(argv[php_optind])) { + if (phpdbg_exec) { + free(phpdbg_exec); } - exec = strdup(argv[php_optind]); + phpdbg_exec = strdup(argv[php_optind]); } php_optind++; } @@ -1331,7 +1325,7 @@ phpdbg_main: for (i = SG(request_info).argc; --i;) { SG(request_info).argv[i] = estrdup(argv[php_optind - 1 + i]); } - SG(request_info).argv[i] = exec ? estrndup(exec, exec_len) : estrdup(""); + SG(request_info).argv[i] = phpdbg_exec ? estrdup(phpdbg_exec) : estrdup(""); php_hash_environment(TSRMLS_C); } @@ -1394,11 +1388,12 @@ phpdbg_main: php_stream_stdio_ops.write = phpdbg_stdiop_write; #endif - if (exec) { /* set execution context */ - PHPDBG_G(exec) = phpdbg_resolve_path(exec TSRMLS_CC); + if (phpdbg_exec) { /* set execution context */ + PHPDBG_G(exec) = phpdbg_resolve_path(phpdbg_exec TSRMLS_CC); PHPDBG_G(exec_len) = strlen(PHPDBG_G(exec)); - free(exec); + free(phpdbg_exec); + phpdbg_exec = NULL; } if (oplog_file) { /* open oplog */ @@ -1448,13 +1443,14 @@ phpdbg_main: PHPDBG_G(flags) |= PHPDBG_IS_STEPPING; } - if (run) { + if (phpdbg_startup_run) { /* no need to try{}, run does it ... */ PHPDBG_COMMAND_HANDLER(run)(NULL TSRMLS_CC); - if (run > 1) { + if (phpdbg_startup_run > 1) { /* if -r is on the command line more than once just quit */ goto phpdbg_out; } + phpdbg_startup_run = 0; } phpdbg_interact: @@ -1494,7 +1490,7 @@ phpdbg_interact: } } } zend_end_try(); - } while(!cleaning && !(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)); + } while (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)); /* this must be forced */ CG(unclean_shutdown) = 0; diff --git a/phpdbg.h b/phpdbg.h index 8c0dbb4afa0..688ba7cdfcb 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -187,9 +187,10 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC); #define PHPDBG_IN_SIGNAL_HANDLER (1<<30) -#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_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) #ifndef _WIN32 # define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_COLOURED|PHPDBG_IS_BP_ENABLED) diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index 30ea48cfbe4..ab0755454ec 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -796,80 +796,30 @@ PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack, zend_bool allow_async PHPDBG_API char *phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */ { + char buf[PHPDBG_MAX_CMD]; char *cmd = NULL; char *buffer = NULL; - if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { + if (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && (buffered == NULL) && !phpdbg_active_sigsafe_mem(TSRMLS_C)) { fflush(PHPDBG_G(io)[PHPDBG_STDOUT].ptr); } if (buffered == NULL) { - if (0) { -disconnect: - PHPDBG_G(flags) |= (PHPDBG_IS_QUITTING|PHPDBG_IS_DISCONNECTED); - zend_bailout(); - return NULL; - } - #define USE_LIB_STAR (defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT)) - /* note: EOF makes readline write prompt again in local console mode - and ignored if compiled without readline */ - /* strongly assuming to be in blocking mode... */ #if USE_LIB_STAR readline: if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) #endif { - char buf[PHPDBG_MAX_CMD]; - int bytes = PHPDBG_G(input_buflen), len = 0; - if (PHPDBG_G(input_buflen)) { - memcpy(buf, PHPDBG_G(input_buffer), bytes); - } - phpdbg_write("prompt", "", "%s", phpdbg_get_prompt(TSRMLS_C)); - PHPDBG_G(last_was_newline) = 1; - - do { - int i; - if (bytes <= 0) { - continue; - } - - for (i = len; i < len + bytes; i++) { - if (buf[i] == '\x03') { - if (i != len + bytes - 1) { - memmove(buf + i, buf + i + 1, len + bytes - i - 1); - } - len--; - i--; - continue; - } - if (buf[i] == '\n') { - PHPDBG_G(input_buflen) = len + bytes - 1 - i; - if (PHPDBG_G(input_buflen)) { - memcpy(PHPDBG_G(input_buffer), buf + i + 1, PHPDBG_G(input_buflen)); - } - if (i != PHPDBG_MAX_CMD - 1) { - buf[i + 1] = 0; - } - cmd = buf; - goto end; - } - } - len += bytes; - /* XXX export the timeout through INI??*/ - } while ((bytes = phpdbg_mixed_read(PHPDBG_G(io)[PHPDBG_STDIN].fd, buf + len, PHPDBG_MAX_CMD - len, -1 TSRMLS_CC)) > 0); - - if (bytes <= 0) { - goto disconnect; - } - - cmd = buf; + phpdbg_consume_stdin_line(cmd = buf TSRMLS_CC); } #if USE_LIB_STAR else { cmd = readline(phpdbg_get_prompt(TSRMLS_C)); + PHPDBG_G(last_was_newline) = 1; } if (!cmd) { @@ -883,8 +833,7 @@ readline: } else { cmd = buffered; } -end: - PHPDBG_G(last_was_newline) = 1; + buffer = estrdup(cmd); #if USE_LIB_STAR @@ -922,3 +871,24 @@ PHPDBG_API void phpdbg_destroy_input(char **input TSRMLS_DC) /*{{{ */ { efree(*input); } /* }}} */ + +PHPDBG_API int phpdbg_ask_user_permission(const char *question TSRMLS_DC) { + if (!(PHPDBG_G(flags) & PHPDBG_WRITE_XML)) { + char buf[PHPDBG_MAX_CMD]; + phpdbg_out("%s", question); + phpdbg_out(" (type y or n): "); + + while (1) { + phpdbg_consume_stdin_line(buf TSRMLS_CC); + if (buf[1] == '\n' && (buf[0] == 'y' || buf[0] == 'n')) { + if (buf[0] == 'y') { + return SUCCESS; + } + return FAILURE; + } + phpdbg_out("Please enter either y (yes) or n (no): "); + } + } + + return SUCCESS; +} diff --git a/phpdbg_cmd.h b/phpdbg_cmd.h index 3896551c9a2..4c9e5383d82 100644 --- a/phpdbg_cmd.h +++ b/phpdbg_cmd.h @@ -131,6 +131,7 @@ typedef struct { */ PHPDBG_API char* phpdbg_read_input(char *buffered TSRMLS_DC); PHPDBG_API void phpdbg_destroy_input(char** TSRMLS_DC); +PHPDBG_API int phpdbg_ask_user_permission(const char *question TSRMLS_DC); /** * Stack Management diff --git a/phpdbg_io.c b/phpdbg_io.c index 97f0356285c..a2a5c5969f4 100644 --- a/phpdbg_io.c +++ b/phpdbg_io.c @@ -47,6 +47,55 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg); +/* is easy to generalize ... but not needed for now */ +PHPDBG_API int phpdbg_consume_stdin_line(char *buf TSRMLS_DC) { + int bytes = PHPDBG_G(input_buflen), len = 0; + + if (PHPDBG_G(input_buflen)) { + memcpy(buf, PHPDBG_G(input_buffer), bytes); + } + + PHPDBG_G(last_was_newline) = 1; + + do { + int i; + if (bytes <= 0) { + continue; + } + + for (i = len; i < len + bytes; i++) { + if (buf[i] == '\x03') { + if (i != len + bytes - 1) { + memmove(buf + i, buf + i + 1, len + bytes - i - 1); + } + len--; + i--; + continue; + } + if (buf[i] == '\n') { + PHPDBG_G(input_buflen) = len + bytes - 1 - i; + if (PHPDBG_G(input_buflen)) { + memcpy(PHPDBG_G(input_buffer), buf + i + 1, PHPDBG_G(input_buflen)); + } + if (i != PHPDBG_MAX_CMD - 1) { + buf[i + 1] = 0; + } + return i; + } + } + + len += bytes; + } while ((bytes = phpdbg_mixed_read(PHPDBG_G(io)[PHPDBG_STDIN].fd, buf + len, PHPDBG_MAX_CMD - len, -1 TSRMLS_CC)) > 0); + + if (bytes <= 0) { + PHPDBG_G(flags) |= PHPDBG_IS_QUITTING | PHPDBG_IS_DISCONNECTED; + zend_bailout(); + return 0; + } + + return bytes; +} + PHPDBG_API int phpdbg_consume_bytes(int sock, char *ptr, int len, int tmo TSRMLS_DC) { int got_now, i = len, j; char *p = ptr; diff --git a/phpdbg_io.h b/phpdbg_io.h index 3ac8f4112d0..a5659e88c65 100644 --- a/phpdbg_io.h +++ b/phpdbg_io.h @@ -21,6 +21,8 @@ #include "phpdbg.h" +PHPDBG_API int phpdbg_consume_stdin_line(char *buf TSRMLS_DC); + PHPDBG_API int phpdbg_consume_bytes(int sock, char *ptr, int len, int tmo TSRMLS_DC); PHPDBG_API int phpdbg_send_bytes(int sock, const char *ptr, int len); PHPDBG_API int phpdbg_mixed_read(int sock, char *ptr, int len, int tmo TSRMLS_DC); diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 2e0c698f050..29c75c583c0 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -43,6 +43,8 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg); ZEND_EXTERN_MODULE_GLOBALS(output); +extern int phpdbg_startup_run; +extern char *phpdbg_exec; #ifdef HAVE_LIBDL #ifdef PHP_WIN32 @@ -355,6 +357,11 @@ PHPDBG_COMMAND(exec) /* {{{ */ size_t res_len = strlen(res); if ((res_len != PHPDBG_G(exec_len)) || (memcmp(res, PHPDBG_G(exec), res_len) != SUCCESS)) { + if (EG(in_execution)) { + if (phpdbg_ask_user_permission("Do you really want to stop execution to set a new execution context?" TSRMLS_CC) == FAILURE) { + return FAILURE; + } + } if (PHPDBG_G(exec)) { phpdbg_notice("exec", "type=\"unset\" context=\"%s\"", "Unsetting old execution context: %s", PHPDBG_G(exec)); @@ -378,9 +385,11 @@ PHPDBG_COMMAND(exec) /* {{{ */ phpdbg_notice("exec", "type=\"set\" context=\"%s\"", "Set execution context: %s", PHPDBG_G(exec)); - if (phpdbg_compile(TSRMLS_C) == FAILURE) { - phpdbg_error("compile", "type=\"compilefailure\" context=\"%s\"", "Failed to compile %s", PHPDBG_G(exec)); + if (EG(in_execution)) { + phpdbg_clean(1 TSRMLS_CC); } + + phpdbg_compile(TSRMLS_C); } else { phpdbg_notice("exec", "type=\"unchanged\"", "Execution context not changed"); } @@ -399,20 +408,15 @@ int phpdbg_compile(TSRMLS_D) /* {{{ */ if (!PHPDBG_G(exec)) { phpdbg_error("inactive", "type=\"nocontext\"", "No execution context"); - return SUCCESS; - } - - if (EG(in_execution)) { - phpdbg_error("inactive", "type=\"isrunning\"", "Cannot compile while in execution"); return FAILURE; } if (php_stream_open_for_zend_ex(PHPDBG_G(exec), &fh, USE_PATH|STREAM_OPEN_FOR_INCLUDE TSRMLS_CC) == SUCCESS) { - PHPDBG_G(ops) = zend_compile_file(&fh, ZEND_INCLUDE TSRMLS_CC); zend_destroy_file_handle(&fh TSRMLS_CC); phpdbg_notice("compile", "context=\"%s\"", "Successful compilation of %s", PHPDBG_G(exec)); + return SUCCESS; } else { phpdbg_error("compile", "type=\"openfailure\" context=\"%s\"", "Could not open file %s", PHPDBG_G(exec)); @@ -570,11 +574,6 @@ static inline void phpdbg_handle_exception(TSRMLS_D) /* }}} */ PHPDBG_COMMAND(run) /* {{{ */ { - if (EG(in_execution)) { - phpdbg_error("inactive", "type=\"isrunning\"", "Cannot start another execution while one is in progress"); - return SUCCESS; - } - if (PHPDBG_G(ops) || PHPDBG_G(exec)) { zend_op **orig_opline = EG(opline_ptr); zend_op_array *orig_op_array = EG(active_op_array); @@ -582,6 +581,14 @@ PHPDBG_COMMAND(run) /* {{{ */ zend_bool restore = 1; zend_execute_data *ex = EG(current_execute_data); + if (EG(in_execution)) { + if (phpdbg_ask_user_permission("Do you really want to restart execution?" TSRMLS_CC) == SUCCESS) { + phpdbg_startup_run++; + phpdbg_clean(1 TSRMLS_CC); + } + return SUCCESS; + } + if (!PHPDBG_G(ops)) { if (phpdbg_compile(TSRMLS_C) == FAILURE) { phpdbg_error("compile", "type=\"compilefailure\" context=\"%s\"", "Failed to compile %s, cannot run", PHPDBG_G(exec)); @@ -643,7 +650,7 @@ PHPDBG_COMMAND(run) /* {{{ */ EG(opline_ptr) = orig_opline; EG(return_value_ptr_ptr) = orig_retval_ptr; - if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { + if (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { phpdbg_error("stop", "type=\"bailout\"", "Caught exit/error from VM"); restore = 0; } @@ -1127,7 +1134,7 @@ PHPDBG_COMMAND(register) /* {{{ */ PHPDBG_COMMAND(quit) /* {{{ */ { /* don't allow this to loop, ever ... */ - if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { + if (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { PHPDBG_G(flags) |= PHPDBG_IS_QUITTING; zend_bailout(); } @@ -1138,8 +1145,9 @@ PHPDBG_COMMAND(quit) /* {{{ */ PHPDBG_COMMAND(clean) /* {{{ */ { if (EG(in_execution)) { - phpdbg_error("inactive", "type=\"isrunning\"", "Cannot clean environment while executing"); - return SUCCESS; + if (phpdbg_ask_user_permission("Do you really want to clean your current environment?" TSRMLS_CC) == FAILURE) { + return SUCCESS; + } } phpdbg_out("Cleaning Execution Environment\n"); @@ -1227,60 +1235,64 @@ int phpdbg_interactive(zend_bool allow_async_unsafe TSRMLS_DC) /* {{{ */ PHPDBG_G(flags) |= PHPDBG_IS_INTERACTIVE; - input = phpdbg_read_input(NULL TSRMLS_CC); + while (1) { + if (PHPDBG_G(flags) & PHPDBG_IS_STOPPING) { + zend_bailout(); + } - if (input) { - do { - phpdbg_init_param(&stack, STACK_PARAM); + if (!(input = phpdbg_read_input(NULL TSRMLS_CC))) { + break; + } - if (phpdbg_do_parse(&stack, input TSRMLS_CC) <= 0) { - phpdbg_activate_err_buf(1 TSRMLS_CC); + + phpdbg_init_param(&stack, STACK_PARAM); + + if (phpdbg_do_parse(&stack, input TSRMLS_CC) <= 0) { + phpdbg_activate_err_buf(1 TSRMLS_CC); #ifdef PHP_WIN32 #define PARA ((phpdbg_param_t *)stack.next)->type - if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE && (RUN_PARAM == PARA || EVAL_PARAM == PARA)) { - sigio_watcher_start(); - } + if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE && (RUN_PARAM == PARA || EVAL_PARAM == PARA)) { + sigio_watcher_start(); + } #endif - switch (ret = phpdbg_stack_execute(&stack, allow_async_unsafe TSRMLS_CC)) { - case FAILURE: - if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { - if (!allow_async_unsafe || phpdbg_call_register(&stack TSRMLS_CC) == FAILURE) { - phpdbg_output_err_buf(NULL, "%b", "%b" TSRMLS_CC); - } + switch (ret = phpdbg_stack_execute(&stack, allow_async_unsafe TSRMLS_CC)) { + case FAILURE: + if (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { + if (!allow_async_unsafe || phpdbg_call_register(&stack TSRMLS_CC) == FAILURE) { + phpdbg_output_err_buf(NULL, "%b", "%b" TSRMLS_CC); } - break; - - case PHPDBG_LEAVE: - case PHPDBG_FINISH: - case PHPDBG_UNTIL: - case PHPDBG_NEXT: { - phpdbg_activate_err_buf(0 TSRMLS_CC); - phpdbg_free_err_buf(TSRMLS_C); - if (!EG(in_execution) && !(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { - phpdbg_error("command", "type=\"noexec\"", "Not running"); - } - goto out; } - } + break; - phpdbg_activate_err_buf(0 TSRMLS_CC); - phpdbg_free_err_buf(TSRMLS_C); -#ifdef PHP_WIN32 - if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE && (RUN_PARAM == PARA || EVAL_PARAM == PARA)) { - sigio_watcher_stop(); + case PHPDBG_LEAVE: + case PHPDBG_FINISH: + case PHPDBG_UNTIL: + case PHPDBG_NEXT: { + phpdbg_activate_err_buf(0 TSRMLS_CC); + phpdbg_free_err_buf(TSRMLS_C); + if (!EG(in_execution) && !(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { + phpdbg_error("command", "type=\"noexec\"", "Not running"); + } + break; } -#undef PARA -#endif } - phpdbg_stack_free(&stack); - phpdbg_destroy_input(&input TSRMLS_CC); - PHPDBG_G(req_id) = 0; - } while ((input = phpdbg_read_input(NULL TSRMLS_CC))); + phpdbg_activate_err_buf(0 TSRMLS_CC); + phpdbg_free_err_buf(TSRMLS_C); +#ifdef PHP_WIN32 + if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE && (RUN_PARAM == PARA || EVAL_PARAM == PARA)) { + sigio_watcher_stop(); + } +#undef PARA +#endif + } + + phpdbg_stack_free(&stack); + phpdbg_destroy_input(&input TSRMLS_CC); + PHPDBG_G(req_id) = 0; } -out: if (input) { phpdbg_stack_free(&stack); phpdbg_destroy_input(&input TSRMLS_CC); @@ -1308,6 +1320,7 @@ void phpdbg_clean(zend_bool full TSRMLS_DC) /* {{{ */ } if (full) { + phpdbg_exec = strdup(PHPDBG_G(exec)); /* preserve exec, don't reparse that from cmd */ PHPDBG_G(flags) |= PHPDBG_IS_CLEANING; zend_bailout(); @@ -1593,7 +1606,7 @@ void phpdbg_force_interruption(TSRMLS_D) { next: PHPDBG_G(flags) &= ~PHPDBG_IN_SIGNAL_HANDLER; - if (PHPDBG_G(flags) & PHPDBG_IS_QUITTING) { + if (PHPDBG_G(flags) & PHPDBG_IS_STOPPING) { zend_bailout(); } } From cc70ec1e6735bb60606673c72c5ce9d9cb076e29 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sun, 26 Oct 2014 03:50:28 +0100 Subject: [PATCH 074/398] Add question to reset execution in run/exec/clean --- sapi/phpdbg/phpdbg.c | 44 ++++++------ sapi/phpdbg/phpdbg.h | 7 +- sapi/phpdbg/phpdbg_cmd.c | 82 ++++++++--------------- sapi/phpdbg/phpdbg_cmd.h | 1 + sapi/phpdbg/phpdbg_io.c | 49 ++++++++++++++ sapi/phpdbg/phpdbg_io.h | 2 + sapi/phpdbg/phpdbg_prompt.c | 129 ++++++++++++++++++++---------------- 7 files changed, 173 insertions(+), 141 deletions(-) diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index aaf1e5f4060..ff03c670d06 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -45,6 +45,8 @@ #endif /* }}} */ ZEND_DECLARE_MODULE_GLOBALS(phpdbg); +int phpdbg_startup_run = 0; +char *phpdbg_exec = NULL; static PHP_INI_MH(OnUpdateEol) { @@ -487,7 +489,7 @@ static void php_sapi_phpdbg_log_message(char *message TSRMLS_DC) /* {{{ */ case PHPDBG_NEXT: return; } - } while (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)); + } while (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)); } } else fprintf(stdout, "%s\n", message); @@ -752,7 +754,7 @@ static void phpdbg_welcome(zend_bool cleaning TSRMLS_DC) /* {{{ */ phpdbg_writeln("intro", "help=\"help\"", "To get help using phpdbg type \"help\" and press enter"); phpdbg_notice("intro", "report=\"%s\"", "Please report bugs to <%s>", PHPDBG_ISSUES); phpdbg_xml(""); - } else { + } else if (phpdbg_startup_run == 0) { if (!(PHPDBG_G(flags) & PHPDBG_WRITE_XML)) { phpdbg_notice(NULL, NULL, "Clean Execution Environment"); } @@ -776,7 +778,7 @@ static inline void phpdbg_sigint_handler(int signo) /* {{{ */ if (PHPDBG_G(flags) & PHPDBG_IS_INTERACTIVE) { /* we quit remote consoles on recv SIGINT */ if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) { - PHPDBG_G(flags) |= PHPDBG_IS_QUITTING; + PHPDBG_G(flags) |= PHPDBG_IS_STOPPING; zend_bailout(); } } else { @@ -961,8 +963,6 @@ int main(int argc, char **argv) /* {{{ */ zend_ulong zend_extensions_len = 0L; zend_bool ini_ignore; char *ini_override; - char *exec; - size_t exec_len; char *init_file; size_t init_file_len; zend_bool init_file_default; @@ -973,7 +973,6 @@ int main(int argc, char **argv) /* {{{ */ int php_optind, opt, show_banner = 1; long cleaning = 0; zend_bool remote = 0; - int run = 0; int step = 0; #ifdef _WIN32 @@ -1046,8 +1045,6 @@ phpdbg_main: ini_override = NULL; zend_extensions = NULL; zend_extensions_len = 0L; - exec = NULL; - exec_len = 0; init_file = NULL; init_file_len = 0; init_file_default = 1; @@ -1057,14 +1054,13 @@ phpdbg_main: php_optarg = NULL; php_optind = 1; opt = 0; - run = 0; step = 0; sapi_name = NULL; while ((opt = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) { switch (opt) { case 'r': - run++; + phpdbg_startup_run++; break; case 'n': ini_ignore = 1; @@ -1201,14 +1197,12 @@ phpdbg_main: } /* set exec if present on command line */ - if ((argc > php_optind) && (strcmp(argv[php_optind-1],"--") != SUCCESS)) - { - exec_len = strlen(argv[php_optind]); - if (exec_len) { - if (exec) { - free(exec); + if (!phpdbg_exec && (argc > php_optind) && (strcmp(argv[php_optind-1],"--") != SUCCESS)) { + if (strlen(argv[php_optind])) { + if (phpdbg_exec) { + free(phpdbg_exec); } - exec = strdup(argv[php_optind]); + phpdbg_exec = strdup(argv[php_optind]); } php_optind++; } @@ -1331,7 +1325,7 @@ phpdbg_main: for (i = SG(request_info).argc; --i;) { SG(request_info).argv[i] = estrdup(argv[php_optind - 1 + i]); } - SG(request_info).argv[i] = exec ? estrndup(exec, exec_len) : estrdup(""); + SG(request_info).argv[i] = phpdbg_exec ? estrdup(phpdbg_exec) : estrdup(""); php_hash_environment(TSRMLS_C); } @@ -1394,11 +1388,12 @@ phpdbg_main: php_stream_stdio_ops.write = phpdbg_stdiop_write; #endif - if (exec) { /* set execution context */ - PHPDBG_G(exec) = phpdbg_resolve_path(exec TSRMLS_CC); + if (phpdbg_exec) { /* set execution context */ + PHPDBG_G(exec) = phpdbg_resolve_path(phpdbg_exec TSRMLS_CC); PHPDBG_G(exec_len) = strlen(PHPDBG_G(exec)); - free(exec); + free(phpdbg_exec); + phpdbg_exec = NULL; } if (oplog_file) { /* open oplog */ @@ -1448,13 +1443,14 @@ phpdbg_main: PHPDBG_G(flags) |= PHPDBG_IS_STEPPING; } - if (run) { + if (phpdbg_startup_run) { /* no need to try{}, run does it ... */ PHPDBG_COMMAND_HANDLER(run)(NULL TSRMLS_CC); - if (run > 1) { + if (phpdbg_startup_run > 1) { /* if -r is on the command line more than once just quit */ goto phpdbg_out; } + phpdbg_startup_run = 0; } phpdbg_interact: @@ -1494,7 +1490,7 @@ phpdbg_interact: } } } zend_end_try(); - } while(!cleaning && !(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)); + } while (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)); /* this must be forced */ CG(unclean_shutdown) = 0; diff --git a/sapi/phpdbg/phpdbg.h b/sapi/phpdbg/phpdbg.h index 8c0dbb4afa0..688ba7cdfcb 100644 --- a/sapi/phpdbg/phpdbg.h +++ b/sapi/phpdbg/phpdbg.h @@ -187,9 +187,10 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC); #define PHPDBG_IN_SIGNAL_HANDLER (1<<30) -#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_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) #ifndef _WIN32 # define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_COLOURED|PHPDBG_IS_BP_ENABLED) diff --git a/sapi/phpdbg/phpdbg_cmd.c b/sapi/phpdbg/phpdbg_cmd.c index 30ea48cfbe4..ab0755454ec 100644 --- a/sapi/phpdbg/phpdbg_cmd.c +++ b/sapi/phpdbg/phpdbg_cmd.c @@ -796,80 +796,30 @@ PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack, zend_bool allow_async PHPDBG_API char *phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */ { + char buf[PHPDBG_MAX_CMD]; char *cmd = NULL; char *buffer = NULL; - if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { + if (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && (buffered == NULL) && !phpdbg_active_sigsafe_mem(TSRMLS_C)) { fflush(PHPDBG_G(io)[PHPDBG_STDOUT].ptr); } if (buffered == NULL) { - if (0) { -disconnect: - PHPDBG_G(flags) |= (PHPDBG_IS_QUITTING|PHPDBG_IS_DISCONNECTED); - zend_bailout(); - return NULL; - } - #define USE_LIB_STAR (defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT)) - /* note: EOF makes readline write prompt again in local console mode - and ignored if compiled without readline */ - /* strongly assuming to be in blocking mode... */ #if USE_LIB_STAR readline: if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) #endif { - char buf[PHPDBG_MAX_CMD]; - int bytes = PHPDBG_G(input_buflen), len = 0; - if (PHPDBG_G(input_buflen)) { - memcpy(buf, PHPDBG_G(input_buffer), bytes); - } - phpdbg_write("prompt", "", "%s", phpdbg_get_prompt(TSRMLS_C)); - PHPDBG_G(last_was_newline) = 1; - - do { - int i; - if (bytes <= 0) { - continue; - } - - for (i = len; i < len + bytes; i++) { - if (buf[i] == '\x03') { - if (i != len + bytes - 1) { - memmove(buf + i, buf + i + 1, len + bytes - i - 1); - } - len--; - i--; - continue; - } - if (buf[i] == '\n') { - PHPDBG_G(input_buflen) = len + bytes - 1 - i; - if (PHPDBG_G(input_buflen)) { - memcpy(PHPDBG_G(input_buffer), buf + i + 1, PHPDBG_G(input_buflen)); - } - if (i != PHPDBG_MAX_CMD - 1) { - buf[i + 1] = 0; - } - cmd = buf; - goto end; - } - } - len += bytes; - /* XXX export the timeout through INI??*/ - } while ((bytes = phpdbg_mixed_read(PHPDBG_G(io)[PHPDBG_STDIN].fd, buf + len, PHPDBG_MAX_CMD - len, -1 TSRMLS_CC)) > 0); - - if (bytes <= 0) { - goto disconnect; - } - - cmd = buf; + phpdbg_consume_stdin_line(cmd = buf TSRMLS_CC); } #if USE_LIB_STAR else { cmd = readline(phpdbg_get_prompt(TSRMLS_C)); + PHPDBG_G(last_was_newline) = 1; } if (!cmd) { @@ -883,8 +833,7 @@ readline: } else { cmd = buffered; } -end: - PHPDBG_G(last_was_newline) = 1; + buffer = estrdup(cmd); #if USE_LIB_STAR @@ -922,3 +871,24 @@ PHPDBG_API void phpdbg_destroy_input(char **input TSRMLS_DC) /*{{{ */ { efree(*input); } /* }}} */ + +PHPDBG_API int phpdbg_ask_user_permission(const char *question TSRMLS_DC) { + if (!(PHPDBG_G(flags) & PHPDBG_WRITE_XML)) { + char buf[PHPDBG_MAX_CMD]; + phpdbg_out("%s", question); + phpdbg_out(" (type y or n): "); + + while (1) { + phpdbg_consume_stdin_line(buf TSRMLS_CC); + if (buf[1] == '\n' && (buf[0] == 'y' || buf[0] == 'n')) { + if (buf[0] == 'y') { + return SUCCESS; + } + return FAILURE; + } + phpdbg_out("Please enter either y (yes) or n (no): "); + } + } + + return SUCCESS; +} diff --git a/sapi/phpdbg/phpdbg_cmd.h b/sapi/phpdbg/phpdbg_cmd.h index 3896551c9a2..4c9e5383d82 100644 --- a/sapi/phpdbg/phpdbg_cmd.h +++ b/sapi/phpdbg/phpdbg_cmd.h @@ -131,6 +131,7 @@ typedef struct { */ PHPDBG_API char* phpdbg_read_input(char *buffered TSRMLS_DC); PHPDBG_API void phpdbg_destroy_input(char** TSRMLS_DC); +PHPDBG_API int phpdbg_ask_user_permission(const char *question TSRMLS_DC); /** * Stack Management diff --git a/sapi/phpdbg/phpdbg_io.c b/sapi/phpdbg/phpdbg_io.c index 97f0356285c..a2a5c5969f4 100644 --- a/sapi/phpdbg/phpdbg_io.c +++ b/sapi/phpdbg/phpdbg_io.c @@ -47,6 +47,55 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg); +/* is easy to generalize ... but not needed for now */ +PHPDBG_API int phpdbg_consume_stdin_line(char *buf TSRMLS_DC) { + int bytes = PHPDBG_G(input_buflen), len = 0; + + if (PHPDBG_G(input_buflen)) { + memcpy(buf, PHPDBG_G(input_buffer), bytes); + } + + PHPDBG_G(last_was_newline) = 1; + + do { + int i; + if (bytes <= 0) { + continue; + } + + for (i = len; i < len + bytes; i++) { + if (buf[i] == '\x03') { + if (i != len + bytes - 1) { + memmove(buf + i, buf + i + 1, len + bytes - i - 1); + } + len--; + i--; + continue; + } + if (buf[i] == '\n') { + PHPDBG_G(input_buflen) = len + bytes - 1 - i; + if (PHPDBG_G(input_buflen)) { + memcpy(PHPDBG_G(input_buffer), buf + i + 1, PHPDBG_G(input_buflen)); + } + if (i != PHPDBG_MAX_CMD - 1) { + buf[i + 1] = 0; + } + return i; + } + } + + len += bytes; + } while ((bytes = phpdbg_mixed_read(PHPDBG_G(io)[PHPDBG_STDIN].fd, buf + len, PHPDBG_MAX_CMD - len, -1 TSRMLS_CC)) > 0); + + if (bytes <= 0) { + PHPDBG_G(flags) |= PHPDBG_IS_QUITTING | PHPDBG_IS_DISCONNECTED; + zend_bailout(); + return 0; + } + + return bytes; +} + PHPDBG_API int phpdbg_consume_bytes(int sock, char *ptr, int len, int tmo TSRMLS_DC) { int got_now, i = len, j; char *p = ptr; diff --git a/sapi/phpdbg/phpdbg_io.h b/sapi/phpdbg/phpdbg_io.h index 3ac8f4112d0..a5659e88c65 100644 --- a/sapi/phpdbg/phpdbg_io.h +++ b/sapi/phpdbg/phpdbg_io.h @@ -21,6 +21,8 @@ #include "phpdbg.h" +PHPDBG_API int phpdbg_consume_stdin_line(char *buf TSRMLS_DC); + PHPDBG_API int phpdbg_consume_bytes(int sock, char *ptr, int len, int tmo TSRMLS_DC); PHPDBG_API int phpdbg_send_bytes(int sock, const char *ptr, int len); PHPDBG_API int phpdbg_mixed_read(int sock, char *ptr, int len, int tmo TSRMLS_DC); diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index 2e0c698f050..29c75c583c0 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -43,6 +43,8 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg); ZEND_EXTERN_MODULE_GLOBALS(output); +extern int phpdbg_startup_run; +extern char *phpdbg_exec; #ifdef HAVE_LIBDL #ifdef PHP_WIN32 @@ -355,6 +357,11 @@ PHPDBG_COMMAND(exec) /* {{{ */ size_t res_len = strlen(res); if ((res_len != PHPDBG_G(exec_len)) || (memcmp(res, PHPDBG_G(exec), res_len) != SUCCESS)) { + if (EG(in_execution)) { + if (phpdbg_ask_user_permission("Do you really want to stop execution to set a new execution context?" TSRMLS_CC) == FAILURE) { + return FAILURE; + } + } if (PHPDBG_G(exec)) { phpdbg_notice("exec", "type=\"unset\" context=\"%s\"", "Unsetting old execution context: %s", PHPDBG_G(exec)); @@ -378,9 +385,11 @@ PHPDBG_COMMAND(exec) /* {{{ */ phpdbg_notice("exec", "type=\"set\" context=\"%s\"", "Set execution context: %s", PHPDBG_G(exec)); - if (phpdbg_compile(TSRMLS_C) == FAILURE) { - phpdbg_error("compile", "type=\"compilefailure\" context=\"%s\"", "Failed to compile %s", PHPDBG_G(exec)); + if (EG(in_execution)) { + phpdbg_clean(1 TSRMLS_CC); } + + phpdbg_compile(TSRMLS_C); } else { phpdbg_notice("exec", "type=\"unchanged\"", "Execution context not changed"); } @@ -399,20 +408,15 @@ int phpdbg_compile(TSRMLS_D) /* {{{ */ if (!PHPDBG_G(exec)) { phpdbg_error("inactive", "type=\"nocontext\"", "No execution context"); - return SUCCESS; - } - - if (EG(in_execution)) { - phpdbg_error("inactive", "type=\"isrunning\"", "Cannot compile while in execution"); return FAILURE; } if (php_stream_open_for_zend_ex(PHPDBG_G(exec), &fh, USE_PATH|STREAM_OPEN_FOR_INCLUDE TSRMLS_CC) == SUCCESS) { - PHPDBG_G(ops) = zend_compile_file(&fh, ZEND_INCLUDE TSRMLS_CC); zend_destroy_file_handle(&fh TSRMLS_CC); phpdbg_notice("compile", "context=\"%s\"", "Successful compilation of %s", PHPDBG_G(exec)); + return SUCCESS; } else { phpdbg_error("compile", "type=\"openfailure\" context=\"%s\"", "Could not open file %s", PHPDBG_G(exec)); @@ -570,11 +574,6 @@ static inline void phpdbg_handle_exception(TSRMLS_D) /* }}} */ PHPDBG_COMMAND(run) /* {{{ */ { - if (EG(in_execution)) { - phpdbg_error("inactive", "type=\"isrunning\"", "Cannot start another execution while one is in progress"); - return SUCCESS; - } - if (PHPDBG_G(ops) || PHPDBG_G(exec)) { zend_op **orig_opline = EG(opline_ptr); zend_op_array *orig_op_array = EG(active_op_array); @@ -582,6 +581,14 @@ PHPDBG_COMMAND(run) /* {{{ */ zend_bool restore = 1; zend_execute_data *ex = EG(current_execute_data); + if (EG(in_execution)) { + if (phpdbg_ask_user_permission("Do you really want to restart execution?" TSRMLS_CC) == SUCCESS) { + phpdbg_startup_run++; + phpdbg_clean(1 TSRMLS_CC); + } + return SUCCESS; + } + if (!PHPDBG_G(ops)) { if (phpdbg_compile(TSRMLS_C) == FAILURE) { phpdbg_error("compile", "type=\"compilefailure\" context=\"%s\"", "Failed to compile %s, cannot run", PHPDBG_G(exec)); @@ -643,7 +650,7 @@ PHPDBG_COMMAND(run) /* {{{ */ EG(opline_ptr) = orig_opline; EG(return_value_ptr_ptr) = orig_retval_ptr; - if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { + if (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { phpdbg_error("stop", "type=\"bailout\"", "Caught exit/error from VM"); restore = 0; } @@ -1127,7 +1134,7 @@ PHPDBG_COMMAND(register) /* {{{ */ PHPDBG_COMMAND(quit) /* {{{ */ { /* don't allow this to loop, ever ... */ - if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { + if (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { PHPDBG_G(flags) |= PHPDBG_IS_QUITTING; zend_bailout(); } @@ -1138,8 +1145,9 @@ PHPDBG_COMMAND(quit) /* {{{ */ PHPDBG_COMMAND(clean) /* {{{ */ { if (EG(in_execution)) { - phpdbg_error("inactive", "type=\"isrunning\"", "Cannot clean environment while executing"); - return SUCCESS; + if (phpdbg_ask_user_permission("Do you really want to clean your current environment?" TSRMLS_CC) == FAILURE) { + return SUCCESS; + } } phpdbg_out("Cleaning Execution Environment\n"); @@ -1227,60 +1235,64 @@ int phpdbg_interactive(zend_bool allow_async_unsafe TSRMLS_DC) /* {{{ */ PHPDBG_G(flags) |= PHPDBG_IS_INTERACTIVE; - input = phpdbg_read_input(NULL TSRMLS_CC); + while (1) { + if (PHPDBG_G(flags) & PHPDBG_IS_STOPPING) { + zend_bailout(); + } - if (input) { - do { - phpdbg_init_param(&stack, STACK_PARAM); + if (!(input = phpdbg_read_input(NULL TSRMLS_CC))) { + break; + } - if (phpdbg_do_parse(&stack, input TSRMLS_CC) <= 0) { - phpdbg_activate_err_buf(1 TSRMLS_CC); + + phpdbg_init_param(&stack, STACK_PARAM); + + if (phpdbg_do_parse(&stack, input TSRMLS_CC) <= 0) { + phpdbg_activate_err_buf(1 TSRMLS_CC); #ifdef PHP_WIN32 #define PARA ((phpdbg_param_t *)stack.next)->type - if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE && (RUN_PARAM == PARA || EVAL_PARAM == PARA)) { - sigio_watcher_start(); - } + if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE && (RUN_PARAM == PARA || EVAL_PARAM == PARA)) { + sigio_watcher_start(); + } #endif - switch (ret = phpdbg_stack_execute(&stack, allow_async_unsafe TSRMLS_CC)) { - case FAILURE: - if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { - if (!allow_async_unsafe || phpdbg_call_register(&stack TSRMLS_CC) == FAILURE) { - phpdbg_output_err_buf(NULL, "%b", "%b" TSRMLS_CC); - } + switch (ret = phpdbg_stack_execute(&stack, allow_async_unsafe TSRMLS_CC)) { + case FAILURE: + if (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { + if (!allow_async_unsafe || phpdbg_call_register(&stack TSRMLS_CC) == FAILURE) { + phpdbg_output_err_buf(NULL, "%b", "%b" TSRMLS_CC); } - break; - - case PHPDBG_LEAVE: - case PHPDBG_FINISH: - case PHPDBG_UNTIL: - case PHPDBG_NEXT: { - phpdbg_activate_err_buf(0 TSRMLS_CC); - phpdbg_free_err_buf(TSRMLS_C); - if (!EG(in_execution) && !(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { - phpdbg_error("command", "type=\"noexec\"", "Not running"); - } - goto out; } - } + break; - phpdbg_activate_err_buf(0 TSRMLS_CC); - phpdbg_free_err_buf(TSRMLS_C); -#ifdef PHP_WIN32 - if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE && (RUN_PARAM == PARA || EVAL_PARAM == PARA)) { - sigio_watcher_stop(); + case PHPDBG_LEAVE: + case PHPDBG_FINISH: + case PHPDBG_UNTIL: + case PHPDBG_NEXT: { + phpdbg_activate_err_buf(0 TSRMLS_CC); + phpdbg_free_err_buf(TSRMLS_C); + if (!EG(in_execution) && !(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { + phpdbg_error("command", "type=\"noexec\"", "Not running"); + } + break; } -#undef PARA -#endif } - phpdbg_stack_free(&stack); - phpdbg_destroy_input(&input TSRMLS_CC); - PHPDBG_G(req_id) = 0; - } while ((input = phpdbg_read_input(NULL TSRMLS_CC))); + phpdbg_activate_err_buf(0 TSRMLS_CC); + phpdbg_free_err_buf(TSRMLS_C); +#ifdef PHP_WIN32 + if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE && (RUN_PARAM == PARA || EVAL_PARAM == PARA)) { + sigio_watcher_stop(); + } +#undef PARA +#endif + } + + phpdbg_stack_free(&stack); + phpdbg_destroy_input(&input TSRMLS_CC); + PHPDBG_G(req_id) = 0; } -out: if (input) { phpdbg_stack_free(&stack); phpdbg_destroy_input(&input TSRMLS_CC); @@ -1308,6 +1320,7 @@ void phpdbg_clean(zend_bool full TSRMLS_DC) /* {{{ */ } if (full) { + phpdbg_exec = strdup(PHPDBG_G(exec)); /* preserve exec, don't reparse that from cmd */ PHPDBG_G(flags) |= PHPDBG_IS_CLEANING; zend_bailout(); @@ -1593,7 +1606,7 @@ void phpdbg_force_interruption(TSRMLS_D) { next: PHPDBG_G(flags) &= ~PHPDBG_IN_SIGNAL_HANDLER; - if (PHPDBG_G(flags) & PHPDBG_IS_QUITTING) { + if (PHPDBG_G(flags) & PHPDBG_IS_STOPPING) { zend_bailout(); } } From fa3a01374d30a9efb6d455ba952aea2187254420 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Sun, 26 Oct 2014 07:08:29 +0000 Subject: [PATCH 075/398] disable output buffering by default --- phpdbg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpdbg.c b/phpdbg.c index ff03c670d06..f8879d77abb 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -730,7 +730,8 @@ const char phpdbg_ini_hardcoded[] = "log_errors=On\n" "max_execution_time=0\n" "max_input_time=-1\n" -"error_log=\n\0"; +"error_log=\n" +"output_buffering=off\0"; /* overwriteable ini defaults must be set in phpdbg_ini_defaults() */ #define INI_DEFAULT(name, value) \ From 51c1cc4ff5a1ae1606d07de79db07d9d826378cf Mon Sep 17 00:00:00 2001 From: krakjoe Date: Sun, 26 Oct 2014 07:08:29 +0000 Subject: [PATCH 076/398] disable output buffering by default --- sapi/phpdbg/phpdbg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index ff03c670d06..f8879d77abb 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -730,7 +730,8 @@ const char phpdbg_ini_hardcoded[] = "log_errors=On\n" "max_execution_time=0\n" "max_input_time=-1\n" -"error_log=\n\0"; +"error_log=\n" +"output_buffering=off\0"; /* overwriteable ini defaults must be set in phpdbg_ini_defaults() */ #define INI_DEFAULT(name, value) \ From de656f8a49ee0e8cd67812bac579747df9de98fa Mon Sep 17 00:00:00 2001 From: krakjoe Date: Sun, 26 Oct 2014 07:24:35 +0000 Subject: [PATCH 077/398] remove dodgy param parser, bring userland breakpoint api inline with PHP7 --- phpdbg.c | 85 ++++++++--- phpdbg_cmd.c | 73 --------- phpdbg_cmd.h | 1 - phpdbg_parser.c | 396 ++++++++++++++++++++++-------------------------- phpdbg_parser.h | 39 +++-- 5 files changed, 278 insertions(+), 316 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index f8879d77abb..493d8ec20c9 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -301,24 +301,12 @@ static PHP_FUNCTION(phpdbg_exec) } } /* }}} */ -/* {{{ proto void phpdbg_break([integer type, string expression]) +/* {{{ proto void phpdbg_break_next() instructs phpdbg to insert a breakpoint at the next opcode */ -static PHP_FUNCTION(phpdbg_break) +static PHP_FUNCTION(phpdbg_break_next) { - if (ZEND_NUM_ARGS() > 0) { - long type = 0; - char *expr = NULL; - int expr_len = 0; - phpdbg_param_t param; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &type, &expr, &expr_len) == FAILURE) { - return; - } - - phpdbg_parse_param(expr, expr_len, ¶m TSRMLS_CC); - phpdbg_do_break(¶m TSRMLS_CC); - phpdbg_clear_param(¶m TSRMLS_CC); - + if (zend_parse_parameters_none() != SUCCESS) { + return; } else if (EG(current_execute_data) && EG(active_op_array)) { zend_ulong opline_num = (EG(current_execute_data)->opline - EG(active_op_array)->opcodes); @@ -328,6 +316,48 @@ static PHP_FUNCTION(phpdbg_break) } } /* }}} */ +/* {{{ proto void phpdbg_break_file(string file, integer line) */ +static PHP_FUNCTION(phpdbg_break_file) +{ + char *file = NULL; + int flen = 0; + long line; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &file, &flen, &line) == FAILURE) { + return; + } + + phpdbg_set_breakpoint_file(file, line TSRMLS_CC); +} /* }}} */ + +/* {{{ proto void phpdbg_break_method(string class, string method) */ +static PHP_FUNCTION(phpdbg_break_method) +{ + char *class = NULL, + *method = NULL; + int clen = 0, + mlen = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &class, &clen, &method, &mlen) == FAILURE) { + return; + } + + phpdbg_set_breakpoint_method(class, method TSRMLS_CC); +} /* }}} */ + +/* {{{ proto void phpdbg_break_function(string function) */ +static PHP_FUNCTION(phpdbg_break_function) +{ + char *function = NULL; + int function_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &function, &function_len) == FAILURE) { + return; + } + + phpdbg_set_breakpoint_symbol(function, function_len TSRMLS_CC); +} /* }}} */ + /* {{{ proto void phpdbg_clear(void) instructs phpdbg to clear breakpoints */ static PHP_FUNCTION(phpdbg_clear) @@ -377,9 +407,21 @@ static PHP_FUNCTION(phpdbg_prompt) phpdbg_set_prompt(prompt TSRMLS_CC); } /* }}} */ -ZEND_BEGIN_ARG_INFO_EX(phpdbg_break_arginfo, 0, 0, 0) - ZEND_ARG_INFO(0, type) - ZEND_ARG_INFO(0, expression) +ZEND_BEGIN_ARG_INFO_EX(phpdbg_break_next_arginfo, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(phpdbg_break_file_arginfo, 0, 0, 2) + ZEND_ARG_INFO(0, file) + ZEND_ARG_INFO(0, line) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(phpdbg_break_method_arginfo, 0, 0, 2) + ZEND_ARG_INFO(0, class) + ZEND_ARG_INFO(0, method) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(phpdbg_break_function_arginfo, 0, 0, 1) + ZEND_ARG_INFO(0, function) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(phpdbg_color_arginfo, 0, 0, 0) @@ -400,7 +442,10 @@ ZEND_END_ARG_INFO() zend_function_entry phpdbg_user_functions[] = { PHP_FE(phpdbg_clear, phpdbg_clear_arginfo) - PHP_FE(phpdbg_break, phpdbg_break_arginfo) + PHP_FE(phpdbg_break_next, phpdbg_break_next_arginfo) + PHP_FE(phpdbg_break_file, phpdbg_break_file_arginfo) + PHP_FE(phpdbg_break_method, phpdbg_break_method_arginfo) + PHP_FE(phpdbg_break_function, phpdbg_break_function_arginfo) PHP_FE(phpdbg_exec, phpdbg_exec_arginfo) PHP_FE(phpdbg_color, phpdbg_color_arginfo) PHP_FE(phpdbg_prompt, phpdbg_prompt_arginfo) diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index ab0755454ec..13d5a0d6340 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -70,79 +70,6 @@ PHPDBG_API const char *phpdbg_get_param_type(const phpdbg_param_t *param TSRMLS_ } } -PHPDBG_API phpdbg_param_type phpdbg_parse_param(const char *str, size_t len, phpdbg_param_t *param TSRMLS_DC) /* {{{ */ -{ - char *class_name, *func_name; - - if (len == 0) { - param->type = EMPTY_PARAM; - goto parsed; - } - - if (phpdbg_is_addr(str)) { - param->addr = strtoul(str, 0, 16); - param->type = ADDR_PARAM; - goto parsed; - - } else if (phpdbg_is_numeric(str)) { - param->num = strtol(str, NULL, 0); - param->type = NUMERIC_PARAM; - goto parsed; - - } else if (phpdbg_is_class_method(str, len+1, &class_name, &func_name)) { - param->method.class = class_name; - param->method.name = func_name; - param->type = METHOD_PARAM; - goto parsed; - } else { - char *line_pos = strrchr(str, ':'); - - if (line_pos && phpdbg_is_numeric(line_pos+1)) { - if (strchr(str, ':') == line_pos) { - char path[MAXPATHLEN]; - - memcpy(path, str, line_pos - str); - path[line_pos - str] = 0; - *line_pos = 0; - param->file.name = phpdbg_resolve_path(path TSRMLS_CC); - param->file.line = strtol(line_pos+1, NULL, 0); - param->type = FILE_PARAM; - - goto parsed; - } - } - - line_pos = strrchr(str, '#'); - - if (line_pos && phpdbg_is_numeric(line_pos+1)) { - if (strchr(str, '#') == line_pos) { - param->num = strtol(line_pos + 1, NULL, 0); - - if (phpdbg_is_class_method(str, line_pos - str, &class_name, &func_name)) { - param->method.class = class_name; - param->method.name = func_name; - param->type = NUMERIC_METHOD_PARAM; - } else { - param->len = line_pos - str; - param->str = estrndup(str, param->len); - param->type = NUMERIC_FUNCTION_PARAM; - } - - goto parsed; - } - } - } - - param->str = estrndup(str, len); - param->len = len; - param->type = STR_PARAM; - -parsed: - phpdbg_debug("phpdbg_parse_param(\"%s\", %lu): %s", - str, len, phpdbg_get_param_type(param TSRMLS_CC)); - return param->type; -} /* }}} */ - PHPDBG_API void phpdbg_clear_param(phpdbg_param_t *param TSRMLS_DC) /* {{{ */ { if (param) { diff --git a/phpdbg_cmd.h b/phpdbg_cmd.h index 4c9e5383d82..a79641c0800 100644 --- a/phpdbg_cmd.h +++ b/phpdbg_cmd.h @@ -145,7 +145,6 @@ PHPDBG_API void phpdbg_stack_free(phpdbg_param_t *stack); /* * Parameter Management */ -PHPDBG_API phpdbg_param_type phpdbg_parse_param(const char*, size_t, phpdbg_param_t* TSRMLS_DC); PHPDBG_API void phpdbg_clear_param(phpdbg_param_t* TSRMLS_DC); PHPDBG_API void phpdbg_copy_param(const phpdbg_param_t*, phpdbg_param_t* TSRMLS_DC); PHPDBG_API zend_bool phpdbg_match_param(const phpdbg_param_t *, const phpdbg_param_t * TSRMLS_DC); diff --git a/phpdbg_parser.c b/phpdbg_parser.c index c7668683699..433423db872 100644 --- a/phpdbg_parser.c +++ b/phpdbg_parser.c @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.5. */ +/* A Bison parser, made by GNU Bison 2.7. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.5" +#define YYBISON_VERSION "2.7" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -58,8 +58,6 @@ /* Pull parsers. */ #define YYPULL 1 -/* Using locations. */ -#define YYLSP_NEEDED 0 /* Substitute the variable and function names. */ #define yyparse phpdbg_parse @@ -70,11 +68,9 @@ #define yydebug phpdbg_debug #define yynerrs phpdbg_nerrs - /* Copy the first part of user declarations. */ - -/* Line 268 of yacc.c */ -#line 1 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 371 of yacc.c */ +#line 1 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" /* @@ -101,14 +97,16 @@ static int yyerror(void ***tsrm_ls, const char *msg); ZEND_EXTERN_MODULE_GLOBALS(phpdbg); +/* Line 371 of yacc.c */ +#line 102 "sapi/phpdbg/phpdbg_parser.c" -/* Line 268 of yacc.c */ -#line 107 "sapi/phpdbg/phpdbg_parser.c" - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif +# ifndef YY_NULL +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULL nullptr +# else +# define YY_NULL 0 +# endif +# endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE @@ -118,15 +116,20 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg); # define YYERROR_VERBOSE 1 #endif -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 0 +/* In a future release of Bison, this section will be replaced + by #include "phpdbg_parser.h". */ +#ifndef YY_PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED +# define YY_PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int phpdbg_debug; #endif - /* "%code requires" blocks. */ - -/* Line 288 of yacc.c */ -#line 31 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 387 of yacc.c */ +#line 31 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" #include "phpdbg.h" #ifndef YY_TYPEDEF_YY_SCANNER_T @@ -135,9 +138,8 @@ typedef void* yyscan_t; #endif - -/* Line 288 of yacc.c */ -#line 141 "sapi/phpdbg/phpdbg_parser.c" +/* Line 387 of yacc.c */ +#line 143 "sapi/phpdbg/phpdbg_parser.c" /* Tokens. */ #ifndef YYTOKENTYPE @@ -189,7 +191,6 @@ typedef void* yyscan_t; - #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 @@ -198,11 +199,26 @@ typedef int YYSTYPE; #endif +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int phpdbg_parse (void *YYPARSE_PARAM); +#else +int phpdbg_parse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int phpdbg_parse (void *tsrm_ls); +#else +int phpdbg_parse (); +#endif +#endif /* ! YYPARSE_PARAM */ + +#endif /* !YY_PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED */ + /* Copy the second part of user declarations. */ - -/* Line 343 of yacc.c */ -#line 206 "sapi/phpdbg/phpdbg_parser.c" +/* Line 390 of yacc.c */ +#line 222 "sapi/phpdbg/phpdbg_parser.c" #ifdef short # undef short @@ -255,24 +271,24 @@ typedef short int yytype_int16; # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) # endif # endif # ifndef YY_ -# define YY_(msgid) msgid +# define YY_(Msgid) Msgid # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ -# define YYUSE(e) ((void) (e)) +# define YYUSE(E) ((void) (E)) #else -# define YYUSE(e) /* empty */ +# define YYUSE(E) /* empty */ #endif /* Identity function, used to suppress warnings about constant conditions. */ #ifndef lint -# define YYID(n) (n) +# define YYID(N) (N) #else #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) @@ -308,6 +324,7 @@ YYID (yyi) # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ + /* Use EXIT_SUCCESS as a witness for stdlib.h. */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif @@ -399,20 +416,20 @@ union yyalloc #endif #if defined YYCOPY_NEEDED && YYCOPY_NEEDED -/* Copy COUNT objects from FROM to TO. The source and destination do +/* Copy COUNT objects from SRC to DST. The source and destination do not overlap. */ # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# define YYCOPY(Dst, Src, Count) \ + __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) # else -# define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ +# define YYCOPY(Dst, Src, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (Dst)[yyi] = (Src)[yyi]; \ + } \ while (YYID (0)) # endif # endif @@ -505,7 +522,7 @@ static const yytype_uint8 yyrline[] = }; #endif -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +#if YYDEBUG || YYERROR_VERBOSE || 1 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = @@ -519,7 +536,7 @@ static const char *const yytname[] = "\"opcode\"", "\"identifier (command or function name)\"", "\"input (input string or data)\"", "\"input\"", "\"request id (-r %d)\"", "$accept", "input", "parameters", "parameter", - "req_id", "full_expression", 0 + "req_id", "full_expression", YY_NULL }; #endif @@ -599,10 +616,10 @@ static const yytype_uint8 yytable[] = 32, 36, 39, 40, 0, 0, 41, 42, 27 }; -#define yypact_value_is_default(yystate) \ - ((yystate) == (-16)) +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-16))) -#define yytable_value_is_error(yytable_value) \ +#define yytable_value_is_error(Yytable_value) \ YYID (0) static const yytype_int8 yycheck[] = @@ -652,62 +669,35 @@ static const yytype_uint8 yystos[] = #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (1); \ - goto yybackup; \ - } \ - else \ - { \ +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ yyerror (tsrm_ls, YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (YYID (0)) - +/* Error token number */ #define YYTERROR 1 #define YYERRCODE 256 -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (YYID (N)) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC (Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC (Rhs, 0).last_column; \ - } \ - while (YYID (0)) -#endif - - /* This macro is provided for backward compatibility. */ - #ifndef YY_LOCATION_PRINT # define YY_LOCATION_PRINT(File, Loc) ((void) 0) #endif /* YYLEX -- calling `yylex' with the right arguments. */ - #ifdef YYLEX_PARAM # define YYLEX yylex (&yylval, YYLEX_PARAM) #else @@ -758,6 +748,8 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, tsrm_ls) void *tsrm_ls; #endif { + FILE *yyo = yyoutput; + YYUSE (yyo); if (!yyvaluep) return; YYUSE (tsrm_ls); @@ -770,7 +762,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, tsrm_ls) switch (yytype) { default: - break; + break; } } @@ -1012,12 +1004,11 @@ static int yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken) { - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); + YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ - const char *yyformat = 0; + const char *yyformat = YY_NULL; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per @@ -1077,11 +1068,13 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, break; } yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; + { + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } } } } @@ -1101,10 +1094,12 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, # undef YYCASE_ } - yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; + { + YYSIZE_T yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } if (*yymsg_alloc < yysize) { @@ -1166,25 +1161,11 @@ yydestruct (yymsg, yytype, yyvaluep, tsrm_ls) { default: - break; + break; } } -/* Prevent warnings from -Wmissing-prototypes. */ -#ifdef YYPARSE_PARAM -#if defined __STDC__ || defined __cplusplus -int yyparse (void *YYPARSE_PARAM); -#else -int yyparse (); -#endif -#else /* ! YYPARSE_PARAM */ -#if defined __STDC__ || defined __cplusplus -int yyparse (void *tsrm_ls); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ /*----------. @@ -1216,8 +1197,31 @@ yyparse (tsrm_ls) /* The lookahead symbol. */ int yychar; + +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") +#else +/* Default value used for initialization, for pacifying older GCCs + or non-GCC compilers. */ +static YYSTYPE yyval_default; +# define YY_INITIAL_VALUE(Value) = Value +#endif +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ +#endif + /* The semantic value of the lookahead symbol. */ -YYSTYPE yylval; +YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); /* Number of syntax errors so far. */ int yynerrs; @@ -1230,7 +1234,7 @@ YYSTYPE yylval; `yyss': related to states. `yyvs': related to semantic values. - Refer to the stacks thru separate pointers, to allow yyoverflow + Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ @@ -1248,7 +1252,7 @@ YYSTYPE yylval; int yyn; int yyresult; /* Lookahead token as an internal (translated) token number. */ - int yytoken; + int yytoken = 0; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; @@ -1266,9 +1270,8 @@ YYSTYPE yylval; Keep to zero when no symbol should be popped. */ int yylen = 0; - yytoken = 0; - yyss = yyssa; - yyvs = yyvsa; + yyssp = yyss = yyssa; + yyvsp = yyvs = yyvsa; yystacksize = YYINITDEPTH; YYDPRINTF ((stderr, "Starting parse\n")); @@ -1277,14 +1280,6 @@ YYSTYPE yylval; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - yyssp = yyss; - yyvsp = yyvs; - goto yysetstate; /*------------------------------------------------------------. @@ -1425,7 +1420,9 @@ yybackup: yychar = YYEMPTY; yystate = yyn; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END goto yynewstate; @@ -1462,37 +1459,32 @@ yyreduce: switch (yyn) { case 3: - -/* Line 1806 of yacc.c */ -#line 68 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 68 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { phpdbg_stack_push(PHPDBG_G(parser_stack), &(yyvsp[(1) - (1)])); } break; case 5: - -/* Line 1806 of yacc.c */ -#line 73 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 73 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { phpdbg_stack_push(PHPDBG_G(parser_stack), &(yyvsp[(1) - (1)])); } break; case 6: - -/* Line 1806 of yacc.c */ -#line 74 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 74 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { phpdbg_stack_push(PHPDBG_G(parser_stack), &(yyvsp[(2) - (2)])); } break; case 7: - -/* Line 1806 of yacc.c */ -#line 75 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 75 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (2)]); } break; case 8: - -/* Line 1806 of yacc.c */ -#line 79 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 79 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = FILE_PARAM; (yyval).file.name = (yyvsp[(2) - (3)]).str; @@ -1501,9 +1493,8 @@ yyreduce: break; case 9: - -/* Line 1806 of yacc.c */ -#line 84 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 84 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = NUMERIC_FILE_PARAM; (yyval).file.name = (yyvsp[(1) - (4)]).str; @@ -1512,9 +1503,8 @@ yyreduce: break; case 10: - -/* Line 1806 of yacc.c */ -#line 89 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 89 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = FILE_PARAM; (yyval).file.name = malloc((yyvsp[(1) - (4)]).len + (yyvsp[(2) - (4)]).len + 1); @@ -1528,9 +1518,8 @@ yyreduce: break; case 11: - -/* Line 1806 of yacc.c */ -#line 99 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 99 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = NUMERIC_FILE_PARAM; (yyval).file.name = malloc((yyvsp[(1) - (5)]).len + (yyvsp[(2) - (5)]).len + 1); @@ -1544,9 +1533,8 @@ yyreduce: break; case 12: - -/* Line 1806 of yacc.c */ -#line 109 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 109 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = METHOD_PARAM; (yyval).method.class = (yyvsp[(1) - (3)]).str; @@ -1555,9 +1543,8 @@ yyreduce: break; case 13: - -/* Line 1806 of yacc.c */ -#line 114 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 114 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = NUMERIC_METHOD_PARAM; (yyval).method.class = (yyvsp[(1) - (5)]).str; @@ -1567,9 +1554,8 @@ yyreduce: break; case 14: - -/* Line 1806 of yacc.c */ -#line 120 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 120 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = NUMERIC_FUNCTION_PARAM; (yyval).str = (yyvsp[(1) - (3)]).str; @@ -1579,9 +1565,8 @@ yyreduce: break; case 15: - -/* Line 1806 of yacc.c */ -#line 126 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 126 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = COND_PARAM; (yyval).str = (yyvsp[(2) - (2)]).str; @@ -1590,65 +1575,56 @@ yyreduce: break; case 16: - -/* Line 1806 of yacc.c */ -#line 131 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 131 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 17: - -/* Line 1806 of yacc.c */ -#line 132 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 132 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 18: - -/* Line 1806 of yacc.c */ -#line 133 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 133 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 19: - -/* Line 1806 of yacc.c */ -#line 134 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 134 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 20: - -/* Line 1806 of yacc.c */ -#line 135 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 135 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 21: - -/* Line 1806 of yacc.c */ -#line 136 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 136 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 22: - -/* Line 1806 of yacc.c */ -#line 137 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 137 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 23: - -/* Line 1806 of yacc.c */ -#line 141 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 141 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { PHPDBG_G(req_id) = (yyvsp[(1) - (1)]).num; } break; case 25: - -/* Line 1806 of yacc.c */ -#line 146 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 146 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = EVAL_PARAM; (yyval).str = (yyvsp[(3) - (3)]).str; @@ -1657,9 +1633,8 @@ yyreduce: break; case 26: - -/* Line 1806 of yacc.c */ -#line 151 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 151 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = SHELL_PARAM; (yyval).str = (yyvsp[(3) - (3)]).str; @@ -1668,9 +1643,8 @@ yyreduce: break; case 27: - -/* Line 1806 of yacc.c */ -#line 156 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 156 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = RUN_PARAM; (yyval).len = 0; @@ -1678,9 +1652,8 @@ yyreduce: break; case 28: - -/* Line 1806 of yacc.c */ -#line 160 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 160 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = RUN_PARAM; (yyval).str = (yyvsp[(3) - (3)]).str; @@ -1689,9 +1662,8 @@ yyreduce: break; - -/* Line 1806 of yacc.c */ -#line 1695 "sapi/phpdbg/phpdbg_parser.c" +/* Line 1792 of yacc.c */ +#line 1667 "sapi/phpdbg/phpdbg_parser.c" default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -1854,7 +1826,9 @@ yyerrlab1: YY_STACK_PRINT (yyss, yyssp); } + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END /* Shift the error token. */ @@ -1878,7 +1852,7 @@ yyabortlab: yyresult = 1; goto yyreturn; -#if !defined(yyoverflow) || YYERROR_VERBOSE +#if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -1920,9 +1894,8 @@ yyreturn: } - -/* Line 2067 of yacc.c */ -#line 167 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 2055 of yacc.c */ +#line 167 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" static int yyerror(void ***tsrm_ls, const char *msg) { @@ -1948,4 +1921,3 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC) { return yyparse(NULL); #endif } - diff --git a/phpdbg_parser.h b/phpdbg_parser.h index dfa155d7184..4cd8ed6d008 100644 --- a/phpdbg_parser.h +++ b/phpdbg_parser.h @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.5. */ +/* A Bison parser, made by GNU Bison 2.7. */ /* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,10 +30,18 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ +#ifndef YY_PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED +# define YY_PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int phpdbg_debug; +#endif /* "%code requires" blocks. */ - -/* Line 2068 of yacc.c */ -#line 31 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 2058 of yacc.c */ +#line 31 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" #include "phpdbg.h" #ifndef YY_TYPEDEF_YY_SCANNER_T @@ -42,9 +50,8 @@ typedef void* yyscan_t; #endif - -/* Line 2068 of yacc.c */ -#line 48 "sapi/phpdbg/phpdbg_parser.h" +/* Line 2058 of yacc.c */ +#line 55 "sapi/phpdbg/phpdbg_parser.h" /* Tokens. */ #ifndef YYTOKENTYPE @@ -96,7 +103,6 @@ typedef void* yyscan_t; - #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 @@ -105,5 +111,18 @@ typedef int YYSTYPE; #endif +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int phpdbg_parse (void *YYPARSE_PARAM); +#else +int phpdbg_parse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int phpdbg_parse (void *tsrm_ls); +#else +int phpdbg_parse (); +#endif +#endif /* ! YYPARSE_PARAM */ - +#endif /* !YY_PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED */ From 41537cdddc71a6e499f1c7c118bf862105ff95fa Mon Sep 17 00:00:00 2001 From: krakjoe Date: Sun, 26 Oct 2014 07:24:35 +0000 Subject: [PATCH 078/398] remove dodgy param parser, bring userland breakpoint api inline with PHP7 --- sapi/phpdbg/phpdbg.c | 85 ++++++-- sapi/phpdbg/phpdbg_cmd.c | 73 ------- sapi/phpdbg/phpdbg_cmd.h | 1 - sapi/phpdbg/phpdbg_parser.c | 396 +++++++++++++++++------------------- sapi/phpdbg/phpdbg_parser.h | 39 +++- 5 files changed, 278 insertions(+), 316 deletions(-) diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index f8879d77abb..493d8ec20c9 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -301,24 +301,12 @@ static PHP_FUNCTION(phpdbg_exec) } } /* }}} */ -/* {{{ proto void phpdbg_break([integer type, string expression]) +/* {{{ proto void phpdbg_break_next() instructs phpdbg to insert a breakpoint at the next opcode */ -static PHP_FUNCTION(phpdbg_break) +static PHP_FUNCTION(phpdbg_break_next) { - if (ZEND_NUM_ARGS() > 0) { - long type = 0; - char *expr = NULL; - int expr_len = 0; - phpdbg_param_t param; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &type, &expr, &expr_len) == FAILURE) { - return; - } - - phpdbg_parse_param(expr, expr_len, ¶m TSRMLS_CC); - phpdbg_do_break(¶m TSRMLS_CC); - phpdbg_clear_param(¶m TSRMLS_CC); - + if (zend_parse_parameters_none() != SUCCESS) { + return; } else if (EG(current_execute_data) && EG(active_op_array)) { zend_ulong opline_num = (EG(current_execute_data)->opline - EG(active_op_array)->opcodes); @@ -328,6 +316,48 @@ static PHP_FUNCTION(phpdbg_break) } } /* }}} */ +/* {{{ proto void phpdbg_break_file(string file, integer line) */ +static PHP_FUNCTION(phpdbg_break_file) +{ + char *file = NULL; + int flen = 0; + long line; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &file, &flen, &line) == FAILURE) { + return; + } + + phpdbg_set_breakpoint_file(file, line TSRMLS_CC); +} /* }}} */ + +/* {{{ proto void phpdbg_break_method(string class, string method) */ +static PHP_FUNCTION(phpdbg_break_method) +{ + char *class = NULL, + *method = NULL; + int clen = 0, + mlen = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &class, &clen, &method, &mlen) == FAILURE) { + return; + } + + phpdbg_set_breakpoint_method(class, method TSRMLS_CC); +} /* }}} */ + +/* {{{ proto void phpdbg_break_function(string function) */ +static PHP_FUNCTION(phpdbg_break_function) +{ + char *function = NULL; + int function_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &function, &function_len) == FAILURE) { + return; + } + + phpdbg_set_breakpoint_symbol(function, function_len TSRMLS_CC); +} /* }}} */ + /* {{{ proto void phpdbg_clear(void) instructs phpdbg to clear breakpoints */ static PHP_FUNCTION(phpdbg_clear) @@ -377,9 +407,21 @@ static PHP_FUNCTION(phpdbg_prompt) phpdbg_set_prompt(prompt TSRMLS_CC); } /* }}} */ -ZEND_BEGIN_ARG_INFO_EX(phpdbg_break_arginfo, 0, 0, 0) - ZEND_ARG_INFO(0, type) - ZEND_ARG_INFO(0, expression) +ZEND_BEGIN_ARG_INFO_EX(phpdbg_break_next_arginfo, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(phpdbg_break_file_arginfo, 0, 0, 2) + ZEND_ARG_INFO(0, file) + ZEND_ARG_INFO(0, line) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(phpdbg_break_method_arginfo, 0, 0, 2) + ZEND_ARG_INFO(0, class) + ZEND_ARG_INFO(0, method) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(phpdbg_break_function_arginfo, 0, 0, 1) + ZEND_ARG_INFO(0, function) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(phpdbg_color_arginfo, 0, 0, 0) @@ -400,7 +442,10 @@ ZEND_END_ARG_INFO() zend_function_entry phpdbg_user_functions[] = { PHP_FE(phpdbg_clear, phpdbg_clear_arginfo) - PHP_FE(phpdbg_break, phpdbg_break_arginfo) + PHP_FE(phpdbg_break_next, phpdbg_break_next_arginfo) + PHP_FE(phpdbg_break_file, phpdbg_break_file_arginfo) + PHP_FE(phpdbg_break_method, phpdbg_break_method_arginfo) + PHP_FE(phpdbg_break_function, phpdbg_break_function_arginfo) PHP_FE(phpdbg_exec, phpdbg_exec_arginfo) PHP_FE(phpdbg_color, phpdbg_color_arginfo) PHP_FE(phpdbg_prompt, phpdbg_prompt_arginfo) diff --git a/sapi/phpdbg/phpdbg_cmd.c b/sapi/phpdbg/phpdbg_cmd.c index ab0755454ec..13d5a0d6340 100644 --- a/sapi/phpdbg/phpdbg_cmd.c +++ b/sapi/phpdbg/phpdbg_cmd.c @@ -70,79 +70,6 @@ PHPDBG_API const char *phpdbg_get_param_type(const phpdbg_param_t *param TSRMLS_ } } -PHPDBG_API phpdbg_param_type phpdbg_parse_param(const char *str, size_t len, phpdbg_param_t *param TSRMLS_DC) /* {{{ */ -{ - char *class_name, *func_name; - - if (len == 0) { - param->type = EMPTY_PARAM; - goto parsed; - } - - if (phpdbg_is_addr(str)) { - param->addr = strtoul(str, 0, 16); - param->type = ADDR_PARAM; - goto parsed; - - } else if (phpdbg_is_numeric(str)) { - param->num = strtol(str, NULL, 0); - param->type = NUMERIC_PARAM; - goto parsed; - - } else if (phpdbg_is_class_method(str, len+1, &class_name, &func_name)) { - param->method.class = class_name; - param->method.name = func_name; - param->type = METHOD_PARAM; - goto parsed; - } else { - char *line_pos = strrchr(str, ':'); - - if (line_pos && phpdbg_is_numeric(line_pos+1)) { - if (strchr(str, ':') == line_pos) { - char path[MAXPATHLEN]; - - memcpy(path, str, line_pos - str); - path[line_pos - str] = 0; - *line_pos = 0; - param->file.name = phpdbg_resolve_path(path TSRMLS_CC); - param->file.line = strtol(line_pos+1, NULL, 0); - param->type = FILE_PARAM; - - goto parsed; - } - } - - line_pos = strrchr(str, '#'); - - if (line_pos && phpdbg_is_numeric(line_pos+1)) { - if (strchr(str, '#') == line_pos) { - param->num = strtol(line_pos + 1, NULL, 0); - - if (phpdbg_is_class_method(str, line_pos - str, &class_name, &func_name)) { - param->method.class = class_name; - param->method.name = func_name; - param->type = NUMERIC_METHOD_PARAM; - } else { - param->len = line_pos - str; - param->str = estrndup(str, param->len); - param->type = NUMERIC_FUNCTION_PARAM; - } - - goto parsed; - } - } - } - - param->str = estrndup(str, len); - param->len = len; - param->type = STR_PARAM; - -parsed: - phpdbg_debug("phpdbg_parse_param(\"%s\", %lu): %s", - str, len, phpdbg_get_param_type(param TSRMLS_CC)); - return param->type; -} /* }}} */ - PHPDBG_API void phpdbg_clear_param(phpdbg_param_t *param TSRMLS_DC) /* {{{ */ { if (param) { diff --git a/sapi/phpdbg/phpdbg_cmd.h b/sapi/phpdbg/phpdbg_cmd.h index 4c9e5383d82..a79641c0800 100644 --- a/sapi/phpdbg/phpdbg_cmd.h +++ b/sapi/phpdbg/phpdbg_cmd.h @@ -145,7 +145,6 @@ PHPDBG_API void phpdbg_stack_free(phpdbg_param_t *stack); /* * Parameter Management */ -PHPDBG_API phpdbg_param_type phpdbg_parse_param(const char*, size_t, phpdbg_param_t* TSRMLS_DC); PHPDBG_API void phpdbg_clear_param(phpdbg_param_t* TSRMLS_DC); PHPDBG_API void phpdbg_copy_param(const phpdbg_param_t*, phpdbg_param_t* TSRMLS_DC); PHPDBG_API zend_bool phpdbg_match_param(const phpdbg_param_t *, const phpdbg_param_t * TSRMLS_DC); diff --git a/sapi/phpdbg/phpdbg_parser.c b/sapi/phpdbg/phpdbg_parser.c index c7668683699..433423db872 100644 --- a/sapi/phpdbg/phpdbg_parser.c +++ b/sapi/phpdbg/phpdbg_parser.c @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.5. */ +/* A Bison parser, made by GNU Bison 2.7. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.5" +#define YYBISON_VERSION "2.7" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -58,8 +58,6 @@ /* Pull parsers. */ #define YYPULL 1 -/* Using locations. */ -#define YYLSP_NEEDED 0 /* Substitute the variable and function names. */ #define yyparse phpdbg_parse @@ -70,11 +68,9 @@ #define yydebug phpdbg_debug #define yynerrs phpdbg_nerrs - /* Copy the first part of user declarations. */ - -/* Line 268 of yacc.c */ -#line 1 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 371 of yacc.c */ +#line 1 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" /* @@ -101,14 +97,16 @@ static int yyerror(void ***tsrm_ls, const char *msg); ZEND_EXTERN_MODULE_GLOBALS(phpdbg); +/* Line 371 of yacc.c */ +#line 102 "sapi/phpdbg/phpdbg_parser.c" -/* Line 268 of yacc.c */ -#line 107 "sapi/phpdbg/phpdbg_parser.c" - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif +# ifndef YY_NULL +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULL nullptr +# else +# define YY_NULL 0 +# endif +# endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE @@ -118,15 +116,20 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg); # define YYERROR_VERBOSE 1 #endif -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 0 +/* In a future release of Bison, this section will be replaced + by #include "phpdbg_parser.h". */ +#ifndef YY_PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED +# define YY_PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int phpdbg_debug; #endif - /* "%code requires" blocks. */ - -/* Line 288 of yacc.c */ -#line 31 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 387 of yacc.c */ +#line 31 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" #include "phpdbg.h" #ifndef YY_TYPEDEF_YY_SCANNER_T @@ -135,9 +138,8 @@ typedef void* yyscan_t; #endif - -/* Line 288 of yacc.c */ -#line 141 "sapi/phpdbg/phpdbg_parser.c" +/* Line 387 of yacc.c */ +#line 143 "sapi/phpdbg/phpdbg_parser.c" /* Tokens. */ #ifndef YYTOKENTYPE @@ -189,7 +191,6 @@ typedef void* yyscan_t; - #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 @@ -198,11 +199,26 @@ typedef int YYSTYPE; #endif +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int phpdbg_parse (void *YYPARSE_PARAM); +#else +int phpdbg_parse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int phpdbg_parse (void *tsrm_ls); +#else +int phpdbg_parse (); +#endif +#endif /* ! YYPARSE_PARAM */ + +#endif /* !YY_PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED */ + /* Copy the second part of user declarations. */ - -/* Line 343 of yacc.c */ -#line 206 "sapi/phpdbg/phpdbg_parser.c" +/* Line 390 of yacc.c */ +#line 222 "sapi/phpdbg/phpdbg_parser.c" #ifdef short # undef short @@ -255,24 +271,24 @@ typedef short int yytype_int16; # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) # endif # endif # ifndef YY_ -# define YY_(msgid) msgid +# define YY_(Msgid) Msgid # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ -# define YYUSE(e) ((void) (e)) +# define YYUSE(E) ((void) (E)) #else -# define YYUSE(e) /* empty */ +# define YYUSE(E) /* empty */ #endif /* Identity function, used to suppress warnings about constant conditions. */ #ifndef lint -# define YYID(n) (n) +# define YYID(N) (N) #else #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) @@ -308,6 +324,7 @@ YYID (yyi) # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ + /* Use EXIT_SUCCESS as a witness for stdlib.h. */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif @@ -399,20 +416,20 @@ union yyalloc #endif #if defined YYCOPY_NEEDED && YYCOPY_NEEDED -/* Copy COUNT objects from FROM to TO. The source and destination do +/* Copy COUNT objects from SRC to DST. The source and destination do not overlap. */ # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# define YYCOPY(Dst, Src, Count) \ + __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) # else -# define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ +# define YYCOPY(Dst, Src, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (Dst)[yyi] = (Src)[yyi]; \ + } \ while (YYID (0)) # endif # endif @@ -505,7 +522,7 @@ static const yytype_uint8 yyrline[] = }; #endif -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +#if YYDEBUG || YYERROR_VERBOSE || 1 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = @@ -519,7 +536,7 @@ static const char *const yytname[] = "\"opcode\"", "\"identifier (command or function name)\"", "\"input (input string or data)\"", "\"input\"", "\"request id (-r %d)\"", "$accept", "input", "parameters", "parameter", - "req_id", "full_expression", 0 + "req_id", "full_expression", YY_NULL }; #endif @@ -599,10 +616,10 @@ static const yytype_uint8 yytable[] = 32, 36, 39, 40, 0, 0, 41, 42, 27 }; -#define yypact_value_is_default(yystate) \ - ((yystate) == (-16)) +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-16))) -#define yytable_value_is_error(yytable_value) \ +#define yytable_value_is_error(Yytable_value) \ YYID (0) static const yytype_int8 yycheck[] = @@ -652,62 +669,35 @@ static const yytype_uint8 yystos[] = #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (1); \ - goto yybackup; \ - } \ - else \ - { \ +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ yyerror (tsrm_ls, YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (YYID (0)) - +/* Error token number */ #define YYTERROR 1 #define YYERRCODE 256 -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (YYID (N)) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC (Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC (Rhs, 0).last_column; \ - } \ - while (YYID (0)) -#endif - - /* This macro is provided for backward compatibility. */ - #ifndef YY_LOCATION_PRINT # define YY_LOCATION_PRINT(File, Loc) ((void) 0) #endif /* YYLEX -- calling `yylex' with the right arguments. */ - #ifdef YYLEX_PARAM # define YYLEX yylex (&yylval, YYLEX_PARAM) #else @@ -758,6 +748,8 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, tsrm_ls) void *tsrm_ls; #endif { + FILE *yyo = yyoutput; + YYUSE (yyo); if (!yyvaluep) return; YYUSE (tsrm_ls); @@ -770,7 +762,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, tsrm_ls) switch (yytype) { default: - break; + break; } } @@ -1012,12 +1004,11 @@ static int yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken) { - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); + YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ - const char *yyformat = 0; + const char *yyformat = YY_NULL; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per @@ -1077,11 +1068,13 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, break; } yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; + { + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } } } } @@ -1101,10 +1094,12 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, # undef YYCASE_ } - yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; + { + YYSIZE_T yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } if (*yymsg_alloc < yysize) { @@ -1166,25 +1161,11 @@ yydestruct (yymsg, yytype, yyvaluep, tsrm_ls) { default: - break; + break; } } -/* Prevent warnings from -Wmissing-prototypes. */ -#ifdef YYPARSE_PARAM -#if defined __STDC__ || defined __cplusplus -int yyparse (void *YYPARSE_PARAM); -#else -int yyparse (); -#endif -#else /* ! YYPARSE_PARAM */ -#if defined __STDC__ || defined __cplusplus -int yyparse (void *tsrm_ls); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ /*----------. @@ -1216,8 +1197,31 @@ yyparse (tsrm_ls) /* The lookahead symbol. */ int yychar; + +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") +#else +/* Default value used for initialization, for pacifying older GCCs + or non-GCC compilers. */ +static YYSTYPE yyval_default; +# define YY_INITIAL_VALUE(Value) = Value +#endif +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ +#endif + /* The semantic value of the lookahead symbol. */ -YYSTYPE yylval; +YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); /* Number of syntax errors so far. */ int yynerrs; @@ -1230,7 +1234,7 @@ YYSTYPE yylval; `yyss': related to states. `yyvs': related to semantic values. - Refer to the stacks thru separate pointers, to allow yyoverflow + Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ @@ -1248,7 +1252,7 @@ YYSTYPE yylval; int yyn; int yyresult; /* Lookahead token as an internal (translated) token number. */ - int yytoken; + int yytoken = 0; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; @@ -1266,9 +1270,8 @@ YYSTYPE yylval; Keep to zero when no symbol should be popped. */ int yylen = 0; - yytoken = 0; - yyss = yyssa; - yyvs = yyvsa; + yyssp = yyss = yyssa; + yyvsp = yyvs = yyvsa; yystacksize = YYINITDEPTH; YYDPRINTF ((stderr, "Starting parse\n")); @@ -1277,14 +1280,6 @@ YYSTYPE yylval; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - yyssp = yyss; - yyvsp = yyvs; - goto yysetstate; /*------------------------------------------------------------. @@ -1425,7 +1420,9 @@ yybackup: yychar = YYEMPTY; yystate = yyn; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END goto yynewstate; @@ -1462,37 +1459,32 @@ yyreduce: switch (yyn) { case 3: - -/* Line 1806 of yacc.c */ -#line 68 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 68 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { phpdbg_stack_push(PHPDBG_G(parser_stack), &(yyvsp[(1) - (1)])); } break; case 5: - -/* Line 1806 of yacc.c */ -#line 73 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 73 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { phpdbg_stack_push(PHPDBG_G(parser_stack), &(yyvsp[(1) - (1)])); } break; case 6: - -/* Line 1806 of yacc.c */ -#line 74 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 74 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { phpdbg_stack_push(PHPDBG_G(parser_stack), &(yyvsp[(2) - (2)])); } break; case 7: - -/* Line 1806 of yacc.c */ -#line 75 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 75 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (2)]); } break; case 8: - -/* Line 1806 of yacc.c */ -#line 79 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 79 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = FILE_PARAM; (yyval).file.name = (yyvsp[(2) - (3)]).str; @@ -1501,9 +1493,8 @@ yyreduce: break; case 9: - -/* Line 1806 of yacc.c */ -#line 84 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 84 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = NUMERIC_FILE_PARAM; (yyval).file.name = (yyvsp[(1) - (4)]).str; @@ -1512,9 +1503,8 @@ yyreduce: break; case 10: - -/* Line 1806 of yacc.c */ -#line 89 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 89 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = FILE_PARAM; (yyval).file.name = malloc((yyvsp[(1) - (4)]).len + (yyvsp[(2) - (4)]).len + 1); @@ -1528,9 +1518,8 @@ yyreduce: break; case 11: - -/* Line 1806 of yacc.c */ -#line 99 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 99 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = NUMERIC_FILE_PARAM; (yyval).file.name = malloc((yyvsp[(1) - (5)]).len + (yyvsp[(2) - (5)]).len + 1); @@ -1544,9 +1533,8 @@ yyreduce: break; case 12: - -/* Line 1806 of yacc.c */ -#line 109 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 109 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = METHOD_PARAM; (yyval).method.class = (yyvsp[(1) - (3)]).str; @@ -1555,9 +1543,8 @@ yyreduce: break; case 13: - -/* Line 1806 of yacc.c */ -#line 114 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 114 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = NUMERIC_METHOD_PARAM; (yyval).method.class = (yyvsp[(1) - (5)]).str; @@ -1567,9 +1554,8 @@ yyreduce: break; case 14: - -/* Line 1806 of yacc.c */ -#line 120 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 120 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = NUMERIC_FUNCTION_PARAM; (yyval).str = (yyvsp[(1) - (3)]).str; @@ -1579,9 +1565,8 @@ yyreduce: break; case 15: - -/* Line 1806 of yacc.c */ -#line 126 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 126 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = COND_PARAM; (yyval).str = (yyvsp[(2) - (2)]).str; @@ -1590,65 +1575,56 @@ yyreduce: break; case 16: - -/* Line 1806 of yacc.c */ -#line 131 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 131 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 17: - -/* Line 1806 of yacc.c */ -#line 132 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 132 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 18: - -/* Line 1806 of yacc.c */ -#line 133 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 133 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 19: - -/* Line 1806 of yacc.c */ -#line 134 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 134 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 20: - -/* Line 1806 of yacc.c */ -#line 135 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 135 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 21: - -/* Line 1806 of yacc.c */ -#line 136 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 136 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 22: - -/* Line 1806 of yacc.c */ -#line 137 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 137 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 23: - -/* Line 1806 of yacc.c */ -#line 141 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 141 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { PHPDBG_G(req_id) = (yyvsp[(1) - (1)]).num; } break; case 25: - -/* Line 1806 of yacc.c */ -#line 146 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 146 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = EVAL_PARAM; (yyval).str = (yyvsp[(3) - (3)]).str; @@ -1657,9 +1633,8 @@ yyreduce: break; case 26: - -/* Line 1806 of yacc.c */ -#line 151 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 151 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = SHELL_PARAM; (yyval).str = (yyvsp[(3) - (3)]).str; @@ -1668,9 +1643,8 @@ yyreduce: break; case 27: - -/* Line 1806 of yacc.c */ -#line 156 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 156 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = RUN_PARAM; (yyval).len = 0; @@ -1678,9 +1652,8 @@ yyreduce: break; case 28: - -/* Line 1806 of yacc.c */ -#line 160 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 1792 of yacc.c */ +#line 160 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" { (yyval).type = RUN_PARAM; (yyval).str = (yyvsp[(3) - (3)]).str; @@ -1689,9 +1662,8 @@ yyreduce: break; - -/* Line 1806 of yacc.c */ -#line 1695 "sapi/phpdbg/phpdbg_parser.c" +/* Line 1792 of yacc.c */ +#line 1667 "sapi/phpdbg/phpdbg_parser.c" default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -1854,7 +1826,9 @@ yyerrlab1: YY_STACK_PRINT (yyss, yyssp); } + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END /* Shift the error token. */ @@ -1878,7 +1852,7 @@ yyabortlab: yyresult = 1; goto yyreturn; -#if !defined(yyoverflow) || YYERROR_VERBOSE +#if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -1920,9 +1894,8 @@ yyreturn: } - -/* Line 2067 of yacc.c */ -#line 167 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 2055 of yacc.c */ +#line 167 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" static int yyerror(void ***tsrm_ls, const char *msg) { @@ -1948,4 +1921,3 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC) { return yyparse(NULL); #endif } - diff --git a/sapi/phpdbg/phpdbg_parser.h b/sapi/phpdbg/phpdbg_parser.h index dfa155d7184..4cd8ed6d008 100644 --- a/sapi/phpdbg/phpdbg_parser.h +++ b/sapi/phpdbg/phpdbg_parser.h @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.5. */ +/* A Bison parser, made by GNU Bison 2.7. */ /* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,10 +30,18 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ +#ifndef YY_PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED +# define YY_PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int phpdbg_debug; +#endif /* "%code requires" blocks. */ - -/* Line 2068 of yacc.c */ -#line 31 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y" +/* Line 2058 of yacc.c */ +#line 31 "/usr/src/php-src/sapi/phpdbg/phpdbg_parser.y" #include "phpdbg.h" #ifndef YY_TYPEDEF_YY_SCANNER_T @@ -42,9 +50,8 @@ typedef void* yyscan_t; #endif - -/* Line 2068 of yacc.c */ -#line 48 "sapi/phpdbg/phpdbg_parser.h" +/* Line 2058 of yacc.c */ +#line 55 "sapi/phpdbg/phpdbg_parser.h" /* Tokens. */ #ifndef YYTOKENTYPE @@ -96,7 +103,6 @@ typedef void* yyscan_t; - #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 @@ -105,5 +111,18 @@ typedef int YYSTYPE; #endif +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int phpdbg_parse (void *YYPARSE_PARAM); +#else +int phpdbg_parse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int phpdbg_parse (void *tsrm_ls); +#else +int phpdbg_parse (); +#endif +#endif /* ! YYPARSE_PARAM */ - +#endif /* !YY_PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED */ From af9c6afa6f3465ae5b287af298fb148792f83d06 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sun, 26 Oct 2014 10:48:45 +0100 Subject: [PATCH 079/398] Fix nullptr dereference in clean without exec context --- phpdbg_prompt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 29c75c583c0..eca4c6ac2ba 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -1320,7 +1320,10 @@ void phpdbg_clean(zend_bool full TSRMLS_DC) /* {{{ */ } if (full) { - phpdbg_exec = strdup(PHPDBG_G(exec)); /* preserve exec, don't reparse that from cmd */ + if (PHPDBG_G(exec)) { + phpdbg_exec = strdup(PHPDBG_G(exec)); /* preserve exec, don't reparse that from cmd */ + } + PHPDBG_G(flags) |= PHPDBG_IS_CLEANING; zend_bailout(); From 69bc61de419ccd92bfa308f356b56591f7696413 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sun, 26 Oct 2014 10:48:45 +0100 Subject: [PATCH 080/398] Fix nullptr dereference in clean without exec context --- sapi/phpdbg/phpdbg_prompt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index 29c75c583c0..eca4c6ac2ba 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -1320,7 +1320,10 @@ void phpdbg_clean(zend_bool full TSRMLS_DC) /* {{{ */ } if (full) { - phpdbg_exec = strdup(PHPDBG_G(exec)); /* preserve exec, don't reparse that from cmd */ + if (PHPDBG_G(exec)) { + phpdbg_exec = strdup(PHPDBG_G(exec)); /* preserve exec, don't reparse that from cmd */ + } + PHPDBG_G(flags) |= PHPDBG_IS_CLEANING; zend_bailout(); From 510676fbbf6391b3f1931e99c2c043db79d3326d Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sun, 26 Oct 2014 20:43:49 +0100 Subject: [PATCH 081/398] Stabilize execution, always run destructors and extended file breakpoints --- phpdbg.c | 104 ++++++++++++++++++++++-------- phpdbg.h | 92 +++++++++++++-------------- phpdbg_bp.c | 164 +++++++++++++++++++++++++++++++++++++----------- phpdbg_bp.h | 26 ++++---- phpdbg_cmd.c | 2 +- phpdbg_list.c | 2 + phpdbg_out.c | 2 + phpdbg_prompt.c | 21 +++---- 8 files changed, 276 insertions(+), 137 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index 493d8ec20c9..3e31f76898a 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -46,7 +46,6 @@ ZEND_DECLARE_MODULE_GLOBALS(phpdbg); int phpdbg_startup_run = 0; -char *phpdbg_exec = NULL; static PHP_INI_MH(OnUpdateEol) { @@ -186,7 +185,8 @@ static void php_phpdbg_destroy_registered(void *data) /* {{{ */ static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */ { - zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], 8, NULL, php_phpdbg_destroy_bp_file, 0); + zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], 8, NULL, php_phpdbg_destroy_bp_file, 0); + zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], 8, NULL, php_phpdbg_destroy_bp_file, 0); zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], 8, NULL, php_phpdbg_destroy_bp_symbol, 0); zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], 8, NULL, php_phpdbg_destroy_bp_methods, 0); zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], 8, NULL, php_phpdbg_destroy_bp_methods, 0); @@ -216,8 +216,8 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */ zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_COND]); zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP]); zend_hash_destroy(&PHPDBG_G(seek)); - zend_hash_destroy(&PHPDBG_G(registered)); zend_hash_destroy(&PHPDBG_G(file_sources)); + zend_hash_destroy(&PHPDBG_G(registered)); zend_hash_destroy(&PHPDBG_G(watchpoints)); zend_llist_destroy(&PHPDBG_G(watchlist_mem)); @@ -363,6 +363,7 @@ static PHP_FUNCTION(phpdbg_break_function) static PHP_FUNCTION(phpdbg_clear) { zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING]); zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM]); zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE]); zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE]); @@ -543,11 +544,27 @@ static void php_sapi_phpdbg_log_message(char *message TSRMLS_DC) /* {{{ */ static int php_sapi_phpdbg_deactivate(TSRMLS_D) /* {{{ */ { + if ((PHPDBG_G(flags) & (PHPDBG_IS_CLEANING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_CLEANING) { + zend_phpdbg_globals *pg = PHPDBG_G(backup) = calloc(1, sizeof(zend_phpdbg_globals)); + + php_phpdbg_globals_ctor(pg); + + pg->exec = strndup(PHPDBG_G(exec), PHPDBG_G(exec_len)); + pg->exec_len = PHPDBG_G(exec_len); + 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)); + pg->eol = PHPDBG_G(eol); + pg->flags = PHPDBG_G(flags) & PHPDBG_PRESERVE_FLAGS_MASK; + } + fflush(stdout); if(SG(request_info).argv0) { free(SG(request_info).argv0); SG(request_info).argv0 = NULL; } + return SUCCESS; } /* }}} */ @@ -1009,6 +1026,7 @@ int main(int argc, char **argv) /* {{{ */ zend_ulong zend_extensions_len = 0L; zend_bool ini_ignore; char *ini_override; + char *exec = NULL; char *init_file; size_t init_file_len; zend_bool init_file_default; @@ -1020,6 +1038,7 @@ int main(int argc, char **argv) /* {{{ */ long cleaning = 0; zend_bool remote = 0; int step = 0; + zend_phpdbg_globals *settings = NULL; #ifdef _WIN32 char *bp_tmp_file = NULL; @@ -1102,6 +1121,9 @@ phpdbg_main: opt = 0; step = 0; sapi_name = NULL; + if (settings) { + exec = settings->exec; + } while ((opt = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) { switch (opt) { @@ -1243,12 +1265,12 @@ phpdbg_main: } /* set exec if present on command line */ - if (!phpdbg_exec && (argc > php_optind) && (strcmp(argv[php_optind-1],"--") != SUCCESS)) { + if (!exec && (argc > php_optind) && (strcmp(argv[php_optind-1], "--") != SUCCESS)) { if (strlen(argv[php_optind])) { - if (phpdbg_exec) { - free(phpdbg_exec); + if (exec) { + free(exec); } - phpdbg_exec = strdup(argv[php_optind]); + exec = strdup(argv[php_optind]); } php_optind++; } @@ -1309,20 +1331,31 @@ phpdbg_main: #endif zend_mm_heap *mm_heap; - /* setup remote server if necessary */ - if (!cleaning && listen > 0) { - server = phpdbg_open_socket(address, listen TSRMLS_CC); - if (-1 > server || phpdbg_remote_init(address, listen, server, &socket, &stream TSRMLS_CC) == FAILURE) { - exit(0); + /* set flags from command line */ + PHPDBG_G(flags) = flags; + + if (settings) { +#ifdef ZTS + *((zend_phpdbg_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(phpdbg_globals_id)]) = *settings; +#else + phpdbg_globals = *settings; +#endif } + /* setup remote server if necessary */ + if (!cleaning && listen > 0) { + server = phpdbg_open_socket(address, listen TSRMLS_CC); + if (-1 > server || phpdbg_remote_init(address, listen, server, &socket, &stream TSRMLS_CC) == FAILURE) { + exit(0); + } + #ifndef _WIN32 - sigaction(SIGIO, &sigio_struct, NULL); + sigaction(SIGIO, &sigio_struct, NULL); #endif - /* set remote flag to stop service shutting down upon quit */ - remote = 1; - } + /* set remote flag to stop service shutting down upon quit */ + remote = 1; + } mm_heap = phpdbg_mm_get_heap(); @@ -1371,7 +1404,7 @@ phpdbg_main: for (i = SG(request_info).argc; --i;) { SG(request_info).argv[i] = estrdup(argv[php_optind - 1 + i]); } - SG(request_info).argv[i] = phpdbg_exec ? estrdup(phpdbg_exec) : estrdup(""); + SG(request_info).argv[i] = exec ? estrdup(exec) : estrdup(""); php_hash_environment(TSRMLS_C); } @@ -1392,9 +1425,6 @@ phpdbg_main: PG(modules_activated) = 0; - /* set flags from command line */ - PHPDBG_G(flags) = flags; - /* setup io here */ if (remote) { PHPDBG_G(flags) |= PHPDBG_IS_REMOTE; @@ -1434,12 +1464,12 @@ phpdbg_main: php_stream_stdio_ops.write = phpdbg_stdiop_write; #endif - if (phpdbg_exec) { /* set execution context */ - PHPDBG_G(exec) = phpdbg_resolve_path(phpdbg_exec TSRMLS_CC); + if (exec) { /* set execution context */ + PHPDBG_G(exec) = phpdbg_resolve_path(exec TSRMLS_CC); PHPDBG_G(exec_len) = strlen(PHPDBG_G(exec)); - free(phpdbg_exec); - phpdbg_exec = NULL; + free(exec); + exec = NULL; } if (oplog_file) { /* open oplog */ @@ -1537,7 +1567,12 @@ phpdbg_interact: } } zend_end_try(); } while (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)); - + + + if (PHPDBG_G(exec) && (PHPDBG_G(flags) & PHPDBG_IS_CLEANING)) { + exec = strdup(PHPDBG_G(exec)); /* preserve exec, don't reparse that from cmd */ + } + /* this must be forced */ CG(unclean_shutdown) = 0; @@ -1590,7 +1625,24 @@ phpdbg_out: /* this is just helpful */ PG(report_memleaks) = 0; - php_request_shutdown((void*)0); + if ((PHPDBG_G(flags) & (PHPDBG_IS_CLEANING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_CLEANING) { + php_free_shutdown_functions(TSRMLS_C); + zend_objects_store_mark_destructed(&EG(objects_store) TSRMLS_CC); + } + + /* sapi_module.deactivate is where to backup things, last chance before mm_shutdown... */ + + zend_try { + php_request_shutdown(NULL); + } zend_end_try(); + + if ((PHPDBG_G(flags) & (PHPDBG_IS_QUITTING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_RUNNING) { + phpdbg_notice("stop", "type=\"normal\"", "Script ended normally"); + } + + if ((PHPDBG_G(flags) & (PHPDBG_IS_CLEANING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_CLEANING) { + settings = PHPDBG_G(backup); + } php_output_deactivate(TSRMLS_C); diff --git a/phpdbg.h b/phpdbg.h index 688ba7cdfcb..57ea7ee570f 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -116,6 +116,7 @@ #include "phpdbg_utils.h" #include "phpdbg_btree.h" #include "phpdbg_watch.h" +#include "phpdbg_bp.h" #ifdef PHP_WIN32 # include "phpdbg_sigio_win32.h" #endif @@ -131,71 +132,62 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC); BEGIN: DO NOT CHANGE DO NOT CHANGE DO NOT CHANGE */ -/* {{{ tables */ -#define PHPDBG_BREAK_FILE 0 -#define PHPDBG_BREAK_SYM 1 -#define PHPDBG_BREAK_OPLINE 2 -#define PHPDBG_BREAK_METHOD 3 -#define PHPDBG_BREAK_COND 4 -#define PHPDBG_BREAK_OPCODE 5 -#define PHPDBG_BREAK_FUNCTION_OPLINE 6 -#define PHPDBG_BREAK_METHOD_OPLINE 7 -#define PHPDBG_BREAK_FILE_OPLINE 8 -#define PHPDBG_BREAK_MAP 9 -#define PHPDBG_BREAK_TABLES 10 /* }}} */ - /* {{{ flags */ -#define PHPDBG_HAS_FILE_BP (1<<1) -#define PHPDBG_HAS_SYM_BP (1<<2) -#define PHPDBG_HAS_OPLINE_BP (1<<3) -#define PHPDBG_HAS_METHOD_BP (1<<4) -#define PHPDBG_HAS_COND_BP (1<<5) -#define PHPDBG_HAS_OPCODE_BP (1<<6) -#define PHPDBG_HAS_FUNCTION_OPLINE_BP (1<<7) -#define PHPDBG_HAS_METHOD_OPLINE_BP (1<<8) -#define PHPDBG_HAS_FILE_OPLINE_BP (1<<9) /* }}} */ +#define PHPDBG_HAS_FILE_BP (1ULL<<1) +#define PHPDBG_HAS_PENDING_FILE_BP (1ULL<<2) +#define PHPDBG_HAS_SYM_BP (1ULL<<3) +#define PHPDBG_HAS_OPLINE_BP (1ULL<<4) +#define PHPDBG_HAS_METHOD_BP (1ULL<<5) +#define PHPDBG_HAS_COND_BP (1ULL<<6) +#define PHPDBG_HAS_OPCODE_BP (1ULL<<7) +#define PHPDBG_HAS_FUNCTION_OPLINE_BP (1ULL<<8) +#define PHPDBG_HAS_METHOD_OPLINE_BP (1ULL<<9) +#define PHPDBG_HAS_FILE_OPLINE_BP (1ULL<<10) /* }}} */ /* END: DO NOT CHANGE DO NOT CHANGE DO NOT CHANGE */ -#define PHPDBG_IN_COND_BP (1<<10) -#define PHPDBG_IN_EVAL (1<<11) +#define PHPDBG_IN_COND_BP (1ULL<<11) +#define PHPDBG_IN_EVAL (1ULL<<12) -#define PHPDBG_IS_STEPPING (1<<12) -#define PHPDBG_STEP_OPCODE (1<<13) -#define PHPDBG_IS_QUIET (1<<14) -#define PHPDBG_IS_QUITTING (1<<15) -#define PHPDBG_IS_COLOURED (1<<16) -#define PHPDBG_IS_CLEANING (1<<17) +#define PHPDBG_IS_STEPPING (1ULL<<13) +#define PHPDBG_STEP_OPCODE (1ULL<<14) +#define PHPDBG_IS_QUIET (1ULL<<15) +#define PHPDBG_IS_QUITTING (1ULL<<16) +#define PHPDBG_IS_COLOURED (1ULL<<17) +#define PHPDBG_IS_CLEANING (1ULL<<18) +#define PHPDBG_IS_RUNNING (1ULL<<19) -#define PHPDBG_IN_UNTIL (1<<18) -#define PHPDBG_IN_FINISH (1<<19) -#define PHPDBG_IN_LEAVE (1<<20) +#define PHPDBG_IN_UNTIL (1ULL<<20) +#define PHPDBG_IN_FINISH (1ULL<<21) +#define PHPDBG_IN_LEAVE (1ULL<<22) -#define PHPDBG_IS_REGISTERED (1<<21) -#define PHPDBG_IS_STEPONEVAL (1<<22) -#define PHPDBG_IS_INITIALIZING (1<<23) -#define PHPDBG_IS_SIGNALED (1<<24) -#define PHPDBG_IS_INTERACTIVE (1<<25) -#define PHPDBG_IS_BP_ENABLED (1<<26) -#define PHPDBG_IS_REMOTE (1<<27) -#define PHPDBG_IS_DISCONNECTED (1<<28) -#define PHPDBG_WRITE_XML (1<<29) +#define PHPDBG_IS_REGISTERED (1ULL<<23) +#define PHPDBG_IS_STEPONEVAL (1ULL<<24) +#define PHPDBG_IS_INITIALIZING (1ULL<<25) +#define PHPDBG_IS_SIGNALED (1ULL<<26) +#define PHPDBG_IS_INTERACTIVE (1ULL<<27) +#define PHPDBG_IS_BP_ENABLED (1ULL<<28) +#define PHPDBG_IS_REMOTE (1ULL<<29) +#define PHPDBG_IS_DISCONNECTED (1ULL<<30) +#define PHPDBG_WRITE_XML (1ULL<<31) -#define PHPDBG_SHOW_REFCOUNTS (1<<30) +#define PHPDBG_SHOW_REFCOUNTS (1ULL<<32) -#define PHPDBG_IN_SIGNAL_HANDLER (1<<30) +#define PHPDBG_IN_SIGNAL_HANDLER (1ULL<<33) #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) + #ifndef _WIN32 -# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_COLOURED|PHPDBG_IS_BP_ENABLED) +# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET | PHPDBG_IS_COLOURED | PHPDBG_IS_BP_ENABLED) #else -# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_BP_ENABLED) +# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET | PHPDBG_IS_BP_ENABLED) #endif /* }}} */ /* {{{ output descriptors */ @@ -256,6 +248,7 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg) FILE *ptr; int fd; } io[PHPDBG_IO_FDS]; /* io */ + int eol; /* type of line ending to use */ size_t (*php_stdiop_write)(php_stream *, const char *, size_t TSRMLS_DC); int in_script_xml; /* in output mode */ struct { @@ -281,17 +274,18 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg) JMP_BUF *sigsegv_bailout; /* bailout address for accesibility probing */ - zend_ulong flags; /* phpdbg flags */ + uint64_t flags; /* phpdbg flags */ char *socket_path; /* phpdbg.path ini setting */ char *sapi_name_ptr; /* store sapi name to free it if necessary to not leak memory */ int socket_fd; /* file descriptor to socket (wait command) (-1 if unused) */ int socket_server_fd; /* file descriptor to master socket (wait command) (-1 if unused) */ #ifdef PHP_WIN32 - HANDLE sigio_watcher_thread; /* sigio watcher thread handle */ + HANDLE sigio_watcher_thread; /* sigio watcher thread handle */ struct win32_sigio_watcher_data swd; #endif - int8_t eol; + + struct _zend_phpdbg_globals *backup; /* backup of data to store */ ZEND_END_MODULE_GLOBALS(phpdbg) /* }}} */ #endif diff --git a/phpdbg_bp.c b/phpdbg_bp.c index 81674a0daf1..9333b353ce6 100644 --- a/phpdbg_bp.c +++ b/phpdbg_bp.c @@ -220,51 +220,119 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRML { php_stream_statbuf ssb; char realpath[MAXPATHLEN]; + const char *original_path = path; + zend_bool pending; - if (php_stream_stat_path(path, &ssb) != FAILURE) { - if (ssb.sb.st_mode & (S_IFREG|S_IFLNK)) { - HashTable *broken; - phpdbg_breakfile_t new_break; - size_t path_len = 0L; + HashTable *broken, *file_breaks = &PHPDBG_G(bp)[PHPDBG_BREAK_FILE]; + phpdbg_breakfile_t new_break; + size_t path_len = 0L; - if (VCWD_REALPATH(path, realpath)) { - path = realpath; + if (VCWD_REALPATH(path, realpath)) { + path = realpath; + } + path_len = strlen(path); + + if (!zend_hash_exists(&PHPDBG_G(file_sources), path, path_len)) { + if (php_stream_stat_path(path, &ssb) == FAILURE) { + if (original_path[0] == '/') { + phpdbg_error("breakpoint", "type=\"nofile\" add=\"fail\" file=\"%s\"", "Cannot stat %s, it does not exist", original_path); + return; } + + file_breaks = &PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING]; + path = original_path; path_len = strlen(path); - - if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], - path, path_len, (void**)&broken) == FAILURE) { - HashTable breaks; - - zend_hash_init(&breaks, 8, NULL, phpdbg_file_breaks_dtor, 0); - - zend_hash_update(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], - path, path_len, &breaks, sizeof(HashTable), - (void**)&broken); - } - - if (!zend_hash_index_exists(broken, line_num)) { - PHPDBG_G(flags) |= PHPDBG_HAS_FILE_BP; - - PHPDBG_BREAK_INIT(new_break, PHPDBG_BREAK_FILE); - new_break.filename = estrndup(path, path_len); - new_break.line = line_num; - - zend_hash_index_update( broken, line_num, (void**)&new_break, sizeof(phpdbg_breakfile_t), NULL); - - phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" file=\"%s\" line=\"%ld\"", "Breakpoint #%d added at %s:%ld", - new_break.id, new_break.filename, new_break.line); - - PHPDBG_BREAK_MAPPING(new_break.id, broken); - } else { - phpdbg_error("breakpoint", "type=\"exists\" add=\"fail\" file=\"%s\" line=\"%ld\"", "Breakpoint at %s:%ld exists", path, line_num); - } - - } else { + pending = 1; + } else if (!(ssb.sb.st_mode & (S_IFREG|S_IFLNK))) { phpdbg_error("breakpoint", "type=\"notregular\" add=\"fail\" file=\"%s\"", "Cannot set breakpoint in %s, it is not a regular file", path); + return; } + } + + if (zend_hash_find(file_breaks, path, path_len, (void **) &broken) == FAILURE) { + HashTable breaks; + zend_hash_init(&breaks, 8, NULL, phpdbg_file_breaks_dtor, 0); + + zend_hash_add(file_breaks, path, path_len, &breaks, sizeof(HashTable), (void **) &broken); + } + + if (!zend_hash_index_exists(broken, line_num)) { + PHPDBG_BREAK_INIT(new_break, PHPDBG_BREAK_FILE); + new_break.filename = estrndup(path, path_len); + new_break.line = line_num; + + zend_hash_index_update(broken, line_num, (void **) &new_break, sizeof(phpdbg_breakfile_t), NULL); + + if (pending) { + PHPDBG_G(flags) |= PHPDBG_HAS_PENDING_FILE_BP; + + phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" file=\"%s\" line=\"%ld\" pending=\"pending\"", "Pending breakpoint #%d added at %s:%ld", new_break.id, new_break.filename, new_break.line); + } else { + PHPDBG_G(flags) |= PHPDBG_HAS_FILE_BP; + + phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" file=\"%s\" line=\"%ld\"", "Breakpoint #%d added at %s:%ld", new_break.id, new_break.filename, new_break.line); + } + + PHPDBG_BREAK_MAPPING(new_break.id, broken); } else { - phpdbg_error("breakpoint", "type=\"nofile\" add=\"fail\" file=\"%s\"", "Cannot stat %s, it does not exist", path); + phpdbg_error("breakpoint", "type=\"exists\" add=\"fail\" file=\"%s\" line=\"%ld\"", "Breakpoint at %s:%ld exists", path, line_num); + } +} /* }}} */ + +PHPDBG_API void phpdbg_resolve_pending_file_break(const char *file TSRMLS_DC) /* {{{ */ +{ + HashPosition position[2]; + HashTable *fileht; + uint filelen = strlen(file); + + zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position[0]); + while (zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], (void**) &fileht, &position[0]) == SUCCESS) { + const char *cur; + uint curlen; + + zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], (char **) &cur, &curlen, NULL, 0, &position[0]); + zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position[0]); + + if (curlen < filelen && file[filelen - curlen - 1] == '/' && !memcmp(file + filelen - curlen, cur, curlen)) { + phpdbg_breakfile_t *brake, new_brake; + HashTable *master = NULL; + dtor_func_t dtor; + + PHPDBG_G(flags) |= PHPDBG_HAS_FILE_BP; + + if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, (void **) &master) == FAILURE) { + dtor = PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor; + PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor = NULL; + zend_hash_add(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, fileht, sizeof(HashTable), (void **) &fileht); + } + + for (zend_hash_internal_pointer_reset_ex(fileht, &position[1]); + zend_hash_get_current_data_ex(fileht, (void**)&brake, &position[1]) == SUCCESS; + zend_hash_move_forward_ex(fileht, &position[1])) { + new_brake = *brake; + new_brake.filename = estrndup(file, filelen); + PHPDBG_BREAK_UNMAPPING(brake->id); + + if (master) { + zend_hash_index_update(master, brake->line, (void **) &new_brake, sizeof(phpdbg_breakfile_t), NULL); + PHPDBG_BREAK_MAPPING(brake->id, master); + } else { + efree((char *) brake->filename); + *brake = new_brake; + PHPDBG_BREAK_MAPPING(brake->id, fileht); + } + } + + zend_hash_del(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], cur, curlen); + + if (!master) { + PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor = dtor; + } + + if (!zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING])) { + PHPDBG_G(flags) &= ~PHPDBG_HAS_PENDING_FILE_BP; + } + } } } /* }}} */ @@ -1141,6 +1209,7 @@ PHPDBG_API void phpdbg_delete_breakpoint(zend_ulong num TSRMLS_DC) /* {{{ */ PHPDBG_API void phpdbg_clear_breakpoints(TSRMLS_D) /* {{{ */ { zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING]); zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM]); zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]); zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE]); @@ -1398,6 +1467,25 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); } } + } if ((PHPDBG_G(flags) & PHPDBG_HAS_PENDING_FILE_BP)) { + HashPosition position[2]; + HashTable *points; + + phpdbg_out(SEPARATE "\n"); + phpdbg_out("Pending File Breakpoints:\n"); + for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position[0]); + zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], (void**) &points, &position[0]) == SUCCESS; + zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position[0])) { + phpdbg_breakfile_t *brake; + + for (zend_hash_internal_pointer_reset_ex(points, &position[1]); + zend_hash_get_current_data_ex(points, (void**)&brake, &position[1]) == SUCCESS; + zend_hash_move_forward_ex(points, &position[1])) { + phpdbg_writeln("file", "id=\"%d\" name=\"%s\" line=\"%lu\" disabled=\"%s\" pending=\"pending\"", "#%d\t\t%s:%lu%s", + brake->id, brake->filename, brake->line, + ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); + } + } } break; diff --git a/phpdbg_bp.h b/phpdbg_bp.h index a6227cba6c9..606085ddcfc 100644 --- a/phpdbg_bp.h +++ b/phpdbg_bp.h @@ -23,16 +23,17 @@ /* {{{ defines */ #define PHPDBG_BREAK_FILE 0 -#define PHPDBG_BREAK_SYM 1 -#define PHPDBG_BREAK_OPLINE 2 -#define PHPDBG_BREAK_METHOD 3 -#define PHPDBG_BREAK_COND 4 -#define PHPDBG_BREAK_OPCODE 5 -#define PHPDBG_BREAK_FUNCTION_OPLINE 6 -#define PHPDBG_BREAK_METHOD_OPLINE 7 -#define PHPDBG_BREAK_FILE_OPLINE 8 -#define PHPDBG_BREAK_MAP 9 -#define PHPDBG_BREAK_TABLES 10 /* }}} */ +#define PHPDBG_BREAK_FILE_PENDING 1 +#define PHPDBG_BREAK_SYM 2 +#define PHPDBG_BREAK_OPLINE 3 +#define PHPDBG_BREAK_METHOD 4 +#define PHPDBG_BREAK_COND 5 +#define PHPDBG_BREAK_OPCODE 6 +#define PHPDBG_BREAK_FUNCTION_OPLINE 7 +#define PHPDBG_BREAK_METHOD_OPLINE 8 +#define PHPDBG_BREAK_FILE_OPLINE 9 +#define PHPDBG_BREAK_MAP 10 +#define PHPDBG_BREAK_TABLES 11 /* }}} */ /* {{{ */ typedef struct _zend_op *phpdbg_opline_ptr_t; /* }}} */ @@ -116,10 +117,11 @@ typedef struct _phpdbg_breakcond_t { zend_op_array *ops; } phpdbg_breakcond_t; -/* {{{ Opline breaks API */ +/* {{{ Resolving breaks API */ PHPDBG_API void phpdbg_resolve_op_array_breaks(zend_op_array *op_array TSRMLS_DC); PHPDBG_API int phpdbg_resolve_op_array_break(phpdbg_breakopline_t *brake, zend_op_array *op_array TSRMLS_DC); -PHPDBG_API int phpdbg_resolve_opline_break(phpdbg_breakopline_t *new_break TSRMLS_DC); /* }}} */ +PHPDBG_API int phpdbg_resolve_opline_break(phpdbg_breakopline_t *new_break TSRMLS_DC); +PHPDBG_API void phpdbg_resolve_pending_file_break(const char *file TSRMLS_DC); /* }}} */ /* {{{ Breakpoint Creation API */ PHPDBG_API void phpdbg_set_breakpoint_file(const char* filename, long lineno TSRMLS_DC); diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index 13d5a0d6340..a170d529555 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -727,7 +727,7 @@ PHPDBG_API char *phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */ char *cmd = NULL; char *buffer = NULL; - if (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { + if ((PHPDBG_G(flags) & (PHPDBG_IS_STOPPING | PHPDBG_IS_RUNNING)) != PHPDBG_IS_STOPPING) { if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && (buffered == NULL) && !phpdbg_active_sigsafe_mem(TSRMLS_C)) { fflush(PHPDBG_G(io)[PHPDBG_STDOUT].ptr); } diff --git a/phpdbg_list.c b/phpdbg_list.c index 7aa8c4f9e08..8ab4c8922a8 100644 --- a/phpdbg_list.c +++ b/phpdbg_list.c @@ -278,6 +278,8 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type TSRMLS_DC) { dataptr->line[line] = endptr - data.buf; dataptr = erealloc(dataptr, sizeof(phpdbg_file_source) + sizeof(uint) * line); + phpdbg_resolve_pending_file_break(filename TSRMLS_CC); + ret = PHPDBG_G(compile_file)(&fake, type TSRMLS_CC); fake.opened_path = NULL; diff --git a/phpdbg_out.c b/phpdbg_out.c index a4793f144f6..365708c71ed 100644 --- a/phpdbg_out.c +++ b/phpdbg_out.c @@ -1117,6 +1117,8 @@ PHPDBG_API int phpdbg_vprint(int type TSRMLS_DC, int fd, const char *tag, const } if (PHPDBG_G(err_buf).active && type != P_STDOUT && type != P_STDERR) { + phpdbg_free_err_buf(TSRMLS_C); + PHPDBG_G(err_buf).type = type; PHPDBG_G(err_buf).fd = fd; PHPDBG_G(err_buf).tag = estrdup(tag); diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index eca4c6ac2ba..a2e4d41042d 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -28,7 +28,6 @@ #include "phpdbg_print.h" #include "phpdbg_info.h" #include "phpdbg_break.h" -#include "phpdbg_bp.h" #include "phpdbg_opcode.h" #include "phpdbg_list.h" #include "phpdbg_utils.h" @@ -44,7 +43,6 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg); ZEND_EXTERN_MODULE_GLOBALS(output); extern int phpdbg_startup_run; -extern char *phpdbg_exec; #ifdef HAVE_LIBDL #ifdef PHP_WIN32 @@ -641,10 +639,10 @@ PHPDBG_COMMAND(run) /* {{{ */ } zend_try { - PHPDBG_G(flags) ^= PHPDBG_IS_INTERACTIVE; + PHPDBG_G(flags) &= ~PHPDBG_IS_INTERACTIVE; + PHPDBG_G(flags) |= PHPDBG_IS_RUNNING; zend_execute(EG(active_op_array) TSRMLS_CC); - PHPDBG_G(flags) ^= PHPDBG_IS_INTERACTIVE; - phpdbg_notice("stop", "type=\"normal\"", "Script ended normally"); + PHPDBG_G(flags) |= PHPDBG_IS_INTERACTIVE; } zend_catch { EG(active_op_array) = orig_op_array; EG(opline_ptr) = orig_opline; @@ -669,7 +667,11 @@ PHPDBG_COMMAND(run) /* {{{ */ EG(active_op_array) = orig_op_array; EG(opline_ptr) = orig_opline; EG(return_value_ptr_ptr) = orig_retval_ptr; + + phpdbg_clean(1 TSRMLS_CC); } + + PHPDBG_G(flags) &= ~PHPDBG_IS_RUNNING; } else { phpdbg_error("inactive", "type=\"nocontext\"", "Nothing to execute!"); } @@ -1235,8 +1237,8 @@ int phpdbg_interactive(zend_bool allow_async_unsafe TSRMLS_DC) /* {{{ */ PHPDBG_G(flags) |= PHPDBG_IS_INTERACTIVE; - while (1) { - if (PHPDBG_G(flags) & PHPDBG_IS_STOPPING) { + while (ret == SUCCESS || ret == FAILURE) { + if ((PHPDBG_G(flags) & (PHPDBG_IS_STOPPING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_STOPPING) { zend_bailout(); } @@ -1291,6 +1293,7 @@ int phpdbg_interactive(zend_bool allow_async_unsafe TSRMLS_DC) /* {{{ */ phpdbg_stack_free(&stack); phpdbg_destroy_input(&input TSRMLS_CC); PHPDBG_G(req_id) = 0; + input = NULL; } if (input) { @@ -1320,10 +1323,6 @@ void phpdbg_clean(zend_bool full TSRMLS_DC) /* {{{ */ } if (full) { - if (PHPDBG_G(exec)) { - phpdbg_exec = strdup(PHPDBG_G(exec)); /* preserve exec, don't reparse that from cmd */ - } - PHPDBG_G(flags) |= PHPDBG_IS_CLEANING; zend_bailout(); From 3ab7734b88f1842b818526e2e3f34022c3270057 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sun, 26 Oct 2014 20:43:49 +0100 Subject: [PATCH 082/398] Stabilize execution, always run destructors and extended file breakpoints --- sapi/phpdbg/phpdbg.c | 104 +++++++++++++++++------ sapi/phpdbg/phpdbg.h | 92 ++++++++++---------- sapi/phpdbg/phpdbg_bp.c | 164 +++++++++++++++++++++++++++--------- sapi/phpdbg/phpdbg_bp.h | 26 +++--- sapi/phpdbg/phpdbg_cmd.c | 2 +- sapi/phpdbg/phpdbg_list.c | 2 + sapi/phpdbg/phpdbg_out.c | 2 + sapi/phpdbg/phpdbg_prompt.c | 21 +++-- 8 files changed, 276 insertions(+), 137 deletions(-) diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 493d8ec20c9..3e31f76898a 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -46,7 +46,6 @@ ZEND_DECLARE_MODULE_GLOBALS(phpdbg); int phpdbg_startup_run = 0; -char *phpdbg_exec = NULL; static PHP_INI_MH(OnUpdateEol) { @@ -186,7 +185,8 @@ static void php_phpdbg_destroy_registered(void *data) /* {{{ */ static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */ { - zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], 8, NULL, php_phpdbg_destroy_bp_file, 0); + zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], 8, NULL, php_phpdbg_destroy_bp_file, 0); + zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], 8, NULL, php_phpdbg_destroy_bp_file, 0); zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], 8, NULL, php_phpdbg_destroy_bp_symbol, 0); zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], 8, NULL, php_phpdbg_destroy_bp_methods, 0); zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], 8, NULL, php_phpdbg_destroy_bp_methods, 0); @@ -216,8 +216,8 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */ zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_COND]); zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP]); zend_hash_destroy(&PHPDBG_G(seek)); - zend_hash_destroy(&PHPDBG_G(registered)); zend_hash_destroy(&PHPDBG_G(file_sources)); + zend_hash_destroy(&PHPDBG_G(registered)); zend_hash_destroy(&PHPDBG_G(watchpoints)); zend_llist_destroy(&PHPDBG_G(watchlist_mem)); @@ -363,6 +363,7 @@ static PHP_FUNCTION(phpdbg_break_function) static PHP_FUNCTION(phpdbg_clear) { zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING]); zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM]); zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE]); zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE]); @@ -543,11 +544,27 @@ static void php_sapi_phpdbg_log_message(char *message TSRMLS_DC) /* {{{ */ static int php_sapi_phpdbg_deactivate(TSRMLS_D) /* {{{ */ { + if ((PHPDBG_G(flags) & (PHPDBG_IS_CLEANING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_CLEANING) { + zend_phpdbg_globals *pg = PHPDBG_G(backup) = calloc(1, sizeof(zend_phpdbg_globals)); + + php_phpdbg_globals_ctor(pg); + + pg->exec = strndup(PHPDBG_G(exec), PHPDBG_G(exec_len)); + pg->exec_len = PHPDBG_G(exec_len); + 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)); + pg->eol = PHPDBG_G(eol); + pg->flags = PHPDBG_G(flags) & PHPDBG_PRESERVE_FLAGS_MASK; + } + fflush(stdout); if(SG(request_info).argv0) { free(SG(request_info).argv0); SG(request_info).argv0 = NULL; } + return SUCCESS; } /* }}} */ @@ -1009,6 +1026,7 @@ int main(int argc, char **argv) /* {{{ */ zend_ulong zend_extensions_len = 0L; zend_bool ini_ignore; char *ini_override; + char *exec = NULL; char *init_file; size_t init_file_len; zend_bool init_file_default; @@ -1020,6 +1038,7 @@ int main(int argc, char **argv) /* {{{ */ long cleaning = 0; zend_bool remote = 0; int step = 0; + zend_phpdbg_globals *settings = NULL; #ifdef _WIN32 char *bp_tmp_file = NULL; @@ -1102,6 +1121,9 @@ phpdbg_main: opt = 0; step = 0; sapi_name = NULL; + if (settings) { + exec = settings->exec; + } while ((opt = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) { switch (opt) { @@ -1243,12 +1265,12 @@ phpdbg_main: } /* set exec if present on command line */ - if (!phpdbg_exec && (argc > php_optind) && (strcmp(argv[php_optind-1],"--") != SUCCESS)) { + if (!exec && (argc > php_optind) && (strcmp(argv[php_optind-1], "--") != SUCCESS)) { if (strlen(argv[php_optind])) { - if (phpdbg_exec) { - free(phpdbg_exec); + if (exec) { + free(exec); } - phpdbg_exec = strdup(argv[php_optind]); + exec = strdup(argv[php_optind]); } php_optind++; } @@ -1309,20 +1331,31 @@ phpdbg_main: #endif zend_mm_heap *mm_heap; - /* setup remote server if necessary */ - if (!cleaning && listen > 0) { - server = phpdbg_open_socket(address, listen TSRMLS_CC); - if (-1 > server || phpdbg_remote_init(address, listen, server, &socket, &stream TSRMLS_CC) == FAILURE) { - exit(0); + /* set flags from command line */ + PHPDBG_G(flags) = flags; + + if (settings) { +#ifdef ZTS + *((zend_phpdbg_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(phpdbg_globals_id)]) = *settings; +#else + phpdbg_globals = *settings; +#endif } + /* setup remote server if necessary */ + if (!cleaning && listen > 0) { + server = phpdbg_open_socket(address, listen TSRMLS_CC); + if (-1 > server || phpdbg_remote_init(address, listen, server, &socket, &stream TSRMLS_CC) == FAILURE) { + exit(0); + } + #ifndef _WIN32 - sigaction(SIGIO, &sigio_struct, NULL); + sigaction(SIGIO, &sigio_struct, NULL); #endif - /* set remote flag to stop service shutting down upon quit */ - remote = 1; - } + /* set remote flag to stop service shutting down upon quit */ + remote = 1; + } mm_heap = phpdbg_mm_get_heap(); @@ -1371,7 +1404,7 @@ phpdbg_main: for (i = SG(request_info).argc; --i;) { SG(request_info).argv[i] = estrdup(argv[php_optind - 1 + i]); } - SG(request_info).argv[i] = phpdbg_exec ? estrdup(phpdbg_exec) : estrdup(""); + SG(request_info).argv[i] = exec ? estrdup(exec) : estrdup(""); php_hash_environment(TSRMLS_C); } @@ -1392,9 +1425,6 @@ phpdbg_main: PG(modules_activated) = 0; - /* set flags from command line */ - PHPDBG_G(flags) = flags; - /* setup io here */ if (remote) { PHPDBG_G(flags) |= PHPDBG_IS_REMOTE; @@ -1434,12 +1464,12 @@ phpdbg_main: php_stream_stdio_ops.write = phpdbg_stdiop_write; #endif - if (phpdbg_exec) { /* set execution context */ - PHPDBG_G(exec) = phpdbg_resolve_path(phpdbg_exec TSRMLS_CC); + if (exec) { /* set execution context */ + PHPDBG_G(exec) = phpdbg_resolve_path(exec TSRMLS_CC); PHPDBG_G(exec_len) = strlen(PHPDBG_G(exec)); - free(phpdbg_exec); - phpdbg_exec = NULL; + free(exec); + exec = NULL; } if (oplog_file) { /* open oplog */ @@ -1537,7 +1567,12 @@ phpdbg_interact: } } zend_end_try(); } while (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)); - + + + if (PHPDBG_G(exec) && (PHPDBG_G(flags) & PHPDBG_IS_CLEANING)) { + exec = strdup(PHPDBG_G(exec)); /* preserve exec, don't reparse that from cmd */ + } + /* this must be forced */ CG(unclean_shutdown) = 0; @@ -1590,7 +1625,24 @@ phpdbg_out: /* this is just helpful */ PG(report_memleaks) = 0; - php_request_shutdown((void*)0); + if ((PHPDBG_G(flags) & (PHPDBG_IS_CLEANING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_CLEANING) { + php_free_shutdown_functions(TSRMLS_C); + zend_objects_store_mark_destructed(&EG(objects_store) TSRMLS_CC); + } + + /* sapi_module.deactivate is where to backup things, last chance before mm_shutdown... */ + + zend_try { + php_request_shutdown(NULL); + } zend_end_try(); + + if ((PHPDBG_G(flags) & (PHPDBG_IS_QUITTING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_RUNNING) { + phpdbg_notice("stop", "type=\"normal\"", "Script ended normally"); + } + + if ((PHPDBG_G(flags) & (PHPDBG_IS_CLEANING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_CLEANING) { + settings = PHPDBG_G(backup); + } php_output_deactivate(TSRMLS_C); diff --git a/sapi/phpdbg/phpdbg.h b/sapi/phpdbg/phpdbg.h index 688ba7cdfcb..57ea7ee570f 100644 --- a/sapi/phpdbg/phpdbg.h +++ b/sapi/phpdbg/phpdbg.h @@ -116,6 +116,7 @@ #include "phpdbg_utils.h" #include "phpdbg_btree.h" #include "phpdbg_watch.h" +#include "phpdbg_bp.h" #ifdef PHP_WIN32 # include "phpdbg_sigio_win32.h" #endif @@ -131,71 +132,62 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC); BEGIN: DO NOT CHANGE DO NOT CHANGE DO NOT CHANGE */ -/* {{{ tables */ -#define PHPDBG_BREAK_FILE 0 -#define PHPDBG_BREAK_SYM 1 -#define PHPDBG_BREAK_OPLINE 2 -#define PHPDBG_BREAK_METHOD 3 -#define PHPDBG_BREAK_COND 4 -#define PHPDBG_BREAK_OPCODE 5 -#define PHPDBG_BREAK_FUNCTION_OPLINE 6 -#define PHPDBG_BREAK_METHOD_OPLINE 7 -#define PHPDBG_BREAK_FILE_OPLINE 8 -#define PHPDBG_BREAK_MAP 9 -#define PHPDBG_BREAK_TABLES 10 /* }}} */ - /* {{{ flags */ -#define PHPDBG_HAS_FILE_BP (1<<1) -#define PHPDBG_HAS_SYM_BP (1<<2) -#define PHPDBG_HAS_OPLINE_BP (1<<3) -#define PHPDBG_HAS_METHOD_BP (1<<4) -#define PHPDBG_HAS_COND_BP (1<<5) -#define PHPDBG_HAS_OPCODE_BP (1<<6) -#define PHPDBG_HAS_FUNCTION_OPLINE_BP (1<<7) -#define PHPDBG_HAS_METHOD_OPLINE_BP (1<<8) -#define PHPDBG_HAS_FILE_OPLINE_BP (1<<9) /* }}} */ +#define PHPDBG_HAS_FILE_BP (1ULL<<1) +#define PHPDBG_HAS_PENDING_FILE_BP (1ULL<<2) +#define PHPDBG_HAS_SYM_BP (1ULL<<3) +#define PHPDBG_HAS_OPLINE_BP (1ULL<<4) +#define PHPDBG_HAS_METHOD_BP (1ULL<<5) +#define PHPDBG_HAS_COND_BP (1ULL<<6) +#define PHPDBG_HAS_OPCODE_BP (1ULL<<7) +#define PHPDBG_HAS_FUNCTION_OPLINE_BP (1ULL<<8) +#define PHPDBG_HAS_METHOD_OPLINE_BP (1ULL<<9) +#define PHPDBG_HAS_FILE_OPLINE_BP (1ULL<<10) /* }}} */ /* END: DO NOT CHANGE DO NOT CHANGE DO NOT CHANGE */ -#define PHPDBG_IN_COND_BP (1<<10) -#define PHPDBG_IN_EVAL (1<<11) +#define PHPDBG_IN_COND_BP (1ULL<<11) +#define PHPDBG_IN_EVAL (1ULL<<12) -#define PHPDBG_IS_STEPPING (1<<12) -#define PHPDBG_STEP_OPCODE (1<<13) -#define PHPDBG_IS_QUIET (1<<14) -#define PHPDBG_IS_QUITTING (1<<15) -#define PHPDBG_IS_COLOURED (1<<16) -#define PHPDBG_IS_CLEANING (1<<17) +#define PHPDBG_IS_STEPPING (1ULL<<13) +#define PHPDBG_STEP_OPCODE (1ULL<<14) +#define PHPDBG_IS_QUIET (1ULL<<15) +#define PHPDBG_IS_QUITTING (1ULL<<16) +#define PHPDBG_IS_COLOURED (1ULL<<17) +#define PHPDBG_IS_CLEANING (1ULL<<18) +#define PHPDBG_IS_RUNNING (1ULL<<19) -#define PHPDBG_IN_UNTIL (1<<18) -#define PHPDBG_IN_FINISH (1<<19) -#define PHPDBG_IN_LEAVE (1<<20) +#define PHPDBG_IN_UNTIL (1ULL<<20) +#define PHPDBG_IN_FINISH (1ULL<<21) +#define PHPDBG_IN_LEAVE (1ULL<<22) -#define PHPDBG_IS_REGISTERED (1<<21) -#define PHPDBG_IS_STEPONEVAL (1<<22) -#define PHPDBG_IS_INITIALIZING (1<<23) -#define PHPDBG_IS_SIGNALED (1<<24) -#define PHPDBG_IS_INTERACTIVE (1<<25) -#define PHPDBG_IS_BP_ENABLED (1<<26) -#define PHPDBG_IS_REMOTE (1<<27) -#define PHPDBG_IS_DISCONNECTED (1<<28) -#define PHPDBG_WRITE_XML (1<<29) +#define PHPDBG_IS_REGISTERED (1ULL<<23) +#define PHPDBG_IS_STEPONEVAL (1ULL<<24) +#define PHPDBG_IS_INITIALIZING (1ULL<<25) +#define PHPDBG_IS_SIGNALED (1ULL<<26) +#define PHPDBG_IS_INTERACTIVE (1ULL<<27) +#define PHPDBG_IS_BP_ENABLED (1ULL<<28) +#define PHPDBG_IS_REMOTE (1ULL<<29) +#define PHPDBG_IS_DISCONNECTED (1ULL<<30) +#define PHPDBG_WRITE_XML (1ULL<<31) -#define PHPDBG_SHOW_REFCOUNTS (1<<30) +#define PHPDBG_SHOW_REFCOUNTS (1ULL<<32) -#define PHPDBG_IN_SIGNAL_HANDLER (1<<30) +#define PHPDBG_IN_SIGNAL_HANDLER (1ULL<<33) #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) + #ifndef _WIN32 -# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_COLOURED|PHPDBG_IS_BP_ENABLED) +# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET | PHPDBG_IS_COLOURED | PHPDBG_IS_BP_ENABLED) #else -# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_BP_ENABLED) +# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET | PHPDBG_IS_BP_ENABLED) #endif /* }}} */ /* {{{ output descriptors */ @@ -256,6 +248,7 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg) FILE *ptr; int fd; } io[PHPDBG_IO_FDS]; /* io */ + int eol; /* type of line ending to use */ size_t (*php_stdiop_write)(php_stream *, const char *, size_t TSRMLS_DC); int in_script_xml; /* in output mode */ struct { @@ -281,17 +274,18 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg) JMP_BUF *sigsegv_bailout; /* bailout address for accesibility probing */ - zend_ulong flags; /* phpdbg flags */ + uint64_t flags; /* phpdbg flags */ char *socket_path; /* phpdbg.path ini setting */ char *sapi_name_ptr; /* store sapi name to free it if necessary to not leak memory */ int socket_fd; /* file descriptor to socket (wait command) (-1 if unused) */ int socket_server_fd; /* file descriptor to master socket (wait command) (-1 if unused) */ #ifdef PHP_WIN32 - HANDLE sigio_watcher_thread; /* sigio watcher thread handle */ + HANDLE sigio_watcher_thread; /* sigio watcher thread handle */ struct win32_sigio_watcher_data swd; #endif - int8_t eol; + + struct _zend_phpdbg_globals *backup; /* backup of data to store */ ZEND_END_MODULE_GLOBALS(phpdbg) /* }}} */ #endif diff --git a/sapi/phpdbg/phpdbg_bp.c b/sapi/phpdbg/phpdbg_bp.c index 81674a0daf1..9333b353ce6 100644 --- a/sapi/phpdbg/phpdbg_bp.c +++ b/sapi/phpdbg/phpdbg_bp.c @@ -220,51 +220,119 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRML { php_stream_statbuf ssb; char realpath[MAXPATHLEN]; + const char *original_path = path; + zend_bool pending; - if (php_stream_stat_path(path, &ssb) != FAILURE) { - if (ssb.sb.st_mode & (S_IFREG|S_IFLNK)) { - HashTable *broken; - phpdbg_breakfile_t new_break; - size_t path_len = 0L; + HashTable *broken, *file_breaks = &PHPDBG_G(bp)[PHPDBG_BREAK_FILE]; + phpdbg_breakfile_t new_break; + size_t path_len = 0L; - if (VCWD_REALPATH(path, realpath)) { - path = realpath; + if (VCWD_REALPATH(path, realpath)) { + path = realpath; + } + path_len = strlen(path); + + if (!zend_hash_exists(&PHPDBG_G(file_sources), path, path_len)) { + if (php_stream_stat_path(path, &ssb) == FAILURE) { + if (original_path[0] == '/') { + phpdbg_error("breakpoint", "type=\"nofile\" add=\"fail\" file=\"%s\"", "Cannot stat %s, it does not exist", original_path); + return; } + + file_breaks = &PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING]; + path = original_path; path_len = strlen(path); - - if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], - path, path_len, (void**)&broken) == FAILURE) { - HashTable breaks; - - zend_hash_init(&breaks, 8, NULL, phpdbg_file_breaks_dtor, 0); - - zend_hash_update(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], - path, path_len, &breaks, sizeof(HashTable), - (void**)&broken); - } - - if (!zend_hash_index_exists(broken, line_num)) { - PHPDBG_G(flags) |= PHPDBG_HAS_FILE_BP; - - PHPDBG_BREAK_INIT(new_break, PHPDBG_BREAK_FILE); - new_break.filename = estrndup(path, path_len); - new_break.line = line_num; - - zend_hash_index_update( broken, line_num, (void**)&new_break, sizeof(phpdbg_breakfile_t), NULL); - - phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" file=\"%s\" line=\"%ld\"", "Breakpoint #%d added at %s:%ld", - new_break.id, new_break.filename, new_break.line); - - PHPDBG_BREAK_MAPPING(new_break.id, broken); - } else { - phpdbg_error("breakpoint", "type=\"exists\" add=\"fail\" file=\"%s\" line=\"%ld\"", "Breakpoint at %s:%ld exists", path, line_num); - } - - } else { + pending = 1; + } else if (!(ssb.sb.st_mode & (S_IFREG|S_IFLNK))) { phpdbg_error("breakpoint", "type=\"notregular\" add=\"fail\" file=\"%s\"", "Cannot set breakpoint in %s, it is not a regular file", path); + return; } + } + + if (zend_hash_find(file_breaks, path, path_len, (void **) &broken) == FAILURE) { + HashTable breaks; + zend_hash_init(&breaks, 8, NULL, phpdbg_file_breaks_dtor, 0); + + zend_hash_add(file_breaks, path, path_len, &breaks, sizeof(HashTable), (void **) &broken); + } + + if (!zend_hash_index_exists(broken, line_num)) { + PHPDBG_BREAK_INIT(new_break, PHPDBG_BREAK_FILE); + new_break.filename = estrndup(path, path_len); + new_break.line = line_num; + + zend_hash_index_update(broken, line_num, (void **) &new_break, sizeof(phpdbg_breakfile_t), NULL); + + if (pending) { + PHPDBG_G(flags) |= PHPDBG_HAS_PENDING_FILE_BP; + + phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" file=\"%s\" line=\"%ld\" pending=\"pending\"", "Pending breakpoint #%d added at %s:%ld", new_break.id, new_break.filename, new_break.line); + } else { + PHPDBG_G(flags) |= PHPDBG_HAS_FILE_BP; + + phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" file=\"%s\" line=\"%ld\"", "Breakpoint #%d added at %s:%ld", new_break.id, new_break.filename, new_break.line); + } + + PHPDBG_BREAK_MAPPING(new_break.id, broken); } else { - phpdbg_error("breakpoint", "type=\"nofile\" add=\"fail\" file=\"%s\"", "Cannot stat %s, it does not exist", path); + phpdbg_error("breakpoint", "type=\"exists\" add=\"fail\" file=\"%s\" line=\"%ld\"", "Breakpoint at %s:%ld exists", path, line_num); + } +} /* }}} */ + +PHPDBG_API void phpdbg_resolve_pending_file_break(const char *file TSRMLS_DC) /* {{{ */ +{ + HashPosition position[2]; + HashTable *fileht; + uint filelen = strlen(file); + + zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position[0]); + while (zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], (void**) &fileht, &position[0]) == SUCCESS) { + const char *cur; + uint curlen; + + zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], (char **) &cur, &curlen, NULL, 0, &position[0]); + zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position[0]); + + if (curlen < filelen && file[filelen - curlen - 1] == '/' && !memcmp(file + filelen - curlen, cur, curlen)) { + phpdbg_breakfile_t *brake, new_brake; + HashTable *master = NULL; + dtor_func_t dtor; + + PHPDBG_G(flags) |= PHPDBG_HAS_FILE_BP; + + if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, (void **) &master) == FAILURE) { + dtor = PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor; + PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor = NULL; + zend_hash_add(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, fileht, sizeof(HashTable), (void **) &fileht); + } + + for (zend_hash_internal_pointer_reset_ex(fileht, &position[1]); + zend_hash_get_current_data_ex(fileht, (void**)&brake, &position[1]) == SUCCESS; + zend_hash_move_forward_ex(fileht, &position[1])) { + new_brake = *brake; + new_brake.filename = estrndup(file, filelen); + PHPDBG_BREAK_UNMAPPING(brake->id); + + if (master) { + zend_hash_index_update(master, brake->line, (void **) &new_brake, sizeof(phpdbg_breakfile_t), NULL); + PHPDBG_BREAK_MAPPING(brake->id, master); + } else { + efree((char *) brake->filename); + *brake = new_brake; + PHPDBG_BREAK_MAPPING(brake->id, fileht); + } + } + + zend_hash_del(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], cur, curlen); + + if (!master) { + PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor = dtor; + } + + if (!zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING])) { + PHPDBG_G(flags) &= ~PHPDBG_HAS_PENDING_FILE_BP; + } + } } } /* }}} */ @@ -1141,6 +1209,7 @@ PHPDBG_API void phpdbg_delete_breakpoint(zend_ulong num TSRMLS_DC) /* {{{ */ PHPDBG_API void phpdbg_clear_breakpoints(TSRMLS_D) /* {{{ */ { zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING]); zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM]); zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]); zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE]); @@ -1398,6 +1467,25 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); } } + } if ((PHPDBG_G(flags) & PHPDBG_HAS_PENDING_FILE_BP)) { + HashPosition position[2]; + HashTable *points; + + phpdbg_out(SEPARATE "\n"); + phpdbg_out("Pending File Breakpoints:\n"); + for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position[0]); + zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], (void**) &points, &position[0]) == SUCCESS; + zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position[0])) { + phpdbg_breakfile_t *brake; + + for (zend_hash_internal_pointer_reset_ex(points, &position[1]); + zend_hash_get_current_data_ex(points, (void**)&brake, &position[1]) == SUCCESS; + zend_hash_move_forward_ex(points, &position[1])) { + phpdbg_writeln("file", "id=\"%d\" name=\"%s\" line=\"%lu\" disabled=\"%s\" pending=\"pending\"", "#%d\t\t%s:%lu%s", + brake->id, brake->filename, brake->line, + ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : ""); + } + } } break; diff --git a/sapi/phpdbg/phpdbg_bp.h b/sapi/phpdbg/phpdbg_bp.h index a6227cba6c9..606085ddcfc 100644 --- a/sapi/phpdbg/phpdbg_bp.h +++ b/sapi/phpdbg/phpdbg_bp.h @@ -23,16 +23,17 @@ /* {{{ defines */ #define PHPDBG_BREAK_FILE 0 -#define PHPDBG_BREAK_SYM 1 -#define PHPDBG_BREAK_OPLINE 2 -#define PHPDBG_BREAK_METHOD 3 -#define PHPDBG_BREAK_COND 4 -#define PHPDBG_BREAK_OPCODE 5 -#define PHPDBG_BREAK_FUNCTION_OPLINE 6 -#define PHPDBG_BREAK_METHOD_OPLINE 7 -#define PHPDBG_BREAK_FILE_OPLINE 8 -#define PHPDBG_BREAK_MAP 9 -#define PHPDBG_BREAK_TABLES 10 /* }}} */ +#define PHPDBG_BREAK_FILE_PENDING 1 +#define PHPDBG_BREAK_SYM 2 +#define PHPDBG_BREAK_OPLINE 3 +#define PHPDBG_BREAK_METHOD 4 +#define PHPDBG_BREAK_COND 5 +#define PHPDBG_BREAK_OPCODE 6 +#define PHPDBG_BREAK_FUNCTION_OPLINE 7 +#define PHPDBG_BREAK_METHOD_OPLINE 8 +#define PHPDBG_BREAK_FILE_OPLINE 9 +#define PHPDBG_BREAK_MAP 10 +#define PHPDBG_BREAK_TABLES 11 /* }}} */ /* {{{ */ typedef struct _zend_op *phpdbg_opline_ptr_t; /* }}} */ @@ -116,10 +117,11 @@ typedef struct _phpdbg_breakcond_t { zend_op_array *ops; } phpdbg_breakcond_t; -/* {{{ Opline breaks API */ +/* {{{ Resolving breaks API */ PHPDBG_API void phpdbg_resolve_op_array_breaks(zend_op_array *op_array TSRMLS_DC); PHPDBG_API int phpdbg_resolve_op_array_break(phpdbg_breakopline_t *brake, zend_op_array *op_array TSRMLS_DC); -PHPDBG_API int phpdbg_resolve_opline_break(phpdbg_breakopline_t *new_break TSRMLS_DC); /* }}} */ +PHPDBG_API int phpdbg_resolve_opline_break(phpdbg_breakopline_t *new_break TSRMLS_DC); +PHPDBG_API void phpdbg_resolve_pending_file_break(const char *file TSRMLS_DC); /* }}} */ /* {{{ Breakpoint Creation API */ PHPDBG_API void phpdbg_set_breakpoint_file(const char* filename, long lineno TSRMLS_DC); diff --git a/sapi/phpdbg/phpdbg_cmd.c b/sapi/phpdbg/phpdbg_cmd.c index 13d5a0d6340..a170d529555 100644 --- a/sapi/phpdbg/phpdbg_cmd.c +++ b/sapi/phpdbg/phpdbg_cmd.c @@ -727,7 +727,7 @@ PHPDBG_API char *phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */ char *cmd = NULL; char *buffer = NULL; - if (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { + if ((PHPDBG_G(flags) & (PHPDBG_IS_STOPPING | PHPDBG_IS_RUNNING)) != PHPDBG_IS_STOPPING) { if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && (buffered == NULL) && !phpdbg_active_sigsafe_mem(TSRMLS_C)) { fflush(PHPDBG_G(io)[PHPDBG_STDOUT].ptr); } diff --git a/sapi/phpdbg/phpdbg_list.c b/sapi/phpdbg/phpdbg_list.c index 7aa8c4f9e08..8ab4c8922a8 100644 --- a/sapi/phpdbg/phpdbg_list.c +++ b/sapi/phpdbg/phpdbg_list.c @@ -278,6 +278,8 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type TSRMLS_DC) { dataptr->line[line] = endptr - data.buf; dataptr = erealloc(dataptr, sizeof(phpdbg_file_source) + sizeof(uint) * line); + phpdbg_resolve_pending_file_break(filename TSRMLS_CC); + ret = PHPDBG_G(compile_file)(&fake, type TSRMLS_CC); fake.opened_path = NULL; diff --git a/sapi/phpdbg/phpdbg_out.c b/sapi/phpdbg/phpdbg_out.c index a4793f144f6..365708c71ed 100644 --- a/sapi/phpdbg/phpdbg_out.c +++ b/sapi/phpdbg/phpdbg_out.c @@ -1117,6 +1117,8 @@ PHPDBG_API int phpdbg_vprint(int type TSRMLS_DC, int fd, const char *tag, const } if (PHPDBG_G(err_buf).active && type != P_STDOUT && type != P_STDERR) { + phpdbg_free_err_buf(TSRMLS_C); + PHPDBG_G(err_buf).type = type; PHPDBG_G(err_buf).fd = fd; PHPDBG_G(err_buf).tag = estrdup(tag); diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index eca4c6ac2ba..a2e4d41042d 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -28,7 +28,6 @@ #include "phpdbg_print.h" #include "phpdbg_info.h" #include "phpdbg_break.h" -#include "phpdbg_bp.h" #include "phpdbg_opcode.h" #include "phpdbg_list.h" #include "phpdbg_utils.h" @@ -44,7 +43,6 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg); ZEND_EXTERN_MODULE_GLOBALS(output); extern int phpdbg_startup_run; -extern char *phpdbg_exec; #ifdef HAVE_LIBDL #ifdef PHP_WIN32 @@ -641,10 +639,10 @@ PHPDBG_COMMAND(run) /* {{{ */ } zend_try { - PHPDBG_G(flags) ^= PHPDBG_IS_INTERACTIVE; + PHPDBG_G(flags) &= ~PHPDBG_IS_INTERACTIVE; + PHPDBG_G(flags) |= PHPDBG_IS_RUNNING; zend_execute(EG(active_op_array) TSRMLS_CC); - PHPDBG_G(flags) ^= PHPDBG_IS_INTERACTIVE; - phpdbg_notice("stop", "type=\"normal\"", "Script ended normally"); + PHPDBG_G(flags) |= PHPDBG_IS_INTERACTIVE; } zend_catch { EG(active_op_array) = orig_op_array; EG(opline_ptr) = orig_opline; @@ -669,7 +667,11 @@ PHPDBG_COMMAND(run) /* {{{ */ EG(active_op_array) = orig_op_array; EG(opline_ptr) = orig_opline; EG(return_value_ptr_ptr) = orig_retval_ptr; + + phpdbg_clean(1 TSRMLS_CC); } + + PHPDBG_G(flags) &= ~PHPDBG_IS_RUNNING; } else { phpdbg_error("inactive", "type=\"nocontext\"", "Nothing to execute!"); } @@ -1235,8 +1237,8 @@ int phpdbg_interactive(zend_bool allow_async_unsafe TSRMLS_DC) /* {{{ */ PHPDBG_G(flags) |= PHPDBG_IS_INTERACTIVE; - while (1) { - if (PHPDBG_G(flags) & PHPDBG_IS_STOPPING) { + while (ret == SUCCESS || ret == FAILURE) { + if ((PHPDBG_G(flags) & (PHPDBG_IS_STOPPING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_STOPPING) { zend_bailout(); } @@ -1291,6 +1293,7 @@ int phpdbg_interactive(zend_bool allow_async_unsafe TSRMLS_DC) /* {{{ */ phpdbg_stack_free(&stack); phpdbg_destroy_input(&input TSRMLS_CC); PHPDBG_G(req_id) = 0; + input = NULL; } if (input) { @@ -1320,10 +1323,6 @@ void phpdbg_clean(zend_bool full TSRMLS_DC) /* {{{ */ } if (full) { - if (PHPDBG_G(exec)) { - phpdbg_exec = strdup(PHPDBG_G(exec)); /* preserve exec, don't reparse that from cmd */ - } - PHPDBG_G(flags) |= PHPDBG_IS_CLEANING; zend_bailout(); From 26babfb3576907c03caa8aa9698344754a09c7fc Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sun, 26 Oct 2014 22:21:18 +0100 Subject: [PATCH 083/398] Fix last commit, and do not output unnecessary information --- phpdbg.c | 44 +++++++++++++++++++++++----------- phpdbg.h | 4 +++- phpdbg_io.c | 4 ++++ phpdbg_prompt.c | 11 +++++++-- tests/commands/0104_clean.test | 1 - 5 files changed, 46 insertions(+), 18 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index 3e31f76898a..b7fb5e5afc4 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -544,7 +544,7 @@ static void php_sapi_phpdbg_log_message(char *message TSRMLS_DC) /* {{{ */ 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); @@ -554,7 +554,7 @@ static int php_sapi_phpdbg_deactivate(TSRMLS_D) /* {{{ */ 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; } @@ -1035,7 +1035,7 @@ int main(int argc, char **argv) /* {{{ */ 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; @@ -1491,21 +1491,20 @@ phpdbg_main: /* 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; @@ -1514,14 +1513,24 @@ phpdbg_main: 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; @@ -1537,7 +1546,9 @@ phpdbg_interact: } 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 { @@ -1589,9 +1600,13 @@ phpdbg_out: } __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 */ @@ -1638,9 +1653,10 @@ phpdbg_out: 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); } @@ -1654,7 +1670,7 @@ phpdbg_out: } - if (cleaning || remote) { + if (cleaning > 0 || remote) { goto phpdbg_main; } diff --git a/phpdbg.h b/phpdbg.h index 57ea7ee570f..65bdcd0d6f3 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -177,12 +177,14 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC); #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) diff --git a/phpdbg_io.c b/phpdbg_io.c index a2a5c5969f4..6908a687d7e 100644 --- a/phpdbg_io.c +++ b/phpdbg_io.c @@ -187,6 +187,10 @@ PHPDBG_API int phpdbg_mixed_read(int sock, char *ptr, int len, int tmo TSRMLS_DC PHPDBG_API int phpdbg_mixed_write(int sock, const char *ptr, int len TSRMLS_DC) { + if (PHPDBG_G(flags) & PHPDBG_DISCARD_OUTPUT) { + return 0; + } + if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) { return phpdbg_send_bytes(sock, ptr, len); } diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index a2e4d41042d..fd4af2c3cd7 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -263,7 +263,7 @@ void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_ goto next_line; } - { + zend_try { char *input = phpdbg_read_input(cmd TSRMLS_CC); phpdbg_param_t stack; @@ -287,7 +287,12 @@ void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_ 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++; @@ -1160,6 +1165,8 @@ PHPDBG_COMMAND(clean) /* {{{ */ 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(""); diff --git a/tests/commands/0104_clean.test b/tests/commands/0104_clean.test index d50903c479e..2c7660ad60e 100644 --- a/tests/commands/0104_clean.test +++ b/tests/commands/0104_clean.test @@ -9,7 +9,6 @@ #Functions %d #Constants %d #Includes %d -#[Nothing to execute!] ################################################# clean quit From 190f4f9f18643a306fab7a71b625bf01168b0093 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sun, 26 Oct 2014 22:21:18 +0100 Subject: [PATCH 084/398] Fix last commit, and do not output unnecessary information --- sapi/phpdbg/phpdbg.c | 44 +++++++++++++++------- sapi/phpdbg/phpdbg.h | 4 +- sapi/phpdbg/phpdbg_io.c | 4 ++ sapi/phpdbg/phpdbg_prompt.c | 11 +++++- sapi/phpdbg/tests/commands/0104_clean.test | 1 - 5 files changed, 46 insertions(+), 18 deletions(-) diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 3e31f76898a..b7fb5e5afc4 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -544,7 +544,7 @@ static void php_sapi_phpdbg_log_message(char *message TSRMLS_DC) /* {{{ */ 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); @@ -554,7 +554,7 @@ static int php_sapi_phpdbg_deactivate(TSRMLS_D) /* {{{ */ 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; } @@ -1035,7 +1035,7 @@ int main(int argc, char **argv) /* {{{ */ 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; @@ -1491,21 +1491,20 @@ phpdbg_main: /* 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; @@ -1514,14 +1513,24 @@ phpdbg_main: 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; @@ -1537,7 +1546,9 @@ phpdbg_interact: } 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 { @@ -1589,9 +1600,13 @@ phpdbg_out: } __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 */ @@ -1638,9 +1653,10 @@ phpdbg_out: 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); } @@ -1654,7 +1670,7 @@ phpdbg_out: } - if (cleaning || remote) { + if (cleaning > 0 || remote) { goto phpdbg_main; } diff --git a/sapi/phpdbg/phpdbg.h b/sapi/phpdbg/phpdbg.h index 57ea7ee570f..65bdcd0d6f3 100644 --- a/sapi/phpdbg/phpdbg.h +++ b/sapi/phpdbg/phpdbg.h @@ -177,12 +177,14 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC); #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) diff --git a/sapi/phpdbg/phpdbg_io.c b/sapi/phpdbg/phpdbg_io.c index a2a5c5969f4..6908a687d7e 100644 --- a/sapi/phpdbg/phpdbg_io.c +++ b/sapi/phpdbg/phpdbg_io.c @@ -187,6 +187,10 @@ PHPDBG_API int phpdbg_mixed_read(int sock, char *ptr, int len, int tmo TSRMLS_DC PHPDBG_API int phpdbg_mixed_write(int sock, const char *ptr, int len TSRMLS_DC) { + if (PHPDBG_G(flags) & PHPDBG_DISCARD_OUTPUT) { + return 0; + } + if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) { return phpdbg_send_bytes(sock, ptr, len); } diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index a2e4d41042d..fd4af2c3cd7 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -263,7 +263,7 @@ void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_ goto next_line; } - { + zend_try { char *input = phpdbg_read_input(cmd TSRMLS_CC); phpdbg_param_t stack; @@ -287,7 +287,12 @@ void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_ 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++; @@ -1160,6 +1165,8 @@ PHPDBG_COMMAND(clean) /* {{{ */ 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(""); diff --git a/sapi/phpdbg/tests/commands/0104_clean.test b/sapi/phpdbg/tests/commands/0104_clean.test index d50903c479e..2c7660ad60e 100644 --- a/sapi/phpdbg/tests/commands/0104_clean.test +++ b/sapi/phpdbg/tests/commands/0104_clean.test @@ -9,7 +9,6 @@ #Functions %d #Constants %d #Includes %d -#[Nothing to execute!] ################################################# clean quit From e7ddcbcb865ad03a3ad5e500d4ac6d271019473c Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sun, 26 Oct 2014 23:33:54 +0100 Subject: [PATCH 085/398] Do not execute anything after quit or clean command --- phpdbg_prompt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index fd4af2c3cd7..5e2cc03d502 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -1438,6 +1438,10 @@ void phpdbg_execute_ex(zend_op_array *op_array TSRMLS_DC) /* {{{ */ } #endif + if ((PHPDBG_G(flags) & (PHPDBG_IS_STOPPING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_STOPPING) { + zend_bailout(); + } + EG(in_execution) = 1; #if PHP_VERSION_ID >= 50500 From 50756b515c76bb9c43a01bfce03207906f596005 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sun, 26 Oct 2014 23:33:54 +0100 Subject: [PATCH 086/398] Do not execute anything after quit or clean command --- sapi/phpdbg/phpdbg_prompt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index fd4af2c3cd7..5e2cc03d502 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -1438,6 +1438,10 @@ void phpdbg_execute_ex(zend_op_array *op_array TSRMLS_DC) /* {{{ */ } #endif + if ((PHPDBG_G(flags) & (PHPDBG_IS_STOPPING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_STOPPING) { + zend_bailout(); + } + EG(in_execution) = 1; #if PHP_VERSION_ID >= 50500 From c8e1fae17f215a71ffddf834ef8ca409dfd8e50b Mon Sep 17 00:00:00 2001 From: Rasmus Lerdorf Date: Sun, 26 Oct 2014 16:59:17 -0700 Subject: [PATCH 087/398] Fix off-by-one here --- ext/opcache/zend_accelerator_module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c index 001c3ee9ed2..fcaf96408c9 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -499,7 +499,7 @@ static int accelerator_get_scripts(zval *return_value TSRMLS_DC) timerclear(&exec_time); timerclear(&fetch_time); - zend_hash_str_update(Z_ARRVAL_P(return_value), cache_entry->key, cache_entry->key_length-1, &persistent_script_report); + zend_hash_str_update(Z_ARRVAL_P(return_value), cache_entry->key, cache_entry->key_length, &persistent_script_report); } } accelerator_shm_read_unlock(TSRMLS_C); From 3c925b18fa96043e5d7e86f9ce544b143c3c2079 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 27 Oct 2014 07:45:34 +0100 Subject: [PATCH 088/398] Fix bug #63595 GMP memory management conflicts with other libraries using GMP Drop use of php memory allocators as this raise various conflicts with other extensions and libraries which use libgmp. No other solution found. We cannot for ensure correct use of allocator with shared lib. Some memory can allocated before php init Some memory can be freed after php shutdown Known broken run cases - php + curl + gnutls + gmp - mod_gnutls + mod_php + gnutls + gmp - php + freetds + gnutls + gmp - php + odbc + freetds + gnutls + gmp - php + php-mapi (zarafa) + gnutls + gmp --- ext/gmp/gmp.c | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index f51bd8c59c0..b1553fa16f0 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -324,30 +324,6 @@ static void _php_gmpnum_free(zend_rsrc_list_entry *rsrc TSRMLS_DC); # define MAX_BASE 36 #endif -/* {{{ gmp_emalloc - */ -static void *gmp_emalloc(size_t size) -{ - return emalloc(size); -} -/* }}} */ - -/* {{{ gmp_erealloc - */ -static void *gmp_erealloc(void *ptr, size_t old_size, size_t new_size) -{ - return erealloc(ptr, new_size); -} -/* }}} */ - -/* {{{ gmp_efree - */ -static void gmp_efree(void *ptr, size_t size) -{ - efree(ptr); -} -/* }}} */ - /* {{{ ZEND_GINIT_FUNCTION */ static ZEND_GINIT_FUNCTION(gmp) @@ -369,8 +345,6 @@ ZEND_MODULE_STARTUP_D(gmp) #endif REGISTER_STRING_CONSTANT("GMP_VERSION", (char *)gmp_version, CONST_CS | CONST_PERSISTENT); - mp_set_memory_functions(gmp_emalloc, gmp_erealloc, gmp_efree); - return SUCCESS; } /* }}} */ From 88527e456951d13a681fbef65984bc3c4907fded Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 27 Oct 2014 07:47:18 +0100 Subject: [PATCH 089/398] NEWS --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index abcaa7b461e..c7fd7afe4a5 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,10 @@ PHP NEWS - GD: . Fixed bug #65171 (imagescale() fails without height param). (Remi) +- GMP: + . Fixed bug #63595 (GMP memory management conflicts with other libraries + using GMP). (Remi) + - Mysqli: . Fixed bug #68114 (linker error on some OS X machines with fixed width decimal support) (Keyur Govande) From cc91072f0ef69b5884f23eb758ef6e12e8858034 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 27 Oct 2014 07:51:50 +0100 Subject: [PATCH 090/398] NEWS --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 2b68ac14933..5f9e41d0652 100644 --- a/NEWS +++ b/NEWS @@ -37,6 +37,8 @@ PHP NEWS - GMP: . Implemented gmp_random_range() and gmp_random_bits(). (Leigh) + . Fixed bug #63595 (GMP memory management conflicts with other libraries + using GMP). (Remi) - Reflection: . Fixed bug #68103 (Duplicate entry in Reflection for class alias). (Remi) From 0e7987c61aef9965d9b6b9dd0cd6f0bc3d6acae0 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 10:08:58 +0100 Subject: [PATCH 091/398] improve the current sigio handling on win32 --- phpdbg_prompt.c | 12 ++++++++++-- phpdbg_sigio_win32.c | 25 +++++++++++-------------- phpdbg_sigio_win32.h | 2 -- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 82444fbf1d3..72063c194af 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -1211,7 +1211,8 @@ int phpdbg_interactive(zend_bool allow_async_unsafe TSRMLS_DC) /* {{{ */ #ifdef PHP_WIN32 #define PARA ((phpdbg_param_t *)stack.next)->type - if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE && (RUN_PARAM == PARA || EVAL_PARAM == PARA)) { +#define HANDLE_SIGIO (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && PARA != EMPTY_PARAM + if (HANDLE_SIGIO) { sigio_watcher_start(); } #endif @@ -1228,6 +1229,12 @@ int phpdbg_interactive(zend_bool allow_async_unsafe TSRMLS_DC) /* {{{ */ case PHPDBG_FINISH: case PHPDBG_UNTIL: case PHPDBG_NEXT: { +#ifdef PHP_WIN32 + if (HANDLE_SIGIO) { + sigio_watcher_stop(); + sigio_watcher_start(); + } +#endif phpdbg_activate_err_buf(0 TSRMLS_CC); phpdbg_free_err_buf(TSRMLS_C); if (!EG(in_execution) && !(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { @@ -1240,10 +1247,11 @@ int phpdbg_interactive(zend_bool allow_async_unsafe TSRMLS_DC) /* {{{ */ phpdbg_activate_err_buf(0 TSRMLS_CC); phpdbg_free_err_buf(TSRMLS_C); #ifdef PHP_WIN32 - if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE && (RUN_PARAM == PARA || EVAL_PARAM == PARA)) { + if (HANDLE_SIGIO) { sigio_watcher_stop(); } #undef PARA +#undef HANDLE_SIGIO #endif } diff --git a/phpdbg_sigio_win32.c b/phpdbg_sigio_win32.c index 24e9ac0e0aa..158e034872b 100644 --- a/phpdbg_sigio_win32.c +++ b/phpdbg_sigio_win32.c @@ -33,30 +33,31 @@ SigIoWatcherThread(VOID *p) struct win32_sigio_watcher_data *swd = (struct win32_sigio_watcher_data *)p; #ifdef ZTS void ***tsrm_ls = swd->tsrm_ls; -top: - (void)phpdbg_consume_bytes(swd->fd, &sig, 1, -1, tsrm_ls); -#else -top: - (void)phpdbg_consume_bytes(swd->fd, &sig, 1, -1); #endif +top: + (void)phpdbg_consume_bytes(swd->fd, &sig, 1, -1 TSRMLS_CC); + if (3 == sig) { - printf("signaled, got %d", sig); /* XXX completely not sure it is done right here */ - if (swd->flags & PHPDBG_IS_INTERACTIVE) { + if (PHPDBG_G(flags) & PHPDBG_IS_INTERACTIVE) { if (raise(sig)) { - /* just out*/ - exit(0); + goto top; } } - if (swd->flags & PHPDBG_IS_SIGNALED) { + if (PHPDBG_G(flags) & PHPDBG_IS_SIGNALED) { phpdbg_set_sigsafe_mem(&sig TSRMLS_CC); zend_try { phpdbg_force_interruption(TSRMLS_C); } zend_end_try(); phpdbg_clear_sigsafe_mem(TSRMLS_C); + goto end; } + if (!(PHPDBG_G(flags) & PHPDBG_IS_INTERACTIVE)) { + PHPDBG_G(flags) |= PHPDBG_IS_SIGNALED; + } +end: /* XXX set signaled flag to the caller thread, question is - whether it's needed */ ExitThread(sig); } else { @@ -74,8 +75,6 @@ sigio_watcher_start(void) TSRMLS_FETCH(); PHPDBG_G(swd).fd = PHPDBG_G(io)[PHPDBG_STDIN].fd; - PHPDBG_G(swd).running = 1; - PHPDBG_G(swd).flags = PHPDBG_G(flags); #ifdef ZTS PHPDBG_G(swd).tsrm_ls = tsrm_ls; #endif @@ -113,8 +112,6 @@ sigio_watcher_stop(void) } PHPDBG_G(swd).fd = -1; - PHPDBG_G(swd).running = 0; - PHPDBG_G(swd).flags = 0; PHPDBG_G(sigio_watcher_thread) = INVALID_HANDLE_VALUE; } diff --git a/phpdbg_sigio_win32.h b/phpdbg_sigio_win32.h index 796b477f936..8c8a381d64b 100644 --- a/phpdbg_sigio_win32.h +++ b/phpdbg_sigio_win32.h @@ -25,12 +25,10 @@ #include "phpdbg_io.h" struct win32_sigio_watcher_data { - zend_ulong flags; #ifdef ZTS void ***tsrm_ls; #endif int fd; - zend_uchar running; }; void From 5e8359d360c668b5ca4f5b5dbb62e65b6e033f2c Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Mon, 27 Oct 2014 10:44:01 +0100 Subject: [PATCH 092/398] Fix listening on port --- phpdbg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpdbg.c b/phpdbg.c index b7fb5e5afc4..02a9260eb97 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -1343,7 +1343,7 @@ phpdbg_main: } /* setup remote server if necessary */ - if (!cleaning && listen > 0) { + if (cleaning <= 0 && listen > 0) { server = phpdbg_open_socket(address, listen TSRMLS_CC); if (-1 > server || phpdbg_remote_init(address, listen, server, &socket, &stream TSRMLS_CC) == FAILURE) { exit(0); From 9139d031d8877f061f7cefafefa41260017e9563 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Mon, 27 Oct 2014 11:01:43 +0100 Subject: [PATCH 093/398] Fix segfault when cleaning without execution context --- phpdbg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpdbg.c b/phpdbg.c index 02a9260eb97..9c56b1d7bc9 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -1466,7 +1466,7 @@ phpdbg_main: if (exec) { /* set execution context */ PHPDBG_G(exec) = phpdbg_resolve_path(exec TSRMLS_CC); - PHPDBG_G(exec_len) = strlen(PHPDBG_G(exec)); + PHPDBG_G(exec_len) = strlen(exec); free(exec); exec = NULL; From b4db856d374d0df47e902b65639ab9a06346aa8a Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Mon, 27 Oct 2014 11:02:08 +0100 Subject: [PATCH 094/398] Fix failing quit when quitting during execution --- phpdbg_prompt.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 0e527c6f6bf..73ecbcb892c 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -653,6 +653,10 @@ PHPDBG_COMMAND(run) /* {{{ */ EG(opline_ptr) = orig_opline; EG(return_value_ptr_ptr) = orig_retval_ptr; + if (PHPDBG_G(flags) & PHPDBG_IS_QUITTING) { + zend_bailout(); + } + if (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { phpdbg_error("stop", "type=\"bailout\"", "Caught exit/error from VM"); restore = 0; @@ -1143,6 +1147,7 @@ PHPDBG_COMMAND(quit) /* {{{ */ /* don't allow this to loop, ever ... */ if (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { PHPDBG_G(flags) |= PHPDBG_IS_QUITTING; + PHPDBG_G(flags) &= ~(PHPDBG_IS_RUNNING | PHPDBG_IS_CLEANING); zend_bailout(); } @@ -1261,8 +1266,7 @@ int phpdbg_interactive(zend_bool allow_async_unsafe TSRMLS_DC) /* {{{ */ #ifdef PHP_WIN32 #define PARA ((phpdbg_param_t *)stack.next)->type -#define HANDLE_SIGIO (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && PARA != EMPTY_PARAM - if (HANDLE_SIGIO) { + if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE && (RUN_PARAM == PARA || EVAL_PARAM == PARA)) { sigio_watcher_start(); } #endif @@ -1279,29 +1283,22 @@ int phpdbg_interactive(zend_bool allow_async_unsafe TSRMLS_DC) /* {{{ */ case PHPDBG_FINISH: case PHPDBG_UNTIL: case PHPDBG_NEXT: { -#ifdef PHP_WIN32 - if (HANDLE_SIGIO) { - sigio_watcher_stop(); - sigio_watcher_start(); - } -#endif phpdbg_activate_err_buf(0 TSRMLS_CC); phpdbg_free_err_buf(TSRMLS_C); - if (!EG(in_execution) && !(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { + if (!EG(in_execution) && !(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { phpdbg_error("command", "type=\"noexec\"", "Not running"); } + break; } - break; } phpdbg_activate_err_buf(0 TSRMLS_CC); phpdbg_free_err_buf(TSRMLS_C); #ifdef PHP_WIN32 - if (HANDLE_SIGIO) { + if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE && (RUN_PARAM == PARA || EVAL_PARAM == PARA)) { sigio_watcher_stop(); } #undef PARA -#undef HANDLE_SIGIO #endif } @@ -1446,7 +1443,7 @@ void phpdbg_execute_ex(zend_op_array *op_array TSRMLS_DC) /* {{{ */ } #endif - if ((PHPDBG_G(flags) & (PHPDBG_IS_STOPPING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_STOPPING) { + if ((PHPDBG_G(flags) & PHPDBG_IS_STOPPING) && !(PHPDBG_G(flags) & PHPDBG_IS_RUNNING)) { zend_bailout(); } From 35d90d3858be64b83196b194492f25945666088e Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Mon, 27 Oct 2014 13:11:13 +0100 Subject: [PATCH 095/398] Merge phpdbg into PHP-5.6 Conflicts: sapi/phpdbg/phpdbg.c sapi/phpdbg/phpdbg_prompt.c --- phpdbg.c | 4 ++-- phpdbg.h | 9 ++++++--- phpdbg_prompt.c | 7 ++++++- phpdbg_sigio_win32.c | 25 +++++++++++-------------- phpdbg_sigio_win32.h | 2 -- 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index b7fb5e5afc4..9c56b1d7bc9 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -1343,7 +1343,7 @@ phpdbg_main: } /* setup remote server if necessary */ - if (!cleaning && listen > 0) { + if (cleaning <= 0 && listen > 0) { server = phpdbg_open_socket(address, listen TSRMLS_CC); if (-1 > server || phpdbg_remote_init(address, listen, server, &socket, &stream TSRMLS_CC) == FAILURE) { exit(0); @@ -1466,7 +1466,7 @@ phpdbg_main: if (exec) { /* set execution context */ PHPDBG_G(exec) = phpdbg_resolve_path(exec TSRMLS_CC); - PHPDBG_G(exec_len) = strlen(PHPDBG_G(exec)); + PHPDBG_G(exec_len) = strlen(exec); free(exec); exec = NULL; diff --git a/phpdbg.h b/phpdbg.h index 65bdcd0d6f3..2aae533d845 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -29,8 +29,12 @@ # define PHPDBG_API #endif -#include -#include +#ifndef PHP_WIN32 +# include +# include +#else +# include "win32/php_stdint.h" +#endif #include "php.h" #include "php_globals.h" #include "php_variables.h" @@ -50,7 +54,6 @@ #if defined(_WIN32) && !defined(__MINGW32__) # include # include "config.w32.h" -# include "win32/php_stdint.h" # undef strcasecmp # undef strncasecmp # define strcasecmp _stricmp diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 5e2cc03d502..73ecbcb892c 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -653,6 +653,10 @@ PHPDBG_COMMAND(run) /* {{{ */ EG(opline_ptr) = orig_opline; EG(return_value_ptr_ptr) = orig_retval_ptr; + if (PHPDBG_G(flags) & PHPDBG_IS_QUITTING) { + zend_bailout(); + } + if (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { phpdbg_error("stop", "type=\"bailout\"", "Caught exit/error from VM"); restore = 0; @@ -1143,6 +1147,7 @@ PHPDBG_COMMAND(quit) /* {{{ */ /* don't allow this to loop, ever ... */ if (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { PHPDBG_G(flags) |= PHPDBG_IS_QUITTING; + PHPDBG_G(flags) &= ~(PHPDBG_IS_RUNNING | PHPDBG_IS_CLEANING); zend_bailout(); } @@ -1438,7 +1443,7 @@ void phpdbg_execute_ex(zend_op_array *op_array TSRMLS_DC) /* {{{ */ } #endif - if ((PHPDBG_G(flags) & (PHPDBG_IS_STOPPING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_STOPPING) { + if ((PHPDBG_G(flags) & PHPDBG_IS_STOPPING) && !(PHPDBG_G(flags) & PHPDBG_IS_RUNNING)) { zend_bailout(); } diff --git a/phpdbg_sigio_win32.c b/phpdbg_sigio_win32.c index 24e9ac0e0aa..158e034872b 100644 --- a/phpdbg_sigio_win32.c +++ b/phpdbg_sigio_win32.c @@ -33,30 +33,31 @@ SigIoWatcherThread(VOID *p) struct win32_sigio_watcher_data *swd = (struct win32_sigio_watcher_data *)p; #ifdef ZTS void ***tsrm_ls = swd->tsrm_ls; -top: - (void)phpdbg_consume_bytes(swd->fd, &sig, 1, -1, tsrm_ls); -#else -top: - (void)phpdbg_consume_bytes(swd->fd, &sig, 1, -1); #endif +top: + (void)phpdbg_consume_bytes(swd->fd, &sig, 1, -1 TSRMLS_CC); + if (3 == sig) { - printf("signaled, got %d", sig); /* XXX completely not sure it is done right here */ - if (swd->flags & PHPDBG_IS_INTERACTIVE) { + if (PHPDBG_G(flags) & PHPDBG_IS_INTERACTIVE) { if (raise(sig)) { - /* just out*/ - exit(0); + goto top; } } - if (swd->flags & PHPDBG_IS_SIGNALED) { + if (PHPDBG_G(flags) & PHPDBG_IS_SIGNALED) { phpdbg_set_sigsafe_mem(&sig TSRMLS_CC); zend_try { phpdbg_force_interruption(TSRMLS_C); } zend_end_try(); phpdbg_clear_sigsafe_mem(TSRMLS_C); + goto end; } + if (!(PHPDBG_G(flags) & PHPDBG_IS_INTERACTIVE)) { + PHPDBG_G(flags) |= PHPDBG_IS_SIGNALED; + } +end: /* XXX set signaled flag to the caller thread, question is - whether it's needed */ ExitThread(sig); } else { @@ -74,8 +75,6 @@ sigio_watcher_start(void) TSRMLS_FETCH(); PHPDBG_G(swd).fd = PHPDBG_G(io)[PHPDBG_STDIN].fd; - PHPDBG_G(swd).running = 1; - PHPDBG_G(swd).flags = PHPDBG_G(flags); #ifdef ZTS PHPDBG_G(swd).tsrm_ls = tsrm_ls; #endif @@ -113,8 +112,6 @@ sigio_watcher_stop(void) } PHPDBG_G(swd).fd = -1; - PHPDBG_G(swd).running = 0; - PHPDBG_G(swd).flags = 0; PHPDBG_G(sigio_watcher_thread) = INVALID_HANDLE_VALUE; } diff --git a/phpdbg_sigio_win32.h b/phpdbg_sigio_win32.h index 796b477f936..8c8a381d64b 100644 --- a/phpdbg_sigio_win32.h +++ b/phpdbg_sigio_win32.h @@ -25,12 +25,10 @@ #include "phpdbg_io.h" struct win32_sigio_watcher_data { - zend_ulong flags; #ifdef ZTS void ***tsrm_ls; #endif int fd; - zend_uchar running; }; void From 8b98ffea5f2adcc46ca1fbafd3809728dcaafb3d Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Mon, 27 Oct 2014 13:27:54 +0100 Subject: [PATCH 096/398] Never exist xml mode... --- phpdbg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpdbg.h b/phpdbg.h index 2aae533d845..a9be80436e9 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -187,7 +187,7 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC); #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 | PHPDBG_IS_QUIET | PHPDBG_IS_COLOURED) +#define PHPDBG_PRESERVE_FLAGS_MASK (PHPDBG_SHOW_REFCOUNTS | PHPDBG_IS_STEPONEVAL | PHPDBG_IS_BP_ENABLED | PHPDBG_STEP_OPCODE | PHPDBG_IS_QUIET | PHPDBG_IS_COLOURED | PHPDBG_IS_REMOTE | PHPDBG_WRITE_XML | PHPDBG_IS_DISCONNECTED) #ifndef _WIN32 # define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET | PHPDBG_IS_COLOURED | PHPDBG_IS_BP_ENABLED) From 2297a9aa01bf1414bfe3dedc666b9ad09d3fa428 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Mon, 27 Oct 2014 13:55:20 +0100 Subject: [PATCH 097/398] Fix resolving breakpoints of already loaded files --- phpdbg_bp.c | 123 ++++++++++++++++++++++++++++++++-------------------- phpdbg_bp.h | 1 + 2 files changed, 76 insertions(+), 48 deletions(-) diff --git a/phpdbg_bp.c b/phpdbg_bp.c index 9333b353ce6..cf28a338859 100644 --- a/phpdbg_bp.c +++ b/phpdbg_bp.c @@ -257,12 +257,31 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRML } if (!zend_hash_index_exists(broken, line_num)) { + HashPosition position; + char *file; + uint filelen; + PHPDBG_BREAK_INIT(new_break, PHPDBG_BREAK_FILE); new_break.filename = estrndup(path, path_len); new_break.line = line_num; zend_hash_index_update(broken, line_num, (void **) &new_break, sizeof(phpdbg_breakfile_t), NULL); + PHPDBG_BREAK_MAPPING(new_break.id, broken); + + if (pending) { + for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(file_sources), &position); + zend_hash_get_current_key_ex(&PHPDBG_G(file_sources), &file, &filelen, NULL, 0, &position) == HASH_KEY_IS_STRING; + zend_hash_move_forward_ex(&PHPDBG_G(file_sources), &position)) { + if (!(pending = ((broken = phpdbg_resolve_pending_file_break_ex(file, filelen, path, path_len, broken TSRMLS_CC)) == NULL))) { + phpdbg_breakfile_t *brake; + zend_hash_index_find(broken, line_num, (void **) &brake); + new_break = *brake; + break; + } + } + } + if (pending) { PHPDBG_G(flags) |= PHPDBG_HAS_PENDING_FILE_BP; @@ -272,69 +291,77 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRML phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" file=\"%s\" line=\"%ld\"", "Breakpoint #%d added at %s:%ld", new_break.id, new_break.filename, new_break.line); } - - PHPDBG_BREAK_MAPPING(new_break.id, broken); } else { phpdbg_error("breakpoint", "type=\"exists\" add=\"fail\" file=\"%s\" line=\"%ld\"", "Breakpoint at %s:%ld exists", path, line_num); } } /* }}} */ +PHPDBG_API HashTable *phpdbg_resolve_pending_file_break_ex(const char *file, uint filelen, const char *cur, uint curlen, HashTable *fileht TSRMLS_DC) /* {{{ */ +{ + if (curlen < filelen && file[filelen - curlen - 1] == '/' && !memcmp(file + filelen - curlen, cur, curlen)) { + phpdbg_breakfile_t *brake, new_brake; + HashTable *master = NULL; + HashPosition position; + dtor_func_t dtor; + + PHPDBG_G(flags) |= PHPDBG_HAS_FILE_BP; + + if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, (void **) &master) == FAILURE) { + dtor = PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor; + PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor = NULL; + zend_hash_add(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, fileht, sizeof(HashTable), (void **) &fileht); + } + + for (zend_hash_internal_pointer_reset_ex(fileht, &position); + zend_hash_get_current_data_ex(fileht, (void**)&brake, &position) == SUCCESS; + zend_hash_move_forward_ex(fileht, &position)) { + new_brake = *brake; + new_brake.filename = estrndup(file, filelen); + PHPDBG_BREAK_UNMAPPING(brake->id); + + if (master) { + zend_hash_index_update(master, brake->line, (void **) &new_brake, sizeof(phpdbg_breakfile_t), NULL); + PHPDBG_BREAK_MAPPING(brake->id, master); + } else { + efree((char *) brake->filename); + *brake = new_brake; + PHPDBG_BREAK_MAPPING(brake->id, fileht); + } + } + + zend_hash_del(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], cur, curlen); + + if (!master) { + PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor = dtor; + } + + if (!zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING])) { + PHPDBG_G(flags) &= ~PHPDBG_HAS_PENDING_FILE_BP; + } + + return fileht; + } + + return NULL; +} /* }}} */ + PHPDBG_API void phpdbg_resolve_pending_file_break(const char *file TSRMLS_DC) /* {{{ */ { - HashPosition position[2]; + HashPosition position; HashTable *fileht; uint filelen = strlen(file); - zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position[0]); - while (zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], (void**) &fileht, &position[0]) == SUCCESS) { + zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position); + while (zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], (void**) &fileht, &position) == SUCCESS) { const char *cur; uint curlen; - zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], (char **) &cur, &curlen, NULL, 0, &position[0]); - zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position[0]); + zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], (char **) &cur, &curlen, NULL, 0, &position); + zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position); - if (curlen < filelen && file[filelen - curlen - 1] == '/' && !memcmp(file + filelen - curlen, cur, curlen)) { - phpdbg_breakfile_t *brake, new_brake; - HashTable *master = NULL; - dtor_func_t dtor; - - PHPDBG_G(flags) |= PHPDBG_HAS_FILE_BP; - - if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, (void **) &master) == FAILURE) { - dtor = PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor; - PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor = NULL; - zend_hash_add(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, fileht, sizeof(HashTable), (void **) &fileht); - } - - for (zend_hash_internal_pointer_reset_ex(fileht, &position[1]); - zend_hash_get_current_data_ex(fileht, (void**)&brake, &position[1]) == SUCCESS; - zend_hash_move_forward_ex(fileht, &position[1])) { - new_brake = *brake; - new_brake.filename = estrndup(file, filelen); - PHPDBG_BREAK_UNMAPPING(brake->id); - - if (master) { - zend_hash_index_update(master, brake->line, (void **) &new_brake, sizeof(phpdbg_breakfile_t), NULL); - PHPDBG_BREAK_MAPPING(brake->id, master); - } else { - efree((char *) brake->filename); - *brake = new_brake; - PHPDBG_BREAK_MAPPING(brake->id, fileht); - } - } - - zend_hash_del(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], cur, curlen); - - if (!master) { - PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor = dtor; - } - - if (!zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING])) { - PHPDBG_G(flags) &= ~PHPDBG_HAS_PENDING_FILE_BP; - } - } + phpdbg_resolve_pending_file_break_ex(file, filelen, cur, curlen, fileht TSRMLS_CC); } -} /* }}} */ +} PHPDBG_API void phpdbg_set_breakpoint_symbol(const char *name, size_t name_len TSRMLS_DC) /* {{{ */ { diff --git a/phpdbg_bp.h b/phpdbg_bp.h index 606085ddcfc..eca595321b3 100644 --- a/phpdbg_bp.h +++ b/phpdbg_bp.h @@ -121,6 +121,7 @@ typedef struct _phpdbg_breakcond_t { PHPDBG_API void phpdbg_resolve_op_array_breaks(zend_op_array *op_array TSRMLS_DC); PHPDBG_API int phpdbg_resolve_op_array_break(phpdbg_breakopline_t *brake, zend_op_array *op_array TSRMLS_DC); PHPDBG_API int phpdbg_resolve_opline_break(phpdbg_breakopline_t *new_break TSRMLS_DC); +PHPDBG_API HashTable *phpdbg_resolve_pending_file_break_ex(const char *file, uint filelen, const char *cur, uint curlen, HashTable *fileht TSRMLS_DC); PHPDBG_API void phpdbg_resolve_pending_file_break(const char *file TSRMLS_DC); /* }}} */ /* {{{ Breakpoint Creation API */ From 44079a0c820e08de1709d8dff2682ba4b2c03965 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Mon, 27 Oct 2014 14:07:26 +0100 Subject: [PATCH 098/398] Merge phpdbg into PHP-5.6 --- phpdbg.h | 2 +- phpdbg_bp.c | 123 ++++++++++++++++++++++++++++++++-------------------- phpdbg_bp.h | 1 + 3 files changed, 77 insertions(+), 49 deletions(-) diff --git a/phpdbg.h b/phpdbg.h index 2aae533d845..a9be80436e9 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -187,7 +187,7 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC); #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 | PHPDBG_IS_QUIET | PHPDBG_IS_COLOURED) +#define PHPDBG_PRESERVE_FLAGS_MASK (PHPDBG_SHOW_REFCOUNTS | PHPDBG_IS_STEPONEVAL | PHPDBG_IS_BP_ENABLED | PHPDBG_STEP_OPCODE | PHPDBG_IS_QUIET | PHPDBG_IS_COLOURED | PHPDBG_IS_REMOTE | PHPDBG_WRITE_XML | PHPDBG_IS_DISCONNECTED) #ifndef _WIN32 # define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET | PHPDBG_IS_COLOURED | PHPDBG_IS_BP_ENABLED) diff --git a/phpdbg_bp.c b/phpdbg_bp.c index 9333b353ce6..cf28a338859 100644 --- a/phpdbg_bp.c +++ b/phpdbg_bp.c @@ -257,12 +257,31 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRML } if (!zend_hash_index_exists(broken, line_num)) { + HashPosition position; + char *file; + uint filelen; + PHPDBG_BREAK_INIT(new_break, PHPDBG_BREAK_FILE); new_break.filename = estrndup(path, path_len); new_break.line = line_num; zend_hash_index_update(broken, line_num, (void **) &new_break, sizeof(phpdbg_breakfile_t), NULL); + PHPDBG_BREAK_MAPPING(new_break.id, broken); + + if (pending) { + for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(file_sources), &position); + zend_hash_get_current_key_ex(&PHPDBG_G(file_sources), &file, &filelen, NULL, 0, &position) == HASH_KEY_IS_STRING; + zend_hash_move_forward_ex(&PHPDBG_G(file_sources), &position)) { + if (!(pending = ((broken = phpdbg_resolve_pending_file_break_ex(file, filelen, path, path_len, broken TSRMLS_CC)) == NULL))) { + phpdbg_breakfile_t *brake; + zend_hash_index_find(broken, line_num, (void **) &brake); + new_break = *brake; + break; + } + } + } + if (pending) { PHPDBG_G(flags) |= PHPDBG_HAS_PENDING_FILE_BP; @@ -272,69 +291,77 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRML phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" file=\"%s\" line=\"%ld\"", "Breakpoint #%d added at %s:%ld", new_break.id, new_break.filename, new_break.line); } - - PHPDBG_BREAK_MAPPING(new_break.id, broken); } else { phpdbg_error("breakpoint", "type=\"exists\" add=\"fail\" file=\"%s\" line=\"%ld\"", "Breakpoint at %s:%ld exists", path, line_num); } } /* }}} */ +PHPDBG_API HashTable *phpdbg_resolve_pending_file_break_ex(const char *file, uint filelen, const char *cur, uint curlen, HashTable *fileht TSRMLS_DC) /* {{{ */ +{ + if (curlen < filelen && file[filelen - curlen - 1] == '/' && !memcmp(file + filelen - curlen, cur, curlen)) { + phpdbg_breakfile_t *brake, new_brake; + HashTable *master = NULL; + HashPosition position; + dtor_func_t dtor; + + PHPDBG_G(flags) |= PHPDBG_HAS_FILE_BP; + + if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, (void **) &master) == FAILURE) { + dtor = PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor; + PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor = NULL; + zend_hash_add(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, fileht, sizeof(HashTable), (void **) &fileht); + } + + for (zend_hash_internal_pointer_reset_ex(fileht, &position); + zend_hash_get_current_data_ex(fileht, (void**)&brake, &position) == SUCCESS; + zend_hash_move_forward_ex(fileht, &position)) { + new_brake = *brake; + new_brake.filename = estrndup(file, filelen); + PHPDBG_BREAK_UNMAPPING(brake->id); + + if (master) { + zend_hash_index_update(master, brake->line, (void **) &new_brake, sizeof(phpdbg_breakfile_t), NULL); + PHPDBG_BREAK_MAPPING(brake->id, master); + } else { + efree((char *) brake->filename); + *brake = new_brake; + PHPDBG_BREAK_MAPPING(brake->id, fileht); + } + } + + zend_hash_del(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], cur, curlen); + + if (!master) { + PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor = dtor; + } + + if (!zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING])) { + PHPDBG_G(flags) &= ~PHPDBG_HAS_PENDING_FILE_BP; + } + + return fileht; + } + + return NULL; +} /* }}} */ + PHPDBG_API void phpdbg_resolve_pending_file_break(const char *file TSRMLS_DC) /* {{{ */ { - HashPosition position[2]; + HashPosition position; HashTable *fileht; uint filelen = strlen(file); - zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position[0]); - while (zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], (void**) &fileht, &position[0]) == SUCCESS) { + zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position); + while (zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], (void**) &fileht, &position) == SUCCESS) { const char *cur; uint curlen; - zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], (char **) &cur, &curlen, NULL, 0, &position[0]); - zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position[0]); + zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], (char **) &cur, &curlen, NULL, 0, &position); + zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position); - if (curlen < filelen && file[filelen - curlen - 1] == '/' && !memcmp(file + filelen - curlen, cur, curlen)) { - phpdbg_breakfile_t *brake, new_brake; - HashTable *master = NULL; - dtor_func_t dtor; - - PHPDBG_G(flags) |= PHPDBG_HAS_FILE_BP; - - if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, (void **) &master) == FAILURE) { - dtor = PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor; - PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor = NULL; - zend_hash_add(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, fileht, sizeof(HashTable), (void **) &fileht); - } - - for (zend_hash_internal_pointer_reset_ex(fileht, &position[1]); - zend_hash_get_current_data_ex(fileht, (void**)&brake, &position[1]) == SUCCESS; - zend_hash_move_forward_ex(fileht, &position[1])) { - new_brake = *brake; - new_brake.filename = estrndup(file, filelen); - PHPDBG_BREAK_UNMAPPING(brake->id); - - if (master) { - zend_hash_index_update(master, brake->line, (void **) &new_brake, sizeof(phpdbg_breakfile_t), NULL); - PHPDBG_BREAK_MAPPING(brake->id, master); - } else { - efree((char *) brake->filename); - *brake = new_brake; - PHPDBG_BREAK_MAPPING(brake->id, fileht); - } - } - - zend_hash_del(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], cur, curlen); - - if (!master) { - PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor = dtor; - } - - if (!zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING])) { - PHPDBG_G(flags) &= ~PHPDBG_HAS_PENDING_FILE_BP; - } - } + phpdbg_resolve_pending_file_break_ex(file, filelen, cur, curlen, fileht TSRMLS_CC); } -} /* }}} */ +} PHPDBG_API void phpdbg_set_breakpoint_symbol(const char *name, size_t name_len TSRMLS_DC) /* {{{ */ { diff --git a/phpdbg_bp.h b/phpdbg_bp.h index 606085ddcfc..eca595321b3 100644 --- a/phpdbg_bp.h +++ b/phpdbg_bp.h @@ -121,6 +121,7 @@ typedef struct _phpdbg_breakcond_t { PHPDBG_API void phpdbg_resolve_op_array_breaks(zend_op_array *op_array TSRMLS_DC); PHPDBG_API int phpdbg_resolve_op_array_break(phpdbg_breakopline_t *brake, zend_op_array *op_array TSRMLS_DC); PHPDBG_API int phpdbg_resolve_opline_break(phpdbg_breakopline_t *new_break TSRMLS_DC); +PHPDBG_API HashTable *phpdbg_resolve_pending_file_break_ex(const char *file, uint filelen, const char *cur, uint curlen, HashTable *fileht TSRMLS_DC); PHPDBG_API void phpdbg_resolve_pending_file_break(const char *file TSRMLS_DC); /* }}} */ /* {{{ Breakpoint Creation API */ From 8fdaeef8e8df79562662c19ced80b0209cdcc110 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 11:50:49 +0100 Subject: [PATCH 099/398] fix datatype mismatches --- Zend/zend_inheritance.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index f240ed71592..c6f8c6ae158 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -372,7 +372,7 @@ static zend_string *zend_get_function_declaration(zend_function *fptr TSRMLS_DC) for (i = 0; i < fptr->common.num_args;) { if (arg_info->class_name) { const char *class_name; - uint32_t class_name_len; + size_t class_name_len; if (!strcasecmp(arg_info->class_name, "self") && fptr->common.scope) { class_name = fptr->common.scope->name->val; class_name_len = fptr->common.scope->name->len; From 5b5e2d3d456b6ca7d7a0ba2af074b153d84fe997 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 11:52:17 +0100 Subject: [PATCH 100/398] fix datatype mismatch warnings --- Zend/zend_ini.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c index e60e58d2aa1..0b13f43315e 100644 --- a/Zend/zend_ini.c +++ b/Zend/zend_ini.c @@ -658,7 +658,7 @@ ZEND_API ZEND_INI_MH(OnUpdateLong) /* {{{ */ p = (zend_long *) (base+(size_t) mh_arg1); - *p = zend_atol(new_value->val, new_value->len); + *p = zend_atol(new_value->val, (int)new_value->len); return SUCCESS; } /* }}} */ @@ -674,7 +674,7 @@ ZEND_API ZEND_INI_MH(OnUpdateLongGEZero) /* {{{ */ base = (char *) ts_resource(*((int *) mh_arg2)); #endif - tmp = zend_atol(new_value->val, new_value->len); + tmp = zend_atol(new_value->val, (int)new_value->len); if (tmp < 0) { return FAILURE; } From b0d86d87d829a986ce2dd226e410e7f010702c6a Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 12:00:25 +0100 Subject: [PATCH 101/398] fix datatype mismatches --- Zend/zend_llist.c | 2 +- Zend/zend_llist.h | 2 +- main/streams/streams.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Zend/zend_llist.c b/Zend/zend_llist.c index 0fb49abf5b4..0df7e702f18 100644 --- a/Zend/zend_llist.c +++ b/Zend/zend_llist.c @@ -243,7 +243,7 @@ ZEND_API void zend_llist_apply_with_arguments(zend_llist *l, llist_apply_with_ar } -ZEND_API int zend_llist_count(zend_llist *l) +ZEND_API size_t zend_llist_count(zend_llist *l) { return l->count; } diff --git a/Zend/zend_llist.h b/Zend/zend_llist.h index 602884c27da..ffe0c3cf991 100644 --- a/Zend/zend_llist.h +++ b/Zend/zend_llist.h @@ -59,7 +59,7 @@ ZEND_API void zend_llist_apply(zend_llist *l, llist_apply_func_t func TSRMLS_DC) ZEND_API void zend_llist_apply_with_del(zend_llist *l, int (*func)(void *data)); ZEND_API void zend_llist_apply_with_argument(zend_llist *l, llist_apply_with_arg_func_t func, void *arg TSRMLS_DC); ZEND_API void zend_llist_apply_with_arguments(zend_llist *l, llist_apply_with_args_func_t func TSRMLS_DC, int num_args, ...); -ZEND_API int zend_llist_count(zend_llist *l); +ZEND_API size_t zend_llist_count(zend_llist *l); ZEND_API void zend_llist_sort(zend_llist *l, llist_compare_func_t comp_func TSRMLS_DC); /* traversal */ diff --git a/main/streams/streams.c b/main/streams/streams.c index 6be2b91dc7a..e49eb1712e7 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -177,7 +177,7 @@ void php_stream_display_wrapper_errors(php_stream_wrapper *wrapper, const char * size_t l = 0; int brlen; int i; - int count = zend_llist_count(err_list); + int count = (int)zend_llist_count(err_list); const char *br; const char **err_buf_p; zend_llist_position pos; From ac964fbe30c0dcd406b10c47a54b135f43a36861 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 12:03:05 +0100 Subject: [PATCH 102/398] fix datatype mismatches --- Zend/zend_operators.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 03e913c31d8..d6a7bf5aa6a 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -84,7 +84,7 @@ ZEND_API int zend_atoi(const char *str, int str_len) /* {{{ */ int retval; if (!str_len) { - str_len = strlen(str); + str_len = (int)strlen(str); } retval = ZEND_STRTOL(str, NULL, 0); if (str_len>0) { @@ -112,7 +112,7 @@ ZEND_API zend_long zend_atol(const char *str, int str_len) /* {{{ */ zend_long retval; if (!str_len) { - str_len = strlen(str); + str_len = (int)strlen(str); } retval = ZEND_STRTOL(str, NULL, 0); if (str_len>0) { From ae06555003370dd46c6b5ec0d7771ef2bdd3f308 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 12:07:44 +0100 Subject: [PATCH 103/398] fix datatype mismatch warnings --- main/fopen_wrappers.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index 8d6bf3d0bcc..b5b12eba56f 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -157,7 +157,7 @@ PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path strlcpy(local_open_basedir, basedir, sizeof(local_open_basedir)); } - path_len = strlen(path); + path_len = (int)strlen(path); if (path_len > (MAXPATHLEN - 1)) { /* empty and too long paths are invalid */ return -1; @@ -168,7 +168,7 @@ PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path return -1; } - path_len = strlen(resolved_name); + path_len = (int)strlen(resolved_name); memcpy(path_tmp, resolved_name, path_len + 1); /* safe */ while (VCWD_REALPATH(path_tmp, resolved_name) == NULL) { @@ -243,7 +243,7 @@ PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path resolved_basedir[resolved_basedir_len] = '\0'; } - resolved_name_len = strlen(resolved_name); + resolved_name_len = (int)strlen(resolved_name); if (path_tmp[path_len - 1] == PHP_DIR_SEPARATOR) { if (resolved_name[resolved_name_len - 1] != PHP_DIR_SEPARATOR) { resolved_name[resolved_name_len] = PHP_DIR_SEPARATOR; @@ -409,9 +409,9 @@ PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle TSRMLS_DC) } } else #endif - if (PG(doc_root) && path_info && (length = strlen(PG(doc_root))) && + if (PG(doc_root) && path_info && (length = (int)strlen(PG(doc_root))) && IS_ABSOLUTE_PATH(PG(doc_root), length)) { - int path_len = strlen(path_info); + int path_len = (int)strlen(path_info); filename = emalloc(length + path_len + 2); if (filename) { memcpy(filename, PG(doc_root), length); @@ -429,7 +429,7 @@ PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle TSRMLS_DC) if (filename) { - resolved_path = zend_resolve_path(filename, strlen(filename) TSRMLS_CC); + resolved_path = zend_resolve_path(filename, (int)strlen(filename) TSRMLS_CC); } if (!resolved_path) { @@ -542,7 +542,7 @@ PHPAPI char *php_resolve_path(const char *filename, int filename_length, const c memcpy(trypath+(end-ptr)+1, filename, filename_length+1); ptr = end+1; } else { - int len = strlen(ptr); + int len = (int)strlen(ptr); if (len + 1 + filename_length + 1 >= MAXPATHLEN) { break; @@ -577,7 +577,7 @@ PHPAPI char *php_resolve_path(const char *filename, int filename_length, const c */ if (zend_is_executing(TSRMLS_C)) { const char *exec_fname = zend_get_executed_filename(TSRMLS_C); - int exec_fname_length = strlen(exec_fname); + int exec_fname_length = (int)strlen(exec_fname); while ((--exec_fname_length >= 0) && !IS_SLASH(exec_fname[exec_fname_length])); if (exec_fname && exec_fname[0] != '[' && @@ -637,7 +637,7 @@ PHPAPI FILE *php_fopen_with_path(const char *filename, const char *mode, const c return NULL; } - filename_length = strlen(filename); + filename_length = (int)strlen(filename); /* Relative path open */ if ((*filename == '.') @@ -654,8 +654,8 @@ PHPAPI FILE *php_fopen_with_path(const char *filename, const char *mode, const c */ if (zend_is_executing(TSRMLS_C)) { exec_fname = zend_get_executed_filename(TSRMLS_C); - exec_fname_length = strlen(exec_fname); - path_length = strlen(path); + exec_fname_length = (int)strlen(exec_fname); + path_length = (int)strlen(path); while ((--exec_fname_length >= 0) && !IS_SLASH(exec_fname[exec_fname_length])); if ((exec_fname && exec_fname[0] == '[') || exec_fname_length <= 0) { @@ -808,7 +808,7 @@ PHPAPI char *expand_filepath_with_mode(const char *filepath, char *real_path, co } new_state.cwd = estrdup(cwd); - new_state.cwd_length = strlen(cwd); + new_state.cwd_length = (int)strlen(cwd); if (virtual_file_ex(&new_state, filepath, NULL, realpath_mode TSRMLS_CC)) { efree(new_state.cwd); From b9839296525454f6ba45191481a2678781f5d208 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 12:08:57 +0100 Subject: [PATCH 104/398] fix datatype mismatch warnings --- main/getopt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/getopt.c b/main/getopt.c index 8126d577b4c..49ae2ba04a7 100644 --- a/main/getopt.c +++ b/main/getopt.c @@ -81,7 +81,7 @@ PHPAPI int php_getopt(int argc, char* const *argv, const opt_struct opts[], char } if ((argv[*optind][0] == '-') && (argv[*optind][1] == '-')) { const char *pos; - int arg_end = strlen(argv[*optind])-1; + int arg_end = (int)strlen(argv[*optind])-1; /* '--' indicates end of args if not followed by a known long option name */ if (argv[*optind][2] == '\0') { @@ -111,7 +111,7 @@ PHPAPI int php_getopt(int argc, char* const *argv, const opt_struct opts[], char optchr = 0; dash = 0; - arg_start += strlen(opts[php_optidx].opt_name); + arg_start += (int)strlen(opts[php_optidx].opt_name); } else { if (!dash) { dash = 1; From 73ecac89e181da494816528b0bb9db221fc183ac Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 12:21:00 +0100 Subject: [PATCH 105/398] fix datatype mismatches and warnings --- main/main.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/main/main.c b/main/main.c index d7d7c44f802..740d2e441bf 100644 --- a/main/main.c +++ b/main/main.c @@ -178,7 +178,7 @@ static PHP_INI_MH(OnSetPrecision) static PHP_INI_MH(OnChangeMemoryLimit) { if (new_value) { - PG(memory_limit) = zend_atol(new_value->val, new_value->len); + PG(memory_limit) = zend_atol(new_value->val, (int)new_value->len); } else { PG(memory_limit) = 1<<30; /* effectively, no limit */ } @@ -364,7 +364,7 @@ static int php_get_display_errors_mode(char *value, int value_length) */ static PHP_INI_MH(OnUpdateDisplayErrors) { - PG(display_errors) = (zend_bool) php_get_display_errors_mode(new_value->val, new_value->len); + PG(display_errors) = (zend_bool) php_get_display_errors_mode(new_value->val, (int)new_value->len); return SUCCESS; } @@ -380,10 +380,10 @@ static PHP_INI_DISP(display_errors_mode) if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) { tmp_value = (ini_entry->orig_value ? ini_entry->orig_value->val : NULL ); - tmp_value_length = ini_entry->orig_value->len; + tmp_value_length = (int)ini_entry->orig_value->len; } else if (ini_entry->value) { tmp_value = ini_entry->value->val; - tmp_value_length = ini_entry->value->len; + tmp_value_length = (int)ini_entry->value->len; } else { tmp_value = NULL; tmp_value_length = 0; @@ -672,7 +672,7 @@ PHPAPI void php_log_err(char *log_message TSRMLS_DC) fd = VCWD_OPEN_MODE(PG(error_log), O_CREAT | O_APPEND | O_WRONLY, 0644); if (fd != -1) { char *tmp; - int len; + size_t len; zend_string *error_time_str; time(&error_time); @@ -688,8 +688,11 @@ PHPAPI void php_log_err(char *log_message TSRMLS_DC) len = spprintf(&tmp, 0, "[%s] %s%s", error_time_str->val, log_message, PHP_EOL); #ifdef PHP_WIN32 php_flock(fd, 2); -#endif + /* XXX should eventually write in a loop if len > UINT_MAX */ + php_ignore_value(write(fd, tmp, (unsigned)len)); +#else php_ignore_value(write(fd, tmp, len)); +#endif efree(tmp); zend_string_free(error_time_str); close(fd); @@ -757,13 +760,13 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c int is_function = 0; /* get error text into buffer and escape for html if necessary */ - buffer_len = vspprintf(&buffer, 0, format, args); + buffer_len = (int)vspprintf(&buffer, 0, format, args); if (PG(html_errors)) { replace_buffer = php_escape_html_entities(buffer, buffer_len, 0, ENT_COMPAT, NULL TSRMLS_CC); efree(buffer); buffer = replace_buffer->val; - buffer_len = replace_buffer->len; + buffer_len = (int)replace_buffer->len; } /* which function caused the problem if any at all */ @@ -813,9 +816,9 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c /* if we still have memory then format the origin */ if (is_function) { - origin_len = spprintf(&origin, 0, "%s%s%s(%s)", class_name, space, function, params); + origin_len = (int)spprintf(&origin, 0, "%s%s%s(%s)", class_name, space, function, params); } else { - origin_len = spprintf(&origin, 0, "%s", function); + origin_len = (int)spprintf(&origin, 0, "%s", function); } if (PG(html_errors)) { @@ -837,9 +840,9 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c function++; } if (space[0] == '\0') { - doclen = spprintf(&docref_buf, 0, "function.%s", function); + doclen = (int)spprintf(&docref_buf, 0, "function.%s", function); } else { - doclen = spprintf(&docref_buf, 0, "%s.%s", class_name, function); + doclen = (int)spprintf(&docref_buf, 0, "%s.%s", class_name, function); } while((p = strchr(docref_buf, '_')) != NULL) { *p = '-'; @@ -975,7 +978,7 @@ PHPAPI void php_win32_docref2_from_error(DWORD error, const char *param1, const int buf_len; FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, 0, buf, PHP_WIN32_ERROR_MSG_BUFFER_SIZE, NULL); - buf_len = strlen(buf); + buf_len = (int)strlen(buf); if (buf_len >= 2) { buf[buf_len - 1] = '\0'; buf[buf_len - 2] = '\0'; @@ -1001,7 +1004,7 @@ static void php_error_cb(int type, const char *error_filename, const uint error_ int buffer_len, display; TSRMLS_FETCH(); - buffer_len = vspprintf(&buffer, PG(log_errors_max_len), format, args); + buffer_len = (int)vspprintf(&buffer, PG(log_errors_max_len), format, args); /* check for repeated errors to be ignored */ if (PG(ignore_repeated_errors) && PG(last_error_message)) { @@ -1337,7 +1340,7 @@ PHP_FUNCTION(set_time_limit) return; } - new_timeout_strlen = zend_spprintf(&new_timeout_str, 0, ZEND_LONG_FMT, new_timeout); + new_timeout_strlen = (int)zend_spprintf(&new_timeout_str, 0, ZEND_LONG_FMT, new_timeout); key = zend_string_init("max_execution_time", sizeof("max_execution_time")-1, 0); if (zend_alter_ini_entry_chars_ex(key, new_timeout_str, new_timeout_strlen, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC) == SUCCESS) { @@ -2526,7 +2529,7 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC) int realfile_len; if (expand_filepath(primary_file->filename, realfile TSRMLS_CC)) { - realfile_len = strlen(realfile); + realfile_len = (int)strlen(realfile); zend_hash_str_add_empty_element(&EG(included_files), realfile, realfile_len); primary_file->opened_path = estrndup(realfile, realfile_len); } From 82c36cf5e8f830b79352251eb2785a1133c4aeff Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 12:27:57 +0100 Subject: [PATCH 106/398] fix datatype mismatches --- main/mergesort.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main/mergesort.c b/main/mergesort.c index 4555e1bc8f5..b049e683a92 100644 --- a/main/mergesort.c +++ b/main/mergesort.c @@ -104,7 +104,7 @@ static void insertionsort(u_char *a, size_t n, size_t size, int (*cmp)(const voi */ PHPAPI int php_mergesort(void *base, size_t nmemb, size_t size, int (*cmp)(const void *, const void * TSRMLS_DC) TSRMLS_DC) { - register unsigned int i; + register size_t i; register int sense; int big, iflag; register u_char *f1, *f2, *t, *b, *tp2, *q, *l1, *l2; @@ -264,8 +264,8 @@ COPY: b = t; */ static void setup(u_char *list1, u_char *list2, size_t n, size_t size, int (*cmp)(const void *, const void * TSRMLS_DC) TSRMLS_DC) { - int i, length, size2, tmp, sense; - u_char *f1, *f2, *s, *l2, *last, *p2; + size_t i, length, size2, sense; + u_char *f1, *f2, *s, *l2, *last, *p2, tmp; size2 = size*2; if (n <= 5) { @@ -336,7 +336,7 @@ static void setup(u_char *list1, u_char *list2, size_t n, size_t size, int (*cmp static void insertionsort(u_char *a, size_t n, size_t size, int (*cmp)(const void *, const void * TSRMLS_DC) TSRMLS_DC) { u_char *ai, *s, *t, *u, tmp; - int i; + size_t i; for (ai = a+size; --n >= 1; ai += size) for (t = ai; t > a; t -= size) { From 11b119d526229672b3574036beb07effacfa8815 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 13:08:21 +0100 Subject: [PATCH 107/398] fix datatype mismatches --- ext/standard/url_scanner_ex.c | 19 +++++++++++-------- ext/standard/url_scanner_ex.h | 2 +- ext/standard/url_scanner_ex.re | 19 +++++++++++-------- main/output.c | 28 +++++++--------------------- main/php_output.h | 6 +++--- 5 files changed, 33 insertions(+), 41 deletions(-) diff --git a/ext/standard/url_scanner_ex.c b/ext/standard/url_scanner_ex.c index 3d7aa985b8d..6b406e673f5 100644 --- a/ext/standard/url_scanner_ex.c +++ b/ext/standard/url_scanner_ex.c @@ -79,7 +79,7 @@ static PHP_INI_MH(OnUpdateTags) val = strchr(key, '='); if (val) { char *q; - int keylen; + size_t keylen; *val++ = '\0'; for (q = key; *q; q++) @@ -351,7 +351,7 @@ static inline void xx_mainloop(url_adapt_state_ex_t *ctx, const char *newdata, s char *end, *q; char *xp; char *start; - int rest; + size_t rest; smart_str_appendl(&ctx->buf, newdata, newlen); @@ -906,10 +906,13 @@ yy76: stop: - rest = YYLIMIT - start; - scdebug(("stopped in state %d at pos %d (%d:%c) %d\n", STATE, YYCURSOR - ctx->buf.c, *YYCURSOR, *YYCURSOR, rest)); - /* XXX: Crash avoidance. Need to work with reporter to figure out what goes wrong */ - if (rest < 0) rest = 0; + if (YYLIMIT < start) { + /* XXX: Crash avoidance. Need to work with reporter to figure out what goes wrong */ + rest = 0; + } else { + rest = YYLIMIT - start; + scdebug(("stopped in state %d at pos %d (%d:%c) %d\n", STATE, YYCURSOR - ctx->buf.c, *YYCURSOR, *YYCURSOR, rest)); + } if (rest) memmove(ctx->buf.s->val, start, rest); ctx->buf.s->len = rest; @@ -993,7 +996,7 @@ static int php_url_scanner_ex_deactivate(TSRMLS_D) return SUCCESS; } -static void php_url_scanner_output_handler(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC) +static void php_url_scanner_output_handler(char *output, size_t output_len, char **handled_output, size_t *handled_output_len, int mode TSRMLS_DC) { size_t len; @@ -1023,7 +1026,7 @@ static void php_url_scanner_output_handler(char *output, uint output_len, char * } } -PHPAPI int php_url_scanner_add_var(char *name, int name_len, char *value, int value_len, int urlencode TSRMLS_DC) +PHPAPI int php_url_scanner_add_var(char *name, size_t name_len, char *value, size_t value_len, int urlencode TSRMLS_DC) { smart_str val = {0}; zend_string *encoded; diff --git a/ext/standard/url_scanner_ex.h b/ext/standard/url_scanner_ex.h index 3c5b68c95b3..2a9b6921bff 100644 --- a/ext/standard/url_scanner_ex.h +++ b/ext/standard/url_scanner_ex.h @@ -28,7 +28,7 @@ PHP_RINIT_FUNCTION(url_scanner_ex); PHP_RSHUTDOWN_FUNCTION(url_scanner_ex); PHPAPI char *php_url_scanner_adapt_single_url(const char *url, size_t urllen, const char *name, const char *value, size_t *newlen TSRMLS_DC); -PHPAPI int php_url_scanner_add_var(char *name, int name_len, char *value, int value_len, int urlencode TSRMLS_DC); +PHPAPI int php_url_scanner_add_var(char *name, size_t name_len, char *value, size_t value_len, int urlencode TSRMLS_DC); PHPAPI int php_url_scanner_reset_vars(TSRMLS_D); #include "zend_smart_str_public.h" diff --git a/ext/standard/url_scanner_ex.re b/ext/standard/url_scanner_ex.re index 2e74b1fb30b..fed628f0894 100644 --- a/ext/standard/url_scanner_ex.re +++ b/ext/standard/url_scanner_ex.re @@ -77,7 +77,7 @@ static PHP_INI_MH(OnUpdateTags) val = strchr(key, '='); if (val) { char *q; - int keylen; + size_t keylen; *val++ = '\0'; for (q = key; *q; q++) @@ -287,7 +287,7 @@ static inline void xx_mainloop(url_adapt_state_ex_t *ctx, const char *newdata, s char *end, *q; char *xp; char *start; - int rest; + size_t rest; smart_str_appendl(&ctx->buf, newdata, newlen); @@ -358,10 +358,13 @@ state_val: */ stop: - rest = YYLIMIT - start; - scdebug(("stopped in state %d at pos %d (%d:%c) %d\n", STATE, YYCURSOR - ctx->buf.c, *YYCURSOR, *YYCURSOR, rest)); - /* XXX: Crash avoidance. Need to work with reporter to figure out what goes wrong */ - if (rest < 0) rest = 0; + if (YYLIMIT < start) { + /* XXX: Crash avoidance. Need to work with reporter to figure out what goes wrong */ + rest = 0; + } else { + rest = YYLIMIT - start; + scdebug(("stopped in state %d at pos %d (%d:%c) %d\n", STATE, YYCURSOR - ctx->buf.c, *YYCURSOR, *YYCURSOR, rest)); + } if (rest) memmove(ctx->buf.s->val, start, rest); ctx->buf.s->len = rest; @@ -445,7 +448,7 @@ static int php_url_scanner_ex_deactivate(TSRMLS_D) return SUCCESS; } -static void php_url_scanner_output_handler(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC) +static void php_url_scanner_output_handler(char *output, size_t output_len, char **handled_output, size_t *handled_output_len, int mode TSRMLS_DC) { size_t len; @@ -475,7 +478,7 @@ static void php_url_scanner_output_handler(char *output, uint output_len, char * } } -PHPAPI int php_url_scanner_add_var(char *name, int name_len, char *value, int value_len, int urlencode TSRMLS_DC) +PHPAPI int php_url_scanner_add_var(char *name, size_t name_len, char *value, size_t value_len, int urlencode TSRMLS_DC) { smart_str val = {0}; zend_string *encoded; diff --git a/main/output.c b/main/output.c index f44ae178b44..3cafebb730b 100644 --- a/main/output.c +++ b/main/output.c @@ -86,12 +86,12 @@ static inline void php_output_init_globals(zend_output_globals *G) /* }}} */ /* {{{ stderr/stdout writer if not PHP_OUTPUT_ACTIVATED */ -static int php_output_stdout(const char *str, size_t str_len) +static size_t php_output_stdout(const char *str, size_t str_len) { fwrite(str, 1, str_len, stdout); return str_len; } -static int php_output_stderr(const char *str, size_t str_len) +static size_t php_output_stderr(const char *str, size_t str_len) { fwrite(str, 1, str_len, stderr); /* See http://support.microsoft.com/kb/190351 */ @@ -100,7 +100,7 @@ static int php_output_stderr(const char *str, size_t str_len) #endif return str_len; } -static int (*php_output_direct)(const char *str, size_t str_len) = php_output_stderr; +static size_t (*php_output_direct)(const char *str, size_t str_len) = php_output_stderr; /* }}} */ /* {{{ void php_output_header(TSRMLS_D) */ @@ -238,15 +238,8 @@ PHPAPI int php_output_get_status(TSRMLS_D) /* {{{ int php_output_write_unbuffered(const char *str, size_t len TSRMLS_DC) * Unbuffered write */ -PHPAPI int php_output_write_unbuffered(const char *str, size_t len TSRMLS_DC) +PHPAPI size_t php_output_write_unbuffered(const char *str, size_t len TSRMLS_DC) { -#if PHP_DEBUG - if (len > UINT_MAX) { - php_error(E_WARNING, "Attempt to output more than UINT_MAX bytes at once; " - "output will be truncated %lu => %lu", - (unsigned long) len, (unsigned long) (len % UINT_MAX)); - } -#endif if (OG(flags) & PHP_OUTPUT_DISABLED) { return 0; } @@ -259,21 +252,14 @@ PHPAPI int php_output_write_unbuffered(const char *str, size_t len TSRMLS_DC) /* {{{ int php_output_write(const char *str, size_t len TSRMLS_DC) * Buffered write */ -PHPAPI int php_output_write(const char *str, size_t len TSRMLS_DC) +PHPAPI size_t php_output_write(const char *str, size_t len TSRMLS_DC) { -#if PHP_DEBUG - if (len > UINT_MAX) { - php_error(E_WARNING, "Attempt to output more than UINT_MAX bytes at once; " - "output will be truncated %lu => %lu", - (unsigned long) len, (unsigned long) (len % UINT_MAX)); - } -#endif if (OG(flags) & PHP_OUTPUT_DISABLED) { return 0; } if (OG(flags) & PHP_OUTPUT_ACTIVATED) { php_output_op(PHP_OUTPUT_HANDLER_WRITE, str, len TSRMLS_CC); - return (int) len; + return len; } return php_output_direct(str, len); } @@ -1272,7 +1258,7 @@ static int php_output_handler_compat_func(void **handler_context, php_output_con if (func) { char *out_str = NULL; - uint out_len = 0; + size_t out_len = 0; func(output_context->in.data, output_context->in.used, &out_str, &out_len, output_context->op TSRMLS_CC); diff --git a/main/php_output.h b/main/php_output.h index 02b2b85d130..c176063c3b9 100644 --- a/main/php_output.h +++ b/main/php_output.h @@ -110,7 +110,7 @@ typedef struct _php_output_context { #define PHP_OUTPUT_TSRMLS(ctx) TSRMLS_FETCH_FROM_CTX((ctx)->tsrm_ls) /* old-style, stateless callback */ -typedef void (*php_output_handler_func_t)(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC); +typedef void (*php_output_handler_func_t)(char *output, size_t output_len, char **handled_output, size_t *handled_output_len, int mode TSRMLS_DC); /* new-style, opaque context callback */ typedef int (*php_output_handler_context_func_t)(void **handler_context, php_output_context *output_context); /* output handler context dtor */ @@ -206,8 +206,8 @@ PHPAPI void php_output_set_implicit_flush(int flush TSRMLS_DC); PHPAPI const char *php_output_get_start_filename(TSRMLS_D); PHPAPI int php_output_get_start_lineno(TSRMLS_D); -PHPAPI int php_output_write_unbuffered(const char *str, size_t len TSRMLS_DC); -PHPAPI int php_output_write(const char *str, size_t len TSRMLS_DC); +PHPAPI size_t php_output_write_unbuffered(const char *str, size_t len TSRMLS_DC); +PHPAPI size_t php_output_write(const char *str, size_t len TSRMLS_DC); PHPAPI int php_output_flush(TSRMLS_D); PHPAPI void php_output_flush_all(TSRMLS_D); From e99040659eda6b2131ac76c8a15677aa896e4577 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 13:15:47 +0100 Subject: [PATCH 108/398] fix datatype mismatches and warns --- main/php_ini.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/main/php_ini.c b/main/php_ini.c index c90dc9f29fa..a6c325b0fb3 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -80,7 +80,8 @@ static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type TSRMLS_DC) ini_entry->displayer(ini_entry, type); } else { char *display_string; - uint display_string_length, esc_html=0; + size_t display_string_length; + int esc_html=0; if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) { if (ini_entry->orig_value && ini_entry->orig_value->val[0]) { @@ -281,7 +282,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t /* fprintf(stdout, "ZEND_INI_PARSER_SECTION: %s\n",Z_STRVAL_P(arg1)); */ char *key = NULL; - uint key_len; + size_t key_len; /* PATH sections */ if (!strncasecmp(Z_STRVAL_P(arg1), "PATH", sizeof("PATH") - 1)) { @@ -355,14 +356,14 @@ static void php_load_php_extension_cb(void *arg TSRMLS_DC) static void php_load_zend_extension_cb(void *arg TSRMLS_DC) { char *filename = *((char **) arg); - const int length = strlen(filename); + const int length = (int)strlen(filename); if (IS_ABSOLUTE_PATH(filename, length)) { zend_load_extension(filename TSRMLS_CC); } else { char *libpath; char *extension_dir = INI_STR("extension_dir"); - int extension_dir_len = strlen(extension_dir); + int extension_dir_len = (int)strlen(extension_dir); if (IS_SLASH(extension_dir[extension_dir_len-1])) { spprintf(&libpath, 0, "%s%s", extension_dir, filename); @@ -449,7 +450,7 @@ int php_init_config(TSRMLS_D) * Prepare search path */ - search_path_size = MAXPATHLEN * 4 + strlen(env_location) + 3 + 1; + search_path_size = MAXPATHLEN * 4 + (int)strlen(env_location) + 3 + 1; php_ini_search_path = (char *) emalloc(search_path_size); free_ini_search_path = 1; php_ini_search_path[0] = 0; @@ -608,7 +609,7 @@ int php_init_config(TSRMLS_D) /* Or fall back using possible --with-config-file-scan-dir setting (defaults to empty string!) */ php_ini_scanned_path = PHP_CONFIG_FILE_SCAN_DIR; } - php_ini_scanned_path_len = strlen(php_ini_scanned_path); + php_ini_scanned_path_len = (int)strlen(php_ini_scanned_path); /* Scan and parse any .ini files found in scan path if path not empty. */ if (!sapi_module.php_ini_ignore && php_ini_scanned_path_len) { @@ -638,7 +639,7 @@ int php_init_config(TSRMLS_D) to allow "/foo/phd.d:" or ":/foo/php.d" */ debpath = PHP_CONFIG_FILE_SCAN_DIR; } - lenpath = strlen(debpath); + lenpath = (int)strlen(debpath); if (lenpath > 0 && (ndir = php_scandir(debpath, &namelist, 0, php_alphasort)) > 0) { @@ -665,7 +666,7 @@ int php_init_config(TSRMLS_D) if (zend_parse_ini_file(&fh2, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash TSRMLS_CC) == SUCCESS) { /* Here, add it to the list of ini files read */ - l = strlen(ini_file); + l = (int)strlen(ini_file); total_l += l + 2; p = estrndup(ini_file, l); zend_llist_add_element(&scanned_ini_list, &p); @@ -681,7 +682,7 @@ int php_init_config(TSRMLS_D) efree(bufpath); if (total_l) { - int php_ini_scanned_files_len = (php_ini_scanned_files) ? strlen(php_ini_scanned_files) + 1 : 0; + int php_ini_scanned_files_len = (php_ini_scanned_files) ? (int)strlen(php_ini_scanned_files) + 1 : 0; php_ini_scanned_files = (char *) realloc(php_ini_scanned_files, php_ini_scanned_files_len + total_l + 1); if (!php_ini_scanned_files_len) { *php_ini_scanned_files = '\0'; From 05f812c8d33221e8f9056978861fde479c8b2d79 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 13:17:37 +0100 Subject: [PATCH 109/398] catch up with zend_html_puts --- main/main.c | 2 +- main/php_main.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main/main.c b/main/main.c index 740d2e441bf..828831545e4 100644 --- a/main/main.c +++ b/main/main.c @@ -990,7 +990,7 @@ PHPAPI void php_win32_docref2_from_error(DWORD error, const char *param1, const #endif /* {{{ php_html_puts */ -PHPAPI void php_html_puts(const char *str, uint size TSRMLS_DC) +PHPAPI void php_html_puts(const char *str, size_t size TSRMLS_DC) { zend_html_puts(str, size TSRMLS_CC); } diff --git a/main/php_main.h b/main/php_main.h index 07d7dc22807..f03e644c8d9 100644 --- a/main/php_main.h +++ b/main/php_main.h @@ -47,7 +47,7 @@ PHPAPI int php_lint_script(zend_file_handle *file TSRMLS_DC); PHPAPI void php_handle_aborted_connection(void); PHPAPI int php_handle_auth_data(const char *auth TSRMLS_DC); -PHPAPI void php_html_puts(const char *str, uint siz TSRMLS_DC); +PHPAPI void php_html_puts(const char *str, size_t siz TSRMLS_DC); PHPAPI int php_stream_open_for_zend_ex(const char *filename, zend_file_handle *handle, int mode TSRMLS_DC); extern void php_call_shutdown_functions(TSRMLS_D); From d8ed6553518913d5a3a84db1a776c7cc0be63101 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 13:18:09 +0100 Subject: [PATCH 110/398] fix datatype mismatch warns --- main/php_open_temporary_file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/php_open_temporary_file.c b/main/php_open_temporary_file.c index a52619ed47b..955f0d26e18 100644 --- a/main/php_open_temporary_file.c +++ b/main/php_open_temporary_file.c @@ -125,7 +125,7 @@ static int php_do_open_temporary_file(const char *path, const char *pfx, char ** } new_state.cwd = estrdup(cwd); - new_state.cwd_length = strlen(cwd); + new_state.cwd_length = (int)strlen(cwd); if (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH TSRMLS_CC)) { efree(new_state.cwd); @@ -200,7 +200,7 @@ PHPAPI const char* php_get_temporary_directory(TSRMLS_D) { char *sys_temp_dir = PG(sys_temp_dir); if (sys_temp_dir) { - int len = strlen(sys_temp_dir); + int len = (int)strlen(sys_temp_dir); if (len >= 2 && sys_temp_dir[len - 1] == DEFAULT_SLASH) { temporary_directory = zend_strndup(sys_temp_dir, len - 1); return temporary_directory; From 37634c9a67e28a0c5003bfaa77837d811616ce9e Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 13:20:16 +0100 Subject: [PATCH 111/398] fix datatype mismatch --- main/php_variables.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/php_variables.c b/main/php_variables.c index a0acb382647..4f911c2e657 100644 --- a/main/php_variables.c +++ b/main/php_variables.c @@ -59,7 +59,7 @@ PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars char *ip = NULL; /* index pointer */ char *index; char *var, *var_orig; - int var_len, index_len; + size_t var_len, index_len; zval gpc_element, *gpc_element_p; zend_bool is_array = 0; HashTable *symtable1 = NULL; @@ -125,7 +125,7 @@ PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars int nest_level = 0; while (1) { char *index_s; - int new_idx_len = 0; + size_t new_idx_len = 0; if(++nest_level > PG(max_input_nesting_level)) { HashTable *ht; From 52bd403d0ba3b46830cce2891e5dc0ac3ba46467 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 16:38:05 +0100 Subject: [PATCH 112/398] fix datatype mismatches --- main/rfc1867.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/main/rfc1867.c b/main/rfc1867.c index 0eacf896c32..e8b15f8494f 100644 --- a/main/rfc1867.c +++ b/main/rfc1867.c @@ -261,7 +261,7 @@ static int fill_buffer(multipart_buffer *self TSRMLS_DC) char *buf = self->buffer + self->bytes_in_buffer; - actual_read = sapi_module.read_post(buf, bytes_to_read TSRMLS_CC); + actual_read = (int)sapi_module.read_post(buf, bytes_to_read TSRMLS_CC); /* update the buffer length */ if (actual_read > 0) { @@ -300,7 +300,7 @@ static multipart_buffer *multipart_buffer_new(char *boundary, int boundary_len T spprintf(&self->boundary, 0, "--%s", boundary); - self->boundary_next_len = spprintf(&self->boundary_next, 0, "\n--%s", boundary); + self->boundary_next_len = (int)spprintf(&self->boundary_next, 0, "\n--%s", boundary); self->buf_begin = self->buffer; self->bytes_in_buffer = 0; @@ -442,8 +442,8 @@ static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header T } else if (zend_llist_count(header)) { /* If no ':' on the line, add to previous line */ - prev_len = strlen(prev_entry.value); - cur_len = strlen(line); + prev_len = (int)strlen(prev_entry.value); + cur_len = (int)strlen(line); entry.value = emalloc(prev_len + cur_len + 1); memcpy(entry.value, prev_entry.value, prev_len); @@ -551,7 +551,7 @@ static char *php_ap_getword_conf(const zend_encoding *encoding, char *str TSRMLS char quote = *str; str++; - return substring_conf(str, strlen(str), quote); + return substring_conf(str, (int)strlen(str), quote); } else { char *strend = str; @@ -646,11 +646,11 @@ static int multipart_buffer_read(multipart_buffer *self, char *buf, size_t bytes } /* update the buffer */ - self->bytes_in_buffer -= len; + self->bytes_in_buffer -= (int)len; self->buf_begin += len; } - return len; + return (int)len; } /* @@ -721,7 +721,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */ /* Get the boundary */ boundary = strstr(content_type_dup, "boundary"); if (!boundary) { - int content_type_len = strlen(content_type_dup); + int content_type_len = (int)strlen(content_type_dup); char *content_type_lcase = estrndup(content_type_dup, content_type_len); php_strtolower(content_type_lcase, content_type_len); @@ -738,7 +738,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */ } boundary++; - boundary_len = strlen(boundary); + boundary_len = (int)strlen(boundary); if (boundary[0] == '"') { boundary++; @@ -1045,7 +1045,11 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */ #endif cancel_upload = UPLOAD_ERROR_B; } else if (blen > 0) { +#ifdef PHP_WIN32 + wlen = write(fd, buff, (unsigned int)blen); +#else wlen = write(fd, buff, blen); +#endif if (wlen == -1) { /* write failed */ @@ -1113,7 +1117,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */ is_arr_upload = (start_arr = strchr(param,'[')) && (param[strlen(param)-1] == ']'); if (is_arr_upload) { - array_len = strlen(start_arr); + array_len = (int)strlen(start_arr); if (array_index) { efree(array_index); } @@ -1122,7 +1126,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */ /* Add $foo_name */ if (llen < strlen(param) + MAX_SIZE_OF_INDEX + 1) { - llen = strlen(param); + llen = (int)strlen(param); lbuf = (char *) safe_erealloc(lbuf, llen, 1, MAX_SIZE_OF_INDEX + 1); llen += MAX_SIZE_OF_INDEX + 1; } From 868dbf609bfd5eb72f55b2e26ed7a0231b10a647 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 17:02:52 +0100 Subject: [PATCH 113/398] fix datatype mismatches --- main/snprintf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/snprintf.c b/main/snprintf.c index b9f781346c8..826880f62ab 100644 --- a/main/snprintf.c +++ b/main/snprintf.c @@ -1248,7 +1248,7 @@ PHPAPI int ap_php_slprintf(char *buf, size_t len, const char *format,...) /* {{{ strx_printv(&cc, buf, len, format, ap); va_end(ap); if (cc >= len) { - cc = len -1; + cc = (int)len -1; buf[cc] = '\0'; } return cc; @@ -1261,7 +1261,7 @@ PHPAPI int ap_php_vslprintf(char *buf, size_t len, const char *format, va_list a strx_printv(&cc, buf, len, format, ap); if (cc >= len) { - cc = len -1; + cc = (int)len -1; buf[cc] = '\0'; } return cc; From 390182d8e662dde0d81e51acbbec3812aa8978ed Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 17:04:44 +0100 Subject: [PATCH 114/398] fix datatype mismatch warning --- main/spprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/spprintf.c b/main/spprintf.c index cf730dd964c..1fcce9df18e 100644 --- a/main/spprintf.c +++ b/main/spprintf.c @@ -725,7 +725,7 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt case 'n': - *(va_arg(ap, int *)) = is_char? ((smart_string *)xbuf)->len : ((smart_str *)xbuf)->s->len; + *(va_arg(ap, int *)) = is_char? (int)((smart_string *)xbuf)->len : (int)((smart_str *)xbuf)->s->len; goto skip_output; /* From deaeca4000c56a1453cdc3342d09245411e0b8f3 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 17:15:26 +0100 Subject: [PATCH 115/398] fix datatype mismatches --- main/streams/plain_wrapper.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 7432b7c49ea..1aa01f270d5 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -325,7 +325,11 @@ static size_t php_stdiop_write(php_stream *stream, const char *buf, size_t count assert(data != NULL); if (data->fd >= 0) { +#ifdef PHP_WIN32 + int bytes_written = write(data->fd, buf, (unsigned int)count); +#else int bytes_written = write(data->fd, buf, count); +#endif if (bytes_written < 0) return 0; return (size_t) bytes_written; } else { @@ -776,8 +780,8 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void GetSystemInfo(&info); gran = info.dwAllocationGranularity; - loffs = (range->offset / gran) * gran; - delta = range->offset - loffs; + loffs = ((DWORD)range->offset / gran) * gran; + delta = (DWORD)range->offset - loffs; } data->last_mapped_addr = MapViewOfFile(data->file_mapping, acc, 0, loffs, range->length + delta); @@ -1099,11 +1103,11 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f } #ifdef PHP_WIN32 - if (!php_win32_check_trailing_space(url_from, strlen(url_from))) { + if (!php_win32_check_trailing_space(url_from, (int)strlen(url_from))) { php_win32_docref2_from_error(ERROR_INVALID_NAME, url_from, url_to TSRMLS_CC); return 0; } - if (!php_win32_check_trailing_space(url_to, strlen(url_to))) { + if (!php_win32_check_trailing_space(url_to, (int)strlen(url_to))) { php_win32_docref2_from_error(ERROR_INVALID_NAME, url_from, url_to TSRMLS_CC); return 0; } @@ -1195,7 +1199,7 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir, i /* we look for directory separator from the end of string, thus hopefuly reducing our work load */ char *e; zend_stat_t sb; - int dir_len = strlen(dir); + int dir_len = (int)strlen(dir); int offset = 0; char buf[MAXPATHLEN]; @@ -1269,7 +1273,7 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir, i static int php_plain_files_rmdir(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context TSRMLS_DC) { #if PHP_WIN32 - int url_len = strlen(url); + int url_len = (int)strlen(url); #endif if (php_check_open_basedir(url TSRMLS_CC)) { return 0; @@ -1304,7 +1308,7 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, const char *url mode_t mode; int ret = 0; #if PHP_WIN32 - int url_len = strlen(url); + int url_len = (int)strlen(url); #endif #if PHP_WIN32 @@ -1422,7 +1426,7 @@ PHPAPI php_stream *_php_stream_fopen_with_path(const char *filename, const char return NULL; } - filename_length = strlen(filename); + filename_length = (int)strlen(filename); /* Relative path open */ if (*filename == '.' && (IS_SLASH(filename[1]) || filename[1] == '.')) { @@ -1487,8 +1491,8 @@ not_relative_path: */ if (zend_is_executing(TSRMLS_C)) { exec_fname = zend_get_executed_filename(TSRMLS_C); - exec_fname_length = strlen(exec_fname); - path_length = strlen(path); + exec_fname_length = (int)strlen(exec_fname); + path_length = (int)strlen(path); while ((--exec_fname_length >= 0) && !IS_SLASH(exec_fname[exec_fname_length])); if ((exec_fname && exec_fname[0] == '[') From 201f47e5db6e4195c62c67ac2da1ba09a930d0d2 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 17:16:24 +0100 Subject: [PATCH 116/398] fix datatype mismatch --- main/streams/filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/streams/filter.c b/main/streams/filter.c index 36585fa9bfe..56e388403dd 100644 --- a/main/streams/filter.c +++ b/main/streams/filter.c @@ -255,7 +255,7 @@ PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, zval int n; char *period; - n = strlen(filtername); + n = (int)strlen(filtername); if (NULL != (factory = zend_hash_str_find_ptr(filter_hash, filtername, n))) { filter = factory->create_filter(filtername, filterparams, persistent TSRMLS_CC); From fa1e8f70f470ee5b92d99781bded9793ee19cadb Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 17:20:24 +0100 Subject: [PATCH 117/398] fix datatype mismatch --- main/streams/memory.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main/streams/memory.c b/main/streams/memory.c index 97889549886..6b1b2312a9c 100644 --- a/main/streams/memory.c +++ b/main/streams/memory.c @@ -717,10 +717,11 @@ static php_stream * php_stream_url_wrap_rfc2397(php_stream_wrapper *wrapper, con return NULL; } comma = base64_comma->val; - ilen = base64_comma->len; + ilen = (int)base64_comma->len; } else { comma = estrndup(comma, dlen); - ilen = dlen = php_url_decode(comma, dlen); + dlen = php_url_decode(comma, (int)dlen); + ilen = (int)dlen; } if ((stream = php_stream_temp_create_rel(0, ~0u)) != NULL) { From 9858df2f8071dd4864fd5db6d09a18ebca026975 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 17:28:01 +0100 Subject: [PATCH 118/398] fix datatype mismatch warnings --- main/streams/streams.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/main/streams/streams.c b/main/streams/streams.c index e49eb1712e7..13af3626813 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -813,7 +813,7 @@ PHPAPI int _php_stream_getc(php_stream *stream TSRMLS_DC) PHPAPI int _php_stream_puts(php_stream *stream, const char *buf TSRMLS_DC) { - int len; + size_t len; char newline[2] = "\n"; /* is this OK for Win? */ len = strlen(buf); @@ -1364,7 +1364,8 @@ PHPAPI int _php_stream_set_option(php_stream *stream, int option, int value, voi if (ret == PHP_STREAM_OPTION_RETURN_NOTIMPL) { switch(option) { case PHP_STREAM_OPTION_SET_CHUNK_SIZE: - ret = stream->chunk_size; + /* XXX chunk size itself is of size_t, that might be ok or not for a particular case*/ + ret = stream->chunk_size > INT_MAX ? INT_MAX : (int)stream->chunk_size; stream->chunk_size = value; return ret; @@ -1395,7 +1396,7 @@ PHPAPI size_t _php_stream_passthru(php_stream * stream STREAMS_DC TSRMLS_DC) { size_t bcount = 0; char buf[8192]; - int b; + size_t b; if (php_stream_mmap_possible(stream)) { char *p; @@ -1710,7 +1711,7 @@ static inline int php_stream_wrapper_scheme_validate(const char *protocol, unsig /* API for registering GLOBAL wrappers */ PHPAPI int php_register_url_stream_wrapper(const char *protocol, php_stream_wrapper *wrapper TSRMLS_DC) { - unsigned int protocol_len = strlen(protocol); + unsigned int protocol_len = (unsigned int)strlen(protocol); if (php_stream_wrapper_scheme_validate(protocol, protocol_len) == FAILURE) { return FAILURE; @@ -1734,7 +1735,7 @@ static void clone_wrapper_hash(TSRMLS_D) /* API for registering VOLATILE wrappers */ PHPAPI int php_register_url_stream_wrapper_volatile(const char *protocol, php_stream_wrapper *wrapper TSRMLS_DC) { - unsigned int protocol_len = strlen(protocol); + unsigned int protocol_len = (unsigned int)strlen(protocol); if (php_stream_wrapper_scheme_validate(protocol, protocol_len) == FAILURE) { return FAILURE; @@ -2040,7 +2041,7 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod } if (options & USE_PATH) { - resolved_path = zend_resolve_path(path, strlen(path) TSRMLS_CC); + resolved_path = zend_resolve_path(path, (int)strlen(path) TSRMLS_CC); if (resolved_path) { path = resolved_path; /* we've found this file, don't re-check include_path or run realpath */ From 0f5858e3a3283514f97b9fee539a38b68e0698da Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 17:31:38 +0100 Subject: [PATCH 119/398] fix datatype mismatch --- main/streams/xp_socket.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c index bce6a09fb0a..746d9c93d92 100644 --- a/main/streams/xp_socket.c +++ b/main/streams/xp_socket.c @@ -251,7 +251,11 @@ static inline int sock_sendto(php_netstream_data_t *sock, const char *buf, size_ return (ret == SOCK_CONN_ERR) ? -1 : ret; } +#ifdef PHP_WIN32 + return ((ret = send(sock->socket, buf, buflen > INT_MAX ? INT_MAX : (int)buflen, flags)) == SOCK_CONN_ERR) ? -1 : ret; +#else return ((ret = send(sock->socket, buf, buflen, flags)) == SOCK_CONN_ERR) ? -1 : ret; +#endif } static inline int sock_recvfrom(php_netstream_data_t *sock, char *buf, size_t buflen, int flags, From deadeeae1d08877021eb2796aa6790baa74361ed Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Mon, 27 Oct 2014 19:04:46 -0700 Subject: [PATCH 120/398] Fix bug #68095 - invalid read in php_getopt() It's a hacky solution and incomplete, but I don't see other way without refactoring the whole getopt protocol. --- NEWS | 2 ++ main/getopt.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/NEWS b/NEWS index c7fd7afe4a5..15a2951377c 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,8 @@ PHP NEWS ?? ??? 2014, PHP 5.5.19 - Core: + . Fixed bug #68095 (AddressSanitizer reports a heap buffer overflow in + php_getopt()). (Stas) . Fixed bug #68118 ($a->foo .= 'test'; can leave $a->foo undefined). (Nikita) . Fixed bug #68129 (parse_url() - incomplete support for empty usernames and passwords) (Tjerk) diff --git a/main/getopt.c b/main/getopt.c index a31a6c75d58..258173fc22c 100644 --- a/main/getopt.c +++ b/main/getopt.c @@ -59,9 +59,17 @@ PHPAPI int php_getopt(int argc, char* const *argv, const opt_struct opts[], char { static int optchr = 0; static int dash = 0; /* have already seen the - */ + static char **prev_optarg = NULL; php_optidx = -1; + if(prev_optarg && prev_optarg != optarg) { + /* reset the state */ + optchr = 0; + dash = 0; + } + prev_optarg = optarg; + if (*optind >= argc) { return(EOF); } From 13a218d3285f78812bb8a1d2214b9d6e166924b8 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 28 Oct 2014 08:48:22 +0100 Subject: [PATCH 121/398] Ensure we have enough input data before parsing date This check have be removed in http://git.php.net/?p=php-src.git;a=commit;h=ba2f87b50667f147c198abd31fc31eb09522f3d7 But the parser really need 17 char. And the string need to be nul terminated for this check So avoid reading random byte from memory. --- ext/xmlrpc/libxmlrpc/xmlrpc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ext/xmlrpc/libxmlrpc/xmlrpc.c b/ext/xmlrpc/libxmlrpc/xmlrpc.c index b766a5495a4..f184cf49eea 100644 --- a/ext/xmlrpc/libxmlrpc/xmlrpc.c +++ b/ext/xmlrpc/libxmlrpc/xmlrpc.c @@ -201,9 +201,13 @@ static int date_from_ISO8601 (const char *text, time_t * value) { } p++; } - text = buf; + *p2 = 0; + text = buf; } + if (strlen(text)<17) { + return -1; + } tm.tm_isdst = -1; From e6fe3127d0e02a58456fef1af969a8f114f85c31 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Tue, 28 Oct 2014 17:36:03 +0800 Subject: [PATCH 122/398] Fixed bug #68252 (segfault in Zend/zend_hash.c in function _zend_hash_del_el) Don't leave a UNDEF gap in function_table --- NEWS | 2 ++ Zend/zend_builtin_functions.c | 2 +- ext/opcache/tests/bug68252.phpt | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 ext/opcache/tests/bug68252.phpt diff --git a/NEWS b/NEWS index 1c9fd616efa..56441a87914 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,8 @@ PHP NEWS . Update the MIME type list from the one shipped by Apache HTTPD. (Adam) - Core: + . Fixed bug #68252 (segfault in Zend/zend_hash.c in function + _zend_hash_del_el). (Laruence) . Added PHP_INT_MIN constant. (Andrea) . Added Closure::call() method. (Andrea) . Implemented FR #38409 (parse_ini_file() looses the type of booleans). (Tjerk) diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 8203d39e510..940cdefc81c 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1830,6 +1830,7 @@ ZEND_FUNCTION(create_function) RETURN_FALSE; } (*func->refcount)++; + zend_hash_str_del(EG(function_table), LAMBDA_TEMP_FUNCNAME, sizeof(LAMBDA_TEMP_FUNCNAME)-1); function_name = zend_string_alloc(sizeof("0lambda_")+MAX_LENGTH_OF_LONG, 0); function_name->val[0] = '\0'; @@ -1839,7 +1840,6 @@ ZEND_FUNCTION(create_function) } while (zend_hash_add_ptr(EG(function_table), function_name, func) == NULL); static_variables = func->static_variables; func->static_variables = NULL; - zend_hash_str_del(EG(function_table), LAMBDA_TEMP_FUNCNAME, sizeof(LAMBDA_TEMP_FUNCNAME)-1); func->static_variables = static_variables; RETURN_STR(function_name); } else { diff --git a/ext/opcache/tests/bug68252.phpt b/ext/opcache/tests/bug68252.phpt new file mode 100644 index 00000000000..e05467a2440 --- /dev/null +++ b/ext/opcache/tests/bug68252.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #68252 (segfault in Zend/zend_hash.c in function _zend_hash_del_el) +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.fast_shutdown=1 +--SKIPIF-- + +--FILE-- + Date: Tue, 28 Oct 2014 17:40:54 +0800 Subject: [PATCH 123/398] Addtion fix for bug #68252 , forget static variable hanlding --- Zend/zend_builtin_functions.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 940cdefc81c..ddec6a7ddbb 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1830,7 +1830,10 @@ ZEND_FUNCTION(create_function) RETURN_FALSE; } (*func->refcount)++; + static_variables = func->static_variables; + func->static_variables = NULL; zend_hash_str_del(EG(function_table), LAMBDA_TEMP_FUNCNAME, sizeof(LAMBDA_TEMP_FUNCNAME)-1); + func->static_variables = static_variables; function_name = zend_string_alloc(sizeof("0lambda_")+MAX_LENGTH_OF_LONG, 0); function_name->val[0] = '\0'; @@ -1838,9 +1841,6 @@ ZEND_FUNCTION(create_function) do { function_name->len = snprintf(function_name->val + 1, sizeof("lambda_")+MAX_LENGTH_OF_LONG, "lambda_%d", ++EG(lambda_count)) + 1; } while (zend_hash_add_ptr(EG(function_table), function_name, func) == NULL); - static_variables = func->static_variables; - func->static_variables = NULL; - func->static_variables = static_variables; RETURN_STR(function_name); } else { zend_hash_str_del(EG(function_table), LAMBDA_TEMP_FUNCNAME, sizeof(LAMBDA_TEMP_FUNCNAME)-1); From cce9550e48021ea4e3da4f8f8c58fef31087fc6d Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 12:27:19 +0100 Subject: [PATCH 124/398] *Always* clean up and run destructors --- phpdbg_prompt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 73ecbcb892c..262b265a2e9 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -676,10 +676,10 @@ PHPDBG_COMMAND(run) /* {{{ */ EG(active_op_array) = orig_op_array; EG(opline_ptr) = orig_opline; EG(return_value_ptr_ptr) = orig_retval_ptr; - - phpdbg_clean(1 TSRMLS_CC); } + phpdbg_clean(1 TSRMLS_CC); + PHPDBG_G(flags) &= ~PHPDBG_IS_RUNNING; } else { phpdbg_error("inactive", "type=\"nocontext\"", "Nothing to execute!"); From da3d6f3d64042ffe6928127b18986ace760d5c4b Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 12:38:07 +0100 Subject: [PATCH 125/398] Fix potential segfaults and unresolved breaks --- phpdbg_bp.c | 56 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/phpdbg_bp.c b/phpdbg_bp.c index cf28a338859..93902f00529 100644 --- a/phpdbg_bp.c +++ b/phpdbg_bp.c @@ -232,6 +232,8 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRML } path_len = strlen(path); + phpdbg_debug("file path: %s, resolved path: %s, was compiled: %d\n", original_path, path, zend_hash_exists(&PHPDBG_G(file_sources), path, path_len)); + if (!zend_hash_exists(&PHPDBG_G(file_sources), path, path_len)) { if (php_stream_stat_path(path, &ssb) == FAILURE) { if (original_path[0] == '/') { @@ -246,6 +248,8 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRML } else if (!(ssb.sb.st_mode & (S_IFREG|S_IFLNK))) { phpdbg_error("breakpoint", "type=\"notregular\" add=\"fail\" file=\"%s\"", "Cannot set breakpoint in %s, it is not a regular file", path); return; + } else { + phpdbg_debug("File exists, but not compiled\n"); } } @@ -273,9 +277,13 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRML for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(file_sources), &position); zend_hash_get_current_key_ex(&PHPDBG_G(file_sources), &file, &filelen, NULL, 0, &position) == HASH_KEY_IS_STRING; zend_hash_move_forward_ex(&PHPDBG_G(file_sources), &position)) { - if (!(pending = ((broken = phpdbg_resolve_pending_file_break_ex(file, filelen, path, path_len, broken TSRMLS_CC)) == NULL))) { + HashTable *fileht; + + phpdbg_debug("Compare against loaded %s\n", file); + + if (!(pending = ((fileht = phpdbg_resolve_pending_file_break_ex(file, filelen, path, path_len, broken TSRMLS_CC)) == NULL))) { phpdbg_breakfile_t *brake; - zend_hash_index_find(broken, line_num, (void **) &brake); + zend_hash_index_find(fileht, line_num, (void **) &brake); new_break = *brake; break; } @@ -298,18 +306,19 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRML PHPDBG_API HashTable *phpdbg_resolve_pending_file_break_ex(const char *file, uint filelen, const char *cur, uint curlen, HashTable *fileht TSRMLS_DC) /* {{{ */ { - if (curlen < filelen && file[filelen - curlen - 1] == '/' && !memcmp(file + filelen - curlen, cur, curlen)) { + phpdbg_debug("file: %s, filelen: %u, cur: %s, curlen %u, pos: %c, memcmp: %d\n", file, filelen, cur, curlen, filelen > curlen ? file[filelen - curlen - 1] : '?', filelen > curlen ? memcmp(file + filelen - curlen, cur, curlen) : 0); + + if (((curlen < filelen && file[filelen - curlen - 1] == '/') || filelen == curlen) && !memcmp(file + filelen - curlen, cur, curlen)) { phpdbg_breakfile_t *brake, new_brake; HashTable *master = NULL; HashPosition position; - dtor_func_t dtor; PHPDBG_G(flags) |= PHPDBG_HAS_FILE_BP; if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, (void **) &master) == FAILURE) { - dtor = PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor; - PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor = NULL; - zend_hash_add(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, fileht, sizeof(HashTable), (void **) &fileht); + HashTable new_ht; + zend_hash_init(&new_ht, 8, NULL, phpdbg_file_breaks_dtor, 0); + zend_hash_add(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, &new_ht, sizeof(HashTable), (void **) &master); } for (zend_hash_internal_pointer_reset_ex(fileht, &position); @@ -322,24 +331,18 @@ PHPDBG_API HashTable *phpdbg_resolve_pending_file_break_ex(const char *file, uin if (master) { zend_hash_index_update(master, brake->line, (void **) &new_brake, sizeof(phpdbg_breakfile_t), NULL); PHPDBG_BREAK_MAPPING(brake->id, master); - } else { - efree((char *) brake->filename); - *brake = new_brake; - PHPDBG_BREAK_MAPPING(brake->id, fileht); } } zend_hash_del(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], cur, curlen); - if (!master) { - PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor = dtor; - } - if (!zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING])) { PHPDBG_G(flags) &= ~PHPDBG_HAS_PENDING_FILE_BP; } - return fileht; + phpdbg_debug("compiled file: %s, cur bp file: %s\n", file, cur); + + return master; } return NULL; @@ -351,6 +354,8 @@ PHPDBG_API void phpdbg_resolve_pending_file_break(const char *file TSRMLS_DC) /* HashTable *fileht; uint filelen = strlen(file); + phpdbg_debug("was compiled: %s\n", file); + zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position); while (zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], (void**) &fileht, &position) == SUCCESS) { const char *cur; @@ -359,6 +364,8 @@ PHPDBG_API void phpdbg_resolve_pending_file_break(const char *file TSRMLS_DC) /* zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], (char **) &cur, &curlen, NULL, 0, &position); zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position); + phpdbg_debug("check bp: %s\n", cur); + phpdbg_resolve_pending_file_break_ex(file, filelen, cur, curlen, fileht TSRMLS_CC); } } @@ -877,10 +884,21 @@ static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_file(zend_op_array *op_ { HashTable *breaks; phpdbg_breakbase_t *brake; - size_t name_len = strlen(op_array->filename); + size_t path_len; + char realpath[MAXPATHLEN]; + const char *path = op_array->filename; - if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], op_array->filename, - name_len, (void**)&breaks) == FAILURE) { + if (VCWD_REALPATH(path, realpath)) { + path = realpath; + } + + path_len = strlen(path); + +#if 0 + phpdbg_debug("Op at: %.*s %d\n", path_len, path, (*EG(opline_ptr))->lineno); +#endif + + if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], path, path_len, (void**)&breaks) == FAILURE) { return NULL; } From 2b3ea0a2bdcd4f758c27f9ad95260d55b6a154c3 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 13:20:43 +0100 Subject: [PATCH 126/398] Fix possibly unclosed tags --- phpdbg_io.c | 4 ---- phpdbg_out.c | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/phpdbg_io.c b/phpdbg_io.c index 6908a687d7e..a2a5c5969f4 100644 --- a/phpdbg_io.c +++ b/phpdbg_io.c @@ -187,10 +187,6 @@ PHPDBG_API int phpdbg_mixed_read(int sock, char *ptr, int len, int tmo TSRMLS_DC PHPDBG_API int phpdbg_mixed_write(int sock, const char *ptr, int len TSRMLS_DC) { - if (PHPDBG_G(flags) & PHPDBG_DISCARD_OUTPUT) { - return 0; - } - if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) { return phpdbg_send_bytes(sock, ptr, len); } diff --git a/phpdbg_out.c b/phpdbg_out.c index 365708c71ed..7e1dc7b744c 100644 --- a/phpdbg_out.c +++ b/phpdbg_out.c @@ -1168,6 +1168,10 @@ PHPDBG_API int phpdbg_output_err_buf(const char *tag, const char *xmlfmt, const va_list args; int errbuf_active = PHPDBG_G(err_buf).active; + if (PHPDBG_G(flags) & PHPDBG_DISCARD_OUTPUT) { + return 0; + } + PHPDBG_G(err_buf).active = 0; #ifdef ZTS @@ -1188,6 +1192,10 @@ PHPDBG_API int phpdbg_print(int type TSRMLS_DC, int fd, const char *tag, const c va_list args; int len; + if (PHPDBG_G(flags) & PHPDBG_DISCARD_OUTPUT) { + return 0; + } + va_start(args, strfmt); len = phpdbg_vprint(type TSRMLS_CC, fd, tag, xmlfmt, strfmt, args); va_end(args); @@ -1198,6 +1206,10 @@ PHPDBG_API int phpdbg_print(int type TSRMLS_DC, int fd, const char *tag, const c PHPDBG_API int phpdbg_xml_internal(int fd TSRMLS_DC, const char *fmt, ...) { int len = 0; + if (PHPDBG_G(flags) & PHPDBG_DISCARD_OUTPUT) { + return 0; + } + if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) { va_list args; char *buffer; @@ -1243,6 +1255,10 @@ PHPDBG_API int phpdbg_out_internal(int fd TSRMLS_DC, const char *fmt, ...) { int buflen; int len = 0; + if (PHPDBG_G(flags) & PHPDBG_DISCARD_OUTPUT) { + return 0; + } + va_start(args, fmt); buflen = phpdbg_xml_vasprintf(&buffer, fmt, 0, args TSRMLS_CC); va_end(args); From 24a88e39065dd7e80c3a9f2c18d0d878af36cbe8 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 13:27:20 +0100 Subject: [PATCH 127/398] Fix wrong exec length on relative paths --- phpdbg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpdbg.c b/phpdbg.c index 9c56b1d7bc9..4bfbf4c1e91 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -1466,7 +1466,7 @@ phpdbg_main: if (exec) { /* set execution context */ PHPDBG_G(exec) = phpdbg_resolve_path(exec TSRMLS_CC); - PHPDBG_G(exec_len) = strlen(exec); + PHPDBG_G(exec_len) = PHPDBG_G(exec) ? strlen(PHPDBG_G(exec)) : 0; free(exec); exec = NULL; From b8dd98178cd7f1c62c98a5eb695afc15d3ae8bc1 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 13:55:14 +0100 Subject: [PATCH 128/398] Fix quitting on a second run --- phpdbg.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index 4bfbf4c1e91..87bfb858345 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -1527,21 +1527,20 @@ phpdbg_main: PHPDBG_G(flags) |= PHPDBG_IS_STEPPING; } - if (phpdbg_startup_run) { - 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; - } - phpdbg_startup_run = 0; - } - phpdbg_interact: /* phpdbg main() */ do { zend_try { + if (phpdbg_startup_run) { + PHPDBG_COMMAND_HANDLER(run)(NULL TSRMLS_CC); + if (phpdbg_startup_run > 1) { + /* if -r is on the command line more than once just quit */ + EG(bailout) = __orig_bailout; /* reset zend_try */ + break; + } + phpdbg_startup_run = 0; + } + phpdbg_interactive(1 TSRMLS_CC); } zend_catch { if ((PHPDBG_G(flags) & PHPDBG_IS_CLEANING)) { From b24640f46317c6da2519f052f8647f5cfad6c438 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 13:55:56 +0100 Subject: [PATCH 129/398] Typo (notfoundc => notfound) --- phpdbg_prompt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 262b265a2e9..733d3cbe48a 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -1132,7 +1132,7 @@ PHPDBG_COMMAND(register) /* {{{ */ phpdbg_notice("register", "function=\"%s\"", "Registered %s", lcname); } else { - phpdbg_error("register", "type=\"notfoundc\" function=\"%s\"", "The requested function (%s) could not be found", param->str); + phpdbg_error("register", "type=\"notfound\" function=\"%s\"", "The requested function (%s) could not be found", param->str); } } else { phpdbg_error("register", "type=\"inuse\" function=\"%s\"", "The requested name (%s) is already in use", lcname); From 71e200b338654b50142917f1baddd6da36e9eb5d Mon Sep 17 00:00:00 2001 From: Julien Pauli Date: Tue, 28 Oct 2014 15:01:53 +0100 Subject: [PATCH 130/398] PHP 5.5.20 now --- NEWS | 3 +++ configure.in | 2 +- main/php_version.h | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 15a2951377c..9e5e1388c81 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +?? ??? 2014, PHP 5.5.20 + + ?? ??? 2014, PHP 5.5.19 - Core: diff --git a/configure.in b/configure.in index cc5ec47ac71..b16a97e72c4 100644 --- a/configure.in +++ b/configure.in @@ -119,7 +119,7 @@ int zend_sprintf(char *buffer, const char *format, ...); PHP_MAJOR_VERSION=5 PHP_MINOR_VERSION=5 -PHP_RELEASE_VERSION=19 +PHP_RELEASE_VERSION=20 PHP_EXTRA_VERSION="-dev" PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION" PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION` diff --git a/main/php_version.h b/main/php_version.h index b198ad69b1d..3e5d9d8b3e7 100644 --- a/main/php_version.h +++ b/main/php_version.h @@ -2,7 +2,7 @@ /* edit configure.in to change version number */ #define PHP_MAJOR_VERSION 5 #define PHP_MINOR_VERSION 5 -#define PHP_RELEASE_VERSION 19 +#define PHP_RELEASE_VERSION 20 #define PHP_EXTRA_VERSION "-dev" -#define PHP_VERSION "5.5.19-dev" -#define PHP_VERSION_ID 50519 +#define PHP_VERSION "5.5.20-dev" +#define PHP_VERSION_ID 50520 From c7f074b1637ff42016091c84f7e9e23927623271 Mon Sep 17 00:00:00 2001 From: Julien Pauli Date: Tue, 28 Oct 2014 16:00:19 +0100 Subject: [PATCH 131/398] 5.6.4 now --- NEWS | 4 ++++ configure.in | 2 +- main/php_version.h | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 2f300b1ea72..478fa1d26c7 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,9 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +?? ??? 2014, PHP 5.6.4 + + + ?? ??? 2014, PHP 5.6.3 - Core: diff --git a/configure.in b/configure.in index 8eb08baa3e2..096f20c3f29 100644 --- a/configure.in +++ b/configure.in @@ -119,7 +119,7 @@ int zend_sprintf(char *buffer, const char *format, ...); PHP_MAJOR_VERSION=5 PHP_MINOR_VERSION=6 -PHP_RELEASE_VERSION=3 +PHP_RELEASE_VERSION=4 PHP_EXTRA_VERSION="-dev" PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION" PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION` diff --git a/main/php_version.h b/main/php_version.h index be8584d14af..daa633ca339 100644 --- a/main/php_version.h +++ b/main/php_version.h @@ -2,7 +2,7 @@ /* edit configure.in to change version number */ #define PHP_MAJOR_VERSION 5 #define PHP_MINOR_VERSION 6 -#define PHP_RELEASE_VERSION 3 +#define PHP_RELEASE_VERSION 4 #define PHP_EXTRA_VERSION "-dev" -#define PHP_VERSION "5.6.3-dev" -#define PHP_VERSION_ID 50603 +#define PHP_VERSION "5.6.4-dev" +#define PHP_VERSION_ID 50604 From 49e31265edac2c67fb5b155f63ec5752af19eac1 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 17:20:21 +0100 Subject: [PATCH 132/398] Remove the ugly hack via a temp file to store breakpoints --- phpdbg.c | 61 +++++----------- phpdbg_bp.c | 67 +++++++++++------ phpdbg_bp.h | 3 +- phpdbg_prompt.c | 190 ++++++++++++++++++++++++++++-------------------- phpdbg_prompt.h | 1 + 5 files changed, 173 insertions(+), 149 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index 87bfb858345..5ebc203529b 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -1039,13 +1039,7 @@ int main(int argc, char **argv) /* {{{ */ zend_bool remote = 0; int step = 0; zend_phpdbg_globals *settings = NULL; - -#ifdef _WIN32 - char *bp_tmp_file = NULL; -#else - char bp_tmp_file[] = "/tmp/phpdbg.XXXXXX"; -#endif - + char *bp_tmp = NULL; char *address; int listen = -1; int server = -1; @@ -1081,29 +1075,6 @@ int main(int argc, char **argv) /* {{{ */ #endif phpdbg_main: - if (!cleaning) { - -#ifdef _WIN32 - bp_tmp_file = malloc(L_tmpnam); - - if (bp_tmp_file) { - if (!tmpnam(bp_tmp_file)) { - free(bp_tmp_file); - bp_tmp_file = NULL; - } - } - - if (!bp_tmp_file) { - phpdbg_error("tmpfile", "", "Unable to create temporary file"); - return 1; - } -#else - if (!mkstemp(bp_tmp_file)) { - memset(bp_tmp_file, 0, sizeof(bp_tmp_file)); - } -#endif - - } ini_entries = NULL; ini_entries_len = 0; ini_ignore = 0; @@ -1502,9 +1473,13 @@ phpdbg_main: 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; + if (bp_tmp) { + PHPDBG_G(flags) |= PHPDBG_DISCARD_OUTPUT; + phpdbg_string_init(bp_tmp TSRMLS_CC); + free(bp_tmp); + bp_tmp = NULL; + PHPDBG_G(flags) &= ~PHPDBG_DISCARD_OUTPUT; + } } zend_end_try(); PHPDBG_G(flags) &= ~PHPDBG_IS_INITIALIZING; @@ -1532,23 +1507,27 @@ phpdbg_interact: do { zend_try { if (phpdbg_startup_run) { + zend_bool quit_immediately = phpdbg_startup_run > 1; + phpdbg_startup_run = 0; PHPDBG_COMMAND_HANDLER(run)(NULL TSRMLS_CC); - if (phpdbg_startup_run > 1) { + if (quit_immediately) { /* if -r is on the command line more than once just quit */ EG(bailout) = __orig_bailout; /* reset zend_try */ break; } - phpdbg_startup_run = 0; } phpdbg_interactive(1 TSRMLS_CC); } zend_catch { if ((PHPDBG_G(flags) & PHPDBG_IS_CLEANING)) { - FILE *bp_tmp_fp = fopen(bp_tmp_file, "w"); + char *bp_tmp_str; PHPDBG_G(flags) |= PHPDBG_DISCARD_OUTPUT; - phpdbg_export_breakpoints(bp_tmp_fp TSRMLS_CC); + phpdbg_export_breakpoints_to_string(&bp_tmp_str TSRMLS_CC); PHPDBG_G(flags) &= ~PHPDBG_DISCARD_OUTPUT; - fclose(bp_tmp_fp); + if (bp_tmp_str) { + bp_tmp = strdup(bp_tmp_str); + efree(bp_tmp_str); + } cleaning = 1; } else { cleaning = 0; @@ -1688,11 +1667,5 @@ phpdbg_out: free(PHPDBG_G(sapi_name_ptr)); } -#ifdef _WIN32 - free(bp_tmp_file); -#else - unlink(bp_tmp_file); -#endif - return 0; } /* }}} */ diff --git a/phpdbg_bp.c b/phpdbg_bp.c index 93902f00529..33824d4fec4 100644 --- a/phpdbg_bp.c +++ b/phpdbg_bp.c @@ -110,11 +110,20 @@ PHPDBG_API void phpdbg_reset_breakpoints(TSRMLS_D) /* {{{ */ } /* }}} */ PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */ +{ + char *string; + phpdbg_export_breakpoints_to_string(&string TSRMLS_CC); + fputs(string, handle); +} + +PHPDBG_API void phpdbg_export_breakpoints_to_string(char **str TSRMLS_DC) /* {{{ */ { HashPosition position[2]; HashTable **table = NULL; zend_ulong id = 0L; + *str = ""; + if (zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP])) { phpdbg_notice("exportbreakpoint", "count=\"%d\"", "Exporting %d breakpoints", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP])); /* this only looks like magic, it isn't */ @@ -126,55 +135,57 @@ PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */ zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], NULL, NULL, &id, 0, &position[0]); for (zend_hash_internal_pointer_reset_ex((*table), &position[1]); - zend_hash_get_current_data_ex((*table), (void**)&brake, &position[1]) == SUCCESS; - zend_hash_move_forward_ex((*table), &position[1])) { + zend_hash_get_current_data_ex((*table), (void**)&brake, &position[1]) == SUCCESS; + zend_hash_move_forward_ex((*table), &position[1])) { if (brake->id == id) { + char *new_str = NULL; + switch (brake->type) { case PHPDBG_BREAK_FILE: { - fprintf(handle, - "break %s:%lu\n", + phpdbg_asprintf(&new_str, + "%sbreak %s:%lu\n", *str, ((phpdbg_breakfile_t*)brake)->filename, ((phpdbg_breakfile_t*)brake)->line); } break; case PHPDBG_BREAK_SYM: { - fprintf(handle, - "break %s\n", + phpdbg_asprintf(&new_str, + "%sbreak %s\n", *str, ((phpdbg_breaksymbol_t*)brake)->symbol); } break; case PHPDBG_BREAK_METHOD: { - fprintf(handle, - "break %s::%s\n", + phpdbg_asprintf(&new_str, + "%sbreak %s::%s\n", *str, ((phpdbg_breakmethod_t*)brake)->class_name, ((phpdbg_breakmethod_t*)brake)->func_name); } break; case PHPDBG_BREAK_METHOD_OPLINE: { - fprintf(handle, - "break %s::%s#%ld\n", + phpdbg_asprintf(&new_str, + "%sbreak %s::%s#%ld\n", *str, ((phpdbg_breakopline_t*)brake)->class_name, ((phpdbg_breakopline_t*)brake)->func_name, ((phpdbg_breakopline_t*)brake)->opline_num); } break; case PHPDBG_BREAK_FUNCTION_OPLINE: { - fprintf(handle, - "break %s#%ld\n", + phpdbg_asprintf(&new_str, + "%sbreak %s#%ld\n", *str, ((phpdbg_breakopline_t*)brake)->func_name, ((phpdbg_breakopline_t*)brake)->opline_num); } break; case PHPDBG_BREAK_FILE_OPLINE: { - fprintf(handle, - "break %s:#%ld\n", + phpdbg_asprintf(&new_str, + "%sbreak %s:#%ld\n", *str, ((phpdbg_breakopline_t*)brake)->class_name, ((phpdbg_breakopline_t*)brake)->opline_num); } break; case PHPDBG_BREAK_OPCODE: { - fprintf(handle, - "break %s\n", + phpdbg_asprintf(&new_str, + "%sbreak %s\n", *str, ((phpdbg_breakop_t*)brake)->name); } break; @@ -184,20 +195,20 @@ PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */ if (conditional->paramed) { switch (conditional->param.type) { case STR_PARAM: - fprintf(handle, - "break at %s if %s\n", conditional->param.str, conditional->code); + phpdbg_asprintf(&new_str, + "%sbreak at %s if %s\n", *str, conditional->param.str, conditional->code); break; case METHOD_PARAM: - fprintf(handle, - "break at %s::%s if %s\n", + phpdbg_asprintf(&new_str, + "%sbreak at %s::%s if %s\n", *str, conditional->param.method.class, conditional->param.method.name, conditional->code); break; case FILE_PARAM: - fprintf(handle, - "break at %s:%lu if %s\n", + phpdbg_asprintf(&new_str, + "%sbreak at %s:%lu if %s\n", *str, conditional->param.file.name, conditional->param.file.line, conditional->code); break; @@ -205,15 +216,23 @@ PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */ default: { /* do nothing */ } break; } } else { - fprintf( - handle, "break if %s\n", conditional->code); + phpdbg_asprintf(&new_str, "%sbreak if %s\n", str, conditional->code); } } break; } + + if ((*str)[0]) { + efree(*str); + } + *str = new_str; } } } } + + if (!(*str)[0]) { + *str = NULL; + } } /* }}} */ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRMLS_DC) /* {{{ */ diff --git a/phpdbg_bp.h b/phpdbg_bp.h index eca595321b3..63a9961d2a8 100644 --- a/phpdbg_bp.h +++ b/phpdbg_bp.h @@ -157,6 +157,7 @@ PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase(zend_ulong id TSRMLS_DC); PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase_ex(zend_ulong id, HashTable ***table, HashPosition *position TSRMLS_DC); /* }}} */ /* {{{ Breakpoint Exportation API */ -PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC); /* }}} */ +PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC); +PHPDBG_API void phpdbg_export_breakpoints_to_string(char **str TSRMLS_DC); /* }}} */ #endif /* PHPDBG_BP_H */ diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 733d3cbe48a..c1fcb59a086 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -208,6 +208,110 @@ static inline int phpdbg_call_register(phpdbg_param_t *stack TSRMLS_DC) /* {{{ * return FAILURE; } /* }}} */ +struct phpdbg_init_state { + int line; + zend_bool in_code; + char *code; + size_t code_len; + const char *init_file; +}; + +static void phpdbg_line_init(char *cmd, struct phpdbg_init_state *state TSRMLS_DC) { + size_t cmd_len = strlen(cmd); + + state->line++; + + while (cmd_len > 0L && isspace(cmd[cmd_len-1])) { + cmd_len--; + } + + cmd[cmd_len] = '\0'; + + if (*cmd && cmd_len > 0L && cmd[0] != '#') { + if (cmd_len == 2) { + if (memcmp(cmd, "<:", sizeof("<:")-1) == SUCCESS) { + state->in_code = 1; + return; + } else { + if (memcmp(cmd, ":>", sizeof(":>")-1) == SUCCESS) { + state->in_code = 0; + state->code[state->code_len] = '\0'; + zend_eval_stringl(state->code, state->code_len, NULL, "phpdbginit code" TSRMLS_CC); + free(state->code); + state->code = NULL; + return; + } + } + } + + if (state->in_code) { + if (state->code == NULL) { + state->code = malloc(cmd_len + 1); + } else { + state->code = realloc(state->code, state->code_len + cmd_len + 1); + } + + if (state->code) { + memcpy(&state->code[state->code_len], cmd, cmd_len); + state->code_len += cmd_len; + } + + return; + } + + zend_try { + char *input = phpdbg_read_input(cmd TSRMLS_CC); + phpdbg_param_t stack; + + phpdbg_init_param(&stack, STACK_PARAM); + + phpdbg_activate_err_buf(1 TSRMLS_CC); + + if (phpdbg_do_parse(&stack, input TSRMLS_CC) <= 0) { + switch (phpdbg_stack_execute(&stack, 1 /* allow_async_unsafe == 1 */ TSRMLS_CC)) { + case FAILURE: + phpdbg_activate_err_buf(0 TSRMLS_CC); + if (phpdbg_call_register(&stack TSRMLS_CC) == FAILURE) { + if (state->init_file) { + phpdbg_output_err_buf("initfailure", "%b file=\"%s\" line=\"%d\" input=\"%s\"", "Unrecognized command in %s:%d: %s, %b!" TSRMLS_CC, state->init_file, state->line, input); + } else { + phpdbg_output_err_buf("initfailure", "%b line=\"%d\" input=\"%s\"", "Unrecognized command on line %d: %s, %b!" TSRMLS_CC, state->line, input); + } + } + break; + } + } + + phpdbg_activate_err_buf(0 TSRMLS_CC); + phpdbg_free_err_buf(TSRMLS_C); + + 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(); + } + +} + +void phpdbg_string_init(char *buffer TSRMLS_DC) { + struct phpdbg_init_state state = {0}; + char *str = strtok(buffer, "\n"); + + while (str) { + phpdbg_line_init(str, &state TSRMLS_CC); + + str = strtok(NULL, "\n"); + } + + if (state.code) { + free(state.code); + } +} + void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_init TSRMLS_DC) /* {{{ */ { struct stat sb; @@ -215,91 +319,17 @@ void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_ if (init_file && VCWD_STAT(init_file, &sb) != -1) { FILE *fp = fopen(init_file, "r"); if (fp) { - int line = 1; - char cmd[PHPDBG_MAX_CMD]; - size_t cmd_len = 0L; - char *code = NULL; - size_t code_len = 0L; - zend_bool in_code = 0; + struct phpdbg_init_state state = {0}; + + state.init_file = init_file; while (fgets(cmd, PHPDBG_MAX_CMD, fp) != NULL) { - cmd_len = strlen(cmd)-1; - - while (cmd_len > 0L && isspace(cmd[cmd_len-1])) - cmd_len--; - - cmd[cmd_len] = '\0'; - - if (*cmd && cmd_len > 0L && cmd[0] != '#') { - if (cmd_len == 2) { - if (memcmp(cmd, "<:", sizeof("<:")-1) == SUCCESS) { - in_code = 1; - goto next_line; - } else { - if (memcmp(cmd, ":>", sizeof(":>")-1) == SUCCESS) { - in_code = 0; - code[code_len] = '\0'; - { - zend_eval_stringl(code, code_len, NULL, "phpdbginit code" TSRMLS_CC); - } - free(code); - code = NULL; - goto next_line; - } - } - } - - if (in_code) { - if (code == NULL) { - code = malloc(cmd_len + 1); - } else code = realloc(code, code_len + cmd_len + 1); - - if (code) { - memcpy( - &code[code_len], cmd, cmd_len); - code_len += cmd_len; - } - goto next_line; - } - - zend_try { - char *input = phpdbg_read_input(cmd TSRMLS_CC); - phpdbg_param_t stack; - - phpdbg_init_param(&stack, STACK_PARAM); - - phpdbg_activate_err_buf(1 TSRMLS_CC); - - if (phpdbg_do_parse(&stack, input TSRMLS_CC) <= 0) { - switch (phpdbg_stack_execute(&stack, 1 /* allow_async_unsafe == 1 */ TSRMLS_CC)) { - case FAILURE: - phpdbg_activate_err_buf(0 TSRMLS_CC); - if (phpdbg_call_register(&stack TSRMLS_CC) == FAILURE) { - phpdbg_output_err_buf("initfailure", "%b file=\"%s\" line=\"%d\" input=\"%s\"", "Unrecognized command in %s:%d: %s, %b!" TSRMLS_CC, init_file, line, input); - } - break; - } - } - - phpdbg_activate_err_buf(0 TSRMLS_CC); - phpdbg_free_err_buf(TSRMLS_C); - - 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_line_init(cmd, &state TSRMLS_CC); } - if (code) { - free(code); + if (state.code) { + free(state.code); } fclose(fp); diff --git a/phpdbg_prompt.h b/phpdbg_prompt.h index 94e24df8334..f583f2cdcd6 100644 --- a/phpdbg_prompt.h +++ b/phpdbg_prompt.h @@ -22,6 +22,7 @@ #define PHPDBG_PROMPT_H /* {{{ */ +void phpdbg_string_init(char *buffer TSRMLS_DC); void phpdbg_init(char *init_file, size_t init_file_len, zend_bool use_default TSRMLS_DC); void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_init TSRMLS_DC); int phpdbg_interactive(zend_bool allow_async_unsafe TSRMLS_DC); From 99d12cf2026b7363f874bcbf7b19b5c204210553 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 18:42:45 +0100 Subject: [PATCH 133/398] fix datatype mismatch --- main/php_scandir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/php_scandir.c b/main/php_scandir.c index 7dfec7bff79..5275f3ddd36 100644 --- a/main/php_scandir.c +++ b/main/php_scandir.c @@ -97,7 +97,7 @@ PHPAPI int php_scandir(const char *dirname, struct dirent **namelist[], int (*se vector = newv; } - dsize = sizeof (struct dirent) + ((strlen(dp->d_name) + 1) * sizeof(char)); + dsize = sizeof (struct dirent) + (((int)strlen(dp->d_name) + 1) * sizeof(char)); newdp = (struct dirent *) malloc(dsize); if (newdp == NULL) { From 5ac84a5a47481af86d5318d412d44817a1eee524 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 18:46:46 +0100 Subject: [PATCH 134/398] fix datatype mismatch warns --- main/SAPI.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main/SAPI.c b/main/SAPI.c index 50ea8c0a161..b1be4443d2b 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -187,7 +187,7 @@ SAPI_API void sapi_handle_post(void *arg TSRMLS_DC) static void sapi_read_post_data(TSRMLS_D) { sapi_post_entry *post_entry; - uint content_type_length = strlen(SG(request_info).content_type); + uint content_type_length = (uint)strlen(SG(request_info).content_type); char *content_type = estrndup(SG(request_info).content_type, content_type_length); char *p; char oldchar=0; @@ -252,7 +252,7 @@ SAPI_API int sapi_read_post_block(char *buffer, size_t buflen TSRMLS_DC) return -1; } - read_bytes = sapi_module.read_post(buffer, buflen TSRMLS_CC); + read_bytes = (int)sapi_module.read_post(buffer, buflen TSRMLS_CC); if (read_bytes > 0) { /* gogo */ @@ -311,14 +311,14 @@ static inline char *get_default_content_type(uint prefix_len, uint *len TSRMLS_D if (SG(default_mimetype)) { mimetype = SG(default_mimetype); - mimetype_len = strlen(SG(default_mimetype)); + mimetype_len = (uint)strlen(SG(default_mimetype)); } else { mimetype = SAPI_DEFAULT_MIMETYPE; mimetype_len = sizeof(SAPI_DEFAULT_MIMETYPE) - 1; } if (SG(default_charset)) { charset = SG(default_charset); - charset_len = strlen(SG(default_charset)); + charset_len = (uint)strlen(SG(default_charset)); } else { charset = SAPI_DEFAULT_CHARSET; charset_len = sizeof(SAPI_DEFAULT_CHARSET) - 1; @@ -652,7 +652,7 @@ static void sapi_header_add_op(sapi_header_op_enum op, sapi_header_struct *sapi_ char sav = *colon_offset; *colon_offset = 0; - sapi_remove_header(&SG(sapi_headers).headers, sapi_header->header, strlen(sapi_header->header)); + sapi_remove_header(&SG(sapi_headers).headers, sapi_header->header, (int)strlen(sapi_header->header)); *colon_offset = sav; } } @@ -806,7 +806,7 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC) PHP_STRLCPY(newheader, "Content-type: ", newlen, sizeof("Content-type: ")-1); strlcat(newheader, mimetype, newlen); sapi_header.header = newheader; - sapi_header.header_len = newlen - 1; + sapi_header.header_len = (uint)(newlen - 1); efree(header_line); } efree(mimetype); @@ -901,7 +901,7 @@ SAPI_API int sapi_send_headers(TSRMLS_D) if (SG(sapi_headers).http_status_line) { http_status_line.header = SG(sapi_headers).http_status_line; - http_status_line.header_len = strlen(SG(sapi_headers).http_status_line); + http_status_line.header_len = (uint)strlen(SG(sapi_headers).http_status_line); } else { http_status_line.header = buf; http_status_line.header_len = slprintf(buf, sizeof(buf), "HTTP/1.0 %d X", SG(sapi_headers).http_response_code); From e048426402aa81c3b45473aa71c9bf8b9eee1a6f Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 18:49:15 +0100 Subject: [PATCH 135/398] fix datatype mismatch --- win32/glob.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win32/glob.c b/win32/glob.c index 74882ac7d69..43884509ce9 100644 --- a/win32/glob.c +++ b/win32/glob.c @@ -742,7 +742,7 @@ globextend(path, pglob, limitp) for (p = path; *p++;) ; - len = (size_t)(p - path); + len = (u_int)(p - path); *limitp += len; if ((copy = malloc(len)) != NULL) { if (g_Ctoc(path, copy, len)) { From 77ab77fd02b24aac32594c4f5f6ad21a2e961ed7 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 18:57:51 +0100 Subject: [PATCH 136/398] fix datatype mismatch --- win32/readdir.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/win32/readdir.c b/win32/readdir.c index 0edd5764d49..4e5992167c9 100644 --- a/win32/readdir.c +++ b/win32/readdir.c @@ -37,7 +37,7 @@ DIR *opendir(const char *dir) return NULL; } strcpy(filespec, resolved_path_buff); - index = strlen(filespec) - 1; + index = (int)strlen(filespec) - 1; if (index >= 0 && (filespec[index] == '/' || (filespec[index] == '\\' && (index == 0 || !IsDBCSLeadByte(filespec[index-1]))))) filespec[index] = '\0'; @@ -83,7 +83,7 @@ struct dirent *readdir(DIR *dp) strlcpy(dp->dent.d_name, dp->fileinfo.cFileName, _MAX_FNAME+1); dp->dent.d_ino = 1; - dp->dent.d_reclen = strlen(dp->dent.d_name); + dp->dent.d_reclen = (unsigned short)strlen(dp->dent.d_name); dp->dent.d_off = dp->offset; return &(dp->dent); @@ -107,7 +107,7 @@ int readdir_r(DIR *dp, struct dirent *entry, struct dirent **result) strlcpy(dp->dent.d_name, dp->fileinfo.cFileName, _MAX_FNAME+1); dp->dent.d_ino = 1; - dp->dent.d_reclen = strlen(dp->dent.d_name); + dp->dent.d_reclen = (unsigned short)strlen(dp->dent.d_name); dp->dent.d_off = dp->offset; memcpy(entry, &dp->dent, sizeof(*entry)); @@ -152,7 +152,7 @@ int rewinddir(DIR *dp) } strcpy(filespec, dp->dir); - index = strlen(filespec) - 1; + index = (int)strlen(filespec) - 1; if (index >= 0 && (filespec[index] == '/' || (filespec[index] == '\\' && (index == 0 || !IsDBCSLeadByte(filespec[index-1]))))) filespec[index] = '\0'; From 1770ae641ba71dc6f62ca0aaa46fc225a25f43dd Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 19:23:03 +0100 Subject: [PATCH 137/398] fix datatype mismatches --- win32/registry.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/win32/registry.c b/win32/registry.c index 10372cd624e..ef36c145555 100644 --- a/win32/registry.c +++ b/win32/registry.c @@ -27,8 +27,8 @@ static int OpenPhpRegistryKey(char* sub_key, HKEY *hKey) const char **key_name = registry_keys; if (sub_key) { - int main_key_len; - int sub_key_len = strlen(sub_key); + size_t main_key_len; + size_t sub_key_len = strlen(sub_key); char *reg_key; while (*key_name) { @@ -235,7 +235,6 @@ void UpdateIniFromRegistry(char *path TSRMLS_DC) } zend_str_tolower(path, path_len); while (path_len >= 0) { - ZEND_API zval *zend_hash_str_find(const HashTable *ht, const char *key, int len); pht = (HashTable *)zend_hash_str_find_ptr(PW32G(registry_directories), path, path_len+1); if (pht != NULL) { HashTable *ht = pht; From e7945419ddad0c0e952b5aba387c51cf6883fe5e Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 19:36:29 +0100 Subject: [PATCH 138/398] fix datatype mismatches --- ext/standard/user_filters.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/standard/user_filters.c b/ext/standard/user_filters.c index 19e8e454df7..f310e64ae94 100644 --- a/ext/standard/user_filters.c +++ b/ext/standard/user_filters.c @@ -221,7 +221,7 @@ php_stream_filter_status_t userfilter_filter( if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF) { convert_to_long(&retval); - ret = Z_LVAL(retval); + ret = (int)Z_LVAL(retval); } else if (call_result == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to call filter function"); } @@ -287,7 +287,7 @@ static php_stream_filter *user_filter_factory_create(const char *filtername, return NULL; } - len = strlen(filtername); + len = (int)strlen(filtername); /* determine the classname/class entry */ if (NULL == (fdat = zend_hash_str_find_ptr(BG(user_filter_map), (char*)filtername, len))) { From 36b64b44d57f3043ebdaf5bd0c3aa4168f96bd69 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Oct 2014 19:51:14 +0100 Subject: [PATCH 139/398] fix signature, zend_string is used for function name --- Zend/zend_interfaces.c | 2 +- Zend/zend_interfaces.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c index e2997410003..f0762892014 100644 --- a/Zend/zend_interfaces.c +++ b/Zend/zend_interfaces.c @@ -31,7 +31,7 @@ ZEND_API zend_class_entry *zend_ce_serializable; /* {{{ zend_call_method Only returns the returned zval if retval_ptr != NULL */ -ZEND_API zval* zend_call_method(zval *object, zend_class_entry *obj_ce, zend_function **fn_proxy, const char *function_name, int function_name_len, zval *retval_ptr, int param_count, zval* arg1, zval* arg2 TSRMLS_DC) +ZEND_API zval* zend_call_method(zval *object, zend_class_entry *obj_ce, zend_function **fn_proxy, const char *function_name, size_t function_name_len, zval *retval_ptr, int param_count, zval* arg1, zval* arg2 TSRMLS_DC) { int result; zend_fcall_info fci; diff --git a/Zend/zend_interfaces.h b/Zend/zend_interfaces.h index 9bfef0990d9..dff05bc7016 100644 --- a/Zend/zend_interfaces.h +++ b/Zend/zend_interfaces.h @@ -38,7 +38,7 @@ typedef struct _zend_user_iterator { zval value; } zend_user_iterator; -ZEND_API zval* zend_call_method(zval *object_pp, zend_class_entry *obj_ce, zend_function **fn_proxy, const char *function_name, int function_name_len, zval *retval, int param_count, zval* arg1, zval* arg2 TSRMLS_DC); +ZEND_API zval* zend_call_method(zval *object_pp, zend_class_entry *obj_ce, zend_function **fn_proxy, const char *function_name, size_t function_name_len, zval *retval, int param_count, zval* arg1, zval* arg2 TSRMLS_DC); #define zend_call_method_with_0_params(obj, obj_ce, fn_proxy, function_name, retval) \ zend_call_method(obj, obj_ce, fn_proxy, function_name, sizeof(function_name)-1, retval, 0, NULL, NULL TSRMLS_CC) From e4464a8e85cde188e4361c14580adee85b1e7df3 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 28 Oct 2014 10:43:10 +0100 Subject: [PATCH 140/398] convert API for size_t where zend_string is used under the hood --- Zend/zend_ts_hash.c | 6 +++--- Zend/zend_ts_hash.h | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Zend/zend_ts_hash.c b/Zend/zend_ts_hash.c index 43f02b48f81..dd7aaeb9a74 100644 --- a/Zend/zend_ts_hash.c +++ b/Zend/zend_ts_hash.c @@ -333,7 +333,7 @@ ZEND_API int zend_ts_hash_rehash(TsHashTable *ht) return retval; } -ZEND_API zval *zend_ts_hash_str_find(TsHashTable *ht, const char *key, int len) +ZEND_API zval *zend_ts_hash_str_find(TsHashTable *ht, const char *key, size_t len) { zval *retval; @@ -344,7 +344,7 @@ ZEND_API zval *zend_ts_hash_str_find(TsHashTable *ht, const char *key, int len) return retval; } -ZEND_API zval *_zend_ts_hash_str_update(TsHashTable *ht, const char *key, int len, zval *pData ZEND_FILE_LINE_DC) +ZEND_API zval *_zend_ts_hash_str_update(TsHashTable *ht, const char *key, size_t len, zval *pData ZEND_FILE_LINE_DC) { zval *retval; @@ -355,7 +355,7 @@ ZEND_API zval *_zend_ts_hash_str_update(TsHashTable *ht, const char *key, int le return retval; } -ZEND_API zval *_zend_ts_hash_str_add(TsHashTable *ht, const char *key, int len, zval *pData ZEND_FILE_LINE_DC) +ZEND_API zval *_zend_ts_hash_str_add(TsHashTable *ht, const char *key, size_t len, zval *pData ZEND_FILE_LINE_DC) { zval *retval; diff --git a/Zend/zend_ts_hash.h b/Zend/zend_ts_hash.h index 6cb36410b83..4bac7db2050 100644 --- a/Zend/zend_ts_hash.h +++ b/Zend/zend_ts_hash.h @@ -102,16 +102,16 @@ void zend_ts_hash_display_pListTail(TsHashTable *ht); void zend_ts_hash_display(TsHashTable *ht); #endif -ZEND_API zval *zend_ts_hash_str_find(TsHashTable *ht, const char *key, int len); -ZEND_API zval *_zend_ts_hash_str_update(TsHashTable *ht, const char *key, int len, zval *pData ZEND_FILE_LINE_DC); -ZEND_API zval *_zend_ts_hash_str_add(TsHashTable *ht, const char *key, int len, zval *pData ZEND_FILE_LINE_DC); +ZEND_API zval *zend_ts_hash_str_find(TsHashTable *ht, const char *key, size_t len); +ZEND_API zval *_zend_ts_hash_str_update(TsHashTable *ht, const char *key, size_t len, zval *pData ZEND_FILE_LINE_DC); +ZEND_API zval *_zend_ts_hash_str_add(TsHashTable *ht, const char *key, size_t len, zval *pData ZEND_FILE_LINE_DC); #define zend_ts_hash_str_update(ht, key, len, pData) \ _zend_ts_hash_str_update(ht, key, len, pData ZEND_FILE_LINE_CC) #define zend_ts_hash_str_add(ht, key, len, pData) \ _zend_ts_hash_str_add(ht, key, len, pData ZEND_FILE_LINE_CC) -static zend_always_inline void *zend_ts_hash_str_find_ptr(TsHashTable *ht, const char *str, int len) +static zend_always_inline void *zend_ts_hash_str_find_ptr(TsHashTable *ht, const char *str, size_t len) { zval *zv; @@ -119,7 +119,7 @@ static zend_always_inline void *zend_ts_hash_str_find_ptr(TsHashTable *ht, const return zv ? Z_PTR_P(zv) : NULL; } -static zend_always_inline void *zend_ts_hash_str_update_ptr(TsHashTable *ht, const char *str, int len, void *pData) +static zend_always_inline void *zend_ts_hash_str_update_ptr(TsHashTable *ht, const char *str, size_t len, void *pData) { zval tmp, *zv; @@ -128,7 +128,7 @@ static zend_always_inline void *zend_ts_hash_str_update_ptr(TsHashTable *ht, con return zv ? Z_PTR_P(zv) : NULL; } -static zend_always_inline void *zend_ts_hash_str_add_ptr(TsHashTable *ht, const char *str, int len, void *pData) +static zend_always_inline void *zend_ts_hash_str_add_ptr(TsHashTable *ht, const char *str, size_t len, void *pData) { zval tmp, *zv; From 41a505fc7f5546cfbabeb285404026fa31c0682f Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 28 Oct 2014 10:43:58 +0100 Subject: [PATCH 141/398] fix datatype mismatches --- ext/com_dotnet/com_com.c | 18 +++++++++--------- ext/com_dotnet/com_handlers.c | 4 ++-- ext/com_dotnet/com_olechar.c | 2 +- ext/com_dotnet/com_persist.c | 10 +++++----- ext/com_dotnet/com_saproxy.c | 10 +++++----- ext/com_dotnet/com_typeinfo.c | 4 ++-- ext/com_dotnet/com_variant.c | 17 +++++++++++------ ext/com_dotnet/com_wrapper.c | 4 ++-- ext/com_dotnet/php_com_dotnet_internal.h | 5 +++-- 9 files changed, 40 insertions(+), 34 deletions(-) diff --git a/ext/com_dotnet/com_com.c b/ext/com_dotnet/com_com.c index 5f0b8ff6979..ec276ee0040 100644 --- a/ext/com_dotnet/com_com.c +++ b/ext/com_dotnet/com_com.c @@ -129,11 +129,11 @@ PHP_FUNCTION(com_create_instance) if (user_name) { authid.User = php_com_string_to_olestring(user_name, -1, obj->code_page TSRMLS_CC); - authid.UserLength = user_name_len; + authid.UserLength = (ULONG)user_name_len; if (password) { authid.Password = (OLECHAR*)password; - authid.PasswordLength = password_len; + authid.PasswordLength = (ULONG)password_len; } else { authid.Password = (OLECHAR*)""; authid.PasswordLength = 0; @@ -141,7 +141,7 @@ PHP_FUNCTION(com_create_instance) if (domain_name) { authid.Domain = (OLECHAR*)domain_name; - authid.DomainLength = domain_name_len; + authid.DomainLength = (ULONG)domain_name_len; } else { authid.Domain = (OLECHAR*)""; authid.DomainLength = 0; @@ -288,7 +288,7 @@ PHP_FUNCTION(com_get_active_object) { CLSID clsid; char *module_name; - int module_name_len; + size_t module_name_len; zend_long code_page = COMG(code_page); IUnknown *unk = NULL; IDispatch *obj = NULL; @@ -302,7 +302,7 @@ PHP_FUNCTION(com_get_active_object) return; } - module = php_com_string_to_olestring(module_name, module_name_len, code_page TSRMLS_CC); + module = php_com_string_to_olestring(module_name, module_name_len, (int)code_page TSRMLS_CC); res = CLSIDFromString(module, &clsid); @@ -320,7 +320,7 @@ PHP_FUNCTION(com_get_active_object) php_com_throw_exception(res, NULL TSRMLS_CC); } else if (obj) { /* we got our dispatchable object */ - php_com_wrap_dispatch(return_value, obj, code_page TSRMLS_CC); + php_com_wrap_dispatch(return_value, obj, (int)code_page TSRMLS_CC); } } } @@ -427,7 +427,7 @@ HRESULT php_com_get_id_of_name(php_com_dotnet_object *obj, char *name, } if (obj->id_of_name_cache && NULL != (tmp = zend_hash_str_find(obj->id_of_name_cache, name, namelen))) { - *dispid = Z_LVAL_P(tmp); + *dispid = (DISPID)Z_LVAL_P(tmp); return S_OK; } @@ -631,7 +631,7 @@ int php_com_do_invoke_by_id(php_com_dotnet_object *obj, DISPID dispid, return SUCCEEDED(hr) ? SUCCESS : FAILURE; } -int php_com_do_invoke(php_com_dotnet_object *obj, char *name, int namelen, +int php_com_do_invoke(php_com_dotnet_object *obj, char *name, size_t namelen, WORD flags, VARIANT *v, int nargs, zval *args, int allow_noarg TSRMLS_DC) { DISPID dispid; @@ -791,7 +791,7 @@ PHP_FUNCTION(com_message_pump) RETURN_FALSE; php_com_initialize(TSRMLS_C); - result = MsgWaitForMultipleObjects(0, NULL, FALSE, timeoutms, QS_ALLINPUT); + result = MsgWaitForMultipleObjects(0, NULL, FALSE, (DWORD)timeoutms, QS_ALLINPUT); if (result == WAIT_OBJECT_0) { while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { diff --git a/ext/com_dotnet/com_handlers.c b/ext/com_dotnet/com_handlers.c index 6f63a1fbd88..8b721393fd8 100644 --- a/ext/com_dotnet/com_handlers.c +++ b/ext/com_dotnet/com_handlers.c @@ -101,7 +101,7 @@ static zval *com_read_dimension(zval *object, zval *offset, int type, zval *rv T convert_to_long(offset); if (SafeArrayGetDim(V_ARRAY(&obj->v)) == 1) { - if (php_com_safearray_get_elem(&obj->v, &v, Z_LVAL_P(offset) TSRMLS_CC)) { + if (php_com_safearray_get_elem(&obj->v, &v, (LONG)Z_LVAL_P(offset) TSRMLS_CC)) { php_com_wrap_variant(rv, &v, obj->code_page TSRMLS_CC); VariantClear(&v); } @@ -145,7 +145,7 @@ static void com_write_dimension(zval *object, zval *offset, zval *value TSRMLS_D } convert_to_long(offset); - indices = Z_LVAL_P(offset); + indices = (LONG)Z_LVAL_P(offset); VariantInit(&v); php_com_variant_from_zval(&v, value, obj->code_page TSRMLS_CC); diff --git a/ext/com_dotnet/com_olechar.c b/ext/com_dotnet/com_olechar.c index 51cc7e8f1df..2e0b558288a 100644 --- a/ext/com_dotnet/com_olechar.c +++ b/ext/com_dotnet/com_olechar.c @@ -49,7 +49,7 @@ PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(char *string, size_t str /* XXX if that's a real multibyte string, olestring is obviously allocated excessively. This should be fixed by reallocating the olestring, but as emalloc is used, that doesn't matter much. */ - ok = MultiByteToWideChar(codepage, flags, string, string_len, olestring, string_len); + ok = MultiByteToWideChar(codepage, flags, string, (int)string_len, olestring, (int)string_len); if (ok > 0 && ok < string_len) { olestring[ok] = '\0'; } diff --git a/ext/com_dotnet/com_persist.c b/ext/com_dotnet/com_persist.c index eb80e760c8a..dbe8b453004 100644 --- a/ext/com_dotnet/com_persist.c +++ b/ext/com_dotnet/com_persist.c @@ -105,10 +105,10 @@ static ULONG STDMETHODCALLTYPE stm_release(IStream *This) static HRESULT STDMETHODCALLTYPE stm_read(IStream *This, void *pv, ULONG cb, ULONG *pcbRead) { - int nread; + ULONG nread; FETCH_STM(); - nread = php_stream_read(stm->stream, pv, cb); + nread = (ULONG)php_stream_read(stm->stream, pv, cb); if (pcbRead) { *pcbRead = nread > 0 ? nread : 0; @@ -121,10 +121,10 @@ static HRESULT STDMETHODCALLTYPE stm_read(IStream *This, void *pv, ULONG cb, ULO static HRESULT STDMETHODCALLTYPE stm_write(IStream *This, void const *pv, ULONG cb, ULONG *pcbWritten) { - int nwrote; + ULONG nwrote; FETCH_STM(); - nwrote = php_stream_write(stm->stream, pv, cb); + nwrote = (ULONG)php_stream_write(stm->stream, pv, cb); if (pcbWritten) { *pcbWritten = nwrote > 0 ? nwrote : 0; @@ -466,7 +466,7 @@ CPH_METHOD(LoadFromFile) olefilename = php_com_string_to_olestring(fullpath, strlen(fullpath), helper->codepage TSRMLS_CC); efree(fullpath); - res = IPersistFile_Load(helper->ipf, olefilename, flags); + res = IPersistFile_Load(helper->ipf, olefilename, (DWORD)flags); efree(olefilename); if (FAILED(res)) { diff --git a/ext/com_dotnet/com_saproxy.c b/ext/com_dotnet/com_saproxy.c index ddee9bc1795..1d187a77bf3 100644 --- a/ext/com_dotnet/com_saproxy.c +++ b/ext/com_dotnet/com_saproxy.c @@ -167,11 +167,11 @@ static zval *saproxy_read_dimension(zval *object, zval *offset, int type, zval * /* copy indices from proxy */ for (i = 0; i < dims; i++) { convert_to_long(&proxy->indices[i]); - indices[i] = Z_LVAL(proxy->indices[i]); + indices[i] = (LONG)Z_LVAL(proxy->indices[i]); } /* add user-supplied index */ - indices[dims-1] = Z_LVAL_P(offset); + indices[dims-1] = (LONG)Z_LVAL_P(offset); /* now fetch the value */ if (FAILED(SafeArrayGetVartype(sa, &vt)) || vt == VT_EMPTY) { @@ -241,12 +241,12 @@ static void saproxy_write_dimension(zval *object, zval *offset, zval *value TSRM /* copy indices from proxy */ for (i = 0; i < dims; i++) { convert_to_long(&proxy->indices[i]); - indices[i] = Z_LVAL(proxy->indices[i]); + indices[i] = (LONG)Z_LVAL(proxy->indices[i]); } /* add user-supplied index */ convert_to_long(offset); - indices[dims-1] = Z_LVAL_P(offset); + indices[dims-1] = (LONG)Z_LVAL_P(offset); if (FAILED(SafeArrayGetVartype(V_ARRAY(&proxy->obj->v), &vt)) || vt == VT_EMPTY) { vt = V_VT(&proxy->obj->v) & ~VT_ARRAY; @@ -555,7 +555,7 @@ zend_object_iterator *php_com_saproxy_iter_get(zend_class_entry *ce, zval *objec I->indices = safe_emalloc(proxy->dimensions + 1, sizeof(LONG), 0); for (i = 0; i < proxy->dimensions; i++) { convert_to_long(&proxy->indices[i]); - I->indices[i] = Z_LVAL(proxy->indices[i]); + I->indices[i] = (LONG)Z_LVAL(proxy->indices[i]); } SafeArrayGetLBound(V_ARRAY(&proxy->obj->v), proxy->dimensions, &I->imin); diff --git a/ext/com_dotnet/com_typeinfo.c b/ext/com_dotnet/com_typeinfo.c index 33b1c65c9ca..17b69d2460e 100644 --- a/ext/com_dotnet/com_typeinfo.c +++ b/ext/com_dotnet/com_typeinfo.c @@ -116,7 +116,7 @@ PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib(char *search_string, int codep continue; } /* get the default value for this key and compare */ - libnamelen = strlen(search_string)+1; + libnamelen = (DWORD)strlen(search_string)+1; if (ERROR_SUCCESS == RegQueryValue(hsubkey, version, libname, &libnamelen)) { if (0 == stricmp(libname, search_string)) { char *str = NULL; @@ -234,7 +234,7 @@ PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib_via_cache(char *search_string, { ITypeLib *TL; char *name_dup; - int l; + size_t l; l = strlen(search_string); diff --git a/ext/com_dotnet/com_variant.c b/ext/com_dotnet/com_variant.c index dbd5529f6d9..2b91d28daf6 100644 --- a/ext/com_dotnet/com_variant.c +++ b/ext/com_dotnet/com_variant.c @@ -62,7 +62,7 @@ static void safe_array_from_zval(VARIANT *v, zval *z, int codepage TSRMLS_DC) /* allocate the structure */ bound.lLbound = 0; - bound.cElements = intindex + 1; + bound.cElements = (ULONG)(intindex + 1); sa = SafeArrayCreate(VT_VARIANT, 1, &bound); /* get a lock on the array itself */ @@ -146,8 +146,13 @@ PHP_COM_DOTNET_API void php_com_variant_from_zval(VARIANT *v, zval *z, int codep break; case IS_LONG: +#if SIZEOF_ZEND_LONG == 4 V_VT(v) = VT_I4; V_I4(v) = Z_LVAL_P(z); +#else + V_VT(v) = VT_I8; + V_I8(v) = Z_LVAL_P(z); +#endif break; case IS_DOUBLE: @@ -159,9 +164,9 @@ PHP_COM_DOTNET_API void php_com_variant_from_zval(VARIANT *v, zval *z, int codep V_VT(v) = VT_BSTR; olestring = php_com_string_to_olestring(Z_STRVAL_P(z), Z_STRLEN_P(z), codepage TSRMLS_CC); if (CP_UTF8 == codepage) { - V_BSTR(v) = SysAllocStringByteLen((char*)olestring, wcslen(olestring) * sizeof(OLECHAR)); + V_BSTR(v) = SysAllocStringByteLen((char*)olestring, (UINT)(wcslen(olestring) * sizeof(OLECHAR))); } else { - V_BSTR(v) = SysAllocStringByteLen((char*)olestring, Z_STRLEN_P(z) * sizeof(OLECHAR)); + V_BSTR(v) = SysAllocStringByteLen((char*)olestring, (UINT)(Z_STRLEN_P(z) * sizeof(OLECHAR))); } efree(olestring); break; @@ -428,7 +433,7 @@ PHP_FUNCTION(com_variant_create_instance) php_com_initialize(TSRMLS_C); if (ZEND_NUM_ARGS() == 3) { - obj->code_page = codepage; + obj->code_page = (int)codepage; } if (zvalue) { @@ -849,7 +854,7 @@ PHP_FUNCTION(variant_round) return; } - if (SUCCEEDED(VarRound(vleft, decimals, &vres))) { + if (SUCCEEDED(VarRound(vleft, (int)decimals, &vres))) { php_com_wrap_variant(return_value, &vres, codepage TSRMLS_CC); } @@ -909,7 +914,7 @@ PHP_FUNCTION(variant_cmp) return; } - ZVAL_LONG(return_value, VarCmp(vleft, vright, lcid, flags)); + ZVAL_LONG(return_value, VarCmp(vleft, vright, (LCID)lcid, (ULONG)flags)); VariantClear(&left_val); VariantClear(&right_val); diff --git a/ext/com_dotnet/com_wrapper.c b/ext/com_dotnet/com_wrapper.c index 6112dfb4bfa..f7dd7fd4637 100644 --- a/ext/com_dotnet/com_wrapper.c +++ b/ext/com_dotnet/com_wrapper.c @@ -186,7 +186,7 @@ static HRESULT STDMETHODCALLTYPE disp_getidsofnames( ret = DISP_E_UNKNOWNNAME; rgDispId[i] = 0; } else { - rgDispId[i] = Z_LVAL_P(tmp); + rgDispId[i] = (DISPID)Z_LVAL_P(tmp); } efree(name); @@ -231,7 +231,7 @@ static HRESULT STDMETHODCALLTYPE disp_getdispid( /* Lookup the name in the hash */ if ((tmp = zend_hash_str_find(disp->name_to_dispid, name, namelen)) != NULL) { trace("found it\n"); - *pid = Z_LVAL_P(tmp); + *pid = (DISPID)Z_LVAL_P(tmp); ret = S_OK; } diff --git a/ext/com_dotnet/php_com_dotnet_internal.h b/ext/com_dotnet/php_com_dotnet_internal.h index e79e6f586da..e06f50c7d6c 100644 --- a/ext/com_dotnet/php_com_dotnet_internal.h +++ b/ext/com_dotnet/php_com_dotnet_internal.h @@ -37,8 +37,9 @@ typedef struct _php_com_dotnet_object { VARIANT v; int modified; + int code_page; + ITypeInfo *typeinfo; - zend_long code_page; zend_class_entry *ce; @@ -107,7 +108,7 @@ HRESULT php_com_get_id_of_name(php_com_dotnet_object *obj, char *name, size_t namelen, DISPID *dispid TSRMLS_DC); int php_com_do_invoke_by_id(php_com_dotnet_object *obj, DISPID dispid, WORD flags, VARIANT *v, int nargs, zval *args, int silent, int allow_noarg TSRMLS_DC); -int php_com_do_invoke(php_com_dotnet_object *obj, char *name, int namelen, +int php_com_do_invoke(php_com_dotnet_object *obj, char *name, size_t namelen, WORD flags, VARIANT *v, int nargs, zval *args, int allow_noarg TSRMLS_DC); int php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_function *f, WORD flags, VARIANT *v, int nargs, zval *args TSRMLS_DC); From 1493124e2bfac9bc587d87385b094baf808a31a6 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 28 Oct 2014 16:09:17 +0100 Subject: [PATCH 142/398] initialize the input arg lengths --- ext/com_dotnet/com_com.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/com_dotnet/com_com.c b/ext/com_dotnet/com_com.c index ec276ee0040..12fcb62c400 100644 --- a/ext/com_dotnet/com_com.c +++ b/ext/com_dotnet/com_com.c @@ -37,7 +37,7 @@ PHP_FUNCTION(com_create_instance) php_com_dotnet_object *obj; char *module_name, *typelib_name = NULL, *server_name = NULL; char *user_name = NULL, *domain_name = NULL, *password = NULL; - size_t module_name_len, typelib_name_len, server_name_len, + size_t module_name_len = 0, typelib_name_len = 0, server_name_len = 0, user_name_len, domain_name_len, password_len; OLECHAR *moniker; CLSID clsid; From 3b6a9a3916bbf539e2114fefe4a1ea1fe9fba3fb Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 28 Oct 2014 16:10:27 +0100 Subject: [PATCH 143/398] exclude the 32 bit only test --- ext/com_dotnet/tests/bug33386.phpt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ext/com_dotnet/tests/bug33386.phpt b/ext/com_dotnet/tests/bug33386.phpt index e57f1274c16..e7dcd28489a 100644 --- a/ext/com_dotnet/tests/bug33386.phpt +++ b/ext/com_dotnet/tests/bug33386.phpt @@ -2,7 +2,9 @@ Bug #33386 (ScriptControl only sees last function of class) --SKIPIF-- +if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present"; +if (4 != PHP_INT_SIZE) print "skip MSScriptControl isn't available under x64"; +?> --FILE-- Date: Tue, 28 Oct 2014 16:37:04 +0100 Subject: [PATCH 144/398] several fixes to com_dotnet for x64 --- ext/com_dotnet/com_extension.c | 4 + ext/com_dotnet/com_variant.c | 28 +- ext/com_dotnet/tests/variants.phpt | 3 +- ext/com_dotnet/tests/variants_x64.phpt | 638 +++++++++++++++++++++++++ 4 files changed, 670 insertions(+), 3 deletions(-) create mode 100644 ext/com_dotnet/tests/variants_x64.phpt diff --git a/ext/com_dotnet/com_extension.c b/ext/com_dotnet/com_extension.c index f66119842e1..7e158659501 100644 --- a/ext/com_dotnet/com_extension.c +++ b/ext/com_dotnet/com_extension.c @@ -454,6 +454,10 @@ PHP_MINIT_FUNCTION(com_dotnet) COM_ERR_CONST(DISP_E_BADINDEX); COM_ERR_CONST(MK_E_UNAVAILABLE); +#if SIZEOF_ZEND_LONG == 8 + COM_CONST(VT_UI8); + COM_CONST(VT_I8); +#endif return SUCCESS; } /* }}} */ diff --git a/ext/com_dotnet/com_variant.c b/ext/com_dotnet/com_variant.c index 2b91d28daf6..6a81eed102a 100644 --- a/ext/com_dotnet/com_variant.c +++ b/ext/com_dotnet/com_variant.c @@ -204,11 +204,19 @@ PHP_COM_DOTNET_API int php_com_zval_from_variant(zval *z, VARIANT *v, int codepa ZVAL_LONG(z, (zend_long)V_I2(v)); break; case VT_UI4: /* TODO: promote to double if large? */ - ZVAL_LONG(z, (zend_long)V_UI4(v)); + ZVAL_LONG(z, (long)V_UI4(v)); break; case VT_I4: - ZVAL_LONG(z, (zend_long)V_I4(v)); + ZVAL_LONG(z, (long)V_I4(v)); break; +#if SIZEOF_ZEND_LONG == 8 + case VT_UI8: + ZVAL_LONG(z, (zend_long)V_UI8(v)); + break; + case VT_I8: + ZVAL_LONG(z, (zend_long)V_I8(v)); + break; +#endif case VT_INT: ZVAL_LONG(z, V_INT(v)); break; @@ -333,7 +341,23 @@ PHP_COM_DOTNET_API int php_com_copy_variant(VARIANT *dstvar, VARIANT *srcvar TSR V_I4(dstvar) = V_I4(srcvar); } break; +#if SIZEOF_ZEND_LONG == 8 + case VT_UI8: + if (V_VT(dstvar) & VT_BYREF) { + *V_UI8REF(dstvar) = V_UI8(srcvar); + } else { + V_UI8(dstvar) = V_UI8(srcvar); + } + break; + case VT_I8: + if (V_VT(dstvar) & VT_BYREF) { + *V_I8REF(dstvar) = V_I8(srcvar); + } else { + V_I8(dstvar) = V_I8(srcvar); + } + break; +#endif case VT_INT: if (V_VT(dstvar) & VT_BYREF) { *V_INTREF(dstvar) = V_INT(srcvar); diff --git a/ext/com_dotnet/tests/variants.phpt b/ext/com_dotnet/tests/variants.phpt index 0fd27bee5ef..6c50beb738b 100644 --- a/ext/com_dotnet/tests/variants.phpt +++ b/ext/com_dotnet/tests/variants.phpt @@ -2,7 +2,8 @@ COM: General variant tests --SKIPIF-- +if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present"; +if (4 != PHP_INT_SIZE) print "skip x86 only"; ?> --FILE-- +--FILE-- + 42, VT_R8 => 3.5, VT_BSTR => "hello", VT_BOOL => false); +$binary_ops = array('add', 'cat', 'sub', 'mul', 'and', 'div', + 'eqv', 'idiv', 'imp', 'mod', 'or', 'pow', 'xor'); + +foreach ($values as $t => $val) { + $v = new VARIANT($val); + if ($t != variant_get_type($v)) { + printf("Bork: [%d] %d: %s\n", $t, variant_get_type($v), $val); + print $v . "\n"; + } + $results = array(); + + foreach ($values as $op2) { + echo "--\n"; + foreach ($binary_ops as $op) { + try { + echo "$op: " . call_user_func('variant_' . $op, $v, $op2) . "\n"; + } catch (com_exception $e) { + echo "$op:\n"; + echo "\tvariant_$op($v, $op2)\n"; + echo "\texception " . $e->getMessage(); + printf("\tcode %08x\n\n", $e->getCode()); + } + } + } +} + +echo "OK!"; +?> +--EXPECT-- +-- +add: 84 +cat: 4242 +sub: 0 +mul: 1764 +and: 42 +div: 1 +eqv: -1 +idiv: 1 +imp: -1 +mod: 0 +or: 42 +pow: 1.50130937545297E+68 +xor: 0 +-- +add: 45.5 +cat: 423.5 +sub: 38.5 +mul: 147 +and: 0 +div: 12 +eqv: -47 +idiv: 10 +imp: -43 +mod: 2 +or: 46 +pow: 480145.116863642 +xor: 46 +-- +add: + variant_add(42, hello) + exception Type mismatch. + code 80020005 + +cat: 42hello +sub: + variant_sub(42, hello) + exception Type mismatch. + code 80020005 + +mul: + variant_mul(42, hello) + exception Type mismatch. + code 80020005 + +and: + variant_and(42, hello) + exception Type mismatch. + code 80020005 + +div: + variant_div(42, hello) + exception Type mismatch. + code 80020005 + +eqv: + variant_eqv(42, hello) + exception Type mismatch. + code 80020005 + +idiv: + variant_idiv(42, hello) + exception Type mismatch. + code 80020005 + +imp: + variant_imp(42, hello) + exception Type mismatch. + code 80020005 + +mod: + variant_mod(42, hello) + exception Type mismatch. + code 80020005 + +or: + variant_or(42, hello) + exception Type mismatch. + code 80020005 + +pow: + variant_pow(42, hello) + exception Type mismatch. + code 80020005 + +xor: + variant_xor(42, hello) + exception Type mismatch. + code 80020005 + +-- +add: 42 +cat: 42False +sub: 42 +mul: 0 +and: 0 +div: + variant_div(42, ) + exception Division by zero. + code 80020012 + +eqv: -43 +idiv: + variant_idiv(42, ) + exception Division by zero. + code 80020012 + +imp: -43 +mod: + variant_mod(42, ) + exception Division by zero. + code 80020012 + +or: 42 +pow: 1 +xor: 42 +-- +add: 45.5 +cat: 3.542 +sub: -38.5 +mul: 147 +and: 0 +div: 8.33333333333333E-02 +eqv: -47 +idiv: 0 +imp: -5 +mod: 4 +or: 46 +pow: 7.09345573078604E+22 +xor: 46 +-- +add: 7 +cat: 3.53.5 +sub: 0 +mul: 12.25 +and: 4 +div: 1 +eqv: -1 +idiv: 1 +imp: -1 +mod: 0 +or: 4 +pow: 80.2117802289664 +xor: 0 +-- +add: + variant_add(3.5, hello) + exception Type mismatch. + code 80020005 + +cat: 3.5hello +sub: + variant_sub(3.5, hello) + exception Type mismatch. + code 80020005 + +mul: + variant_mul(3.5, hello) + exception Type mismatch. + code 80020005 + +and: + variant_and(3.5, hello) + exception Type mismatch. + code 80020005 + +div: + variant_div(3.5, hello) + exception Type mismatch. + code 80020005 + +eqv: + variant_eqv(3.5, hello) + exception Type mismatch. + code 80020005 + +idiv: + variant_idiv(3.5, hello) + exception Type mismatch. + code 80020005 + +imp: + variant_imp(3.5, hello) + exception Type mismatch. + code 80020005 + +mod: + variant_mod(3.5, hello) + exception Type mismatch. + code 80020005 + +or: + variant_or(3.5, hello) + exception Type mismatch. + code 80020005 + +pow: + variant_pow(3.5, hello) + exception Type mismatch. + code 80020005 + +xor: + variant_xor(3.5, hello) + exception Type mismatch. + code 80020005 + +-- +add: 3.5 +cat: 3.5False +sub: 3.5 +mul: 0 +and: 0 +div: + variant_div(3.5, ) + exception Division by zero. + code 80020012 + +eqv: -5 +idiv: + variant_idiv(3.5, ) + exception Division by zero. + code 80020012 + +imp: -5 +mod: + variant_mod(3.5, ) + exception Division by zero. + code 80020012 + +or: 4 +pow: 1 +xor: 4 +-- +add: + variant_add(hello, 42) + exception Type mismatch. + code 80020005 + +cat: hello42 +sub: + variant_sub(hello, 42) + exception Type mismatch. + code 80020005 + +mul: + variant_mul(hello, 42) + exception Type mismatch. + code 80020005 + +and: + variant_and(hello, 42) + exception Type mismatch. + code 80020005 + +div: + variant_div(hello, 42) + exception Type mismatch. + code 80020005 + +eqv: + variant_eqv(hello, 42) + exception Type mismatch. + code 80020005 + +idiv: + variant_idiv(hello, 42) + exception Type mismatch. + code 80020005 + +imp: + variant_imp(hello, 42) + exception Type mismatch. + code 80020005 + +mod: + variant_mod(hello, 42) + exception Type mismatch. + code 80020005 + +or: + variant_or(hello, 42) + exception Type mismatch. + code 80020005 + +pow: + variant_pow(hello, 42) + exception Type mismatch. + code 80020005 + +xor: + variant_xor(hello, 42) + exception Type mismatch. + code 80020005 + +-- +add: + variant_add(hello, 3.5) + exception Type mismatch. + code 80020005 + +cat: hello3.5 +sub: + variant_sub(hello, 3.5) + exception Type mismatch. + code 80020005 + +mul: + variant_mul(hello, 3.5) + exception Type mismatch. + code 80020005 + +and: + variant_and(hello, 3.5) + exception Type mismatch. + code 80020005 + +div: + variant_div(hello, 3.5) + exception Type mismatch. + code 80020005 + +eqv: + variant_eqv(hello, 3.5) + exception Type mismatch. + code 80020005 + +idiv: + variant_idiv(hello, 3.5) + exception Type mismatch. + code 80020005 + +imp: + variant_imp(hello, 3.5) + exception Type mismatch. + code 80020005 + +mod: + variant_mod(hello, 3.5) + exception Type mismatch. + code 80020005 + +or: + variant_or(hello, 3.5) + exception Type mismatch. + code 80020005 + +pow: + variant_pow(hello, 3.5) + exception Type mismatch. + code 80020005 + +xor: + variant_xor(hello, 3.5) + exception Type mismatch. + code 80020005 + +-- +add: hellohello +cat: hellohello +sub: + variant_sub(hello, hello) + exception Type mismatch. + code 80020005 + +mul: + variant_mul(hello, hello) + exception Type mismatch. + code 80020005 + +and: + variant_and(hello, hello) + exception Type mismatch. + code 80020005 + +div: + variant_div(hello, hello) + exception Type mismatch. + code 80020005 + +eqv: + variant_eqv(hello, hello) + exception Type mismatch. + code 80020005 + +idiv: + variant_idiv(hello, hello) + exception Type mismatch. + code 80020005 + +imp: + variant_imp(hello, hello) + exception Type mismatch. + code 80020005 + +mod: + variant_mod(hello, hello) + exception Type mismatch. + code 80020005 + +or: + variant_or(hello, hello) + exception Type mismatch. + code 80020005 + +pow: + variant_pow(hello, hello) + exception Type mismatch. + code 80020005 + +xor: + variant_xor(hello, hello) + exception Type mismatch. + code 80020005 + +-- +add: + variant_add(hello, ) + exception Type mismatch. + code 80020005 + +cat: helloFalse +sub: + variant_sub(hello, ) + exception Type mismatch. + code 80020005 + +mul: + variant_mul(hello, ) + exception Type mismatch. + code 80020005 + +and: + variant_and(hello, ) + exception Type mismatch. + code 80020005 + +div: + variant_div(hello, ) + exception Type mismatch. + code 80020005 + +eqv: + variant_eqv(hello, ) + exception Type mismatch. + code 80020005 + +idiv: + variant_idiv(hello, ) + exception Type mismatch. + code 80020005 + +imp: + variant_imp(hello, ) + exception Type mismatch. + code 80020005 + +mod: + variant_mod(hello, ) + exception Type mismatch. + code 80020005 + +or: + variant_or(hello, ) + exception Type mismatch. + code 80020005 + +pow: + variant_pow(hello, ) + exception Type mismatch. + code 80020005 + +xor: + variant_xor(hello, ) + exception Type mismatch. + code 80020005 + +-- +add: 42 +cat: False42 +sub: -42 +mul: 0 +and: 0 +div: 0 +eqv: -43 +idiv: 0 +imp: -1 +mod: 0 +or: 42 +pow: 0 +xor: 42 +-- +add: 3.5 +cat: False3.5 +sub: -3.5 +mul: 0 +and: 0 +div: 0 +eqv: -5 +idiv: 0 +imp: -1 +mod: 0 +or: 4 +pow: 0 +xor: 4 +-- +add: + variant_add(0, hello) + exception Type mismatch. + code 80020005 + +cat: Falsehello +sub: + variant_sub(0, hello) + exception Type mismatch. + code 80020005 + +mul: + variant_mul(0, hello) + exception Type mismatch. + code 80020005 + +and: + variant_and(0, hello) + exception Type mismatch. + code 80020005 + +div: + variant_div(0, hello) + exception Type mismatch. + code 80020005 + +eqv: + variant_eqv(0, hello) + exception Type mismatch. + code 80020005 + +idiv: + variant_idiv(0, hello) + exception Type mismatch. + code 80020005 + +imp: + variant_imp(0, hello) + exception Type mismatch. + code 80020005 + +mod: + variant_mod(0, hello) + exception Type mismatch. + code 80020005 + +or: + variant_or(0, hello) + exception Type mismatch. + code 80020005 + +pow: + variant_pow(0, hello) + exception Type mismatch. + code 80020005 + +xor: + variant_xor(0, hello) + exception Type mismatch. + code 80020005 + +-- +add: 0 +cat: FalseFalse +sub: 0 +mul: 0 +and: 0 +div: + variant_div(0, ) + exception Out of present range. + code 8002000a + +eqv: -1 +idiv: + variant_idiv(0, ) + exception Division by zero. + code 80020012 + +imp: -1 +mod: + variant_mod(0, ) + exception Division by zero. + code 80020012 + +or: 0 +pow: 1 +xor: 0 +OK! From e2951a191ef1afea777b865b9c80ac939b603f6b Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 28 Oct 2014 16:52:49 +0100 Subject: [PATCH 145/398] fix error code upcast on x64 --- ext/com_dotnet/com_misc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ext/com_dotnet/com_misc.c b/ext/com_dotnet/com_misc.c index 084a720ea17..f0b21ff014a 100644 --- a/ext/com_dotnet/com_misc.c +++ b/ext/com_dotnet/com_misc.c @@ -36,7 +36,11 @@ void php_com_throw_exception(HRESULT code, char *message TSRMLS_DC) message = php_win32_error_to_msg(code); free_msg = 1; } +#if SIZEOF_ZEND_LONG == 8 + zend_throw_exception(php_com_exception_class_entry, message, (zend_long)(uint32_t)code TSRMLS_CC); +#else zend_throw_exception(php_com_exception_class_entry, message, (zend_long)code TSRMLS_CC); +#endif if (free_msg) { LocalFree(message); } From 05fa1b8ecc025335cef3bd3e22ba94bf9d0632fa Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 28 Oct 2014 17:06:37 +0100 Subject: [PATCH 146/398] fix possible zero deref --- ext/com_dotnet/com_com.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/com_dotnet/com_com.c b/ext/com_dotnet/com_com.c index 12fcb62c400..6328a6b0904 100644 --- a/ext/com_dotnet/com_com.c +++ b/ext/com_dotnet/com_com.c @@ -475,7 +475,7 @@ int php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_function * /* assumption: that the active function (f) is the function we generated for the engine */ if (!f || f->arg_info == NULL) { - f = NULL; + return FAILURE; } hr = php_com_get_id_of_name(obj, f->function_name->val, f->function_name->len, &dispid TSRMLS_CC); From efe9cc3a86a769f1ac3d16f4b12f5e83053c6822 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 28 Oct 2014 17:23:40 +0100 Subject: [PATCH 147/398] rework fix to php_com_do_invoke_byref, fix crashing function with void arguments --- ext/com_dotnet/com_com.c | 50 ++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/ext/com_dotnet/com_com.c b/ext/com_dotnet/com_com.c index 6328a6b0904..e1a9503dffd 100644 --- a/ext/com_dotnet/com_com.c +++ b/ext/com_dotnet/com_com.c @@ -474,7 +474,7 @@ int php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_function * int i, byref_count = 0, j; /* assumption: that the active function (f) is the function we generated for the engine */ - if (!f || f->arg_info == NULL) { + if (!f) { return FAILURE; } @@ -496,7 +496,7 @@ int php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_function * vargs = (VARIANT*)safe_emalloc(sizeof(VARIANT), nargs, 0); } - if (f) { + if (f->arg_info) { for (i = 0; i < nargs; i++) { if (f->arg_info[nargs - i - 1].pass_by_reference) { byref_count++; @@ -551,30 +551,36 @@ int php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_function * /* release variants */ if (vargs) { - for (i = 0, j = 0; i < nargs; i++) { - /* if this was byref, update the zval */ - if (f && f->arg_info[nargs - i - 1].pass_by_reference) { - SEPARATE_ZVAL_IF_NOT_REF(&args[nargs - i - 1]); + if (f && f->arg_info) { + for (i = 0, j = 0; i < nargs; i++) { + /* if this was byref, update the zval */ + if (f->arg_info[nargs - i - 1].pass_by_reference) { + SEPARATE_ZVAL_IF_NOT_REF(&args[nargs - i - 1]); - /* if the variant is pointing at the byref_vals, we need to map - * the pointee value as a zval; otherwise, the value is pointing - * into an existing PHP variant record */ - if (V_VT(&vargs[i]) & VT_BYREF) { - if (vargs[i].byref == &V_UINT(&byref_vals[j])) { - /* copy that value */ - php_com_zval_from_variant(&args[nargs - i - 1], &byref_vals[j], + /* if the variant is pointing at the byref_vals, we need to map + * the pointee value as a zval; otherwise, the value is pointing + * into an existing PHP variant record */ + if (V_VT(&vargs[i]) & VT_BYREF) { + if (vargs[i].byref == &V_UINT(&byref_vals[j])) { + /* copy that value */ + php_com_zval_from_variant(&args[nargs - i - 1], &byref_vals[j], + obj->code_page TSRMLS_CC); + } + } else { + /* not sure if this can ever happen; the variant we marked as BYREF + * is no longer BYREF - copy its value */ + php_com_zval_from_variant(&args[nargs - i - 1], &vargs[i], obj->code_page TSRMLS_CC); } - } else { - /* not sure if this can ever happen; the variant we marked as BYREF - * is no longer BYREF - copy its value */ - php_com_zval_from_variant(&args[nargs - i - 1], &vargs[i], - obj->code_page TSRMLS_CC); + VariantClear(&byref_vals[j]); + j++; } - VariantClear(&byref_vals[j]); - j++; - } - VariantClear(&vargs[i]); + VariantClear(&vargs[i]); + } + } else { + for (i = 0, j = 0; i < nargs; i++) { + VariantClear(&vargs[i]); + } } efree(vargs); } From fe5f5d40f29387bb6cae79dfbab50463a66b53ba Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 12:27:19 +0100 Subject: [PATCH 148/398] *Always* clean up and run destructors --- sapi/phpdbg/phpdbg_prompt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index 73ecbcb892c..262b265a2e9 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -676,10 +676,10 @@ PHPDBG_COMMAND(run) /* {{{ */ EG(active_op_array) = orig_op_array; EG(opline_ptr) = orig_opline; EG(return_value_ptr_ptr) = orig_retval_ptr; - - phpdbg_clean(1 TSRMLS_CC); } + phpdbg_clean(1 TSRMLS_CC); + PHPDBG_G(flags) &= ~PHPDBG_IS_RUNNING; } else { phpdbg_error("inactive", "type=\"nocontext\"", "Nothing to execute!"); From 64774c7ddbdef3844558898a50104ec6dc758b55 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 12:27:19 +0100 Subject: [PATCH 149/398] *Always* clean up and run destructors --- phpdbg_prompt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 73ecbcb892c..262b265a2e9 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -676,10 +676,10 @@ PHPDBG_COMMAND(run) /* {{{ */ EG(active_op_array) = orig_op_array; EG(opline_ptr) = orig_opline; EG(return_value_ptr_ptr) = orig_retval_ptr; - - phpdbg_clean(1 TSRMLS_CC); } + phpdbg_clean(1 TSRMLS_CC); + PHPDBG_G(flags) &= ~PHPDBG_IS_RUNNING; } else { phpdbg_error("inactive", "type=\"nocontext\"", "Nothing to execute!"); From 79c66e7cd20e9e89c932781c93e2c880a6318ecd Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 12:38:07 +0100 Subject: [PATCH 150/398] Fix potential segfaults and unresolved breaks --- sapi/phpdbg/phpdbg_bp.c | 56 +++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/sapi/phpdbg/phpdbg_bp.c b/sapi/phpdbg/phpdbg_bp.c index cf28a338859..93902f00529 100644 --- a/sapi/phpdbg/phpdbg_bp.c +++ b/sapi/phpdbg/phpdbg_bp.c @@ -232,6 +232,8 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRML } path_len = strlen(path); + phpdbg_debug("file path: %s, resolved path: %s, was compiled: %d\n", original_path, path, zend_hash_exists(&PHPDBG_G(file_sources), path, path_len)); + if (!zend_hash_exists(&PHPDBG_G(file_sources), path, path_len)) { if (php_stream_stat_path(path, &ssb) == FAILURE) { if (original_path[0] == '/') { @@ -246,6 +248,8 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRML } else if (!(ssb.sb.st_mode & (S_IFREG|S_IFLNK))) { phpdbg_error("breakpoint", "type=\"notregular\" add=\"fail\" file=\"%s\"", "Cannot set breakpoint in %s, it is not a regular file", path); return; + } else { + phpdbg_debug("File exists, but not compiled\n"); } } @@ -273,9 +277,13 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRML for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(file_sources), &position); zend_hash_get_current_key_ex(&PHPDBG_G(file_sources), &file, &filelen, NULL, 0, &position) == HASH_KEY_IS_STRING; zend_hash_move_forward_ex(&PHPDBG_G(file_sources), &position)) { - if (!(pending = ((broken = phpdbg_resolve_pending_file_break_ex(file, filelen, path, path_len, broken TSRMLS_CC)) == NULL))) { + HashTable *fileht; + + phpdbg_debug("Compare against loaded %s\n", file); + + if (!(pending = ((fileht = phpdbg_resolve_pending_file_break_ex(file, filelen, path, path_len, broken TSRMLS_CC)) == NULL))) { phpdbg_breakfile_t *brake; - zend_hash_index_find(broken, line_num, (void **) &brake); + zend_hash_index_find(fileht, line_num, (void **) &brake); new_break = *brake; break; } @@ -298,18 +306,19 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRML PHPDBG_API HashTable *phpdbg_resolve_pending_file_break_ex(const char *file, uint filelen, const char *cur, uint curlen, HashTable *fileht TSRMLS_DC) /* {{{ */ { - if (curlen < filelen && file[filelen - curlen - 1] == '/' && !memcmp(file + filelen - curlen, cur, curlen)) { + phpdbg_debug("file: %s, filelen: %u, cur: %s, curlen %u, pos: %c, memcmp: %d\n", file, filelen, cur, curlen, filelen > curlen ? file[filelen - curlen - 1] : '?', filelen > curlen ? memcmp(file + filelen - curlen, cur, curlen) : 0); + + if (((curlen < filelen && file[filelen - curlen - 1] == '/') || filelen == curlen) && !memcmp(file + filelen - curlen, cur, curlen)) { phpdbg_breakfile_t *brake, new_brake; HashTable *master = NULL; HashPosition position; - dtor_func_t dtor; PHPDBG_G(flags) |= PHPDBG_HAS_FILE_BP; if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, (void **) &master) == FAILURE) { - dtor = PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor; - PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor = NULL; - zend_hash_add(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, fileht, sizeof(HashTable), (void **) &fileht); + HashTable new_ht; + zend_hash_init(&new_ht, 8, NULL, phpdbg_file_breaks_dtor, 0); + zend_hash_add(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, &new_ht, sizeof(HashTable), (void **) &master); } for (zend_hash_internal_pointer_reset_ex(fileht, &position); @@ -322,24 +331,18 @@ PHPDBG_API HashTable *phpdbg_resolve_pending_file_break_ex(const char *file, uin if (master) { zend_hash_index_update(master, brake->line, (void **) &new_brake, sizeof(phpdbg_breakfile_t), NULL); PHPDBG_BREAK_MAPPING(brake->id, master); - } else { - efree((char *) brake->filename); - *brake = new_brake; - PHPDBG_BREAK_MAPPING(brake->id, fileht); } } zend_hash_del(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], cur, curlen); - if (!master) { - PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor = dtor; - } - if (!zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING])) { PHPDBG_G(flags) &= ~PHPDBG_HAS_PENDING_FILE_BP; } - return fileht; + phpdbg_debug("compiled file: %s, cur bp file: %s\n", file, cur); + + return master; } return NULL; @@ -351,6 +354,8 @@ PHPDBG_API void phpdbg_resolve_pending_file_break(const char *file TSRMLS_DC) /* HashTable *fileht; uint filelen = strlen(file); + phpdbg_debug("was compiled: %s\n", file); + zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position); while (zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], (void**) &fileht, &position) == SUCCESS) { const char *cur; @@ -359,6 +364,8 @@ PHPDBG_API void phpdbg_resolve_pending_file_break(const char *file TSRMLS_DC) /* zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], (char **) &cur, &curlen, NULL, 0, &position); zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position); + phpdbg_debug("check bp: %s\n", cur); + phpdbg_resolve_pending_file_break_ex(file, filelen, cur, curlen, fileht TSRMLS_CC); } } @@ -877,10 +884,21 @@ static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_file(zend_op_array *op_ { HashTable *breaks; phpdbg_breakbase_t *brake; - size_t name_len = strlen(op_array->filename); + size_t path_len; + char realpath[MAXPATHLEN]; + const char *path = op_array->filename; - if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], op_array->filename, - name_len, (void**)&breaks) == FAILURE) { + if (VCWD_REALPATH(path, realpath)) { + path = realpath; + } + + path_len = strlen(path); + +#if 0 + phpdbg_debug("Op at: %.*s %d\n", path_len, path, (*EG(opline_ptr))->lineno); +#endif + + if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], path, path_len, (void**)&breaks) == FAILURE) { return NULL; } From 9990089f2821fc9892533e97cf5dbbd75c6cca2f Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 12:38:07 +0100 Subject: [PATCH 151/398] Fix potential segfaults and unresolved breaks --- phpdbg_bp.c | 56 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/phpdbg_bp.c b/phpdbg_bp.c index cf28a338859..93902f00529 100644 --- a/phpdbg_bp.c +++ b/phpdbg_bp.c @@ -232,6 +232,8 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRML } path_len = strlen(path); + phpdbg_debug("file path: %s, resolved path: %s, was compiled: %d\n", original_path, path, zend_hash_exists(&PHPDBG_G(file_sources), path, path_len)); + if (!zend_hash_exists(&PHPDBG_G(file_sources), path, path_len)) { if (php_stream_stat_path(path, &ssb) == FAILURE) { if (original_path[0] == '/') { @@ -246,6 +248,8 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRML } else if (!(ssb.sb.st_mode & (S_IFREG|S_IFLNK))) { phpdbg_error("breakpoint", "type=\"notregular\" add=\"fail\" file=\"%s\"", "Cannot set breakpoint in %s, it is not a regular file", path); return; + } else { + phpdbg_debug("File exists, but not compiled\n"); } } @@ -273,9 +277,13 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRML for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(file_sources), &position); zend_hash_get_current_key_ex(&PHPDBG_G(file_sources), &file, &filelen, NULL, 0, &position) == HASH_KEY_IS_STRING; zend_hash_move_forward_ex(&PHPDBG_G(file_sources), &position)) { - if (!(pending = ((broken = phpdbg_resolve_pending_file_break_ex(file, filelen, path, path_len, broken TSRMLS_CC)) == NULL))) { + HashTable *fileht; + + phpdbg_debug("Compare against loaded %s\n", file); + + if (!(pending = ((fileht = phpdbg_resolve_pending_file_break_ex(file, filelen, path, path_len, broken TSRMLS_CC)) == NULL))) { phpdbg_breakfile_t *brake; - zend_hash_index_find(broken, line_num, (void **) &brake); + zend_hash_index_find(fileht, line_num, (void **) &brake); new_break = *brake; break; } @@ -298,18 +306,19 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRML PHPDBG_API HashTable *phpdbg_resolve_pending_file_break_ex(const char *file, uint filelen, const char *cur, uint curlen, HashTable *fileht TSRMLS_DC) /* {{{ */ { - if (curlen < filelen && file[filelen - curlen - 1] == '/' && !memcmp(file + filelen - curlen, cur, curlen)) { + phpdbg_debug("file: %s, filelen: %u, cur: %s, curlen %u, pos: %c, memcmp: %d\n", file, filelen, cur, curlen, filelen > curlen ? file[filelen - curlen - 1] : '?', filelen > curlen ? memcmp(file + filelen - curlen, cur, curlen) : 0); + + if (((curlen < filelen && file[filelen - curlen - 1] == '/') || filelen == curlen) && !memcmp(file + filelen - curlen, cur, curlen)) { phpdbg_breakfile_t *brake, new_brake; HashTable *master = NULL; HashPosition position; - dtor_func_t dtor; PHPDBG_G(flags) |= PHPDBG_HAS_FILE_BP; if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, (void **) &master) == FAILURE) { - dtor = PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor; - PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor = NULL; - zend_hash_add(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, fileht, sizeof(HashTable), (void **) &fileht); + HashTable new_ht; + zend_hash_init(&new_ht, 8, NULL, phpdbg_file_breaks_dtor, 0); + zend_hash_add(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, &new_ht, sizeof(HashTable), (void **) &master); } for (zend_hash_internal_pointer_reset_ex(fileht, &position); @@ -322,24 +331,18 @@ PHPDBG_API HashTable *phpdbg_resolve_pending_file_break_ex(const char *file, uin if (master) { zend_hash_index_update(master, brake->line, (void **) &new_brake, sizeof(phpdbg_breakfile_t), NULL); PHPDBG_BREAK_MAPPING(brake->id, master); - } else { - efree((char *) brake->filename); - *brake = new_brake; - PHPDBG_BREAK_MAPPING(brake->id, fileht); } } zend_hash_del(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], cur, curlen); - if (!master) { - PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor = dtor; - } - if (!zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING])) { PHPDBG_G(flags) &= ~PHPDBG_HAS_PENDING_FILE_BP; } - return fileht; + phpdbg_debug("compiled file: %s, cur bp file: %s\n", file, cur); + + return master; } return NULL; @@ -351,6 +354,8 @@ PHPDBG_API void phpdbg_resolve_pending_file_break(const char *file TSRMLS_DC) /* HashTable *fileht; uint filelen = strlen(file); + phpdbg_debug("was compiled: %s\n", file); + zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position); while (zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], (void**) &fileht, &position) == SUCCESS) { const char *cur; @@ -359,6 +364,8 @@ PHPDBG_API void phpdbg_resolve_pending_file_break(const char *file TSRMLS_DC) /* zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], (char **) &cur, &curlen, NULL, 0, &position); zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position); + phpdbg_debug("check bp: %s\n", cur); + phpdbg_resolve_pending_file_break_ex(file, filelen, cur, curlen, fileht TSRMLS_CC); } } @@ -877,10 +884,21 @@ static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_file(zend_op_array *op_ { HashTable *breaks; phpdbg_breakbase_t *brake; - size_t name_len = strlen(op_array->filename); + size_t path_len; + char realpath[MAXPATHLEN]; + const char *path = op_array->filename; - if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], op_array->filename, - name_len, (void**)&breaks) == FAILURE) { + if (VCWD_REALPATH(path, realpath)) { + path = realpath; + } + + path_len = strlen(path); + +#if 0 + phpdbg_debug("Op at: %.*s %d\n", path_len, path, (*EG(opline_ptr))->lineno); +#endif + + if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], path, path_len, (void**)&breaks) == FAILURE) { return NULL; } From cc3587f4a30a3a33f6043c919cf8ef11ba33087b Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 13:20:43 +0100 Subject: [PATCH 152/398] Fix possibly unclosed tags --- sapi/phpdbg/phpdbg_io.c | 4 ---- sapi/phpdbg/phpdbg_out.c | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/sapi/phpdbg/phpdbg_io.c b/sapi/phpdbg/phpdbg_io.c index 6908a687d7e..a2a5c5969f4 100644 --- a/sapi/phpdbg/phpdbg_io.c +++ b/sapi/phpdbg/phpdbg_io.c @@ -187,10 +187,6 @@ PHPDBG_API int phpdbg_mixed_read(int sock, char *ptr, int len, int tmo TSRMLS_DC PHPDBG_API int phpdbg_mixed_write(int sock, const char *ptr, int len TSRMLS_DC) { - if (PHPDBG_G(flags) & PHPDBG_DISCARD_OUTPUT) { - return 0; - } - if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) { return phpdbg_send_bytes(sock, ptr, len); } diff --git a/sapi/phpdbg/phpdbg_out.c b/sapi/phpdbg/phpdbg_out.c index 365708c71ed..7e1dc7b744c 100644 --- a/sapi/phpdbg/phpdbg_out.c +++ b/sapi/phpdbg/phpdbg_out.c @@ -1168,6 +1168,10 @@ PHPDBG_API int phpdbg_output_err_buf(const char *tag, const char *xmlfmt, const va_list args; int errbuf_active = PHPDBG_G(err_buf).active; + if (PHPDBG_G(flags) & PHPDBG_DISCARD_OUTPUT) { + return 0; + } + PHPDBG_G(err_buf).active = 0; #ifdef ZTS @@ -1188,6 +1192,10 @@ PHPDBG_API int phpdbg_print(int type TSRMLS_DC, int fd, const char *tag, const c va_list args; int len; + if (PHPDBG_G(flags) & PHPDBG_DISCARD_OUTPUT) { + return 0; + } + va_start(args, strfmt); len = phpdbg_vprint(type TSRMLS_CC, fd, tag, xmlfmt, strfmt, args); va_end(args); @@ -1198,6 +1206,10 @@ PHPDBG_API int phpdbg_print(int type TSRMLS_DC, int fd, const char *tag, const c PHPDBG_API int phpdbg_xml_internal(int fd TSRMLS_DC, const char *fmt, ...) { int len = 0; + if (PHPDBG_G(flags) & PHPDBG_DISCARD_OUTPUT) { + return 0; + } + if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) { va_list args; char *buffer; @@ -1243,6 +1255,10 @@ PHPDBG_API int phpdbg_out_internal(int fd TSRMLS_DC, const char *fmt, ...) { int buflen; int len = 0; + if (PHPDBG_G(flags) & PHPDBG_DISCARD_OUTPUT) { + return 0; + } + va_start(args, fmt); buflen = phpdbg_xml_vasprintf(&buffer, fmt, 0, args TSRMLS_CC); va_end(args); From a8ac22452df4289d5d6acfd84f0cc616504d1112 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 13:20:43 +0100 Subject: [PATCH 153/398] Fix possibly unclosed tags --- phpdbg_io.c | 4 ---- phpdbg_out.c | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/phpdbg_io.c b/phpdbg_io.c index 6908a687d7e..a2a5c5969f4 100644 --- a/phpdbg_io.c +++ b/phpdbg_io.c @@ -187,10 +187,6 @@ PHPDBG_API int phpdbg_mixed_read(int sock, char *ptr, int len, int tmo TSRMLS_DC PHPDBG_API int phpdbg_mixed_write(int sock, const char *ptr, int len TSRMLS_DC) { - if (PHPDBG_G(flags) & PHPDBG_DISCARD_OUTPUT) { - return 0; - } - if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) { return phpdbg_send_bytes(sock, ptr, len); } diff --git a/phpdbg_out.c b/phpdbg_out.c index 365708c71ed..7e1dc7b744c 100644 --- a/phpdbg_out.c +++ b/phpdbg_out.c @@ -1168,6 +1168,10 @@ PHPDBG_API int phpdbg_output_err_buf(const char *tag, const char *xmlfmt, const va_list args; int errbuf_active = PHPDBG_G(err_buf).active; + if (PHPDBG_G(flags) & PHPDBG_DISCARD_OUTPUT) { + return 0; + } + PHPDBG_G(err_buf).active = 0; #ifdef ZTS @@ -1188,6 +1192,10 @@ PHPDBG_API int phpdbg_print(int type TSRMLS_DC, int fd, const char *tag, const c va_list args; int len; + if (PHPDBG_G(flags) & PHPDBG_DISCARD_OUTPUT) { + return 0; + } + va_start(args, strfmt); len = phpdbg_vprint(type TSRMLS_CC, fd, tag, xmlfmt, strfmt, args); va_end(args); @@ -1198,6 +1206,10 @@ PHPDBG_API int phpdbg_print(int type TSRMLS_DC, int fd, const char *tag, const c PHPDBG_API int phpdbg_xml_internal(int fd TSRMLS_DC, const char *fmt, ...) { int len = 0; + if (PHPDBG_G(flags) & PHPDBG_DISCARD_OUTPUT) { + return 0; + } + if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) { va_list args; char *buffer; @@ -1243,6 +1255,10 @@ PHPDBG_API int phpdbg_out_internal(int fd TSRMLS_DC, const char *fmt, ...) { int buflen; int len = 0; + if (PHPDBG_G(flags) & PHPDBG_DISCARD_OUTPUT) { + return 0; + } + va_start(args, fmt); buflen = phpdbg_xml_vasprintf(&buffer, fmt, 0, args TSRMLS_CC); va_end(args); From c34fd924660a0c2f3b2ef6ce30d95b541b76ef61 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 13:27:20 +0100 Subject: [PATCH 154/398] Fix wrong exec length on relative paths --- sapi/phpdbg/phpdbg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 9c56b1d7bc9..4bfbf4c1e91 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -1466,7 +1466,7 @@ phpdbg_main: if (exec) { /* set execution context */ PHPDBG_G(exec) = phpdbg_resolve_path(exec TSRMLS_CC); - PHPDBG_G(exec_len) = strlen(exec); + PHPDBG_G(exec_len) = PHPDBG_G(exec) ? strlen(PHPDBG_G(exec)) : 0; free(exec); exec = NULL; From b7d83ff8a69f60820ac45ffc02d903482c40399f Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 13:27:20 +0100 Subject: [PATCH 155/398] Fix wrong exec length on relative paths --- phpdbg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpdbg.c b/phpdbg.c index 9c56b1d7bc9..4bfbf4c1e91 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -1466,7 +1466,7 @@ phpdbg_main: if (exec) { /* set execution context */ PHPDBG_G(exec) = phpdbg_resolve_path(exec TSRMLS_CC); - PHPDBG_G(exec_len) = strlen(exec); + PHPDBG_G(exec_len) = PHPDBG_G(exec) ? strlen(PHPDBG_G(exec)) : 0; free(exec); exec = NULL; From 76bd799eb791e29e590ba4d89071ddd9374daefd Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 13:55:14 +0100 Subject: [PATCH 156/398] Fix quitting on a second run --- sapi/phpdbg/phpdbg.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 4bfbf4c1e91..87bfb858345 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -1527,21 +1527,20 @@ phpdbg_main: PHPDBG_G(flags) |= PHPDBG_IS_STEPPING; } - if (phpdbg_startup_run) { - 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; - } - phpdbg_startup_run = 0; - } - phpdbg_interact: /* phpdbg main() */ do { zend_try { + if (phpdbg_startup_run) { + PHPDBG_COMMAND_HANDLER(run)(NULL TSRMLS_CC); + if (phpdbg_startup_run > 1) { + /* if -r is on the command line more than once just quit */ + EG(bailout) = __orig_bailout; /* reset zend_try */ + break; + } + phpdbg_startup_run = 0; + } + phpdbg_interactive(1 TSRMLS_CC); } zend_catch { if ((PHPDBG_G(flags) & PHPDBG_IS_CLEANING)) { From c895fbea22cb0d7bedfa9e3429a073c8eefca84a Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 13:55:14 +0100 Subject: [PATCH 157/398] Fix quitting on a second run --- phpdbg.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index 4bfbf4c1e91..87bfb858345 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -1527,21 +1527,20 @@ phpdbg_main: PHPDBG_G(flags) |= PHPDBG_IS_STEPPING; } - if (phpdbg_startup_run) { - 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; - } - phpdbg_startup_run = 0; - } - phpdbg_interact: /* phpdbg main() */ do { zend_try { + if (phpdbg_startup_run) { + PHPDBG_COMMAND_HANDLER(run)(NULL TSRMLS_CC); + if (phpdbg_startup_run > 1) { + /* if -r is on the command line more than once just quit */ + EG(bailout) = __orig_bailout; /* reset zend_try */ + break; + } + phpdbg_startup_run = 0; + } + phpdbg_interactive(1 TSRMLS_CC); } zend_catch { if ((PHPDBG_G(flags) & PHPDBG_IS_CLEANING)) { From fd8a70b1ee8889234be5e9dded768852f26c9c5e Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 13:55:56 +0100 Subject: [PATCH 158/398] Typo (notfoundc => notfound) --- sapi/phpdbg/phpdbg_prompt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index 262b265a2e9..733d3cbe48a 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -1132,7 +1132,7 @@ PHPDBG_COMMAND(register) /* {{{ */ phpdbg_notice("register", "function=\"%s\"", "Registered %s", lcname); } else { - phpdbg_error("register", "type=\"notfoundc\" function=\"%s\"", "The requested function (%s) could not be found", param->str); + phpdbg_error("register", "type=\"notfound\" function=\"%s\"", "The requested function (%s) could not be found", param->str); } } else { phpdbg_error("register", "type=\"inuse\" function=\"%s\"", "The requested name (%s) is already in use", lcname); From 82640b7363d9fcf0283a4fbe2ff131570254a61e Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 13:55:56 +0100 Subject: [PATCH 159/398] Typo (notfoundc => notfound) --- phpdbg_prompt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 262b265a2e9..733d3cbe48a 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -1132,7 +1132,7 @@ PHPDBG_COMMAND(register) /* {{{ */ phpdbg_notice("register", "function=\"%s\"", "Registered %s", lcname); } else { - phpdbg_error("register", "type=\"notfoundc\" function=\"%s\"", "The requested function (%s) could not be found", param->str); + phpdbg_error("register", "type=\"notfound\" function=\"%s\"", "The requested function (%s) could not be found", param->str); } } else { phpdbg_error("register", "type=\"inuse\" function=\"%s\"", "The requested name (%s) is already in use", lcname); From 297baa0c18d8d04de7a683a51b9f069c84a855f3 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 17:20:21 +0100 Subject: [PATCH 160/398] Remove the ugly hack via a temp file to store breakpoints --- sapi/phpdbg/phpdbg.c | 61 ++++-------- sapi/phpdbg/phpdbg_bp.c | 67 ++++++++----- sapi/phpdbg/phpdbg_bp.h | 3 +- sapi/phpdbg/phpdbg_prompt.c | 190 +++++++++++++++++++++--------------- sapi/phpdbg/phpdbg_prompt.h | 1 + 5 files changed, 173 insertions(+), 149 deletions(-) diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 87bfb858345..5ebc203529b 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -1039,13 +1039,7 @@ int main(int argc, char **argv) /* {{{ */ zend_bool remote = 0; int step = 0; zend_phpdbg_globals *settings = NULL; - -#ifdef _WIN32 - char *bp_tmp_file = NULL; -#else - char bp_tmp_file[] = "/tmp/phpdbg.XXXXXX"; -#endif - + char *bp_tmp = NULL; char *address; int listen = -1; int server = -1; @@ -1081,29 +1075,6 @@ int main(int argc, char **argv) /* {{{ */ #endif phpdbg_main: - if (!cleaning) { - -#ifdef _WIN32 - bp_tmp_file = malloc(L_tmpnam); - - if (bp_tmp_file) { - if (!tmpnam(bp_tmp_file)) { - free(bp_tmp_file); - bp_tmp_file = NULL; - } - } - - if (!bp_tmp_file) { - phpdbg_error("tmpfile", "", "Unable to create temporary file"); - return 1; - } -#else - if (!mkstemp(bp_tmp_file)) { - memset(bp_tmp_file, 0, sizeof(bp_tmp_file)); - } -#endif - - } ini_entries = NULL; ini_entries_len = 0; ini_ignore = 0; @@ -1502,9 +1473,13 @@ phpdbg_main: 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; + if (bp_tmp) { + PHPDBG_G(flags) |= PHPDBG_DISCARD_OUTPUT; + phpdbg_string_init(bp_tmp TSRMLS_CC); + free(bp_tmp); + bp_tmp = NULL; + PHPDBG_G(flags) &= ~PHPDBG_DISCARD_OUTPUT; + } } zend_end_try(); PHPDBG_G(flags) &= ~PHPDBG_IS_INITIALIZING; @@ -1532,23 +1507,27 @@ phpdbg_interact: do { zend_try { if (phpdbg_startup_run) { + zend_bool quit_immediately = phpdbg_startup_run > 1; + phpdbg_startup_run = 0; PHPDBG_COMMAND_HANDLER(run)(NULL TSRMLS_CC); - if (phpdbg_startup_run > 1) { + if (quit_immediately) { /* if -r is on the command line more than once just quit */ EG(bailout) = __orig_bailout; /* reset zend_try */ break; } - phpdbg_startup_run = 0; } phpdbg_interactive(1 TSRMLS_CC); } zend_catch { if ((PHPDBG_G(flags) & PHPDBG_IS_CLEANING)) { - FILE *bp_tmp_fp = fopen(bp_tmp_file, "w"); + char *bp_tmp_str; PHPDBG_G(flags) |= PHPDBG_DISCARD_OUTPUT; - phpdbg_export_breakpoints(bp_tmp_fp TSRMLS_CC); + phpdbg_export_breakpoints_to_string(&bp_tmp_str TSRMLS_CC); PHPDBG_G(flags) &= ~PHPDBG_DISCARD_OUTPUT; - fclose(bp_tmp_fp); + if (bp_tmp_str) { + bp_tmp = strdup(bp_tmp_str); + efree(bp_tmp_str); + } cleaning = 1; } else { cleaning = 0; @@ -1688,11 +1667,5 @@ phpdbg_out: free(PHPDBG_G(sapi_name_ptr)); } -#ifdef _WIN32 - free(bp_tmp_file); -#else - unlink(bp_tmp_file); -#endif - return 0; } /* }}} */ diff --git a/sapi/phpdbg/phpdbg_bp.c b/sapi/phpdbg/phpdbg_bp.c index 93902f00529..33824d4fec4 100644 --- a/sapi/phpdbg/phpdbg_bp.c +++ b/sapi/phpdbg/phpdbg_bp.c @@ -110,11 +110,20 @@ PHPDBG_API void phpdbg_reset_breakpoints(TSRMLS_D) /* {{{ */ } /* }}} */ PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */ +{ + char *string; + phpdbg_export_breakpoints_to_string(&string TSRMLS_CC); + fputs(string, handle); +} + +PHPDBG_API void phpdbg_export_breakpoints_to_string(char **str TSRMLS_DC) /* {{{ */ { HashPosition position[2]; HashTable **table = NULL; zend_ulong id = 0L; + *str = ""; + if (zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP])) { phpdbg_notice("exportbreakpoint", "count=\"%d\"", "Exporting %d breakpoints", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP])); /* this only looks like magic, it isn't */ @@ -126,55 +135,57 @@ PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */ zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], NULL, NULL, &id, 0, &position[0]); for (zend_hash_internal_pointer_reset_ex((*table), &position[1]); - zend_hash_get_current_data_ex((*table), (void**)&brake, &position[1]) == SUCCESS; - zend_hash_move_forward_ex((*table), &position[1])) { + zend_hash_get_current_data_ex((*table), (void**)&brake, &position[1]) == SUCCESS; + zend_hash_move_forward_ex((*table), &position[1])) { if (brake->id == id) { + char *new_str = NULL; + switch (brake->type) { case PHPDBG_BREAK_FILE: { - fprintf(handle, - "break %s:%lu\n", + phpdbg_asprintf(&new_str, + "%sbreak %s:%lu\n", *str, ((phpdbg_breakfile_t*)brake)->filename, ((phpdbg_breakfile_t*)brake)->line); } break; case PHPDBG_BREAK_SYM: { - fprintf(handle, - "break %s\n", + phpdbg_asprintf(&new_str, + "%sbreak %s\n", *str, ((phpdbg_breaksymbol_t*)brake)->symbol); } break; case PHPDBG_BREAK_METHOD: { - fprintf(handle, - "break %s::%s\n", + phpdbg_asprintf(&new_str, + "%sbreak %s::%s\n", *str, ((phpdbg_breakmethod_t*)brake)->class_name, ((phpdbg_breakmethod_t*)brake)->func_name); } break; case PHPDBG_BREAK_METHOD_OPLINE: { - fprintf(handle, - "break %s::%s#%ld\n", + phpdbg_asprintf(&new_str, + "%sbreak %s::%s#%ld\n", *str, ((phpdbg_breakopline_t*)brake)->class_name, ((phpdbg_breakopline_t*)brake)->func_name, ((phpdbg_breakopline_t*)brake)->opline_num); } break; case PHPDBG_BREAK_FUNCTION_OPLINE: { - fprintf(handle, - "break %s#%ld\n", + phpdbg_asprintf(&new_str, + "%sbreak %s#%ld\n", *str, ((phpdbg_breakopline_t*)brake)->func_name, ((phpdbg_breakopline_t*)brake)->opline_num); } break; case PHPDBG_BREAK_FILE_OPLINE: { - fprintf(handle, - "break %s:#%ld\n", + phpdbg_asprintf(&new_str, + "%sbreak %s:#%ld\n", *str, ((phpdbg_breakopline_t*)brake)->class_name, ((phpdbg_breakopline_t*)brake)->opline_num); } break; case PHPDBG_BREAK_OPCODE: { - fprintf(handle, - "break %s\n", + phpdbg_asprintf(&new_str, + "%sbreak %s\n", *str, ((phpdbg_breakop_t*)brake)->name); } break; @@ -184,20 +195,20 @@ PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */ if (conditional->paramed) { switch (conditional->param.type) { case STR_PARAM: - fprintf(handle, - "break at %s if %s\n", conditional->param.str, conditional->code); + phpdbg_asprintf(&new_str, + "%sbreak at %s if %s\n", *str, conditional->param.str, conditional->code); break; case METHOD_PARAM: - fprintf(handle, - "break at %s::%s if %s\n", + phpdbg_asprintf(&new_str, + "%sbreak at %s::%s if %s\n", *str, conditional->param.method.class, conditional->param.method.name, conditional->code); break; case FILE_PARAM: - fprintf(handle, - "break at %s:%lu if %s\n", + phpdbg_asprintf(&new_str, + "%sbreak at %s:%lu if %s\n", *str, conditional->param.file.name, conditional->param.file.line, conditional->code); break; @@ -205,15 +216,23 @@ PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */ default: { /* do nothing */ } break; } } else { - fprintf( - handle, "break if %s\n", conditional->code); + phpdbg_asprintf(&new_str, "%sbreak if %s\n", str, conditional->code); } } break; } + + if ((*str)[0]) { + efree(*str); + } + *str = new_str; } } } } + + if (!(*str)[0]) { + *str = NULL; + } } /* }}} */ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRMLS_DC) /* {{{ */ diff --git a/sapi/phpdbg/phpdbg_bp.h b/sapi/phpdbg/phpdbg_bp.h index eca595321b3..63a9961d2a8 100644 --- a/sapi/phpdbg/phpdbg_bp.h +++ b/sapi/phpdbg/phpdbg_bp.h @@ -157,6 +157,7 @@ PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase(zend_ulong id TSRMLS_DC); PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase_ex(zend_ulong id, HashTable ***table, HashPosition *position TSRMLS_DC); /* }}} */ /* {{{ Breakpoint Exportation API */ -PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC); /* }}} */ +PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC); +PHPDBG_API void phpdbg_export_breakpoints_to_string(char **str TSRMLS_DC); /* }}} */ #endif /* PHPDBG_BP_H */ diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index 733d3cbe48a..c1fcb59a086 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -208,6 +208,110 @@ static inline int phpdbg_call_register(phpdbg_param_t *stack TSRMLS_DC) /* {{{ * return FAILURE; } /* }}} */ +struct phpdbg_init_state { + int line; + zend_bool in_code; + char *code; + size_t code_len; + const char *init_file; +}; + +static void phpdbg_line_init(char *cmd, struct phpdbg_init_state *state TSRMLS_DC) { + size_t cmd_len = strlen(cmd); + + state->line++; + + while (cmd_len > 0L && isspace(cmd[cmd_len-1])) { + cmd_len--; + } + + cmd[cmd_len] = '\0'; + + if (*cmd && cmd_len > 0L && cmd[0] != '#') { + if (cmd_len == 2) { + if (memcmp(cmd, "<:", sizeof("<:")-1) == SUCCESS) { + state->in_code = 1; + return; + } else { + if (memcmp(cmd, ":>", sizeof(":>")-1) == SUCCESS) { + state->in_code = 0; + state->code[state->code_len] = '\0'; + zend_eval_stringl(state->code, state->code_len, NULL, "phpdbginit code" TSRMLS_CC); + free(state->code); + state->code = NULL; + return; + } + } + } + + if (state->in_code) { + if (state->code == NULL) { + state->code = malloc(cmd_len + 1); + } else { + state->code = realloc(state->code, state->code_len + cmd_len + 1); + } + + if (state->code) { + memcpy(&state->code[state->code_len], cmd, cmd_len); + state->code_len += cmd_len; + } + + return; + } + + zend_try { + char *input = phpdbg_read_input(cmd TSRMLS_CC); + phpdbg_param_t stack; + + phpdbg_init_param(&stack, STACK_PARAM); + + phpdbg_activate_err_buf(1 TSRMLS_CC); + + if (phpdbg_do_parse(&stack, input TSRMLS_CC) <= 0) { + switch (phpdbg_stack_execute(&stack, 1 /* allow_async_unsafe == 1 */ TSRMLS_CC)) { + case FAILURE: + phpdbg_activate_err_buf(0 TSRMLS_CC); + if (phpdbg_call_register(&stack TSRMLS_CC) == FAILURE) { + if (state->init_file) { + phpdbg_output_err_buf("initfailure", "%b file=\"%s\" line=\"%d\" input=\"%s\"", "Unrecognized command in %s:%d: %s, %b!" TSRMLS_CC, state->init_file, state->line, input); + } else { + phpdbg_output_err_buf("initfailure", "%b line=\"%d\" input=\"%s\"", "Unrecognized command on line %d: %s, %b!" TSRMLS_CC, state->line, input); + } + } + break; + } + } + + phpdbg_activate_err_buf(0 TSRMLS_CC); + phpdbg_free_err_buf(TSRMLS_C); + + 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(); + } + +} + +void phpdbg_string_init(char *buffer TSRMLS_DC) { + struct phpdbg_init_state state = {0}; + char *str = strtok(buffer, "\n"); + + while (str) { + phpdbg_line_init(str, &state TSRMLS_CC); + + str = strtok(NULL, "\n"); + } + + if (state.code) { + free(state.code); + } +} + void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_init TSRMLS_DC) /* {{{ */ { struct stat sb; @@ -215,91 +319,17 @@ void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_ if (init_file && VCWD_STAT(init_file, &sb) != -1) { FILE *fp = fopen(init_file, "r"); if (fp) { - int line = 1; - char cmd[PHPDBG_MAX_CMD]; - size_t cmd_len = 0L; - char *code = NULL; - size_t code_len = 0L; - zend_bool in_code = 0; + struct phpdbg_init_state state = {0}; + + state.init_file = init_file; while (fgets(cmd, PHPDBG_MAX_CMD, fp) != NULL) { - cmd_len = strlen(cmd)-1; - - while (cmd_len > 0L && isspace(cmd[cmd_len-1])) - cmd_len--; - - cmd[cmd_len] = '\0'; - - if (*cmd && cmd_len > 0L && cmd[0] != '#') { - if (cmd_len == 2) { - if (memcmp(cmd, "<:", sizeof("<:")-1) == SUCCESS) { - in_code = 1; - goto next_line; - } else { - if (memcmp(cmd, ":>", sizeof(":>")-1) == SUCCESS) { - in_code = 0; - code[code_len] = '\0'; - { - zend_eval_stringl(code, code_len, NULL, "phpdbginit code" TSRMLS_CC); - } - free(code); - code = NULL; - goto next_line; - } - } - } - - if (in_code) { - if (code == NULL) { - code = malloc(cmd_len + 1); - } else code = realloc(code, code_len + cmd_len + 1); - - if (code) { - memcpy( - &code[code_len], cmd, cmd_len); - code_len += cmd_len; - } - goto next_line; - } - - zend_try { - char *input = phpdbg_read_input(cmd TSRMLS_CC); - phpdbg_param_t stack; - - phpdbg_init_param(&stack, STACK_PARAM); - - phpdbg_activate_err_buf(1 TSRMLS_CC); - - if (phpdbg_do_parse(&stack, input TSRMLS_CC) <= 0) { - switch (phpdbg_stack_execute(&stack, 1 /* allow_async_unsafe == 1 */ TSRMLS_CC)) { - case FAILURE: - phpdbg_activate_err_buf(0 TSRMLS_CC); - if (phpdbg_call_register(&stack TSRMLS_CC) == FAILURE) { - phpdbg_output_err_buf("initfailure", "%b file=\"%s\" line=\"%d\" input=\"%s\"", "Unrecognized command in %s:%d: %s, %b!" TSRMLS_CC, init_file, line, input); - } - break; - } - } - - phpdbg_activate_err_buf(0 TSRMLS_CC); - phpdbg_free_err_buf(TSRMLS_C); - - 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_line_init(cmd, &state TSRMLS_CC); } - if (code) { - free(code); + if (state.code) { + free(state.code); } fclose(fp); diff --git a/sapi/phpdbg/phpdbg_prompt.h b/sapi/phpdbg/phpdbg_prompt.h index 94e24df8334..f583f2cdcd6 100644 --- a/sapi/phpdbg/phpdbg_prompt.h +++ b/sapi/phpdbg/phpdbg_prompt.h @@ -22,6 +22,7 @@ #define PHPDBG_PROMPT_H /* {{{ */ +void phpdbg_string_init(char *buffer TSRMLS_DC); void phpdbg_init(char *init_file, size_t init_file_len, zend_bool use_default TSRMLS_DC); void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_init TSRMLS_DC); int phpdbg_interactive(zend_bool allow_async_unsafe TSRMLS_DC); From 7561e6b6e32134c6af669cb048eb4bbcb5f5cc4b Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 17:20:21 +0100 Subject: [PATCH 161/398] Remove the ugly hack via a temp file to store breakpoints --- phpdbg.c | 61 +++++----------- phpdbg_bp.c | 67 +++++++++++------ phpdbg_bp.h | 3 +- phpdbg_prompt.c | 190 ++++++++++++++++++++++++++++-------------------- phpdbg_prompt.h | 1 + 5 files changed, 173 insertions(+), 149 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index 87bfb858345..5ebc203529b 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -1039,13 +1039,7 @@ int main(int argc, char **argv) /* {{{ */ zend_bool remote = 0; int step = 0; zend_phpdbg_globals *settings = NULL; - -#ifdef _WIN32 - char *bp_tmp_file = NULL; -#else - char bp_tmp_file[] = "/tmp/phpdbg.XXXXXX"; -#endif - + char *bp_tmp = NULL; char *address; int listen = -1; int server = -1; @@ -1081,29 +1075,6 @@ int main(int argc, char **argv) /* {{{ */ #endif phpdbg_main: - if (!cleaning) { - -#ifdef _WIN32 - bp_tmp_file = malloc(L_tmpnam); - - if (bp_tmp_file) { - if (!tmpnam(bp_tmp_file)) { - free(bp_tmp_file); - bp_tmp_file = NULL; - } - } - - if (!bp_tmp_file) { - phpdbg_error("tmpfile", "", "Unable to create temporary file"); - return 1; - } -#else - if (!mkstemp(bp_tmp_file)) { - memset(bp_tmp_file, 0, sizeof(bp_tmp_file)); - } -#endif - - } ini_entries = NULL; ini_entries_len = 0; ini_ignore = 0; @@ -1502,9 +1473,13 @@ phpdbg_main: 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; + if (bp_tmp) { + PHPDBG_G(flags) |= PHPDBG_DISCARD_OUTPUT; + phpdbg_string_init(bp_tmp TSRMLS_CC); + free(bp_tmp); + bp_tmp = NULL; + PHPDBG_G(flags) &= ~PHPDBG_DISCARD_OUTPUT; + } } zend_end_try(); PHPDBG_G(flags) &= ~PHPDBG_IS_INITIALIZING; @@ -1532,23 +1507,27 @@ phpdbg_interact: do { zend_try { if (phpdbg_startup_run) { + zend_bool quit_immediately = phpdbg_startup_run > 1; + phpdbg_startup_run = 0; PHPDBG_COMMAND_HANDLER(run)(NULL TSRMLS_CC); - if (phpdbg_startup_run > 1) { + if (quit_immediately) { /* if -r is on the command line more than once just quit */ EG(bailout) = __orig_bailout; /* reset zend_try */ break; } - phpdbg_startup_run = 0; } phpdbg_interactive(1 TSRMLS_CC); } zend_catch { if ((PHPDBG_G(flags) & PHPDBG_IS_CLEANING)) { - FILE *bp_tmp_fp = fopen(bp_tmp_file, "w"); + char *bp_tmp_str; PHPDBG_G(flags) |= PHPDBG_DISCARD_OUTPUT; - phpdbg_export_breakpoints(bp_tmp_fp TSRMLS_CC); + phpdbg_export_breakpoints_to_string(&bp_tmp_str TSRMLS_CC); PHPDBG_G(flags) &= ~PHPDBG_DISCARD_OUTPUT; - fclose(bp_tmp_fp); + if (bp_tmp_str) { + bp_tmp = strdup(bp_tmp_str); + efree(bp_tmp_str); + } cleaning = 1; } else { cleaning = 0; @@ -1688,11 +1667,5 @@ phpdbg_out: free(PHPDBG_G(sapi_name_ptr)); } -#ifdef _WIN32 - free(bp_tmp_file); -#else - unlink(bp_tmp_file); -#endif - return 0; } /* }}} */ diff --git a/phpdbg_bp.c b/phpdbg_bp.c index 93902f00529..33824d4fec4 100644 --- a/phpdbg_bp.c +++ b/phpdbg_bp.c @@ -110,11 +110,20 @@ PHPDBG_API void phpdbg_reset_breakpoints(TSRMLS_D) /* {{{ */ } /* }}} */ PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */ +{ + char *string; + phpdbg_export_breakpoints_to_string(&string TSRMLS_CC); + fputs(string, handle); +} + +PHPDBG_API void phpdbg_export_breakpoints_to_string(char **str TSRMLS_DC) /* {{{ */ { HashPosition position[2]; HashTable **table = NULL; zend_ulong id = 0L; + *str = ""; + if (zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP])) { phpdbg_notice("exportbreakpoint", "count=\"%d\"", "Exporting %d breakpoints", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP])); /* this only looks like magic, it isn't */ @@ -126,55 +135,57 @@ PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */ zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], NULL, NULL, &id, 0, &position[0]); for (zend_hash_internal_pointer_reset_ex((*table), &position[1]); - zend_hash_get_current_data_ex((*table), (void**)&brake, &position[1]) == SUCCESS; - zend_hash_move_forward_ex((*table), &position[1])) { + zend_hash_get_current_data_ex((*table), (void**)&brake, &position[1]) == SUCCESS; + zend_hash_move_forward_ex((*table), &position[1])) { if (brake->id == id) { + char *new_str = NULL; + switch (brake->type) { case PHPDBG_BREAK_FILE: { - fprintf(handle, - "break %s:%lu\n", + phpdbg_asprintf(&new_str, + "%sbreak %s:%lu\n", *str, ((phpdbg_breakfile_t*)brake)->filename, ((phpdbg_breakfile_t*)brake)->line); } break; case PHPDBG_BREAK_SYM: { - fprintf(handle, - "break %s\n", + phpdbg_asprintf(&new_str, + "%sbreak %s\n", *str, ((phpdbg_breaksymbol_t*)brake)->symbol); } break; case PHPDBG_BREAK_METHOD: { - fprintf(handle, - "break %s::%s\n", + phpdbg_asprintf(&new_str, + "%sbreak %s::%s\n", *str, ((phpdbg_breakmethod_t*)brake)->class_name, ((phpdbg_breakmethod_t*)brake)->func_name); } break; case PHPDBG_BREAK_METHOD_OPLINE: { - fprintf(handle, - "break %s::%s#%ld\n", + phpdbg_asprintf(&new_str, + "%sbreak %s::%s#%ld\n", *str, ((phpdbg_breakopline_t*)brake)->class_name, ((phpdbg_breakopline_t*)brake)->func_name, ((phpdbg_breakopline_t*)brake)->opline_num); } break; case PHPDBG_BREAK_FUNCTION_OPLINE: { - fprintf(handle, - "break %s#%ld\n", + phpdbg_asprintf(&new_str, + "%sbreak %s#%ld\n", *str, ((phpdbg_breakopline_t*)brake)->func_name, ((phpdbg_breakopline_t*)brake)->opline_num); } break; case PHPDBG_BREAK_FILE_OPLINE: { - fprintf(handle, - "break %s:#%ld\n", + phpdbg_asprintf(&new_str, + "%sbreak %s:#%ld\n", *str, ((phpdbg_breakopline_t*)brake)->class_name, ((phpdbg_breakopline_t*)brake)->opline_num); } break; case PHPDBG_BREAK_OPCODE: { - fprintf(handle, - "break %s\n", + phpdbg_asprintf(&new_str, + "%sbreak %s\n", *str, ((phpdbg_breakop_t*)brake)->name); } break; @@ -184,20 +195,20 @@ PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */ if (conditional->paramed) { switch (conditional->param.type) { case STR_PARAM: - fprintf(handle, - "break at %s if %s\n", conditional->param.str, conditional->code); + phpdbg_asprintf(&new_str, + "%sbreak at %s if %s\n", *str, conditional->param.str, conditional->code); break; case METHOD_PARAM: - fprintf(handle, - "break at %s::%s if %s\n", + phpdbg_asprintf(&new_str, + "%sbreak at %s::%s if %s\n", *str, conditional->param.method.class, conditional->param.method.name, conditional->code); break; case FILE_PARAM: - fprintf(handle, - "break at %s:%lu if %s\n", + phpdbg_asprintf(&new_str, + "%sbreak at %s:%lu if %s\n", *str, conditional->param.file.name, conditional->param.file.line, conditional->code); break; @@ -205,15 +216,23 @@ PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */ default: { /* do nothing */ } break; } } else { - fprintf( - handle, "break if %s\n", conditional->code); + phpdbg_asprintf(&new_str, "%sbreak if %s\n", str, conditional->code); } } break; } + + if ((*str)[0]) { + efree(*str); + } + *str = new_str; } } } } + + if (!(*str)[0]) { + *str = NULL; + } } /* }}} */ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRMLS_DC) /* {{{ */ diff --git a/phpdbg_bp.h b/phpdbg_bp.h index eca595321b3..63a9961d2a8 100644 --- a/phpdbg_bp.h +++ b/phpdbg_bp.h @@ -157,6 +157,7 @@ PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase(zend_ulong id TSRMLS_DC); PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase_ex(zend_ulong id, HashTable ***table, HashPosition *position TSRMLS_DC); /* }}} */ /* {{{ Breakpoint Exportation API */ -PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC); /* }}} */ +PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC); +PHPDBG_API void phpdbg_export_breakpoints_to_string(char **str TSRMLS_DC); /* }}} */ #endif /* PHPDBG_BP_H */ diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 733d3cbe48a..c1fcb59a086 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -208,6 +208,110 @@ static inline int phpdbg_call_register(phpdbg_param_t *stack TSRMLS_DC) /* {{{ * return FAILURE; } /* }}} */ +struct phpdbg_init_state { + int line; + zend_bool in_code; + char *code; + size_t code_len; + const char *init_file; +}; + +static void phpdbg_line_init(char *cmd, struct phpdbg_init_state *state TSRMLS_DC) { + size_t cmd_len = strlen(cmd); + + state->line++; + + while (cmd_len > 0L && isspace(cmd[cmd_len-1])) { + cmd_len--; + } + + cmd[cmd_len] = '\0'; + + if (*cmd && cmd_len > 0L && cmd[0] != '#') { + if (cmd_len == 2) { + if (memcmp(cmd, "<:", sizeof("<:")-1) == SUCCESS) { + state->in_code = 1; + return; + } else { + if (memcmp(cmd, ":>", sizeof(":>")-1) == SUCCESS) { + state->in_code = 0; + state->code[state->code_len] = '\0'; + zend_eval_stringl(state->code, state->code_len, NULL, "phpdbginit code" TSRMLS_CC); + free(state->code); + state->code = NULL; + return; + } + } + } + + if (state->in_code) { + if (state->code == NULL) { + state->code = malloc(cmd_len + 1); + } else { + state->code = realloc(state->code, state->code_len + cmd_len + 1); + } + + if (state->code) { + memcpy(&state->code[state->code_len], cmd, cmd_len); + state->code_len += cmd_len; + } + + return; + } + + zend_try { + char *input = phpdbg_read_input(cmd TSRMLS_CC); + phpdbg_param_t stack; + + phpdbg_init_param(&stack, STACK_PARAM); + + phpdbg_activate_err_buf(1 TSRMLS_CC); + + if (phpdbg_do_parse(&stack, input TSRMLS_CC) <= 0) { + switch (phpdbg_stack_execute(&stack, 1 /* allow_async_unsafe == 1 */ TSRMLS_CC)) { + case FAILURE: + phpdbg_activate_err_buf(0 TSRMLS_CC); + if (phpdbg_call_register(&stack TSRMLS_CC) == FAILURE) { + if (state->init_file) { + phpdbg_output_err_buf("initfailure", "%b file=\"%s\" line=\"%d\" input=\"%s\"", "Unrecognized command in %s:%d: %s, %b!" TSRMLS_CC, state->init_file, state->line, input); + } else { + phpdbg_output_err_buf("initfailure", "%b line=\"%d\" input=\"%s\"", "Unrecognized command on line %d: %s, %b!" TSRMLS_CC, state->line, input); + } + } + break; + } + } + + phpdbg_activate_err_buf(0 TSRMLS_CC); + phpdbg_free_err_buf(TSRMLS_C); + + 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(); + } + +} + +void phpdbg_string_init(char *buffer TSRMLS_DC) { + struct phpdbg_init_state state = {0}; + char *str = strtok(buffer, "\n"); + + while (str) { + phpdbg_line_init(str, &state TSRMLS_CC); + + str = strtok(NULL, "\n"); + } + + if (state.code) { + free(state.code); + } +} + void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_init TSRMLS_DC) /* {{{ */ { struct stat sb; @@ -215,91 +319,17 @@ void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_ if (init_file && VCWD_STAT(init_file, &sb) != -1) { FILE *fp = fopen(init_file, "r"); if (fp) { - int line = 1; - char cmd[PHPDBG_MAX_CMD]; - size_t cmd_len = 0L; - char *code = NULL; - size_t code_len = 0L; - zend_bool in_code = 0; + struct phpdbg_init_state state = {0}; + + state.init_file = init_file; while (fgets(cmd, PHPDBG_MAX_CMD, fp) != NULL) { - cmd_len = strlen(cmd)-1; - - while (cmd_len > 0L && isspace(cmd[cmd_len-1])) - cmd_len--; - - cmd[cmd_len] = '\0'; - - if (*cmd && cmd_len > 0L && cmd[0] != '#') { - if (cmd_len == 2) { - if (memcmp(cmd, "<:", sizeof("<:")-1) == SUCCESS) { - in_code = 1; - goto next_line; - } else { - if (memcmp(cmd, ":>", sizeof(":>")-1) == SUCCESS) { - in_code = 0; - code[code_len] = '\0'; - { - zend_eval_stringl(code, code_len, NULL, "phpdbginit code" TSRMLS_CC); - } - free(code); - code = NULL; - goto next_line; - } - } - } - - if (in_code) { - if (code == NULL) { - code = malloc(cmd_len + 1); - } else code = realloc(code, code_len + cmd_len + 1); - - if (code) { - memcpy( - &code[code_len], cmd, cmd_len); - code_len += cmd_len; - } - goto next_line; - } - - zend_try { - char *input = phpdbg_read_input(cmd TSRMLS_CC); - phpdbg_param_t stack; - - phpdbg_init_param(&stack, STACK_PARAM); - - phpdbg_activate_err_buf(1 TSRMLS_CC); - - if (phpdbg_do_parse(&stack, input TSRMLS_CC) <= 0) { - switch (phpdbg_stack_execute(&stack, 1 /* allow_async_unsafe == 1 */ TSRMLS_CC)) { - case FAILURE: - phpdbg_activate_err_buf(0 TSRMLS_CC); - if (phpdbg_call_register(&stack TSRMLS_CC) == FAILURE) { - phpdbg_output_err_buf("initfailure", "%b file=\"%s\" line=\"%d\" input=\"%s\"", "Unrecognized command in %s:%d: %s, %b!" TSRMLS_CC, init_file, line, input); - } - break; - } - } - - phpdbg_activate_err_buf(0 TSRMLS_CC); - phpdbg_free_err_buf(TSRMLS_C); - - 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_line_init(cmd, &state TSRMLS_CC); } - if (code) { - free(code); + if (state.code) { + free(state.code); } fclose(fp); diff --git a/phpdbg_prompt.h b/phpdbg_prompt.h index 94e24df8334..f583f2cdcd6 100644 --- a/phpdbg_prompt.h +++ b/phpdbg_prompt.h @@ -22,6 +22,7 @@ #define PHPDBG_PROMPT_H /* {{{ */ +void phpdbg_string_init(char *buffer TSRMLS_DC); void phpdbg_init(char *init_file, size_t init_file_len, zend_bool use_default TSRMLS_DC); void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_init TSRMLS_DC); int phpdbg_interactive(zend_bool allow_async_unsafe TSRMLS_DC); From 9028846c6315903a4d43f436aced67ca1d345e69 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 28 Oct 2014 19:10:53 +0100 Subject: [PATCH 162/398] fix phpdbg build when src tree != build tree --- sapi/phpdbg/config.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sapi/phpdbg/config.m4 b/sapi/phpdbg/config.m4 index 528abb5822b..b8aa8526c56 100644 --- a/sapi/phpdbg/config.m4 +++ b/sapi/phpdbg/config.m4 @@ -22,8 +22,8 @@ if test "$BUILD_PHPDBG" == "" && test "$PHP_PHPDBG" != "no"; then fi if test "$PHP_PHPDBG_WEBHELPER" != "no"; then - if ! test -d ext/phpdbg_webhelper; then - ln -s ../sapi/phpdbg ext/phpdbg_webhelper + if ! test -d $abs_srcdir/ext/phpdbg_webhelper; then + ln -s ../sapi/phpdbg $abs_srcdir/ext/phpdbg_webhelper fi if test "$PHP_JSON" != "no"; then PHP_NEW_EXTENSION(phpdbg_webhelper, phpdbg_rinit_hook.c phpdbg_webdata_transfer.c, $ext_shared) From 36fef6dcd9d9e95127726fcfb231303ca59749b9 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 28 Oct 2014 19:10:53 +0100 Subject: [PATCH 163/398] fix phpdbg build when src tree != build tree --- config.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.m4 b/config.m4 index 528abb5822b..b8aa8526c56 100644 --- a/config.m4 +++ b/config.m4 @@ -22,8 +22,8 @@ if test "$BUILD_PHPDBG" == "" && test "$PHP_PHPDBG" != "no"; then fi if test "$PHP_PHPDBG_WEBHELPER" != "no"; then - if ! test -d ext/phpdbg_webhelper; then - ln -s ../sapi/phpdbg ext/phpdbg_webhelper + if ! test -d $abs_srcdir/ext/phpdbg_webhelper; then + ln -s ../sapi/phpdbg $abs_srcdir/ext/phpdbg_webhelper fi if test "$PHP_JSON" != "no"; then PHP_NEW_EXTENSION(phpdbg_webhelper, phpdbg_rinit_hook.c phpdbg_webdata_transfer.c, $ext_shared) From 69b999eb7ed802f488f674f8d4294e09e6d46610 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 22:11:30 +0100 Subject: [PATCH 164/398] Add webhelper in config.w32 --- config.w32 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config.w32 b/config.w32 index 6f0bd8f8113..651c7e6d16a 100644 --- a/config.w32 +++ b/config.w32 @@ -1,5 +1,6 @@ ARG_ENABLE('phpdbg', 'Build phpdbg', 'no'); ARG_ENABLE('phpdbgs', 'Build phpdbg shared', 'no'); +ARG_ENABLE('phpdbgwebhelper', 'Build phpdbg webhelper', 'yes'); PHPDBG_SOURCES='phpdbg.c phpdbg_prompt.c phpdbg_cmd.c phpdbg_info.c phpdbg_help.c phpdbg_break.c ' + 'phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c ' + @@ -14,6 +15,10 @@ if (PHP_PHPDBG == "yes") { ADD_FLAG("LIBS_PHPDBG", "ws2_32.lib user32.lib"); ADD_FLAG("CFLAGS_PHPDBG", "/D YY_NO_UNISTD_H"); ADD_FLAG("LDFLAGS_PHPDBG", "/stack:8388608"); + + if (PHP_PHPDBGWEBHELPER == "yes") { + EXTENSION('phpdbg-webhelper', 'phpdbg_rinit_hook.c phpdbg_webdata_compress.c'); + } } if (PHP_PHPDBGS == "yes") { From d25cc7f09085ea8f162a984b8345c6ecaebf0a65 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 22:14:35 +0100 Subject: [PATCH 165/398] Use serialize instead of json for transfer --- config.m4 | 5 ----- phpdbg_wait.c | 15 ++++++++------- phpdbg_webdata_transfer.c | 20 +++++++++++++------- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/config.m4 b/config.m4 index b8aa8526c56..9603be105cf 100644 --- a/config.m4 +++ b/config.m4 @@ -25,11 +25,6 @@ if test "$BUILD_PHPDBG" == "" && test "$PHP_PHPDBG" != "no"; then if ! test -d $abs_srcdir/ext/phpdbg_webhelper; then ln -s ../sapi/phpdbg $abs_srcdir/ext/phpdbg_webhelper fi - if test "$PHP_JSON" != "no"; then - PHP_NEW_EXTENSION(phpdbg_webhelper, phpdbg_rinit_hook.c phpdbg_webdata_transfer.c, $ext_shared) - else - AC_MSG_ERROR(Webhelper extension of phpdbg needs json enabled) - fi fi PHP_PHPDBG_CFLAGS="-D_GNU_SOURCE" diff --git a/phpdbg_wait.c b/phpdbg_wait.c index ea506a2d932..bdce77180b4 100644 --- a/phpdbg_wait.c +++ b/phpdbg_wait.c @@ -18,7 +18,7 @@ #include "phpdbg_wait.h" #include "phpdbg_prompt.h" -#include "ext/json/JSON_parser.h" +#include "ext/standard/php_var.h" #include "ext/standard/basic_functions.h" ZEND_EXTERN_MODULE_GLOBALS(phpdbg); @@ -127,16 +127,18 @@ static int phpdbg_array_intersect(phpdbg_intersect_ptr *info, zval ***ptr) { } void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) { -#ifdef HAVE_JSON zval *free_zv = NULL; - zval zv, **zvpp; + zval zv, *zvp = &zv, **zvpp; HashTable *ht; - php_json_decode(&zv, msg, len, 1, 1000 /* enough */ TSRMLS_CC); + php_unserialize_data_t var_hash; - if (JSON_G(error_code) != PHP_JSON_ERROR_NONE) { - phpdbg_error("wait", "type=\"invaliddata\" import=\"fail\"", "Malformed JSON was sent to this socket, arborting"); + PHP_VAR_UNSERIALIZE_INIT(var_hash); + if (!php_var_unserialize(&zvp, (const unsigned char **) &msg, (unsigned char *) msg + len, &var_hash TSRMLS_CC)) { + PHP_VAR_UNSERIALIZE_DESTROY(var_hash); + phpdbg_error("wait", "type=\"invaliddata\" import=\"fail\"", "Malformed serialized was sent to this socket, arborting"); return; } + PHP_VAR_UNSERIALIZE_DESTROY(var_hash); ht = Z_ARRVAL(zv); @@ -358,7 +360,6 @@ void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) { /* Reapply raw input */ /* ??? */ -#endif } PHPDBG_COMMAND(wait) /* {{{ */ diff --git a/phpdbg_webdata_transfer.c b/phpdbg_webdata_transfer.c index e7438ea01ab..1cbc4107b5c 100644 --- a/phpdbg_webdata_transfer.c +++ b/phpdbg_webdata_transfer.c @@ -17,11 +17,9 @@ */ #include "phpdbg_webdata_transfer.h" -#include "ext/json/php_json.h" +#include "ext/standard/php_var.h" PHPDBG_API void phpdbg_webdata_compress(char **msg, int *len TSRMLS_DC) { -#ifdef HAVE_JSON - smart_str buf = {0}; zval array; HashTable *ht; /* I really need to change that to an array of zvals... */ @@ -177,9 +175,17 @@ PHPDBG_API void phpdbg_webdata_compress(char **msg, int *len TSRMLS_DC) { } /* encode data */ - php_json_encode(&buf, &array, 0 TSRMLS_CC); - *msg = buf.c; - *len = buf.len; + { + php_serialize_data_t var_hash; + smart_str buf = {0}; + zval *arrayptr = &array; + + PHP_VAR_SERIALIZE_INIT(var_hash); + php_var_serialize(&buf, &arrayptr, &var_hash TSRMLS_CC); + PHP_VAR_SERIALIZE_DESTROY(var_hash); + *msg = buf.c; + *len = buf.len; + } + zval_dtor(&array); -#endif } From 4bc7a91be71f833672cc52134e665ce0b08bd61c Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 22:15:05 +0100 Subject: [PATCH 166/398] Merge ../phpdbg into PHP-5.6 Conflicts: sapi/phpdbg/config.m4 --- config.m4 | 5 ----- config.w32 | 5 +++++ phpdbg_wait.c | 15 ++++++++------- phpdbg_webdata_transfer.c | 20 +++++++++++++------- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/config.m4 b/config.m4 index b8aa8526c56..9603be105cf 100644 --- a/config.m4 +++ b/config.m4 @@ -25,11 +25,6 @@ if test "$BUILD_PHPDBG" == "" && test "$PHP_PHPDBG" != "no"; then if ! test -d $abs_srcdir/ext/phpdbg_webhelper; then ln -s ../sapi/phpdbg $abs_srcdir/ext/phpdbg_webhelper fi - if test "$PHP_JSON" != "no"; then - PHP_NEW_EXTENSION(phpdbg_webhelper, phpdbg_rinit_hook.c phpdbg_webdata_transfer.c, $ext_shared) - else - AC_MSG_ERROR(Webhelper extension of phpdbg needs json enabled) - fi fi PHP_PHPDBG_CFLAGS="-D_GNU_SOURCE" diff --git a/config.w32 b/config.w32 index 6f0bd8f8113..651c7e6d16a 100644 --- a/config.w32 +++ b/config.w32 @@ -1,5 +1,6 @@ ARG_ENABLE('phpdbg', 'Build phpdbg', 'no'); ARG_ENABLE('phpdbgs', 'Build phpdbg shared', 'no'); +ARG_ENABLE('phpdbgwebhelper', 'Build phpdbg webhelper', 'yes'); PHPDBG_SOURCES='phpdbg.c phpdbg_prompt.c phpdbg_cmd.c phpdbg_info.c phpdbg_help.c phpdbg_break.c ' + 'phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c ' + @@ -14,6 +15,10 @@ if (PHP_PHPDBG == "yes") { ADD_FLAG("LIBS_PHPDBG", "ws2_32.lib user32.lib"); ADD_FLAG("CFLAGS_PHPDBG", "/D YY_NO_UNISTD_H"); ADD_FLAG("LDFLAGS_PHPDBG", "/stack:8388608"); + + if (PHP_PHPDBGWEBHELPER == "yes") { + EXTENSION('phpdbg-webhelper', 'phpdbg_rinit_hook.c phpdbg_webdata_compress.c'); + } } if (PHP_PHPDBGS == "yes") { diff --git a/phpdbg_wait.c b/phpdbg_wait.c index ea506a2d932..bdce77180b4 100644 --- a/phpdbg_wait.c +++ b/phpdbg_wait.c @@ -18,7 +18,7 @@ #include "phpdbg_wait.h" #include "phpdbg_prompt.h" -#include "ext/json/JSON_parser.h" +#include "ext/standard/php_var.h" #include "ext/standard/basic_functions.h" ZEND_EXTERN_MODULE_GLOBALS(phpdbg); @@ -127,16 +127,18 @@ static int phpdbg_array_intersect(phpdbg_intersect_ptr *info, zval ***ptr) { } void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) { -#ifdef HAVE_JSON zval *free_zv = NULL; - zval zv, **zvpp; + zval zv, *zvp = &zv, **zvpp; HashTable *ht; - php_json_decode(&zv, msg, len, 1, 1000 /* enough */ TSRMLS_CC); + php_unserialize_data_t var_hash; - if (JSON_G(error_code) != PHP_JSON_ERROR_NONE) { - phpdbg_error("wait", "type=\"invaliddata\" import=\"fail\"", "Malformed JSON was sent to this socket, arborting"); + PHP_VAR_UNSERIALIZE_INIT(var_hash); + if (!php_var_unserialize(&zvp, (const unsigned char **) &msg, (unsigned char *) msg + len, &var_hash TSRMLS_CC)) { + PHP_VAR_UNSERIALIZE_DESTROY(var_hash); + phpdbg_error("wait", "type=\"invaliddata\" import=\"fail\"", "Malformed serialized was sent to this socket, arborting"); return; } + PHP_VAR_UNSERIALIZE_DESTROY(var_hash); ht = Z_ARRVAL(zv); @@ -358,7 +360,6 @@ void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) { /* Reapply raw input */ /* ??? */ -#endif } PHPDBG_COMMAND(wait) /* {{{ */ diff --git a/phpdbg_webdata_transfer.c b/phpdbg_webdata_transfer.c index e7438ea01ab..1cbc4107b5c 100644 --- a/phpdbg_webdata_transfer.c +++ b/phpdbg_webdata_transfer.c @@ -17,11 +17,9 @@ */ #include "phpdbg_webdata_transfer.h" -#include "ext/json/php_json.h" +#include "ext/standard/php_var.h" PHPDBG_API void phpdbg_webdata_compress(char **msg, int *len TSRMLS_DC) { -#ifdef HAVE_JSON - smart_str buf = {0}; zval array; HashTable *ht; /* I really need to change that to an array of zvals... */ @@ -177,9 +175,17 @@ PHPDBG_API void phpdbg_webdata_compress(char **msg, int *len TSRMLS_DC) { } /* encode data */ - php_json_encode(&buf, &array, 0 TSRMLS_CC); - *msg = buf.c; - *len = buf.len; + { + php_serialize_data_t var_hash; + smart_str buf = {0}; + zval *arrayptr = &array; + + PHP_VAR_SERIALIZE_INIT(var_hash); + php_var_serialize(&buf, &arrayptr, &var_hash TSRMLS_CC); + PHP_VAR_SERIALIZE_DESTROY(var_hash); + *msg = buf.c; + *len = buf.len; + } + zval_dtor(&array); -#endif } From 234df7d2cae516cba99619267be2f9db7a1418a7 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 22:33:41 +0100 Subject: [PATCH 167/398] Fix versions & config.m4 --- config.m4 | 1 + phpdbg_wait.c | 2 ++ phpdbg_webdata_transfer.c | 2 ++ 3 files changed, 5 insertions(+) diff --git a/config.m4 b/config.m4 index 9603be105cf..87d38ea8c51 100644 --- a/config.m4 +++ b/config.m4 @@ -25,6 +25,7 @@ if test "$BUILD_PHPDBG" == "" && test "$PHP_PHPDBG" != "no"; then if ! test -d $abs_srcdir/ext/phpdbg_webhelper; then ln -s ../sapi/phpdbg $abs_srcdir/ext/phpdbg_webhelper fi + PHP_NEW_EXTENSION(phpdbg_webhelper, phpdbg_rinit_hook.c phpdbg_webdata_transfer.c, $ext_shared) fi PHP_PHPDBG_CFLAGS="-D_GNU_SOURCE" diff --git a/phpdbg_wait.c b/phpdbg_wait.c index bdce77180b4..a8c7dd49cb2 100644 --- a/phpdbg_wait.c +++ b/phpdbg_wait.c @@ -174,6 +174,7 @@ void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) { free_zv = *zvpp; } +#if PHP_VERSION_ID >= 50600 if (zend_hash_find(ht, "input", sizeof("input"), (void **) &zvpp) == SUCCESS && Z_TYPE_PP(zvpp) == IS_STRING) { if (SG(request_info).request_body) { php_stream_close(SG(request_info).request_body); @@ -182,6 +183,7 @@ void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) { php_stream_truncate_set_size(SG(request_info).request_body, 0); php_stream_write(SG(request_info).request_body, Z_STRVAL_PP(zvpp), Z_STRLEN_PP(zvpp)); } +#endif if (zend_hash_find(ht, "cwd", sizeof("cwd"), (void **) &zvpp) == SUCCESS && Z_TYPE_PP(zvpp) == IS_STRING) { if (VCWD_CHDIR(Z_STRVAL_PP(zvpp)) == SUCCESS) { diff --git a/phpdbg_webdata_transfer.c b/phpdbg_webdata_transfer.c index 1cbc4107b5c..7c169ee1139 100644 --- a/phpdbg_webdata_transfer.c +++ b/phpdbg_webdata_transfer.c @@ -49,6 +49,7 @@ PHPDBG_API void phpdbg_webdata_compress(char **msg, int *len TSRMLS_DC) { zend_hash_add(ht, "GLOBALS", sizeof("GLOBALS"), &zvp1, sizeof(zval *), NULL); } +#if PHP_VERSION_ID >= 50600 /* save php://input */ { php_stream *stream; @@ -64,6 +65,7 @@ PHPDBG_API void phpdbg_webdata_compress(char **msg, int *len TSRMLS_DC) { Z_SET_REFCOUNT(zv2, 2); zend_hash_add(ht, "input", sizeof("input"), &zvp2, sizeof(zval *), NULL); } +#endif /* change sapi name */ { From 45e2dc692b9b0ad13c32444622d85c0353aaee42 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 22:44:29 +0100 Subject: [PATCH 168/398] Merge phpdbg into PHP-5.6 --- config.m4 | 1 + phpdbg_wait.c | 2 ++ phpdbg_webdata_transfer.c | 2 ++ 3 files changed, 5 insertions(+) diff --git a/config.m4 b/config.m4 index 9603be105cf..87d38ea8c51 100644 --- a/config.m4 +++ b/config.m4 @@ -25,6 +25,7 @@ if test "$BUILD_PHPDBG" == "" && test "$PHP_PHPDBG" != "no"; then if ! test -d $abs_srcdir/ext/phpdbg_webhelper; then ln -s ../sapi/phpdbg $abs_srcdir/ext/phpdbg_webhelper fi + PHP_NEW_EXTENSION(phpdbg_webhelper, phpdbg_rinit_hook.c phpdbg_webdata_transfer.c, $ext_shared) fi PHP_PHPDBG_CFLAGS="-D_GNU_SOURCE" diff --git a/phpdbg_wait.c b/phpdbg_wait.c index bdce77180b4..a8c7dd49cb2 100644 --- a/phpdbg_wait.c +++ b/phpdbg_wait.c @@ -174,6 +174,7 @@ void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) { free_zv = *zvpp; } +#if PHP_VERSION_ID >= 50600 if (zend_hash_find(ht, "input", sizeof("input"), (void **) &zvpp) == SUCCESS && Z_TYPE_PP(zvpp) == IS_STRING) { if (SG(request_info).request_body) { php_stream_close(SG(request_info).request_body); @@ -182,6 +183,7 @@ void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) { php_stream_truncate_set_size(SG(request_info).request_body, 0); php_stream_write(SG(request_info).request_body, Z_STRVAL_PP(zvpp), Z_STRLEN_PP(zvpp)); } +#endif if (zend_hash_find(ht, "cwd", sizeof("cwd"), (void **) &zvpp) == SUCCESS && Z_TYPE_PP(zvpp) == IS_STRING) { if (VCWD_CHDIR(Z_STRVAL_PP(zvpp)) == SUCCESS) { diff --git a/phpdbg_webdata_transfer.c b/phpdbg_webdata_transfer.c index 1cbc4107b5c..7c169ee1139 100644 --- a/phpdbg_webdata_transfer.c +++ b/phpdbg_webdata_transfer.c @@ -49,6 +49,7 @@ PHPDBG_API void phpdbg_webdata_compress(char **msg, int *len TSRMLS_DC) { zend_hash_add(ht, "GLOBALS", sizeof("GLOBALS"), &zvp1, sizeof(zval *), NULL); } +#if PHP_VERSION_ID >= 50600 /* save php://input */ { php_stream *stream; @@ -64,6 +65,7 @@ PHPDBG_API void phpdbg_webdata_compress(char **msg, int *len TSRMLS_DC) { Z_SET_REFCOUNT(zv2, 2); zend_hash_add(ht, "input", sizeof("input"), &zvp2, sizeof(zval *), NULL); } +#endif /* change sapi name */ { From 31ada13463f02e3b64f15a24f4331c865b37ac1e Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 23:06:32 +0100 Subject: [PATCH 169/398] Removed last HAVE_JSON check --- phpdbg_wait.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/phpdbg_wait.c b/phpdbg_wait.c index a8c7dd49cb2..3f5ee24faaf 100644 --- a/phpdbg_wait.c +++ b/phpdbg_wait.c @@ -366,7 +366,6 @@ void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) { PHPDBG_COMMAND(wait) /* {{{ */ { -#ifdef HAVE_JSON struct sockaddr_un local, remote; int rlen, sr, sl; unlink(PHPDBG_G(socket_path)); @@ -418,5 +417,4 @@ PHPDBG_COMMAND(wait) /* {{{ */ phpdbg_notice("wait", "import=\"success\"", "Successfully imported request data, stopped before executing"); return SUCCESS; -#endif } /* }}} */ From beb767dbe09dbb9cd65d5d1562b1f14e9b420911 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 23:06:50 +0100 Subject: [PATCH 170/398] Merge phpdbg into PHP-5.6 --- phpdbg_wait.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/phpdbg_wait.c b/phpdbg_wait.c index a8c7dd49cb2..3f5ee24faaf 100644 --- a/phpdbg_wait.c +++ b/phpdbg_wait.c @@ -366,7 +366,6 @@ void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) { PHPDBG_COMMAND(wait) /* {{{ */ { -#ifdef HAVE_JSON struct sockaddr_un local, remote; int rlen, sr, sl; unlink(PHPDBG_G(socket_path)); @@ -418,5 +417,4 @@ PHPDBG_COMMAND(wait) /* {{{ */ phpdbg_notice("wait", "import=\"success\"", "Successfully imported request data, stopped before executing"); return SUCCESS; -#endif } /* }}} */ From 47fd168fede896f2e2f6752d7ffef67232b331f4 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 23:07:36 +0100 Subject: [PATCH 171/398] Move missing zend_hash_* macros from phpdbg.h to zend_hash.h --- Zend/zend_hash.h | 18 ++++++++++++++++++ sapi/phpdbg/phpdbg.h | 18 ------------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index 2b9beca0fcc..0ed47b424d5 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -539,6 +539,19 @@ static zend_always_inline void *zend_hash_index_update_ptr(HashTable *ht, zend_u return zv ? Z_PTR_P(zv) : NULL; } +static zend_always_inline void *zend_hash_index_add_mem(HashTable *ht, zend_ulong h, void *pData, size_t size) +{ + zval tmp, *zv; + + ZVAL_PTR(&tmp, NULL); + if ((zv = zend_hash_index_add(ht, h, &tmp))) { + Z_PTR_P(zv) = pemalloc(size, ht->u.flags & HASH_FLAG_PERSISTENT); + memcpy(Z_PTR_P(zv), pData, size); + return Z_PTR_P(zv); + } + return NULL; +} + static zend_always_inline void *zend_hash_next_index_insert_ptr(HashTable *ht, void *pData) { zval tmp, *zv; @@ -696,6 +709,11 @@ static zend_always_inline void *zend_hash_get_current_data_ptr_ex(HashTable *ht, _key = _p->key; \ _val = _z; +#define ZEND_HASH_FOREACH_NUM_KEY_PTR(ht, _h, _ptr) \ + ZEND_HASH_FOREACH(ht, 0); \ + _h = _p->h; \ + _ptr = Z_PTR_P(_z); + #define ZEND_HASH_FOREACH_STR_KEY_PTR(ht, _key, _ptr) \ ZEND_HASH_FOREACH(ht, 0); \ _key = _p->key; \ diff --git a/sapi/phpdbg/phpdbg.h b/sapi/phpdbg/phpdbg.h index 188431c99af..60d1239a277 100644 --- a/sapi/phpdbg/phpdbg.h +++ b/sapi/phpdbg/phpdbg.h @@ -70,29 +70,11 @@ # include "TSRM.h" #endif -#define ZEND_HASH_FOREACH_NUM_KEY_PTR(ht, _h, _ptr) \ - ZEND_HASH_FOREACH(ht, 0); \ - _h = _p->h; \ - _ptr = Z_PTR_P(_z); - #undef zend_hash_str_add #define zend_hash_str_add_tmp(ht, key, len, pData) \ _zend_hash_str_add(ht, key, len, pData ZEND_FILE_LINE_CC) #define zend_hash_str_add(...) zend_hash_str_add_tmp(__VA_ARGS__) -static zend_always_inline void *zend_hash_index_add_mem(HashTable *ht, zend_ulong h, void *pData, size_t size) -{ - zval tmp, *zv; - - ZVAL_PTR(&tmp, NULL); - if ((zv = zend_hash_index_add(ht, h, &tmp))) { - Z_PTR_P(zv) = pemalloc(size, ht->u.flags & HASH_FLAG_PERSISTENT); - memcpy(Z_PTR_P(zv), pData, size); - return Z_PTR_P(zv); - } - return NULL; -} - #ifdef HAVE_LIBREADLINE # include # include From 7dd871438fec9eaccf06c235faba1f51ff2967da Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 29 Oct 2014 07:26:41 +0100 Subject: [PATCH 172/398] cleanup uneeded json --- sapi/phpdbg/phpdbg_wait.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sapi/phpdbg/phpdbg_wait.c b/sapi/phpdbg/phpdbg_wait.c index 3f5ee24faaf..95024b8d77f 100644 --- a/sapi/phpdbg/phpdbg_wait.c +++ b/sapi/phpdbg/phpdbg_wait.c @@ -22,7 +22,6 @@ #include "ext/standard/basic_functions.h" ZEND_EXTERN_MODULE_GLOBALS(phpdbg); -ZEND_EXTERN_MODULE_GLOBALS(json); static void phpdbg_rebuild_http_globals_array(int type, const char *name TSRMLS_DC) { zval **zvpp; From 89e613cf01b1a57da3ee4431b43296bd92342397 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 29 Oct 2014 07:26:41 +0100 Subject: [PATCH 173/398] cleanup uneeded json --- phpdbg_wait.c | 1 - 1 file changed, 1 deletion(-) diff --git a/phpdbg_wait.c b/phpdbg_wait.c index 3f5ee24faaf..95024b8d77f 100644 --- a/phpdbg_wait.c +++ b/phpdbg_wait.c @@ -22,7 +22,6 @@ #include "ext/standard/basic_functions.h" ZEND_EXTERN_MODULE_GLOBALS(phpdbg); -ZEND_EXTERN_MODULE_GLOBALS(json); static void phpdbg_rebuild_http_globals_array(int type, const char *name TSRMLS_DC) { zval **zvpp; From 919bd3eb0cafb33c6002c32c5458392093700d68 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Wed, 29 Oct 2014 11:28:09 +0100 Subject: [PATCH 174/398] Enable shared builds for webhelper --- phpdbg_rinit_hook.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpdbg_rinit_hook.c b/phpdbg_rinit_hook.c index 049a782d9dc..acbdfb6f258 100644 --- a/phpdbg_rinit_hook.c +++ b/phpdbg_rinit_hook.c @@ -99,3 +99,7 @@ zend_module_entry phpdbg_webhelper_module_entry = { PHPDBG_VERSION, STANDARD_MODULE_PROPERTIES }; + +#ifdef COMPILE_DL_PHPDBG_WEBHELPER +ZEND_GET_MODULE(phpdbg_webhelper) +#endif From daf9357d272c810718aceae57e6e77cdc62e1be8 Mon Sep 17 00:00:00 2001 From: Matteo Beccati Date: Wed, 29 Oct 2014 11:26:22 +0100 Subject: [PATCH 175/398] Fixed test to work with recent libcurl versions --- ext/standard/tests/file/bug52820.phpt | 134 ++++++++++++-------------- 1 file changed, 63 insertions(+), 71 deletions(-) diff --git a/ext/standard/tests/file/bug52820.phpt b/ext/standard/tests/file/bug52820.phpt index 3a9f9c31a46..a00ebf50b63 100644 --- a/ext/standard/tests/file/bug52820.phpt +++ b/ext/standard/tests/file/bug52820.phpt @@ -1,71 +1,63 @@ ---TEST-- -Bug #52820 (writes to fopencookie FILE* not committed when seeking the stream) ---SKIPIF-- - Date: Wed, 29 Oct 2014 14:32:41 +0100 Subject: [PATCH 176/398] Don't treat warnings as failures in the junit output This matches Travis and the actual return code. --- run-tests.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/run-tests.php b/run-tests.php index cc20febf71d..5563385ddf9 100755 --- a/run-tests.php +++ b/run-tests.php @@ -2714,7 +2714,7 @@ function junit_mark_test_as($type, $file_name, $test_name, $time = null, $messag if (is_array($type)) { $output_type = $type[0] . 'ED'; - $temp = array_intersect(array('XFAIL', 'FAIL'), $type); + $temp = array_intersect(array('XFAIL', 'FAIL', 'WARN'), $type); $type = reset($temp); } else { $output_type = $type . 'ED'; @@ -2728,6 +2728,9 @@ function junit_mark_test_as($type, $file_name, $test_name, $time = null, $messag } elseif ('SKIP' == $type) { junit_suite_record($suite, 'test_skip'); $JUNIT['files'][$file_name]['xml'] .= "$escaped_message\n"; + } elseif ('WARN' == $type) { + junit_suite_record($suite, 'test_warn'); + $JUNIT['files'][$file_name]['xml'] .= "$escaped_message\n"; } elseif('FAIL' == $type) { junit_suite_record($suite, 'test_fail'); $JUNIT['files'][$file_name]['xml'] .= "$escaped_details\n"; From abfb30dc67dfbfb3d3abaa502faa29ef9d82c459 Mon Sep 17 00:00:00 2001 From: Matteo Beccati Date: Wed, 29 Oct 2014 14:32:41 +0100 Subject: [PATCH 177/398] Don't treat warnings as failures in the junit output This matches Travis and the actual return code. --- run-tests.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/run-tests.php b/run-tests.php index 4f29345d9fd..17930b29bc1 100755 --- a/run-tests.php +++ b/run-tests.php @@ -2724,7 +2724,7 @@ function junit_mark_test_as($type, $file_name, $test_name, $time = null, $messag if (is_array($type)) { $output_type = $type[0] . 'ED'; - $temp = array_intersect(array('XFAIL', 'FAIL'), $type); + $temp = array_intersect(array('XFAIL', 'FAIL', 'WARN'), $type); $type = reset($temp); } else { $output_type = $type . 'ED'; @@ -2738,6 +2738,9 @@ function junit_mark_test_as($type, $file_name, $test_name, $time = null, $messag } elseif ('SKIP' == $type) { junit_suite_record($suite, 'test_skip'); $JUNIT['files'][$file_name]['xml'] .= "$escaped_message\n"; + } elseif ('WARN' == $type) { + junit_suite_record($suite, 'test_warn'); + $JUNIT['files'][$file_name]['xml'] .= "$escaped_message\n"; } elseif('FAIL' == $type) { junit_suite_record($suite, 'test_fail'); $JUNIT['files'][$file_name]['xml'] .= "$escaped_details\n"; From 8bd58502ca39d65df45c0020a4d5165072397199 Mon Sep 17 00:00:00 2001 From: Matteo Beccati Date: Wed, 29 Oct 2014 14:32:41 +0100 Subject: [PATCH 178/398] Don't treat warnings as failures in the junit output This matches Travis and the actual return code. --- run-tests.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/run-tests.php b/run-tests.php index 1b5bcec2532..315ae09200a 100755 --- a/run-tests.php +++ b/run-tests.php @@ -2718,7 +2718,7 @@ function junit_mark_test_as($type, $file_name, $test_name, $time = null, $messag if (is_array($type)) { $output_type = $type[0] . 'ED'; - $temp = array_intersect(array('XFAIL', 'FAIL'), $type); + $temp = array_intersect(array('XFAIL', 'FAIL', 'WARN'), $type); $type = reset($temp); } else { $output_type = $type . 'ED'; @@ -2732,6 +2732,9 @@ function junit_mark_test_as($type, $file_name, $test_name, $time = null, $messag } elseif ('SKIP' == $type) { junit_suite_record($suite, 'test_skip'); $JUNIT['files'][$file_name]['xml'] .= "$escaped_message\n"; + } elseif ('WARN' == $type) { + junit_suite_record($suite, 'test_warn'); + $JUNIT['files'][$file_name]['xml'] .= "$escaped_message\n"; } elseif('FAIL' == $type) { junit_suite_record($suite, 'test_fail'); $JUNIT['files'][$file_name]['xml'] .= "$escaped_details\n"; From d9d16d2e68c897fe02848e96623aaa73d170fb39 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 28 Oct 2014 18:43:22 +0100 Subject: [PATCH 179/398] fix datatype mismatch warnings --- Zend/zend_ini_parser.y | 6 +- Zend/zend_ini_scanner.c | 4 +- Zend/zend_ini_scanner.l | 4 +- Zend/zend_language_parser.y | 2 +- Zend/zend_language_scanner.c | 700 ++++++++++++++++++----------------- Zend/zend_language_scanner.l | 12 +- 6 files changed, 366 insertions(+), 362 deletions(-) diff --git a/Zend/zend_ini_parser.y b/Zend/zend_ini_parser.y index e343fcd92a3..90e0fdc0076 100644 --- a/Zend/zend_ini_parser.y +++ b/Zend/zend_ini_parser.y @@ -99,8 +99,8 @@ static void zend_ini_init_string(zval *result) */ static void zend_ini_add_string(zval *result, zval *op1, zval *op2) { - int op1_len = Z_STRLEN_P(op1); - int length = op1_len + Z_STRLEN_P(op2); + int op1_len = (int)Z_STRLEN_P(op1); + int length = op1_len + (int)Z_STRLEN_P(op2); ZVAL_NEW_STR(result, zend_string_realloc(Z_STR_P(op1), length, 1)); memcpy(Z_STRVAL_P(result)+op1_len, Z_STRVAL_P(op2), Z_STRLEN_P(op2)); @@ -168,7 +168,7 @@ static void ini_error(const char *msg) currently_parsed_filename = zend_ini_scanner_get_filename(TSRMLS_C); if (currently_parsed_filename) { - error_buf_len = 128 + strlen(msg) + strlen(currently_parsed_filename); /* should be more than enough */ + error_buf_len = 128 + (int)strlen(msg) + (int)strlen(currently_parsed_filename); /* should be more than enough */ error_buf = (char *) emalloc(error_buf_len); sprintf(error_buf, "%s in %s on line %d\n", msg, currently_parsed_filename, zend_ini_scanner_get_lineno(TSRMLS_C)); diff --git a/Zend/zend_ini_scanner.c b/Zend/zend_ini_scanner.c index 2abf1140fcd..61e7575dadc 100644 --- a/Zend/zend_ini_scanner.c +++ b/Zend/zend_ini_scanner.c @@ -283,7 +283,7 @@ int zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode TSRML return FAILURE; } - yy_scan_buffer(buf, size TSRMLS_CC); + yy_scan_buffer(buf, (unsigned int)size TSRMLS_CC); return SUCCESS; } @@ -293,7 +293,7 @@ int zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode TSRML */ int zend_ini_prepare_string_for_scanning(char *str, int scanner_mode TSRMLS_DC) { - int len = strlen(str); + int len = (int)strlen(str); if (init_ini_scanner(scanner_mode, NULL TSRMLS_CC) == FAILURE) { return FAILURE; diff --git a/Zend/zend_ini_scanner.l b/Zend/zend_ini_scanner.l index 3bfb1557b10..79d82764b18 100644 --- a/Zend/zend_ini_scanner.l +++ b/Zend/zend_ini_scanner.l @@ -281,7 +281,7 @@ int zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode TSRML return FAILURE; } - yy_scan_buffer(buf, size TSRMLS_CC); + yy_scan_buffer(buf, (unsigned int)size TSRMLS_CC); return SUCCESS; } @@ -291,7 +291,7 @@ int zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode TSRML */ int zend_ini_prepare_string_for_scanning(char *str, int scanner_mode TSRMLS_DC) { - int len = strlen(str); + int len = (int)strlen(str); if (init_ini_scanner(scanner_mode, NULL TSRMLS_CC) == FAILURE) { return FAILURE; diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index 97fc4de5464..d25e1d2e07b 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -1187,7 +1187,7 @@ static YYSIZE_T zend_yytnamerr(char *yyres, const char *yystr) str = LANG_SCNG(yy_text); end = memchr(str, '\n', LANG_SCNG(yy_leng)); - yystr_len = yystrlen(yystr); + yystr_len = (unsigned int)yystrlen(yystr); if ((tok1 = memchr(yystr, '(', yystr_len)) != NULL && (tok2 = zend_memrchr(yystr, ')', yystr_len)) != NULL) { diff --git a/Zend/zend_language_scanner.c b/Zend/zend_language_scanner.c index 034369a4c23..7a7c04b0d29 100644 --- a/Zend/zend_language_scanner.c +++ b/Zend/zend_language_scanner.c @@ -286,7 +286,8 @@ static const zend_encoding *zend_multibyte_detect_utf_encoding(const unsigned ch /* utf-16 or utf-32? */ p = script; - while ((p-script) < script_size) { + assert(p >= script); + while ((size_t)(p-script) < script_size) { p = memchr(p, 0, script_size-(p-script)-2); if (!p) { break; @@ -302,7 +303,8 @@ static const zend_encoding *zend_multibyte_detect_utf_encoding(const unsigned ch /* BE or LE? */ p = script; - while ((p-script) < script_size) { + assert(p >= script); + while ((size_t)(p-script) < script_size) { if (*p == '\0' && *(p+wchar_size-1) != '\0') { /* BE */ le = 0; @@ -522,7 +524,7 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC) } } SCNG(yy_start) = (unsigned char *)buf - offset; - yy_scan_buffer(buf, size TSRMLS_CC); + yy_scan_buffer(buf, (unsigned int)size TSRMLS_CC); } else { zend_error_noreturn(E_COMPILE_ERROR, "zend_stream_mmap() failed"); } @@ -683,7 +685,7 @@ ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_D } } - yy_scan_buffer(buf, size TSRMLS_CC); + yy_scan_buffer(buf, (unsigned int)size TSRMLS_CC); new_compiled_filename = zend_string_init(filename, strlen(filename), 0); zend_set_compiled_filename(new_compiled_filename TSRMLS_CC); @@ -992,7 +994,7 @@ restart: SCNG(yy_text) = YYCURSOR; -#line 996 "Zend/zend_language_scanner.c" +#line 998 "Zend/zend_language_scanner.c" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -1046,7 +1048,7 @@ yyc_INITIAL: yy3: YYDEBUG(3, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1631 "Zend/zend_language_scanner.l" +#line 1633 "Zend/zend_language_scanner.l" { if (YYCURSOR > YYLIMIT) { return 0; @@ -1075,7 +1077,7 @@ inline_char_handler: yyleng = YYCURSOR - SCNG(yy_text); if (SCNG(output_filter)) { - int readsize; + size_t readsize; char *s = NULL; size_t sz = 0; // TODO: avoid reallocation ??? @@ -1091,7 +1093,7 @@ inline_char_handler: HANDLE_NEWLINES(yytext, yyleng); return T_INLINE_HTML; } -#line 1095 "Zend/zend_language_scanner.c" +#line 1097 "Zend/zend_language_scanner.c" yy4: YYDEBUG(4, *YYCURSOR); yych = *++YYCURSOR; @@ -1109,7 +1111,7 @@ yy5: yy6: YYDEBUG(6, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1622 "Zend/zend_language_scanner.l" +#line 1624 "Zend/zend_language_scanner.l" { if (CG(short_tags)) { BEGIN(ST_IN_SCRIPTING); @@ -1118,18 +1120,18 @@ yy6: goto inline_char_handler; } } -#line 1122 "Zend/zend_language_scanner.c" +#line 1124 "Zend/zend_language_scanner.c" yy7: YYDEBUG(7, *YYCURSOR); ++YYCURSOR; YYDEBUG(8, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1609 "Zend/zend_language_scanner.l" +#line 1611 "Zend/zend_language_scanner.l" { BEGIN(ST_IN_SCRIPTING); return T_OPEN_TAG_WITH_ECHO; } -#line 1133 "Zend/zend_language_scanner.c" +#line 1135 "Zend/zend_language_scanner.c" yy9: YYDEBUG(9, *YYCURSOR); yych = *++YYCURSOR; @@ -1160,13 +1162,13 @@ yy13: yy14: YYDEBUG(14, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1615 "Zend/zend_language_scanner.l" +#line 1617 "Zend/zend_language_scanner.l" { HANDLE_NEWLINE(yytext[yyleng-1]); BEGIN(ST_IN_SCRIPTING); return T_OPEN_TAG; } -#line 1170 "Zend/zend_language_scanner.c" +#line 1172 "Zend/zend_language_scanner.c" yy15: YYDEBUG(15, *YYCURSOR); ++YYCURSOR; @@ -1236,7 +1238,7 @@ yyc_ST_BACKQUOTE: yy19: YYDEBUG(19, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2042 "Zend/zend_language_scanner.l" +#line 2044 "Zend/zend_language_scanner.l" { if (YYCURSOR > YYLIMIT) { return 0; @@ -1277,7 +1279,7 @@ yy19: zend_scan_escape_string(zendlval, yytext, yyleng, '`' TSRMLS_CC); return T_ENCAPSED_AND_WHITESPACE; } -#line 1281 "Zend/zend_language_scanner.c" +#line 1283 "Zend/zend_language_scanner.c" yy20: YYDEBUG(20, *YYCURSOR); yych = *++YYCURSOR; @@ -1288,12 +1290,12 @@ yy21: ++YYCURSOR; YYDEBUG(22, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1986 "Zend/zend_language_scanner.l" +#line 1988 "Zend/zend_language_scanner.l" { BEGIN(ST_IN_SCRIPTING); return '`'; } -#line 1297 "Zend/zend_language_scanner.c" +#line 1299 "Zend/zend_language_scanner.c" yy23: YYDEBUG(23, *YYCURSOR); yych = *++YYCURSOR; @@ -1303,14 +1305,14 @@ yy24: ++YYCURSOR; YYDEBUG(25, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1973 "Zend/zend_language_scanner.l" +#line 1975 "Zend/zend_language_scanner.l" { Z_LVAL_P(zendlval) = (zend_long) '{'; yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); yyless(1); return T_CURLY_OPEN; } -#line 1314 "Zend/zend_language_scanner.c" +#line 1316 "Zend/zend_language_scanner.c" yy26: YYDEBUG(26, *YYCURSOR); yyaccept = 0; @@ -1326,23 +1328,23 @@ yy26: yy28: YYDEBUG(28, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1696 "Zend/zend_language_scanner.l" +#line 1698 "Zend/zend_language_scanner.l" { zend_copy_value(zendlval, (yytext+1), (yyleng-1)); return T_VARIABLE; } -#line 1335 "Zend/zend_language_scanner.c" +#line 1337 "Zend/zend_language_scanner.c" yy29: YYDEBUG(29, *YYCURSOR); ++YYCURSOR; YYDEBUG(30, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1462 "Zend/zend_language_scanner.l" +#line 1464 "Zend/zend_language_scanner.l" { yy_push_state(ST_LOOKING_FOR_VARNAME TSRMLS_CC); return T_DOLLAR_OPEN_CURLY_BRACES; } -#line 1346 "Zend/zend_language_scanner.c" +#line 1348 "Zend/zend_language_scanner.c" yy31: YYDEBUG(31, *YYCURSOR); yych = *++YYCURSOR; @@ -1356,14 +1358,14 @@ yy33: ++YYCURSOR; YYDEBUG(34, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1689 "Zend/zend_language_scanner.l" +#line 1691 "Zend/zend_language_scanner.l" { yyless(yyleng - 1); yy_push_state(ST_VAR_OFFSET TSRMLS_CC); zend_copy_value(zendlval, (yytext+1), (yyleng-1)); return T_VARIABLE; } -#line 1367 "Zend/zend_language_scanner.c" +#line 1369 "Zend/zend_language_scanner.c" yy35: YYDEBUG(35, *YYCURSOR); yych = *++YYCURSOR; @@ -1381,14 +1383,14 @@ yy36: ++YYCURSOR; YYDEBUG(37, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1680 "Zend/zend_language_scanner.l" +#line 1682 "Zend/zend_language_scanner.l" { yyless(yyleng - 3); yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC); zend_copy_value(zendlval, (yytext+1), (yyleng-1)); return T_VARIABLE; } -#line 1392 "Zend/zend_language_scanner.c" +#line 1394 "Zend/zend_language_scanner.c" } /* *********************************** */ yyc_ST_DOUBLE_QUOTES: @@ -1456,7 +1458,7 @@ yy40: yy41: YYDEBUG(41, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1992 "Zend/zend_language_scanner.l" +#line 1994 "Zend/zend_language_scanner.l" { if (GET_DOUBLE_QUOTES_SCANNED_LENGTH()) { YYCURSOR += GET_DOUBLE_QUOTES_SCANNED_LENGTH() - 1; @@ -1505,7 +1507,7 @@ double_quotes_scan_done: zend_scan_escape_string(zendlval, yytext, yyleng, '"' TSRMLS_CC); return T_ENCAPSED_AND_WHITESPACE; } -#line 1509 "Zend/zend_language_scanner.c" +#line 1511 "Zend/zend_language_scanner.c" yy42: YYDEBUG(42, *YYCURSOR); yych = *++YYCURSOR; @@ -1516,12 +1518,12 @@ yy43: ++YYCURSOR; YYDEBUG(44, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1981 "Zend/zend_language_scanner.l" +#line 1983 "Zend/zend_language_scanner.l" { BEGIN(ST_IN_SCRIPTING); return '"'; } -#line 1525 "Zend/zend_language_scanner.c" +#line 1527 "Zend/zend_language_scanner.c" yy45: YYDEBUG(45, *YYCURSOR); yych = *++YYCURSOR; @@ -1531,14 +1533,14 @@ yy46: ++YYCURSOR; YYDEBUG(47, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1973 "Zend/zend_language_scanner.l" +#line 1975 "Zend/zend_language_scanner.l" { Z_LVAL_P(zendlval) = (zend_long) '{'; yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); yyless(1); return T_CURLY_OPEN; } -#line 1542 "Zend/zend_language_scanner.c" +#line 1544 "Zend/zend_language_scanner.c" yy48: YYDEBUG(48, *YYCURSOR); yyaccept = 0; @@ -1554,23 +1556,23 @@ yy48: yy50: YYDEBUG(50, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1696 "Zend/zend_language_scanner.l" +#line 1698 "Zend/zend_language_scanner.l" { zend_copy_value(zendlval, (yytext+1), (yyleng-1)); return T_VARIABLE; } -#line 1563 "Zend/zend_language_scanner.c" +#line 1565 "Zend/zend_language_scanner.c" yy51: YYDEBUG(51, *YYCURSOR); ++YYCURSOR; YYDEBUG(52, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1462 "Zend/zend_language_scanner.l" +#line 1464 "Zend/zend_language_scanner.l" { yy_push_state(ST_LOOKING_FOR_VARNAME TSRMLS_CC); return T_DOLLAR_OPEN_CURLY_BRACES; } -#line 1574 "Zend/zend_language_scanner.c" +#line 1576 "Zend/zend_language_scanner.c" yy53: YYDEBUG(53, *YYCURSOR); yych = *++YYCURSOR; @@ -1584,14 +1586,14 @@ yy55: ++YYCURSOR; YYDEBUG(56, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1689 "Zend/zend_language_scanner.l" +#line 1691 "Zend/zend_language_scanner.l" { yyless(yyleng - 1); yy_push_state(ST_VAR_OFFSET TSRMLS_CC); zend_copy_value(zendlval, (yytext+1), (yyleng-1)); return T_VARIABLE; } -#line 1595 "Zend/zend_language_scanner.c" +#line 1597 "Zend/zend_language_scanner.c" yy57: YYDEBUG(57, *YYCURSOR); yych = *++YYCURSOR; @@ -1609,14 +1611,14 @@ yy58: ++YYCURSOR; YYDEBUG(59, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1680 "Zend/zend_language_scanner.l" +#line 1682 "Zend/zend_language_scanner.l" { yyless(yyleng - 3); yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC); zend_copy_value(zendlval, (yytext+1), (yyleng-1)); return T_VARIABLE; } -#line 1620 "Zend/zend_language_scanner.c" +#line 1622 "Zend/zend_language_scanner.c" } /* *********************************** */ yyc_ST_END_HEREDOC: @@ -1627,7 +1629,7 @@ yyc_ST_END_HEREDOC: ++YYCURSOR; YYDEBUG(63, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1959 "Zend/zend_language_scanner.l" +#line 1961 "Zend/zend_language_scanner.l" { zend_heredoc_label *heredoc_label = zend_ptr_stack_pop(&SCNG(heredoc_label_stack)); @@ -1640,7 +1642,7 @@ yyc_ST_END_HEREDOC: BEGIN(ST_IN_SCRIPTING); return T_END_HEREDOC; } -#line 1644 "Zend/zend_language_scanner.c" +#line 1646 "Zend/zend_language_scanner.c" /* *********************************** */ yyc_ST_HEREDOC: { @@ -1702,7 +1704,7 @@ yy66: yy67: YYDEBUG(67, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2084 "Zend/zend_language_scanner.l" +#line 2086 "Zend/zend_language_scanner.l" { int newline = 0; @@ -1775,7 +1777,7 @@ heredoc_scan_done: zend_scan_escape_string(zendlval, yytext, yyleng - newline, 0 TSRMLS_CC); return T_ENCAPSED_AND_WHITESPACE; } -#line 1779 "Zend/zend_language_scanner.c" +#line 1781 "Zend/zend_language_scanner.c" yy68: YYDEBUG(68, *YYCURSOR); yych = *++YYCURSOR; @@ -1790,14 +1792,14 @@ yy70: ++YYCURSOR; YYDEBUG(71, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1973 "Zend/zend_language_scanner.l" +#line 1975 "Zend/zend_language_scanner.l" { Z_LVAL_P(zendlval) = (zend_long) '{'; yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); yyless(1); return T_CURLY_OPEN; } -#line 1801 "Zend/zend_language_scanner.c" +#line 1803 "Zend/zend_language_scanner.c" yy72: YYDEBUG(72, *YYCURSOR); yyaccept = 0; @@ -1813,23 +1815,23 @@ yy72: yy74: YYDEBUG(74, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1696 "Zend/zend_language_scanner.l" +#line 1698 "Zend/zend_language_scanner.l" { zend_copy_value(zendlval, (yytext+1), (yyleng-1)); return T_VARIABLE; } -#line 1822 "Zend/zend_language_scanner.c" +#line 1824 "Zend/zend_language_scanner.c" yy75: YYDEBUG(75, *YYCURSOR); ++YYCURSOR; YYDEBUG(76, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1462 "Zend/zend_language_scanner.l" +#line 1464 "Zend/zend_language_scanner.l" { yy_push_state(ST_LOOKING_FOR_VARNAME TSRMLS_CC); return T_DOLLAR_OPEN_CURLY_BRACES; } -#line 1833 "Zend/zend_language_scanner.c" +#line 1835 "Zend/zend_language_scanner.c" yy77: YYDEBUG(77, *YYCURSOR); yych = *++YYCURSOR; @@ -1843,14 +1845,14 @@ yy79: ++YYCURSOR; YYDEBUG(80, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1689 "Zend/zend_language_scanner.l" +#line 1691 "Zend/zend_language_scanner.l" { yyless(yyleng - 1); yy_push_state(ST_VAR_OFFSET TSRMLS_CC); zend_copy_value(zendlval, (yytext+1), (yyleng-1)); return T_VARIABLE; } -#line 1854 "Zend/zend_language_scanner.c" +#line 1856 "Zend/zend_language_scanner.c" yy81: YYDEBUG(81, *YYCURSOR); yych = *++YYCURSOR; @@ -1868,14 +1870,14 @@ yy82: ++YYCURSOR; YYDEBUG(83, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1680 "Zend/zend_language_scanner.l" +#line 1682 "Zend/zend_language_scanner.l" { yyless(yyleng - 3); yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC); zend_copy_value(zendlval, (yytext+1), (yyleng-1)); return T_VARIABLE; } -#line 1879 "Zend/zend_language_scanner.c" +#line 1881 "Zend/zend_language_scanner.c" } /* *********************************** */ yyc_ST_IN_SCRIPTING: @@ -2058,12 +2060,12 @@ yy86: yy87: YYDEBUG(87, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1719 "Zend/zend_language_scanner.l" +#line 1721 "Zend/zend_language_scanner.l" { zend_copy_value(zendlval, yytext, yyleng); return T_STRING; } -#line 2067 "Zend/zend_language_scanner.c" +#line 2069 "Zend/zend_language_scanner.c" yy88: YYDEBUG(88, *YYCURSOR); yych = *++YYCURSOR; @@ -2295,11 +2297,11 @@ yy101: yy102: YYDEBUG(102, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1451 "Zend/zend_language_scanner.l" +#line 1453 "Zend/zend_language_scanner.l" { return yytext[0]; } -#line 2303 "Zend/zend_language_scanner.c" +#line 2305 "Zend/zend_language_scanner.c" yy103: YYDEBUG(103, *YYCURSOR); ++YYCURSOR; @@ -2308,12 +2310,12 @@ yy103: yy104: YYDEBUG(104, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1170 "Zend/zend_language_scanner.l" +#line 1172 "Zend/zend_language_scanner.l" { HANDLE_NEWLINES(yytext, yyleng); return T_WHITESPACE; } -#line 2317 "Zend/zend_language_scanner.c" +#line 2319 "Zend/zend_language_scanner.c" yy105: YYDEBUG(105, *YYCURSOR); yych = *++YYCURSOR; @@ -2324,11 +2326,11 @@ yy106: ++YYCURSOR; YYDEBUG(107, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1195 "Zend/zend_language_scanner.l" +#line 1197 "Zend/zend_language_scanner.l" { return T_NS_SEPARATOR; } -#line 2332 "Zend/zend_language_scanner.c" +#line 2334 "Zend/zend_language_scanner.c" yy108: YYDEBUG(108, *YYCURSOR); yyaccept = 1; @@ -2557,18 +2559,18 @@ yy131: ++YYCURSOR; YYDEBUG(132, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1456 "Zend/zend_language_scanner.l" +#line 1458 "Zend/zend_language_scanner.l" { yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); return '{'; } -#line 2566 "Zend/zend_language_scanner.c" +#line 2568 "Zend/zend_language_scanner.c" yy133: YYDEBUG(133, *YYCURSOR); ++YYCURSOR; YYDEBUG(134, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1468 "Zend/zend_language_scanner.l" +#line 1470 "Zend/zend_language_scanner.l" { RESET_DOC_COMMENT(); if (!zend_stack_is_empty(&SCNG(state_stack))) { @@ -2576,7 +2578,7 @@ yy133: } return '}'; } -#line 2580 "Zend/zend_language_scanner.c" +#line 2582 "Zend/zend_language_scanner.c" yy135: YYDEBUG(135, *YYCURSOR); yyaccept = 2; @@ -2604,7 +2606,7 @@ yy135: yy136: YYDEBUG(136, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1516 "Zend/zend_language_scanner.l" +#line 1518 "Zend/zend_language_scanner.l" { if (yyleng < MAX_LENGTH_OF_LONG - 1) { /* Won't overflow */ ZVAL_LONG(zendlval, ZEND_STRTOL(yytext, NULL, 0)); @@ -2622,7 +2624,7 @@ yy136: } return T_LNUMBER; } -#line 2626 "Zend/zend_language_scanner.c" +#line 2628 "Zend/zend_language_scanner.c" yy137: YYDEBUG(137, *YYCURSOR); yyaccept = 2; @@ -2650,7 +2652,7 @@ yy139: yy140: YYDEBUG(140, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1725 "Zend/zend_language_scanner.l" +#line 1727 "Zend/zend_language_scanner.l" { while (YYCURSOR < YYLIMIT) { switch (*YYCURSOR++) { @@ -2679,14 +2681,14 @@ yy140: return T_COMMENT; } -#line 2683 "Zend/zend_language_scanner.c" +#line 2685 "Zend/zend_language_scanner.c" yy141: YYDEBUG(141, *YYCURSOR); ++YYCURSOR; yy142: YYDEBUG(142, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1793 "Zend/zend_language_scanner.l" +#line 1795 "Zend/zend_language_scanner.l" { register char *s, *t; char *end; @@ -2755,14 +2757,14 @@ yy142: } return T_CONSTANT_ENCAPSED_STRING; } -#line 2759 "Zend/zend_language_scanner.c" +#line 2761 "Zend/zend_language_scanner.c" yy143: YYDEBUG(143, *YYCURSOR); ++YYCURSOR; yy144: YYDEBUG(144, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1863 "Zend/zend_language_scanner.l" +#line 1865 "Zend/zend_language_scanner.l" { int bprefix = (yytext[0] != '"') ? 1 : 0; @@ -2803,24 +2805,24 @@ yy144: BEGIN(ST_DOUBLE_QUOTES); return '"'; } -#line 2807 "Zend/zend_language_scanner.c" +#line 2809 "Zend/zend_language_scanner.c" yy145: YYDEBUG(145, *YYCURSOR); ++YYCURSOR; YYDEBUG(146, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1953 "Zend/zend_language_scanner.l" +#line 1955 "Zend/zend_language_scanner.l" { BEGIN(ST_BACKQUOTE); return '`'; } -#line 2818 "Zend/zend_language_scanner.c" +#line 2820 "Zend/zend_language_scanner.c" yy147: YYDEBUG(147, *YYCURSOR); ++YYCURSOR; YYDEBUG(148, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2215 "Zend/zend_language_scanner.l" +#line 2217 "Zend/zend_language_scanner.l" { if (YYCURSOR > YYLIMIT) { return 0; @@ -2829,7 +2831,7 @@ yy147: zend_error(E_COMPILE_WARNING,"Unexpected character in input: '%c' (ASCII=%d) state=%d", yytext[0], yytext[0], YYSTATE); goto restart; } -#line 2833 "Zend/zend_language_scanner.c" +#line 2835 "Zend/zend_language_scanner.c" yy149: YYDEBUG(149, *YYCURSOR); ++YYCURSOR; @@ -2856,12 +2858,12 @@ yy151: yy153: YYDEBUG(153, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1571 "Zend/zend_language_scanner.l" +#line 1573 "Zend/zend_language_scanner.l" { ZVAL_DOUBLE(zendlval, zend_strtod(yytext, NULL)); return T_DNUMBER; } -#line 2865 "Zend/zend_language_scanner.c" +#line 2867 "Zend/zend_language_scanner.c" yy154: YYDEBUG(154, *YYCURSOR); yyaccept = 2; @@ -2953,7 +2955,7 @@ yy163: } YYDEBUG(165, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1493 "Zend/zend_language_scanner.l" +#line 1495 "Zend/zend_language_scanner.l" { char *bin = yytext + 2; /* Skip "0b" */ int len = yyleng - 2; @@ -2976,7 +2978,7 @@ yy163: return T_DNUMBER; } } -#line 2980 "Zend/zend_language_scanner.c" +#line 2982 "Zend/zend_language_scanner.c" yy166: YYDEBUG(166, *YYCURSOR); ++YYCURSOR; @@ -2988,7 +2990,7 @@ yy166: } YYDEBUG(168, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1534 "Zend/zend_language_scanner.l" +#line 1536 "Zend/zend_language_scanner.l" { char *hex = yytext + 2; /* Skip "0x" */ int len = yyleng - 2; @@ -3011,7 +3013,7 @@ yy166: return T_DNUMBER; } } -#line 3015 "Zend/zend_language_scanner.c" +#line 3017 "Zend/zend_language_scanner.c" yy169: YYDEBUG(169, *YYCURSOR); ++YYCURSOR; @@ -3036,12 +3038,12 @@ yy169: yy171: YYDEBUG(171, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1696 "Zend/zend_language_scanner.l" +#line 1698 "Zend/zend_language_scanner.l" { zend_copy_value(zendlval, (yytext+1), (yyleng-1)); return T_VARIABLE; } -#line 3045 "Zend/zend_language_scanner.c" +#line 3047 "Zend/zend_language_scanner.c" yy172: YYDEBUG(172, *YYCURSOR); yych = *++YYCURSOR; @@ -3055,11 +3057,11 @@ yy173: } YYDEBUG(174, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1439 "Zend/zend_language_scanner.l" +#line 1441 "Zend/zend_language_scanner.l" { return T_LOGICAL_XOR; } -#line 3063 "Zend/zend_language_scanner.c" +#line 3065 "Zend/zend_language_scanner.c" yy175: YYDEBUG(175, *YYCURSOR); ++YYCURSOR; @@ -3068,71 +3070,71 @@ yy175: } YYDEBUG(176, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1431 "Zend/zend_language_scanner.l" +#line 1433 "Zend/zend_language_scanner.l" { return T_LOGICAL_OR; } -#line 3076 "Zend/zend_language_scanner.c" +#line 3078 "Zend/zend_language_scanner.c" yy177: YYDEBUG(177, *YYCURSOR); ++YYCURSOR; YYDEBUG(178, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1419 "Zend/zend_language_scanner.l" +#line 1421 "Zend/zend_language_scanner.l" { return T_XOR_EQUAL; } -#line 3086 "Zend/zend_language_scanner.c" +#line 3088 "Zend/zend_language_scanner.c" yy179: YYDEBUG(179, *YYCURSOR); ++YYCURSOR; YYDEBUG(180, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1423 "Zend/zend_language_scanner.l" +#line 1425 "Zend/zend_language_scanner.l" { return T_BOOLEAN_OR; } -#line 3096 "Zend/zend_language_scanner.c" +#line 3098 "Zend/zend_language_scanner.c" yy181: YYDEBUG(181, *YYCURSOR); ++YYCURSOR; YYDEBUG(182, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1415 "Zend/zend_language_scanner.l" +#line 1417 "Zend/zend_language_scanner.l" { return T_OR_EQUAL; } -#line 3106 "Zend/zend_language_scanner.c" +#line 3108 "Zend/zend_language_scanner.c" yy183: YYDEBUG(183, *YYCURSOR); ++YYCURSOR; YYDEBUG(184, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1427 "Zend/zend_language_scanner.l" +#line 1429 "Zend/zend_language_scanner.l" { return T_BOOLEAN_AND; } -#line 3116 "Zend/zend_language_scanner.c" +#line 3118 "Zend/zend_language_scanner.c" yy185: YYDEBUG(185, *YYCURSOR); ++YYCURSOR; YYDEBUG(186, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1411 "Zend/zend_language_scanner.l" +#line 1413 "Zend/zend_language_scanner.l" { return T_AND_EQUAL; } -#line 3126 "Zend/zend_language_scanner.c" +#line 3128 "Zend/zend_language_scanner.c" yy187: YYDEBUG(187, *YYCURSOR); ++YYCURSOR; YYDEBUG(188, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1399 "Zend/zend_language_scanner.l" +#line 1401 "Zend/zend_language_scanner.l" { return T_MOD_EQUAL; } -#line 3136 "Zend/zend_language_scanner.c" +#line 3138 "Zend/zend_language_scanner.c" yy189: YYDEBUG(189, *YYCURSOR); yyaccept = 4; @@ -3141,7 +3143,7 @@ yy189: yy190: YYDEBUG(190, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1754 "Zend/zend_language_scanner.l" +#line 1756 "Zend/zend_language_scanner.l" { int doc_com; @@ -3174,7 +3176,7 @@ yy190: return T_COMMENT; } -#line 3178 "Zend/zend_language_scanner.c" +#line 3180 "Zend/zend_language_scanner.c" yy191: YYDEBUG(191, *YYCURSOR); yych = *++YYCURSOR; @@ -3184,11 +3186,11 @@ yy192: ++YYCURSOR; YYDEBUG(193, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1391 "Zend/zend_language_scanner.l" +#line 1393 "Zend/zend_language_scanner.l" { return T_DIV_EQUAL; } -#line 3192 "Zend/zend_language_scanner.c" +#line 3194 "Zend/zend_language_scanner.c" yy194: YYDEBUG(194, *YYCURSOR); yych = *++YYCURSOR; @@ -3212,62 +3214,62 @@ yy197: if ((yych = *YYCURSOR) == '=') goto yy201; YYDEBUG(198, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1383 "Zend/zend_language_scanner.l" +#line 1385 "Zend/zend_language_scanner.l" { return T_POW; } -#line 3220 "Zend/zend_language_scanner.c" +#line 3222 "Zend/zend_language_scanner.c" yy199: YYDEBUG(199, *YYCURSOR); ++YYCURSOR; YYDEBUG(200, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1379 "Zend/zend_language_scanner.l" +#line 1381 "Zend/zend_language_scanner.l" { return T_MUL_EQUAL; } -#line 3230 "Zend/zend_language_scanner.c" +#line 3232 "Zend/zend_language_scanner.c" yy201: YYDEBUG(201, *YYCURSOR); ++YYCURSOR; YYDEBUG(202, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1387 "Zend/zend_language_scanner.l" +#line 1389 "Zend/zend_language_scanner.l" { return T_POW_EQUAL; } -#line 3240 "Zend/zend_language_scanner.c" +#line 3242 "Zend/zend_language_scanner.c" yy203: YYDEBUG(203, *YYCURSOR); ++YYCURSOR; if ((yych = *YYCURSOR) == '=') goto yy207; YYDEBUG(204, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1447 "Zend/zend_language_scanner.l" +#line 1449 "Zend/zend_language_scanner.l" { return T_SR; } -#line 3251 "Zend/zend_language_scanner.c" +#line 3253 "Zend/zend_language_scanner.c" yy205: YYDEBUG(205, *YYCURSOR); ++YYCURSOR; YYDEBUG(206, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1367 "Zend/zend_language_scanner.l" +#line 1369 "Zend/zend_language_scanner.l" { return T_IS_GREATER_OR_EQUAL; } -#line 3261 "Zend/zend_language_scanner.c" +#line 3263 "Zend/zend_language_scanner.c" yy207: YYDEBUG(207, *YYCURSOR); ++YYCURSOR; YYDEBUG(208, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1407 "Zend/zend_language_scanner.l" +#line 1409 "Zend/zend_language_scanner.l" { return T_SR_EQUAL; } -#line 3271 "Zend/zend_language_scanner.c" +#line 3273 "Zend/zend_language_scanner.c" yy209: YYDEBUG(209, *YYCURSOR); yyaccept = 5; @@ -3278,42 +3280,42 @@ yy209: yy210: YYDEBUG(210, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1443 "Zend/zend_language_scanner.l" +#line 1445 "Zend/zend_language_scanner.l" { return T_SL; } -#line 3286 "Zend/zend_language_scanner.c" +#line 3288 "Zend/zend_language_scanner.c" yy211: YYDEBUG(211, *YYCURSOR); ++YYCURSOR; YYDEBUG(212, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1363 "Zend/zend_language_scanner.l" +#line 1365 "Zend/zend_language_scanner.l" { return T_IS_SMALLER_OR_EQUAL; } -#line 3296 "Zend/zend_language_scanner.c" +#line 3298 "Zend/zend_language_scanner.c" yy213: YYDEBUG(213, *YYCURSOR); ++YYCURSOR; yy214: YYDEBUG(214, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1359 "Zend/zend_language_scanner.l" +#line 1361 "Zend/zend_language_scanner.l" { return T_IS_NOT_EQUAL; } -#line 3307 "Zend/zend_language_scanner.c" +#line 3309 "Zend/zend_language_scanner.c" yy215: YYDEBUG(215, *YYCURSOR); ++YYCURSOR; YYDEBUG(216, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1403 "Zend/zend_language_scanner.l" +#line 1405 "Zend/zend_language_scanner.l" { return T_SL_EQUAL; } -#line 3317 "Zend/zend_language_scanner.c" +#line 3319 "Zend/zend_language_scanner.c" yy217: YYDEBUG(217, *YYCURSOR); ++YYCURSOR; @@ -3418,7 +3420,7 @@ yy226: yy227: YYDEBUG(227, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1905 "Zend/zend_language_scanner.l" +#line 1907 "Zend/zend_language_scanner.l" { char *s; int bprefix = (yytext[0] != '<') ? 1 : 0; @@ -3465,7 +3467,7 @@ yy227: return T_START_HEREDOC; } -#line 3469 "Zend/zend_language_scanner.c" +#line 3471 "Zend/zend_language_scanner.c" yy228: YYDEBUG(228, *YYCURSOR); yych = *++YYCURSOR; @@ -3505,31 +3507,31 @@ yy231: ++YYCURSOR; YYDEBUG(233, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1351 "Zend/zend_language_scanner.l" +#line 1353 "Zend/zend_language_scanner.l" { return T_IS_NOT_IDENTICAL; } -#line 3513 "Zend/zend_language_scanner.c" +#line 3515 "Zend/zend_language_scanner.c" yy234: YYDEBUG(234, *YYCURSOR); ++YYCURSOR; YYDEBUG(235, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1371 "Zend/zend_language_scanner.l" +#line 1373 "Zend/zend_language_scanner.l" { return T_PLUS_EQUAL; } -#line 3523 "Zend/zend_language_scanner.c" +#line 3525 "Zend/zend_language_scanner.c" yy236: YYDEBUG(236, *YYCURSOR); ++YYCURSOR; YYDEBUG(237, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1339 "Zend/zend_language_scanner.l" +#line 1341 "Zend/zend_language_scanner.l" { return T_INC; } -#line 3533 "Zend/zend_language_scanner.c" +#line 3535 "Zend/zend_language_scanner.c" yy238: YYDEBUG(238, *YYCURSOR); yych = *++YYCURSOR; @@ -3548,42 +3550,42 @@ yy240: } YYDEBUG(241, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1327 "Zend/zend_language_scanner.l" +#line 1329 "Zend/zend_language_scanner.l" { return T_LIST; } -#line 3556 "Zend/zend_language_scanner.c" +#line 3558 "Zend/zend_language_scanner.c" yy242: YYDEBUG(242, *YYCURSOR); ++YYCURSOR; if ((yych = *YYCURSOR) == '=') goto yy246; YYDEBUG(243, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1355 "Zend/zend_language_scanner.l" +#line 1357 "Zend/zend_language_scanner.l" { return T_IS_EQUAL; } -#line 3567 "Zend/zend_language_scanner.c" +#line 3569 "Zend/zend_language_scanner.c" yy244: YYDEBUG(244, *YYCURSOR); ++YYCURSOR; YYDEBUG(245, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1323 "Zend/zend_language_scanner.l" +#line 1325 "Zend/zend_language_scanner.l" { return T_DOUBLE_ARROW; } -#line 3577 "Zend/zend_language_scanner.c" +#line 3579 "Zend/zend_language_scanner.c" yy246: YYDEBUG(246, *YYCURSOR); ++YYCURSOR; YYDEBUG(247, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1347 "Zend/zend_language_scanner.l" +#line 1349 "Zend/zend_language_scanner.l" { return T_IS_IDENTICAL; } -#line 3587 "Zend/zend_language_scanner.c" +#line 3589 "Zend/zend_language_scanner.c" yy248: YYDEBUG(248, *YYCURSOR); yych = *++YYCURSOR; @@ -3713,11 +3715,11 @@ yy264: } YYDEBUG(267, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1604 "Zend/zend_language_scanner.l" +#line 1606 "Zend/zend_language_scanner.l" { return T_NS_C; } -#line 3721 "Zend/zend_language_scanner.c" +#line 3723 "Zend/zend_language_scanner.c" yy268: YYDEBUG(268, *YYCURSOR); yych = *++YYCURSOR; @@ -3737,11 +3739,11 @@ yy269: } YYDEBUG(272, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1600 "Zend/zend_language_scanner.l" +#line 1602 "Zend/zend_language_scanner.l" { return T_DIR; } -#line 3745 "Zend/zend_language_scanner.c" +#line 3747 "Zend/zend_language_scanner.c" yy273: YYDEBUG(273, *YYCURSOR); yych = *++YYCURSOR; @@ -3766,11 +3768,11 @@ yy275: } YYDEBUG(278, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1592 "Zend/zend_language_scanner.l" +#line 1594 "Zend/zend_language_scanner.l" { return T_LINE; } -#line 3774 "Zend/zend_language_scanner.c" +#line 3776 "Zend/zend_language_scanner.c" yy279: YYDEBUG(279, *YYCURSOR); yych = *++YYCURSOR; @@ -3805,11 +3807,11 @@ yy283: } YYDEBUG(286, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1588 "Zend/zend_language_scanner.l" +#line 1590 "Zend/zend_language_scanner.l" { return T_METHOD_C; } -#line 3813 "Zend/zend_language_scanner.c" +#line 3815 "Zend/zend_language_scanner.c" yy287: YYDEBUG(287, *YYCURSOR); yych = *++YYCURSOR; @@ -3860,11 +3862,11 @@ yy294: } YYDEBUG(297, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1584 "Zend/zend_language_scanner.l" +#line 1586 "Zend/zend_language_scanner.l" { return T_FUNC_C; } -#line 3868 "Zend/zend_language_scanner.c" +#line 3870 "Zend/zend_language_scanner.c" yy298: YYDEBUG(298, *YYCURSOR); yych = *++YYCURSOR; @@ -3884,11 +3886,11 @@ yy299: } YYDEBUG(302, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1596 "Zend/zend_language_scanner.l" +#line 1598 "Zend/zend_language_scanner.l" { return T_FILE; } -#line 3892 "Zend/zend_language_scanner.c" +#line 3894 "Zend/zend_language_scanner.c" yy303: YYDEBUG(303, *YYCURSOR); yych = *++YYCURSOR; @@ -3918,11 +3920,11 @@ yy306: } YYDEBUG(309, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1580 "Zend/zend_language_scanner.l" +#line 1582 "Zend/zend_language_scanner.l" { return T_TRAIT_C; } -#line 3926 "Zend/zend_language_scanner.c" +#line 3928 "Zend/zend_language_scanner.c" yy310: YYDEBUG(310, *YYCURSOR); yych = *++YYCURSOR; @@ -3952,11 +3954,11 @@ yy313: } YYDEBUG(316, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1576 "Zend/zend_language_scanner.l" +#line 1578 "Zend/zend_language_scanner.l" { return T_CLASS_C; } -#line 3960 "Zend/zend_language_scanner.c" +#line 3962 "Zend/zend_language_scanner.c" yy317: YYDEBUG(317, *YYCURSOR); yych = *++YYCURSOR; @@ -4018,11 +4020,11 @@ yy328: } YYDEBUG(329, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1291 "Zend/zend_language_scanner.l" +#line 1293 "Zend/zend_language_scanner.l" { return T_HALT_COMPILER; } -#line 4026 "Zend/zend_language_scanner.c" +#line 4028 "Zend/zend_language_scanner.c" yy330: YYDEBUG(330, *YYCURSOR); yych = *++YYCURSOR; @@ -4042,11 +4044,11 @@ yy332: } YYDEBUG(333, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1271 "Zend/zend_language_scanner.l" +#line 1273 "Zend/zend_language_scanner.l" { return T_USE; } -#line 4050 "Zend/zend_language_scanner.c" +#line 4052 "Zend/zend_language_scanner.c" yy334: YYDEBUG(334, *YYCURSOR); yych = *++YYCURSOR; @@ -4065,11 +4067,11 @@ yy336: } YYDEBUG(337, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1319 "Zend/zend_language_scanner.l" +#line 1321 "Zend/zend_language_scanner.l" { return T_UNSET; } -#line 4073 "Zend/zend_language_scanner.c" +#line 4075 "Zend/zend_language_scanner.c" yy338: YYDEBUG(338, *YYCURSOR); ++YYCURSOR; @@ -4241,11 +4243,11 @@ yy353: ++YYCURSOR; YYDEBUG(355, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1219 "Zend/zend_language_scanner.l" +#line 1221 "Zend/zend_language_scanner.l" { return T_INT_CAST; } -#line 4249 "Zend/zend_language_scanner.c" +#line 4251 "Zend/zend_language_scanner.c" yy356: YYDEBUG(356, *YYCURSOR); yych = *++YYCURSOR; @@ -4289,11 +4291,11 @@ yy361: ++YYCURSOR; YYDEBUG(364, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1223 "Zend/zend_language_scanner.l" +#line 1225 "Zend/zend_language_scanner.l" { return T_DOUBLE_CAST; } -#line 4297 "Zend/zend_language_scanner.c" +#line 4299 "Zend/zend_language_scanner.c" yy365: YYDEBUG(365, *YYCURSOR); yych = *++YYCURSOR; @@ -4363,11 +4365,11 @@ yy375: ++YYCURSOR; YYDEBUG(378, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1227 "Zend/zend_language_scanner.l" +#line 1229 "Zend/zend_language_scanner.l" { return T_STRING_CAST; } -#line 4371 "Zend/zend_language_scanner.c" +#line 4373 "Zend/zend_language_scanner.c" yy379: YYDEBUG(379, *YYCURSOR); yych = *++YYCURSOR; @@ -4400,11 +4402,11 @@ yy382: ++YYCURSOR; YYDEBUG(385, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1231 "Zend/zend_language_scanner.l" +#line 1233 "Zend/zend_language_scanner.l" { return T_ARRAY_CAST; } -#line 4408 "Zend/zend_language_scanner.c" +#line 4410 "Zend/zend_language_scanner.c" yy386: YYDEBUG(386, *YYCURSOR); yych = *++YYCURSOR; @@ -4442,11 +4444,11 @@ yy390: ++YYCURSOR; YYDEBUG(393, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1235 "Zend/zend_language_scanner.l" +#line 1237 "Zend/zend_language_scanner.l" { return T_OBJECT_CAST; } -#line 4450 "Zend/zend_language_scanner.c" +#line 4452 "Zend/zend_language_scanner.c" yy394: YYDEBUG(394, *YYCURSOR); yych = *++YYCURSOR; @@ -4487,11 +4489,11 @@ yy399: ++YYCURSOR; YYDEBUG(401, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1239 "Zend/zend_language_scanner.l" +#line 1241 "Zend/zend_language_scanner.l" { return T_BOOL_CAST; } -#line 4495 "Zend/zend_language_scanner.c" +#line 4497 "Zend/zend_language_scanner.c" yy402: YYDEBUG(402, *YYCURSOR); yych = *++YYCURSOR; @@ -4551,11 +4553,11 @@ yy410: ++YYCURSOR; YYDEBUG(413, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1243 "Zend/zend_language_scanner.l" +#line 1245 "Zend/zend_language_scanner.l" { return T_UNSET_CAST; } -#line 4559 "Zend/zend_language_scanner.c" +#line 4561 "Zend/zend_language_scanner.c" yy414: YYDEBUG(414, *YYCURSOR); yych = *++YYCURSOR; @@ -4569,11 +4571,11 @@ yy415: } YYDEBUG(416, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1215 "Zend/zend_language_scanner.l" +#line 1217 "Zend/zend_language_scanner.l" { return T_VAR; } -#line 4577 "Zend/zend_language_scanner.c" +#line 4579 "Zend/zend_language_scanner.c" yy417: YYDEBUG(417, *YYCURSOR); yych = *++YYCURSOR; @@ -4593,11 +4595,11 @@ yy419: } YYDEBUG(420, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1207 "Zend/zend_language_scanner.l" +#line 1209 "Zend/zend_language_scanner.l" { return T_NEW; } -#line 4601 "Zend/zend_language_scanner.c" +#line 4603 "Zend/zend_language_scanner.c" yy421: YYDEBUG(421, *YYCURSOR); yych = *++YYCURSOR; @@ -4636,11 +4638,11 @@ yy427: } YYDEBUG(428, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1267 "Zend/zend_language_scanner.l" +#line 1269 "Zend/zend_language_scanner.l" { return T_NAMESPACE; } -#line 4644 "Zend/zend_language_scanner.c" +#line 4646 "Zend/zend_language_scanner.c" yy429: YYDEBUG(429, *YYCURSOR); ++YYCURSOR; @@ -4649,22 +4651,22 @@ yy429: yy430: YYDEBUG(430, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1787 "Zend/zend_language_scanner.l" +#line 1789 "Zend/zend_language_scanner.l" { BEGIN(INITIAL); return T_CLOSE_TAG; /* implicit ';' at php-end tag */ } -#line 4658 "Zend/zend_language_scanner.c" +#line 4660 "Zend/zend_language_scanner.c" yy431: YYDEBUG(431, *YYCURSOR); ++YYCURSOR; YYDEBUG(432, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1203 "Zend/zend_language_scanner.l" +#line 1205 "Zend/zend_language_scanner.l" { return T_COALESCE; } -#line 4668 "Zend/zend_language_scanner.c" +#line 4670 "Zend/zend_language_scanner.c" yy433: YYDEBUG(433, *YYCURSOR); yych = *++YYCURSOR; @@ -4695,11 +4697,11 @@ yy437: ++YYCURSOR; YYDEBUG(438, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1395 "Zend/zend_language_scanner.l" +#line 1397 "Zend/zend_language_scanner.l" { return T_CONCAT_EQUAL; } -#line 4703 "Zend/zend_language_scanner.c" +#line 4705 "Zend/zend_language_scanner.c" yy439: YYDEBUG(439, *YYCURSOR); yych = *++YYCURSOR; @@ -4708,21 +4710,21 @@ yy439: ++YYCURSOR; YYDEBUG(441, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1199 "Zend/zend_language_scanner.l" +#line 1201 "Zend/zend_language_scanner.l" { return T_ELLIPSIS; } -#line 4716 "Zend/zend_language_scanner.c" +#line 4718 "Zend/zend_language_scanner.c" yy442: YYDEBUG(442, *YYCURSOR); ++YYCURSOR; YYDEBUG(443, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1191 "Zend/zend_language_scanner.l" +#line 1193 "Zend/zend_language_scanner.l" { return T_PAAMAYIM_NEKUDOTAYIM; } -#line 4726 "Zend/zend_language_scanner.c" +#line 4728 "Zend/zend_language_scanner.c" yy444: YYDEBUG(444, *YYCURSOR); ++YYCURSOR; @@ -4744,32 +4746,32 @@ yy446: ++YYCURSOR; YYDEBUG(447, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1375 "Zend/zend_language_scanner.l" +#line 1377 "Zend/zend_language_scanner.l" { return T_MINUS_EQUAL; } -#line 4752 "Zend/zend_language_scanner.c" +#line 4754 "Zend/zend_language_scanner.c" yy448: YYDEBUG(448, *YYCURSOR); ++YYCURSOR; YYDEBUG(449, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1343 "Zend/zend_language_scanner.l" +#line 1345 "Zend/zend_language_scanner.l" { return T_DEC; } -#line 4762 "Zend/zend_language_scanner.c" +#line 4764 "Zend/zend_language_scanner.c" yy450: YYDEBUG(450, *YYCURSOR); ++YYCURSOR; YYDEBUG(451, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1165 "Zend/zend_language_scanner.l" +#line 1167 "Zend/zend_language_scanner.l" { yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC); return T_OBJECT_OPERATOR; } -#line 4773 "Zend/zend_language_scanner.c" +#line 4775 "Zend/zend_language_scanner.c" yy452: YYDEBUG(452, *YYCURSOR); yych = *++YYCURSOR; @@ -4814,11 +4816,11 @@ yy457: } YYDEBUG(458, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1315 "Zend/zend_language_scanner.l" +#line 1317 "Zend/zend_language_scanner.l" { return T_PUBLIC; } -#line 4822 "Zend/zend_language_scanner.c" +#line 4824 "Zend/zend_language_scanner.c" yy459: YYDEBUG(459, *YYCURSOR); yych = *++YYCURSOR; @@ -4873,11 +4875,11 @@ yy466: } YYDEBUG(467, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1311 "Zend/zend_language_scanner.l" +#line 1313 "Zend/zend_language_scanner.l" { return T_PROTECTED; } -#line 4881 "Zend/zend_language_scanner.c" +#line 4883 "Zend/zend_language_scanner.c" yy468: YYDEBUG(468, *YYCURSOR); yych = *++YYCURSOR; @@ -4907,11 +4909,11 @@ yy472: } YYDEBUG(473, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1307 "Zend/zend_language_scanner.l" +#line 1309 "Zend/zend_language_scanner.l" { return T_PRIVATE; } -#line 4915 "Zend/zend_language_scanner.c" +#line 4917 "Zend/zend_language_scanner.c" yy474: YYDEBUG(474, *YYCURSOR); ++YYCURSOR; @@ -4920,11 +4922,11 @@ yy474: } YYDEBUG(475, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1141 "Zend/zend_language_scanner.l" +#line 1143 "Zend/zend_language_scanner.l" { return T_PRINT; } -#line 4928 "Zend/zend_language_scanner.c" +#line 4930 "Zend/zend_language_scanner.c" yy476: YYDEBUG(476, *YYCURSOR); yych = *++YYCURSOR; @@ -4949,11 +4951,11 @@ yy479: } YYDEBUG(480, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1133 "Zend/zend_language_scanner.l" +#line 1135 "Zend/zend_language_scanner.l" { return T_GOTO; } -#line 4957 "Zend/zend_language_scanner.c" +#line 4959 "Zend/zend_language_scanner.c" yy481: YYDEBUG(481, *YYCURSOR); yych = *++YYCURSOR; @@ -4977,11 +4979,11 @@ yy484: } YYDEBUG(485, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1279 "Zend/zend_language_scanner.l" +#line 1281 "Zend/zend_language_scanner.l" { return T_GLOBAL; } -#line 4985 "Zend/zend_language_scanner.c" +#line 4987 "Zend/zend_language_scanner.c" yy486: YYDEBUG(486, *YYCURSOR); yych = *++YYCURSOR; @@ -5018,11 +5020,11 @@ yy492: } YYDEBUG(493, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1125 "Zend/zend_language_scanner.l" +#line 1127 "Zend/zend_language_scanner.l" { return T_BREAK; } -#line 5026 "Zend/zend_language_scanner.c" +#line 5028 "Zend/zend_language_scanner.c" yy494: YYDEBUG(494, *YYCURSOR); yych = *++YYCURSOR; @@ -5062,11 +5064,11 @@ yy500: } YYDEBUG(501, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1109 "Zend/zend_language_scanner.l" +#line 1111 "Zend/zend_language_scanner.l" { return T_SWITCH; } -#line 5070 "Zend/zend_language_scanner.c" +#line 5072 "Zend/zend_language_scanner.c" yy502: YYDEBUG(502, *YYCURSOR); yych = *++YYCURSOR; @@ -5090,11 +5092,11 @@ yy505: } YYDEBUG(506, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1295 "Zend/zend_language_scanner.l" +#line 1297 "Zend/zend_language_scanner.l" { return T_STATIC; } -#line 5098 "Zend/zend_language_scanner.c" +#line 5100 "Zend/zend_language_scanner.c" yy507: YYDEBUG(507, *YYCURSOR); yych = *++YYCURSOR; @@ -5121,11 +5123,11 @@ yy510: } YYDEBUG(511, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1105 "Zend/zend_language_scanner.l" +#line 1107 "Zend/zend_language_scanner.l" { return T_AS; } -#line 5129 "Zend/zend_language_scanner.c" +#line 5131 "Zend/zend_language_scanner.c" yy512: YYDEBUG(512, *YYCURSOR); yych = *++YYCURSOR; @@ -5144,11 +5146,11 @@ yy514: } YYDEBUG(515, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1331 "Zend/zend_language_scanner.l" +#line 1333 "Zend/zend_language_scanner.l" { return T_ARRAY; } -#line 5152 "Zend/zend_language_scanner.c" +#line 5154 "Zend/zend_language_scanner.c" yy516: YYDEBUG(516, *YYCURSOR); ++YYCURSOR; @@ -5157,11 +5159,11 @@ yy516: } YYDEBUG(517, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1435 "Zend/zend_language_scanner.l" +#line 1437 "Zend/zend_language_scanner.l" { return T_LOGICAL_AND; } -#line 5165 "Zend/zend_language_scanner.c" +#line 5167 "Zend/zend_language_scanner.c" yy518: YYDEBUG(518, *YYCURSOR); yych = *++YYCURSOR; @@ -5195,11 +5197,11 @@ yy523: } YYDEBUG(524, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1299 "Zend/zend_language_scanner.l" +#line 1301 "Zend/zend_language_scanner.l" { return T_ABSTRACT; } -#line 5203 "Zend/zend_language_scanner.c" +#line 5205 "Zend/zend_language_scanner.c" yy525: YYDEBUG(525, *YYCURSOR); yych = *++YYCURSOR; @@ -5223,11 +5225,11 @@ yy528: } YYDEBUG(529, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1065 "Zend/zend_language_scanner.l" +#line 1067 "Zend/zend_language_scanner.l" { return T_WHILE; } -#line 5231 "Zend/zend_language_scanner.c" +#line 5233 "Zend/zend_language_scanner.c" yy530: YYDEBUG(530, *YYCURSOR); ++YYCURSOR; @@ -5236,11 +5238,11 @@ yy530: } YYDEBUG(531, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1049 "Zend/zend_language_scanner.l" +#line 1051 "Zend/zend_language_scanner.l" { return T_IF; } -#line 5244 "Zend/zend_language_scanner.c" +#line 5246 "Zend/zend_language_scanner.c" yy532: YYDEBUG(532, *YYCURSOR); yych = *++YYCURSOR; @@ -5292,11 +5294,11 @@ yy537: } YYDEBUG(538, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1283 "Zend/zend_language_scanner.l" +#line 1285 "Zend/zend_language_scanner.l" { return T_ISSET; } -#line 5300 "Zend/zend_language_scanner.c" +#line 5302 "Zend/zend_language_scanner.c" yy539: YYDEBUG(539, *YYCURSOR); yych = *++YYCURSOR; @@ -5350,11 +5352,11 @@ yy545: yy546: YYDEBUG(546, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1251 "Zend/zend_language_scanner.l" +#line 1253 "Zend/zend_language_scanner.l" { return T_INCLUDE; } -#line 5358 "Zend/zend_language_scanner.c" +#line 5360 "Zend/zend_language_scanner.c" yy547: YYDEBUG(547, *YYCURSOR); yych = *++YYCURSOR; @@ -5383,11 +5385,11 @@ yy551: } YYDEBUG(552, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1255 "Zend/zend_language_scanner.l" +#line 1257 "Zend/zend_language_scanner.l" { return T_INCLUDE_ONCE; } -#line 5391 "Zend/zend_language_scanner.c" +#line 5393 "Zend/zend_language_scanner.c" yy553: YYDEBUG(553, *YYCURSOR); yych = *++YYCURSOR; @@ -5421,11 +5423,11 @@ yy558: } YYDEBUG(559, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1149 "Zend/zend_language_scanner.l" +#line 1151 "Zend/zend_language_scanner.l" { return T_INTERFACE; } -#line 5429 "Zend/zend_language_scanner.c" +#line 5431 "Zend/zend_language_scanner.c" yy560: YYDEBUG(560, *YYCURSOR); yych = *++YYCURSOR; @@ -5475,11 +5477,11 @@ yy566: } YYDEBUG(567, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1275 "Zend/zend_language_scanner.l" +#line 1277 "Zend/zend_language_scanner.l" { return T_INSTEADOF; } -#line 5483 "Zend/zend_language_scanner.c" +#line 5485 "Zend/zend_language_scanner.c" yy568: YYDEBUG(568, *YYCURSOR); yych = *++YYCURSOR; @@ -5508,11 +5510,11 @@ yy572: } YYDEBUG(573, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1101 "Zend/zend_language_scanner.l" +#line 1103 "Zend/zend_language_scanner.l" { return T_INSTANCEOF; } -#line 5516 "Zend/zend_language_scanner.c" +#line 5518 "Zend/zend_language_scanner.c" yy574: YYDEBUG(574, *YYCURSOR); yych = *++YYCURSOR; @@ -5556,11 +5558,11 @@ yy581: } YYDEBUG(582, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1161 "Zend/zend_language_scanner.l" +#line 1163 "Zend/zend_language_scanner.l" { return T_IMPLEMENTS; } -#line 5564 "Zend/zend_language_scanner.c" +#line 5566 "Zend/zend_language_scanner.c" yy583: YYDEBUG(583, *YYCURSOR); yych = *++YYCURSOR; @@ -5588,11 +5590,11 @@ yy584: } YYDEBUG(586, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1033 "Zend/zend_language_scanner.l" +#line 1035 "Zend/zend_language_scanner.l" { return T_TRY; } -#line 5596 "Zend/zend_language_scanner.c" +#line 5598 "Zend/zend_language_scanner.c" yy587: YYDEBUG(587, *YYCURSOR); yych = *++YYCURSOR; @@ -5611,11 +5613,11 @@ yy589: } YYDEBUG(590, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1153 "Zend/zend_language_scanner.l" +#line 1155 "Zend/zend_language_scanner.l" { return T_TRAIT; } -#line 5619 "Zend/zend_language_scanner.c" +#line 5621 "Zend/zend_language_scanner.c" yy591: YYDEBUG(591, *YYCURSOR); yych = *++YYCURSOR; @@ -5634,11 +5636,11 @@ yy593: } YYDEBUG(594, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1045 "Zend/zend_language_scanner.l" +#line 1047 "Zend/zend_language_scanner.l" { return T_THROW; } -#line 5642 "Zend/zend_language_scanner.c" +#line 5644 "Zend/zend_language_scanner.c" yy595: YYDEBUG(595, *YYCURSOR); yych = *++YYCURSOR; @@ -5662,11 +5664,11 @@ yy598: } YYDEBUG(599, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1029 "Zend/zend_language_scanner.l" +#line 1031 "Zend/zend_language_scanner.l" { return T_YIELD; } -#line 5670 "Zend/zend_language_scanner.c" +#line 5672 "Zend/zend_language_scanner.c" yy600: YYDEBUG(600, *YYCURSOR); yych = *++YYCURSOR; @@ -5727,11 +5729,11 @@ yy606: yy607: YYDEBUG(607, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1259 "Zend/zend_language_scanner.l" +#line 1261 "Zend/zend_language_scanner.l" { return T_REQUIRE; } -#line 5735 "Zend/zend_language_scanner.c" +#line 5737 "Zend/zend_language_scanner.c" yy608: YYDEBUG(608, *YYCURSOR); yych = *++YYCURSOR; @@ -5760,11 +5762,11 @@ yy612: } YYDEBUG(613, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1263 "Zend/zend_language_scanner.l" +#line 1265 "Zend/zend_language_scanner.l" { return T_REQUIRE_ONCE; } -#line 5768 "Zend/zend_language_scanner.c" +#line 5770 "Zend/zend_language_scanner.c" yy614: YYDEBUG(614, *YYCURSOR); yych = *++YYCURSOR; @@ -5783,11 +5785,11 @@ yy616: } YYDEBUG(617, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1025 "Zend/zend_language_scanner.l" +#line 1027 "Zend/zend_language_scanner.l" { return T_RETURN; } -#line 5791 "Zend/zend_language_scanner.c" +#line 5793 "Zend/zend_language_scanner.c" yy618: YYDEBUG(618, *YYCURSOR); yych = *++YYCURSOR; @@ -5877,11 +5879,11 @@ yy627: } YYDEBUG(628, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1129 "Zend/zend_language_scanner.l" +#line 1131 "Zend/zend_language_scanner.l" { return T_CONTINUE; } -#line 5885 "Zend/zend_language_scanner.c" +#line 5887 "Zend/zend_language_scanner.c" yy629: YYDEBUG(629, *YYCURSOR); ++YYCURSOR; @@ -5890,11 +5892,11 @@ yy629: } YYDEBUG(630, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1021 "Zend/zend_language_scanner.l" +#line 1023 "Zend/zend_language_scanner.l" { return T_CONST; } -#line 5898 "Zend/zend_language_scanner.c" +#line 5900 "Zend/zend_language_scanner.c" yy631: YYDEBUG(631, *YYCURSOR); yych = *++YYCURSOR; @@ -5919,11 +5921,11 @@ yy634: } YYDEBUG(635, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1211 "Zend/zend_language_scanner.l" +#line 1213 "Zend/zend_language_scanner.l" { return T_CLONE; } -#line 5927 "Zend/zend_language_scanner.c" +#line 5929 "Zend/zend_language_scanner.c" yy636: YYDEBUG(636, *YYCURSOR); yych = *++YYCURSOR; @@ -5937,11 +5939,11 @@ yy637: } YYDEBUG(638, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1145 "Zend/zend_language_scanner.l" +#line 1147 "Zend/zend_language_scanner.l" { return T_CLASS; } -#line 5945 "Zend/zend_language_scanner.c" +#line 5947 "Zend/zend_language_scanner.c" yy639: YYDEBUG(639, *YYCURSOR); yych = *++YYCURSOR; @@ -5987,11 +5989,11 @@ yy646: } YYDEBUG(647, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1335 "Zend/zend_language_scanner.l" +#line 1337 "Zend/zend_language_scanner.l" { return T_CALLABLE; } -#line 5995 "Zend/zend_language_scanner.c" +#line 5997 "Zend/zend_language_scanner.c" yy648: YYDEBUG(648, *YYCURSOR); ++YYCURSOR; @@ -6000,11 +6002,11 @@ yy648: } YYDEBUG(649, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1117 "Zend/zend_language_scanner.l" +#line 1119 "Zend/zend_language_scanner.l" { return T_CASE; } -#line 6008 "Zend/zend_language_scanner.c" +#line 6010 "Zend/zend_language_scanner.c" yy650: YYDEBUG(650, *YYCURSOR); yych = *++YYCURSOR; @@ -6018,11 +6020,11 @@ yy651: } YYDEBUG(652, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1037 "Zend/zend_language_scanner.l" +#line 1039 "Zend/zend_language_scanner.l" { return T_CATCH; } -#line 6026 "Zend/zend_language_scanner.c" +#line 6028 "Zend/zend_language_scanner.c" yy653: YYDEBUG(653, *YYCURSOR); yych = *++YYCURSOR; @@ -6073,11 +6075,11 @@ yy661: } YYDEBUG(662, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1017 "Zend/zend_language_scanner.l" +#line 1019 "Zend/zend_language_scanner.l" { return T_FUNCTION; } -#line 6081 "Zend/zend_language_scanner.c" +#line 6083 "Zend/zend_language_scanner.c" yy663: YYDEBUG(663, *YYCURSOR); ++YYCURSOR; @@ -6101,11 +6103,11 @@ yy663: yy664: YYDEBUG(664, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1077 "Zend/zend_language_scanner.l" +#line 1079 "Zend/zend_language_scanner.l" { return T_FOR; } -#line 6109 "Zend/zend_language_scanner.c" +#line 6111 "Zend/zend_language_scanner.c" yy665: YYDEBUG(665, *YYCURSOR); yych = *++YYCURSOR; @@ -6129,11 +6131,11 @@ yy668: } YYDEBUG(669, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1085 "Zend/zend_language_scanner.l" +#line 1087 "Zend/zend_language_scanner.l" { return T_FOREACH; } -#line 6137 "Zend/zend_language_scanner.c" +#line 6139 "Zend/zend_language_scanner.c" yy670: YYDEBUG(670, *YYCURSOR); yych = *++YYCURSOR; @@ -6167,11 +6169,11 @@ yy672: yy673: YYDEBUG(673, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1303 "Zend/zend_language_scanner.l" +#line 1305 "Zend/zend_language_scanner.l" { return T_FINAL; } -#line 6175 "Zend/zend_language_scanner.c" +#line 6177 "Zend/zend_language_scanner.c" yy674: YYDEBUG(674, *YYCURSOR); yych = *++YYCURSOR; @@ -6185,11 +6187,11 @@ yy675: } YYDEBUG(676, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1041 "Zend/zend_language_scanner.l" +#line 1043 "Zend/zend_language_scanner.l" { return T_FINALLY; } -#line 6193 "Zend/zend_language_scanner.c" +#line 6195 "Zend/zend_language_scanner.c" yy677: YYDEBUG(677, *YYCURSOR); yych = *++YYCURSOR; @@ -6220,11 +6222,11 @@ yy679: } YYDEBUG(680, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1073 "Zend/zend_language_scanner.l" +#line 1075 "Zend/zend_language_scanner.l" { return T_DO; } -#line 6228 "Zend/zend_language_scanner.c" +#line 6230 "Zend/zend_language_scanner.c" yy681: YYDEBUG(681, *YYCURSOR); ++YYCURSOR; @@ -6233,11 +6235,11 @@ yy681: } YYDEBUG(682, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1013 "Zend/zend_language_scanner.l" +#line 1015 "Zend/zend_language_scanner.l" { return T_EXIT; } -#line 6241 "Zend/zend_language_scanner.c" +#line 6243 "Zend/zend_language_scanner.c" yy683: YYDEBUG(683, *YYCURSOR); yych = *++YYCURSOR; @@ -6272,11 +6274,11 @@ yy688: } YYDEBUG(689, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1121 "Zend/zend_language_scanner.l" +#line 1123 "Zend/zend_language_scanner.l" { return T_DEFAULT; } -#line 6280 "Zend/zend_language_scanner.c" +#line 6282 "Zend/zend_language_scanner.c" yy690: YYDEBUG(690, *YYCURSOR); yych = *++YYCURSOR; @@ -6300,11 +6302,11 @@ yy693: } YYDEBUG(694, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1093 "Zend/zend_language_scanner.l" +#line 1095 "Zend/zend_language_scanner.l" { return T_DECLARE; } -#line 6308 "Zend/zend_language_scanner.c" +#line 6310 "Zend/zend_language_scanner.c" yy695: YYDEBUG(695, *YYCURSOR); yych = *++YYCURSOR; @@ -6384,11 +6386,11 @@ yy706: } YYDEBUG(707, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1157 "Zend/zend_language_scanner.l" +#line 1159 "Zend/zend_language_scanner.l" { return T_EXTENDS; } -#line 6392 "Zend/zend_language_scanner.c" +#line 6394 "Zend/zend_language_scanner.c" yy708: YYDEBUG(708, *YYCURSOR); ++YYCURSOR; @@ -6397,11 +6399,11 @@ yy708: } YYDEBUG(709, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1009 "Zend/zend_language_scanner.l" +#line 1011 "Zend/zend_language_scanner.l" { return T_EXIT; } -#line 6405 "Zend/zend_language_scanner.c" +#line 6407 "Zend/zend_language_scanner.c" yy710: YYDEBUG(710, *YYCURSOR); yych = *++YYCURSOR; @@ -6415,11 +6417,11 @@ yy711: } YYDEBUG(712, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1247 "Zend/zend_language_scanner.l" +#line 1249 "Zend/zend_language_scanner.l" { return T_EVAL; } -#line 6423 "Zend/zend_language_scanner.c" +#line 6425 "Zend/zend_language_scanner.c" yy713: YYDEBUG(713, *YYCURSOR); yych = *++YYCURSOR; @@ -6489,11 +6491,11 @@ yy722: } YYDEBUG(723, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1069 "Zend/zend_language_scanner.l" +#line 1071 "Zend/zend_language_scanner.l" { return T_ENDWHILE; } -#line 6497 "Zend/zend_language_scanner.c" +#line 6499 "Zend/zend_language_scanner.c" yy724: YYDEBUG(724, *YYCURSOR); yych = *++YYCURSOR; @@ -6522,11 +6524,11 @@ yy728: } YYDEBUG(729, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1113 "Zend/zend_language_scanner.l" +#line 1115 "Zend/zend_language_scanner.l" { return T_ENDSWITCH; } -#line 6530 "Zend/zend_language_scanner.c" +#line 6532 "Zend/zend_language_scanner.c" yy730: YYDEBUG(730, *YYCURSOR); ++YYCURSOR; @@ -6535,11 +6537,11 @@ yy730: } YYDEBUG(731, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1057 "Zend/zend_language_scanner.l" +#line 1059 "Zend/zend_language_scanner.l" { return T_ENDIF; } -#line 6543 "Zend/zend_language_scanner.c" +#line 6545 "Zend/zend_language_scanner.c" yy732: YYDEBUG(732, *YYCURSOR); yych = *++YYCURSOR; @@ -6568,11 +6570,11 @@ yy733: yy734: YYDEBUG(734, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1081 "Zend/zend_language_scanner.l" +#line 1083 "Zend/zend_language_scanner.l" { return T_ENDFOR; } -#line 6576 "Zend/zend_language_scanner.c" +#line 6578 "Zend/zend_language_scanner.c" yy735: YYDEBUG(735, *YYCURSOR); yych = *++YYCURSOR; @@ -6596,11 +6598,11 @@ yy738: } YYDEBUG(739, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1089 "Zend/zend_language_scanner.l" +#line 1091 "Zend/zend_language_scanner.l" { return T_ENDFOREACH; } -#line 6604 "Zend/zend_language_scanner.c" +#line 6606 "Zend/zend_language_scanner.c" yy740: YYDEBUG(740, *YYCURSOR); yych = *++YYCURSOR; @@ -6634,11 +6636,11 @@ yy745: } YYDEBUG(746, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1097 "Zend/zend_language_scanner.l" +#line 1099 "Zend/zend_language_scanner.l" { return T_ENDDECLARE; } -#line 6642 "Zend/zend_language_scanner.c" +#line 6644 "Zend/zend_language_scanner.c" yy747: YYDEBUG(747, *YYCURSOR); yych = *++YYCURSOR; @@ -6657,11 +6659,11 @@ yy749: } YYDEBUG(750, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1287 "Zend/zend_language_scanner.l" +#line 1289 "Zend/zend_language_scanner.l" { return T_EMPTY; } -#line 6665 "Zend/zend_language_scanner.c" +#line 6667 "Zend/zend_language_scanner.c" yy751: YYDEBUG(751, *YYCURSOR); yych = *++YYCURSOR; @@ -6690,11 +6692,11 @@ yy752: yy753: YYDEBUG(753, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1061 "Zend/zend_language_scanner.l" +#line 1063 "Zend/zend_language_scanner.l" { return T_ELSE; } -#line 6698 "Zend/zend_language_scanner.c" +#line 6700 "Zend/zend_language_scanner.c" yy754: YYDEBUG(754, *YYCURSOR); yych = *++YYCURSOR; @@ -6708,11 +6710,11 @@ yy755: } YYDEBUG(756, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1053 "Zend/zend_language_scanner.l" +#line 1055 "Zend/zend_language_scanner.l" { return T_ELSEIF; } -#line 6716 "Zend/zend_language_scanner.c" +#line 6718 "Zend/zend_language_scanner.c" yy757: YYDEBUG(757, *YYCURSOR); yych = *++YYCURSOR; @@ -6726,11 +6728,11 @@ yy758: } YYDEBUG(759, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1137 "Zend/zend_language_scanner.l" +#line 1139 "Zend/zend_language_scanner.l" { return T_ECHO; } -#line 6734 "Zend/zend_language_scanner.c" +#line 6736 "Zend/zend_language_scanner.c" } /* *********************************** */ yyc_ST_LOOKING_FOR_PROPERTY: @@ -6803,12 +6805,12 @@ yy762: yy763: YYDEBUG(763, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1170 "Zend/zend_language_scanner.l" +#line 1172 "Zend/zend_language_scanner.l" { HANDLE_NEWLINES(yytext, yyleng); return T_WHITESPACE; } -#line 6812 "Zend/zend_language_scanner.c" +#line 6814 "Zend/zend_language_scanner.c" yy764: YYDEBUG(764, *YYCURSOR); ++YYCURSOR; @@ -6816,13 +6818,13 @@ yy764: yy765: YYDEBUG(765, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1185 "Zend/zend_language_scanner.l" +#line 1187 "Zend/zend_language_scanner.l" { yyless(0); yy_pop_state(TSRMLS_C); goto restart; } -#line 6826 "Zend/zend_language_scanner.c" +#line 6828 "Zend/zend_language_scanner.c" yy766: YYDEBUG(766, *YYCURSOR); ++YYCURSOR; @@ -6831,13 +6833,13 @@ yy766: yy767: YYDEBUG(767, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1179 "Zend/zend_language_scanner.l" +#line 1181 "Zend/zend_language_scanner.l" { yy_pop_state(TSRMLS_C); zend_copy_value(zendlval, yytext, yyleng); return T_STRING; } -#line 6841 "Zend/zend_language_scanner.c" +#line 6843 "Zend/zend_language_scanner.c" yy768: YYDEBUG(768, *YYCURSOR); yych = *++YYCURSOR; @@ -6858,11 +6860,11 @@ yy771: ++YYCURSOR; YYDEBUG(772, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1175 "Zend/zend_language_scanner.l" +#line 1177 "Zend/zend_language_scanner.l" { return T_OBJECT_OPERATOR; } -#line 6866 "Zend/zend_language_scanner.c" +#line 6868 "Zend/zend_language_scanner.c" yy773: YYDEBUG(773, *YYCURSOR); ++YYCURSOR; @@ -6947,14 +6949,14 @@ yy777: yy778: YYDEBUG(778, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1486 "Zend/zend_language_scanner.l" +#line 1488 "Zend/zend_language_scanner.l" { yyless(0); yy_pop_state(TSRMLS_C); yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); goto restart; } -#line 6958 "Zend/zend_language_scanner.c" +#line 6960 "Zend/zend_language_scanner.c" yy779: YYDEBUG(779, *YYCURSOR); yych = *++YYCURSOR; @@ -6979,7 +6981,7 @@ yy783: ++YYCURSOR; YYDEBUG(784, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1477 "Zend/zend_language_scanner.l" +#line 1479 "Zend/zend_language_scanner.l" { yyless(yyleng - 1); zend_copy_value(zendlval, yytext, yyleng); @@ -6987,7 +6989,7 @@ yy783: yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); return T_STRING_VARNAME; } -#line 6991 "Zend/zend_language_scanner.c" +#line 6993 "Zend/zend_language_scanner.c" } /* *********************************** */ yyc_ST_NOWDOC: @@ -6998,7 +7000,7 @@ yyc_ST_NOWDOC: ++YYCURSOR; YYDEBUG(788, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2158 "Zend/zend_language_scanner.l" +#line 2160 "Zend/zend_language_scanner.l" { int newline = 0; @@ -7054,7 +7056,7 @@ nowdoc_scan_done: HANDLE_NEWLINES(yytext, yyleng - newline); return T_ENCAPSED_AND_WHITESPACE; } -#line 7058 "Zend/zend_language_scanner.c" +#line 7060 "Zend/zend_language_scanner.c" /* *********************************** */ yyc_ST_VAR_OFFSET: { @@ -7161,7 +7163,7 @@ yy791: yy792: YYDEBUG(792, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1557 "Zend/zend_language_scanner.l" +#line 1559 "Zend/zend_language_scanner.l" { /* Offset could be treated as a long */ if (yyleng < MAX_LENGTH_OF_LONG - 1 || (yyleng == MAX_LENGTH_OF_LONG - 1 && strcmp(yytext, long_min_digits) < 0)) { ZVAL_LONG(zendlval, ZEND_STRTOL(yytext, NULL, 10)); @@ -7170,7 +7172,7 @@ yy792: } return T_NUM_STRING; } -#line 7174 "Zend/zend_language_scanner.c" +#line 7176 "Zend/zend_language_scanner.c" yy793: YYDEBUG(793, *YYCURSOR); yych = *++YYCURSOR; @@ -7190,23 +7192,23 @@ yy794: yy795: YYDEBUG(795, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1706 "Zend/zend_language_scanner.l" +#line 1708 "Zend/zend_language_scanner.l" { /* Only '[' can be valid, but returning other tokens will allow a more explicit parse error */ return yytext[0]; } -#line 7199 "Zend/zend_language_scanner.c" +#line 7201 "Zend/zend_language_scanner.c" yy796: YYDEBUG(796, *YYCURSOR); ++YYCURSOR; YYDEBUG(797, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1701 "Zend/zend_language_scanner.l" +#line 1703 "Zend/zend_language_scanner.l" { yy_pop_state(TSRMLS_C); return ']'; } -#line 7210 "Zend/zend_language_scanner.c" +#line 7212 "Zend/zend_language_scanner.c" yy798: YYDEBUG(798, *YYCURSOR); yych = *++YYCURSOR; @@ -7216,7 +7218,7 @@ yy799: ++YYCURSOR; YYDEBUG(800, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1711 "Zend/zend_language_scanner.l" +#line 1713 "Zend/zend_language_scanner.l" { /* Invalid rule to return a more explicit parse error with proper line number */ yyless(0); @@ -7224,7 +7226,7 @@ yy799: ZVAL_NULL(zendlval); return T_ENCAPSED_AND_WHITESPACE; } -#line 7228 "Zend/zend_language_scanner.c" +#line 7230 "Zend/zend_language_scanner.c" yy801: YYDEBUG(801, *YYCURSOR); ++YYCURSOR; @@ -7233,18 +7235,18 @@ yy801: yy802: YYDEBUG(802, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1719 "Zend/zend_language_scanner.l" +#line 1721 "Zend/zend_language_scanner.l" { zend_copy_value(zendlval, yytext, yyleng); return T_STRING; } -#line 7242 "Zend/zend_language_scanner.c" +#line 7244 "Zend/zend_language_scanner.c" yy803: YYDEBUG(803, *YYCURSOR); ++YYCURSOR; YYDEBUG(804, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2215 "Zend/zend_language_scanner.l" +#line 2217 "Zend/zend_language_scanner.l" { if (YYCURSOR > YYLIMIT) { return 0; @@ -7253,7 +7255,7 @@ yy803: zend_error(E_COMPILE_WARNING,"Unexpected character in input: '%c' (ASCII=%d) state=%d", yytext[0], yytext[0], YYSTATE); goto restart; } -#line 7257 "Zend/zend_language_scanner.c" +#line 7259 "Zend/zend_language_scanner.c" yy805: YYDEBUG(805, *YYCURSOR); ++YYCURSOR; @@ -7289,12 +7291,12 @@ yy807: yy809: YYDEBUG(809, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1696 "Zend/zend_language_scanner.l" +#line 1698 "Zend/zend_language_scanner.l" { zend_copy_value(zendlval, (yytext+1), (yyleng-1)); return T_VARIABLE; } -#line 7298 "Zend/zend_language_scanner.c" +#line 7300 "Zend/zend_language_scanner.c" yy810: YYDEBUG(810, *YYCURSOR); ++YYCURSOR; @@ -7334,12 +7336,12 @@ yy815: yy817: YYDEBUG(817, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1566 "Zend/zend_language_scanner.l" +#line 1568 "Zend/zend_language_scanner.l" { /* Offset must be treated as a string */ ZVAL_STRINGL(zendlval, yytext, yyleng); return T_NUM_STRING; } -#line 7343 "Zend/zend_language_scanner.c" +#line 7345 "Zend/zend_language_scanner.c" yy818: YYDEBUG(818, *YYCURSOR); ++YYCURSOR; @@ -7362,6 +7364,6 @@ yy820: goto yy817; } } -#line 2224 "Zend/zend_language_scanner.l" +#line 2226 "Zend/zend_language_scanner.l" } diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index 572b8713cb8..f87d7bada79 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -284,7 +284,8 @@ static const zend_encoding *zend_multibyte_detect_utf_encoding(const unsigned ch /* utf-16 or utf-32? */ p = script; - while ((p-script) < script_size) { + assert(p >= script); + while ((size_t)(p-script) < script_size) { p = memchr(p, 0, script_size-(p-script)-2); if (!p) { break; @@ -300,7 +301,8 @@ static const zend_encoding *zend_multibyte_detect_utf_encoding(const unsigned ch /* BE or LE? */ p = script; - while ((p-script) < script_size) { + assert(p >= script); + while ((size_t)(p-script) < script_size) { if (*p == '\0' && *(p+wchar_size-1) != '\0') { /* BE */ le = 0; @@ -520,7 +522,7 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC) } } SCNG(yy_start) = (unsigned char *)buf - offset; - yy_scan_buffer(buf, size TSRMLS_CC); + yy_scan_buffer(buf, (unsigned int)size TSRMLS_CC); } else { zend_error_noreturn(E_COMPILE_ERROR, "zend_stream_mmap() failed"); } @@ -681,7 +683,7 @@ ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_D } } - yy_scan_buffer(buf, size TSRMLS_CC); + yy_scan_buffer(buf, (unsigned int)size TSRMLS_CC); new_compiled_filename = zend_string_init(filename, strlen(filename), 0); zend_set_compiled_filename(new_compiled_filename TSRMLS_CC); @@ -1656,7 +1658,7 @@ inline_char_handler: yyleng = YYCURSOR - SCNG(yy_text); if (SCNG(output_filter)) { - int readsize; + size_t readsize; char *s = NULL; size_t sz = 0; // TODO: avoid reallocation ??? From cf581178e7123a3e5328cd0ed8d9f2e19fee38c1 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 28 Oct 2014 19:18:47 +0100 Subject: [PATCH 180/398] fix "inconsistent dll linkage" warning caused by bison stdlib.h might not be always using _STDLIB_H, that will move bison to redeclare the malloc/free prototypes. --- Zend/zend_ini_parser.y | 5 +++++ Zend/zend_language_parser.y | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/Zend/zend_ini_parser.y b/Zend/zend_ini_parser.y index 90e0fdc0076..d04988442f4 100644 --- a/Zend/zend_ini_parser.y +++ b/Zend/zend_ini_parser.y @@ -43,6 +43,11 @@ int ini_parse(void); #define ZEND_INI_PARSER_CB (CG(ini_parser_param))->ini_parser_cb #define ZEND_INI_PARSER_ARG (CG(ini_parser_param))->arg +#ifdef _MSC_VER +#define YYMALLOC malloc +#define YYFREE free +#endif + /* {{{ zend_ini_do_op() */ static void zend_ini_do_op(char type, zval *result, zval *op1, zval *op2) diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index d25e1d2e07b..88286203da9 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -43,6 +43,11 @@ static YYSIZE_T zend_yytnamerr(char*, const char*); #define YYERROR_VERBOSE #define YYSTYPE zend_parser_stack_elem +#ifdef _MSC_VER +#define YYMALLOC malloc +#define YYFREE free +#endif + %} %pure_parser From 9fd0364576c470c1a1febc003eace88fe8d19c8d Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 28 Oct 2014 19:25:55 +0100 Subject: [PATCH 181/398] fix datatype mismatch warnings --- win32/sendmail.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/win32/sendmail.c b/win32/sendmail.c index 3e81ecd4bcc..aaeeea3aa5f 100644 --- a/win32/sendmail.c +++ b/win32/sendmail.c @@ -170,7 +170,7 @@ static zend_string *php_win32_mail_trim_header(char *header TSRMLS_DC) //zend_string *php_pcre_replace(zend_string *regex, char *subject, int subject_len, zval *replace_val, int is_callable_replace, int limit, int *replace_count TSRMLS_DC); result = php_pcre_replace(regex, - header, strlen(header), + header, (int)strlen(header), &replace, 0, -1, @@ -186,7 +186,7 @@ static zend_string *php_win32_mail_trim_header(char *header TSRMLS_DC) regex = zend_string_init(PHP_WIN32_MAIL_RMVDBL_PATTERN, sizeof(PHP_WIN32_MAIL_RMVDBL_PATTERN)-1, 0); result2 = php_pcre_replace(regex, - result->val, result->len, + result->val, (int)result->len, &replace, 0, -1, @@ -792,7 +792,7 @@ static int MailConnect() return (FAILED_TO_GET_HOSTNAME); } - namelen = strlen(ent->h_name); + namelen = (int)strlen(ent->h_name); #ifdef HAVE_IPV6 if (inet_pton(AF_INET, ent->h_name, &addr) == 1 || inet_pton(AF_INET6, ent->h_name, &addr6) == 1) @@ -853,7 +853,7 @@ static int MailConnect() //********************************************************************/ static int Post(LPCSTR msg) { - int len = strlen(msg); + int len = (int)strlen(msg); int slen; int index = 0; From 842a98ef3213107c2e3746e54623c271f99114d9 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 28 Oct 2014 19:29:07 +0100 Subject: [PATCH 182/398] fix datatype mismatch warn --- win32/winutil.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/win32/winutil.c b/win32/winutil.c index 5203fb4e66f..eab3df9cdaf 100644 --- a/win32/winutil.c +++ b/win32/winutil.c @@ -115,7 +115,8 @@ PHPAPI int php_win32_get_random_bytes(unsigned char *buf, size_t size) { /* {{{ return FAILURE; } - ret = CryptGenRandom(hCryptProv, size, buf); + /* XXX should go in the loop if size exceeds UINT_MAX */ + ret = CryptGenRandom(hCryptProv, (DWORD)size, buf); if (ret) { return SUCCESS; From 20f8f533e115e6f3c206335328411c5c570d08ee Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 28 Oct 2014 19:32:51 +0100 Subject: [PATCH 183/398] fix datatype mismatch warns --- TSRM/tsrm_win32.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c index faa186a1bbf..9936320a951 100644 --- a/TSRM/tsrm_win32.c +++ b/TSRM/tsrm_win32.c @@ -279,14 +279,14 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode TSRMLS_DC) if (CWDG(realpath_cache_size_limit)) { t = time(0); - bucket = realpath_cache_lookup(pathname, strlen(pathname), t TSRMLS_CC); + bucket = realpath_cache_lookup(pathname, (int)strlen(pathname), t TSRMLS_CC); if(bucket == NULL && real_path == NULL) { /* We used the pathname directly. Call tsrm_realpath */ /* so that entry is created in realpath cache */ real_path = (char *)malloc(MAX_PATH); if(tsrm_realpath(pathname, real_path TSRMLS_CC) != NULL) { pathname = real_path; - bucket = realpath_cache_lookup(pathname, strlen(pathname), t TSRMLS_CC); + bucket = realpath_cache_lookup(pathname, (int)strlen(pathname), t TSRMLS_CC); } } } @@ -477,7 +477,7 @@ TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, } /*The following two checks can be removed once we drop XP support */ - type_len = strlen(type); + type_len = (int)strlen(type); if (type_len <1 || type_len > 2) { return NULL; } From 10d843b0fb3b24dea03f683071095dd208bdc10c Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 28 Oct 2014 19:50:06 +0100 Subject: [PATCH 184/398] fix datatype mismatch warnings --- ext/spl/php_spl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index 1de8e021dd9..aa740c40e25 100644 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -255,7 +255,7 @@ static int spl_autoload(zend_string *class_name, zend_string *lc_name, const cha zval result; int ret; - class_file_len = spprintf(&class_file, 0, "%s%.*s", lc_name->val, ext_len, ext); + class_file_len = (int)spprintf(&class_file, 0, "%s%.*s", lc_name->val, ext_len, ext); #if DEFAULT_SLASH != '\\' { @@ -320,7 +320,7 @@ PHP_FUNCTION(spl_autoload) pos_len = sizeof(SPL_DEFAULT_FILE_EXTENSIONS) - 1; } else { pos = file_exts->val; - pos_len = file_exts->len; + pos_len = (int)file_exts->len; } lc_name = zend_string_alloc(class_name->len, 0); @@ -328,7 +328,7 @@ PHP_FUNCTION(spl_autoload) while (pos && *pos && !EG(exception)) { pos1 = strchr(pos, ','); if (pos1) { - pos1_len = pos1 - pos; + pos1_len = (int)(pos1 - pos); } else { pos1_len = pos_len; } @@ -759,7 +759,7 @@ PHPAPI zend_string *php_spl_object_hash(zval *obj TSRMLS_DC) /* {{{*/ if (!SPL_G(hash_mask_init)) { if (!BG(mt_rand_is_seeded)) { - php_mt_srand(GENERATE_SEED() TSRMLS_CC); + php_mt_srand((uint32_t)GENERATE_SEED() TSRMLS_CC); } SPL_G(hash_mask_handle) = (intptr_t)(php_mt_rand(TSRMLS_C) >> 1); From c6116bea572059baa643f38e491704ec2cb7e030 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 28 Oct 2014 19:59:31 +0100 Subject: [PATCH 185/398] fix datatype mismatches --- ext/spl/spl_directory.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 73588ff1bd8..108eafddc40 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -199,7 +199,7 @@ static inline void spl_filesystem_object_get_file_name(spl_filesystem_object *in php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized"); break; case SPL_FS_DIR: - intern->file_name_len = spprintf(&intern->file_name, 0, "%s%c%s", + intern->file_name_len = (int)spprintf(&intern->file_name, 0, "%s%c%s", spl_filesystem_object_get_path(intern, NULL TSRMLS_CC), slash, intern->u.dir.entry.d_name); break; @@ -233,7 +233,7 @@ static void spl_filesystem_dir_open(spl_filesystem_object* intern, char *path TS int skip_dots = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_SKIPDOTS); intern->type = SPL_FS_DIR; - intern->_path_len = strlen(path); + intern->_path_len = (int)strlen(path); intern->u.dir.dirp = php_stream_opendir(path, REPORT_ERRORS, FG(default_context)); if (intern->_path_len > 1 && IS_SLASH_AT(path, intern->_path_len-1)) { @@ -384,7 +384,7 @@ void spl_filesystem_info_set_filename(spl_filesystem_object *intern, char *path, } intern->file_name = use_copy ? estrndup(path, len) : path; - intern->file_name_len = len; + intern->file_name_len = (int)len; while (intern->file_name_len > 1 && IS_SLASH_AT(intern->file_name, intern->file_name_len-1)) { intern->file_name[intern->file_name_len-1] = 0; @@ -398,7 +398,7 @@ void spl_filesystem_info_set_filename(spl_filesystem_object *intern, char *path, p2 = 0; #endif if (p1 || p2) { - intern->_path_len = (p1 > p2 ? p1 : p2) - intern->file_name; + intern->_path_len = (int)((p1 > p2 ? p1 : p2) - intern->file_name); } else { intern->_path_len = 0; } @@ -934,7 +934,8 @@ SPL_METHOD(SplFileInfo, getExtension) p = zend_memrchr(ret->val, '.', ret->len); if (p) { - idx = p - ret->val; + assert(p > ret->val); + idx = (int)(p - ret->val); RETVAL_STRINGL(ret->val + idx + 1, ret->len - idx - 1); zend_string_release(ret); return; @@ -962,7 +963,8 @@ SPL_METHOD(DirectoryIterator, getExtension) p = zend_memrchr(fname->val, '.', fname->len); if (p) { - idx = p - fname->val; + assert(p > fname->val); + idx = (int)(p - fname->val); RETVAL_STRINGL(fname->val + idx + 1, fname->len - idx - 1); zend_string_release(fname); } else { @@ -1389,7 +1391,7 @@ SPL_METHOD(SplFileInfo, getPathInfo) if (path) { char *dpath = estrndup(path, path_len); path_len = php_dirname(dpath, path_len); - spl_filesystem_object_create_info(intern, dpath, path_len, 1, ce, return_value TSRMLS_CC); + spl_filesystem_object_create_info(intern, dpath, (int)path_len, 1, ce, return_value TSRMLS_CC); efree(dpath); } } @@ -1516,9 +1518,9 @@ SPL_METHOD(RecursiveDirectoryIterator, getChildren) subdir = Z_SPLFILESYSTEM_P(return_value); if (subdir) { if (intern->u.dir.sub_path && intern->u.dir.sub_path[0]) { - subdir->u.dir.sub_path_len = spprintf(&subdir->u.dir.sub_path, 0, "%s%c%s", intern->u.dir.sub_path, slash, intern->u.dir.entry.d_name); + subdir->u.dir.sub_path_len = (int)spprintf(&subdir->u.dir.sub_path, 0, "%s%c%s", intern->u.dir.sub_path, slash, intern->u.dir.entry.d_name); } else { - subdir->u.dir.sub_path_len = strlen(intern->u.dir.entry.d_name); + subdir->u.dir.sub_path_len = (int)strlen(intern->u.dir.entry.d_name); subdir->u.dir.sub_path = estrndup(intern->u.dir.entry.d_name, subdir->u.dir.sub_path_len); } subdir->info_class = intern->info_class; @@ -1553,7 +1555,7 @@ SPL_METHOD(RecursiveDirectoryIterator, getSubPathname) { spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis()); char *sub_name; - int len; + size_t len; char slash = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_UNIXPATHS) ? '/' : DEFAULT_SLASH; if (zend_parse_parameters_none() == FAILURE) { @@ -2303,7 +2305,7 @@ SPL_METHOD(SplFileObject, __construct) p2 = 0; #endif if (p1 || p2) { - intern->_path_len = (p1 > p2 ? p1 : p2) - tmp_path; + intern->_path_len = (int)((p1 > p2 ? p1 : p2) - tmp_path); } else { intern->_path_len = 0; } @@ -2627,7 +2629,7 @@ SPL_METHOD(SplFileObject, fputcsv) char delimiter = intern->u.file.delimiter, enclosure = intern->u.file.enclosure, escape = intern->u.file.escape; char *delim = NULL, *enclo = NULL; size_t d_len = 0, e_len = 0; - int ret; + zend_long ret; zval *fields = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|ss", &fields, &delim, &d_len, &enclo, &e_len) == SUCCESS) { @@ -2776,7 +2778,7 @@ SPL_METHOD(SplFileObject, fseek) } spl_filesystem_file_free_line(intern TSRMLS_CC); - RETURN_LONG(php_stream_seek(intern->u.file.stream, pos, whence)); + RETURN_LONG(php_stream_seek(intern->u.file.stream, pos, (int)whence)); } /* }}} */ /* {{{ proto int SplFileObject::fgetc() From 8041bbb76bb07274cb96bc6b8b8e0cee42648edc Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 28 Oct 2014 20:11:53 +0100 Subject: [PATCH 186/398] fix datatype mismatch warning --- ext/spl/spl_dllist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c index 945f7c7ab4e..8a614075894 100644 --- a/ext/spl/spl_dllist.c +++ b/ext/spl/spl_dllist.c @@ -1182,7 +1182,7 @@ SPL_METHOD(SplDoublyLinkedList, unserialize) goto error; } - intern->flags = Z_LVAL(flags); + intern->flags = (int)Z_LVAL(flags); zval_ptr_dtor(&flags); /* elements */ From e888f3e4de511faf65924eba7ac92bb9d02f32b5 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 28 Oct 2014 20:12:20 +0100 Subject: [PATCH 187/398] fix datatype mismatches --- ext/spl/spl_fixedarray.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c index ee5ef6b9909..d63ac2e6e6f 100644 --- a/ext/spl/spl_fixedarray.c +++ b/ext/spl/spl_fixedarray.c @@ -151,7 +151,7 @@ static HashTable* spl_fixedarray_object_get_gc(zval *obj, zval **table, int *n T if (intern->array) { *table = intern->array->elements; - *n = intern->array->size; + *n = (int)intern->array->size; } else { *table = NULL; *n = 0; @@ -165,10 +165,10 @@ static HashTable* spl_fixedarray_object_get_properties(zval *obj TSRMLS_DC) /* { { spl_fixedarray_object *intern = Z_SPLFIXEDARRAY_P(obj); HashTable *ht = zend_std_get_properties(obj TSRMLS_CC); - int i = 0; + zend_long i = 0; if (intern->array) { - int j = zend_hash_num_elements(ht); + zend_long j = zend_hash_num_elements(ht); for (i = 0; i < intern->array->size; i++) { if (!Z_ISUNDEF(intern->array->elements[i])) { From 3a6db1e77a166914f4693bab274d1dbfecb5231b Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 29 Oct 2014 11:39:54 +0100 Subject: [PATCH 188/398] fix datatype mismatch --- ext/spl/spl_heap.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c index d29150c1d6d..b9f404ab113 100644 --- a/ext/spl/spl_heap.c +++ b/ext/spl/spl_heap.c @@ -160,12 +160,12 @@ static int spl_ptr_heap_zval_max_cmp(zval *a, zval *b, zval *object TSRMLS_DC) { /* exception or call failure */ return 0; } - return lval; + return lval > 0 ? 1 : -1; } } compare_function(&result, a, b TSRMLS_CC); - return Z_LVAL(result); + return (int)Z_LVAL(result); } /* }}} */ @@ -184,12 +184,12 @@ static int spl_ptr_heap_zval_min_cmp(zval *a, zval *b, zval *object TSRMLS_DC) { /* exception or call failure */ return 0; } - return lval; + return lval > 0 ? 1 : -1; } } compare_function(&result, b, a TSRMLS_CC); - return Z_LVAL(result); + return (int)Z_LVAL(result); } /* }}} */ @@ -215,12 +215,12 @@ static int spl_ptr_pqueue_zval_cmp(zval *a, zval *b, zval *object TSRMLS_DC) { / /* exception or call failure */ return 0; } - return lval; + return lval > 0 ? 1 : -1; } } compare_function(&result, a_priority_p, b_priority_p TSRMLS_CC); - return Z_LVAL(result); + return (int)Z_LVAL(result); } /* }}} */ From da1d0ee1bd8718cc5c10a010f1980bec7083d3fc Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 29 Oct 2014 11:48:29 +0100 Subject: [PATCH 189/398] fix the comparison return value --- ext/spl/spl_heap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c index b9f404ab113..b421c03757a 100644 --- a/ext/spl/spl_heap.c +++ b/ext/spl/spl_heap.c @@ -160,7 +160,7 @@ static int spl_ptr_heap_zval_max_cmp(zval *a, zval *b, zval *object TSRMLS_DC) { /* exception or call failure */ return 0; } - return lval > 0 ? 1 : -1; + return lval > 0 ? 1 : (lval < 0 ? -1 : 0); } } @@ -184,7 +184,7 @@ static int spl_ptr_heap_zval_min_cmp(zval *a, zval *b, zval *object TSRMLS_DC) { /* exception or call failure */ return 0; } - return lval > 0 ? 1 : -1; + return lval > 0 ? 1 : (lval < 0 ? -1 : 0); } } @@ -215,7 +215,7 @@ static int spl_ptr_pqueue_zval_cmp(zval *a, zval *b, zval *object TSRMLS_DC) { / /* exception or call failure */ return 0; } - return lval > 0 ? 1 : -1; + return lval > 0 ? 1 : (lval < 0 ? -1 : 0); } } From 9d21ff6b9e6fbc16807640c1e7e471cebaff21c4 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 29 Oct 2014 13:36:10 +0100 Subject: [PATCH 190/398] fix datatype mismatches PCRE uses plain datatypes, no typedefs. --- ext/pcre/php_pcre.c | 60 ++++++++++++++++++++++----------------------- ext/pcre/php_pcre.h | 10 ++++---- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 67857da2c7a..918214edb14 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -423,8 +423,8 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex TSRMLS extra = pcre_study(re, soptions, &error); if (extra) { extra->flags |= PCRE_EXTRA_MATCH_LIMIT | PCRE_EXTRA_MATCH_LIMIT_RECURSION; - extra->match_limit = PCRE_G(backtrack_limit); - extra->match_limit_recursion = PCRE_G(recursion_limit); + extra->match_limit = (unsigned long)PCRE_G(backtrack_limit); + extra->match_limit_recursion = (unsigned long)PCRE_G(recursion_limit); } if (error != NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error while studying pattern"); @@ -568,14 +568,14 @@ static void php_do_pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global) /* {{{ * RETURN_FALSE; } - php_pcre_match_impl(pce, subject->val, subject->len, return_value, subpats, + php_pcre_match_impl(pce, subject->val, (int)subject->len, return_value, subpats, global, ZEND_NUM_ARGS() >= 4, flags, start_offset TSRMLS_CC); } /* }}} */ /* {{{ php_pcre_match_impl() */ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, int subject_len, zval *return_value, - zval *subpats, int global, int use_flags, long flags, long start_offset TSRMLS_DC) + zval *subpats, int global, int use_flags, zend_long flags, zend_long start_offset TSRMLS_DC) { zval result_set, /* Holds a set of subpatterns after a global match */ @@ -640,8 +640,8 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, int subjec extra_data.flags = PCRE_EXTRA_MATCH_LIMIT | PCRE_EXTRA_MATCH_LIMIT_RECURSION; extra = &extra_data; } - extra->match_limit = PCRE_G(backtrack_limit); - extra->match_limit_recursion = PCRE_G(recursion_limit); + extra->match_limit = (unsigned long)PCRE_G(backtrack_limit); + extra->match_limit_recursion = (unsigned long)PCRE_G(recursion_limit); #ifdef PCRE_EXTRA_MARK extra->mark = &mark; extra->flags |= PCRE_EXTRA_MARK; @@ -682,7 +682,7 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, int subjec do { /* Execute the regular expression. */ - count = pcre_exec(pce->re, extra, subject, subject_len, start_offset, + count = pcre_exec(pce->re, extra, subject, (int)subject_len, (int)start_offset, exoptions|g_notempty, offsets, size_offsets); /* the string was already proved to be valid UTF-8 */ @@ -834,8 +834,8 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, int subjec the start offset, and continue. Fudge the offset values to achieve this, unless we're already at the end of the string. */ if (g_notempty != 0 && start_offset < subject_len) { - offsets[0] = start_offset; - offsets[1] = start_offset + 1; + offsets[0] = (int)start_offset; + offsets[1] = (int)(start_offset + 1); } else break; } else { @@ -1130,8 +1130,8 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, extra_data.flags = PCRE_EXTRA_MATCH_LIMIT | PCRE_EXTRA_MATCH_LIMIT_RECURSION; extra = &extra_data; } - extra->match_limit = PCRE_G(backtrack_limit); - extra->match_limit_recursion = PCRE_G(recursion_limit); + extra->match_limit = (unsigned long)PCRE_G(backtrack_limit); + extra->match_limit_recursion = (unsigned long)PCRE_G(recursion_limit); eval = pce->preg_options & PREG_REPLACE_EVAL; if (is_callable_replace) { @@ -1141,7 +1141,7 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, } } else { replace = Z_STRVAL_P(replace_val); - replace_len = Z_STRLEN_P(replace_val); + replace_len = (int)Z_STRLEN_P(replace_val); replace_end = replace + replace_len; } @@ -1212,11 +1212,11 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, if (eval) { eval_result = preg_do_eval(replace, replace_len, subject, offsets, count TSRMLS_CC); - new_len += eval_result->len; + new_len += (int)eval_result->len; } else if (is_callable_replace) { /* Use custom function to get replacement string and its length. */ eval_result = preg_do_repl_func(replace_val, subject, offsets, subpat_names, count, mark TSRMLS_CC); - new_len += eval_result->len; + new_len += (int)eval_result->len; } else { /* do regular substitution */ walk = replace; walk_last = 0; @@ -1245,7 +1245,7 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, } /* copy the part of the string before the match */ memcpy(&result->val[result_len], piece, match-piece); - result_len += match-piece; + result_len += (int)(match-piece); /* copy replacement and backrefs */ walkbuf = result->val + result_len; @@ -1254,7 +1254,7 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, * and clean up. */ if (eval || is_callable_replace) { memcpy(walkbuf, eval_result->val, eval_result->len); - result_len += eval_result->len; + result_len += (int)eval_result->len; if (eval_result) zend_string_release(eval_result); } else { /* do regular backreference copying */ walk = replace; @@ -1280,7 +1280,7 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, } *walkbuf = '\0'; /* increment the result length by how much we've added to the string */ - result_len += walkbuf - (result->val + result_len); + result_len += (int)(walkbuf - (result->val + result_len)); } if (limit != -1) @@ -1393,7 +1393,7 @@ static zend_string *php_replace_in_subject(zval *regex, zval *replace, zval *sub for further replacements. */ if ((result = php_pcre_replace(regex_str, subject_str->val, - subject_str->len, + (int)subject_str->len, replace_value, is_callable_replace, limit, @@ -1413,7 +1413,7 @@ static zend_string *php_replace_in_subject(zval *regex, zval *replace, zval *sub } else { result = php_pcre_replace(Z_STR_P(regex), subject_str->val, - subject_str->len, + (int)subject_str->len, replace, is_callable_replace, limit, @@ -1477,7 +1477,7 @@ static void preg_replace_impl(INTERNAL_FUNCTION_PARAMETERS, int is_callable_repl } if (ZEND_NUM_ARGS() > 3) { - limit_val = limit; + limit_val = (int)limit; } if (Z_TYPE_P(regex) != IS_ARRAY) { @@ -1579,14 +1579,14 @@ static PHP_FUNCTION(preg_split) RETURN_FALSE; } - php_pcre_split_impl(pce, subject->val, subject->len, return_value, limit_val, flags TSRMLS_CC); + php_pcre_split_impl(pce, subject->val, (int)subject->len, return_value, (int)limit_val, flags TSRMLS_CC); } /* }}} */ /* {{{ php_pcre_split */ PHPAPI void php_pcre_split_impl(pcre_cache_entry *pce, char *subject, int subject_len, zval *return_value, - long limit_val, long flags TSRMLS_DC) + zend_long limit_val, zend_long flags TSRMLS_DC) { pcre_extra *extra = NULL; /* Holds results of studying */ pcre *re_bump = NULL; /* Regex instance for empty matches */ @@ -1617,8 +1617,8 @@ PHPAPI void php_pcre_split_impl(pcre_cache_entry *pce, char *subject, int subjec extra_data.flags = PCRE_EXTRA_MATCH_LIMIT | PCRE_EXTRA_MATCH_LIMIT_RECURSION; extra = &extra_data; } - extra->match_limit = PCRE_G(backtrack_limit); - extra->match_limit_recursion = PCRE_G(recursion_limit); + extra->match_limit = (unsigned long)PCRE_G(backtrack_limit); + extra->match_limit_recursion = (unsigned long)PCRE_G(recursion_limit); #ifdef PCRE_EXTRA_MARK extra->flags &= ~PCRE_EXTRA_MARK; #endif @@ -1661,7 +1661,7 @@ PHPAPI void php_pcre_split_impl(pcre_cache_entry *pce, char *subject, int subjec if (offset_capture) { /* Add (match, offset) pair to the return value */ - add_offset_pair(return_value, last_match, &subject[offsets[0]]-last_match, next_offset, NULL); + add_offset_pair(return_value, last_match, (int)(&subject[offsets[0]]-last_match), next_offset, NULL); } else { /* Add the piece to the return value */ add_next_index_stringl(return_value, last_match, @@ -1737,7 +1737,7 @@ PHPAPI void php_pcre_split_impl(pcre_cache_entry *pce, char *subject, int subjec } - start_offset = last_match - subject; /* the offset might have been incremented, but without further successful matches */ + start_offset = (int)(last_match - subject); /* the offset might have been incremented, but without further successful matches */ if (!no_empty || start_offset < subject_len) { @@ -1889,7 +1889,7 @@ static PHP_FUNCTION(preg_grep) } /* }}} */ -PHPAPI void php_pcre_grep_impl(pcre_cache_entry *pce, zval *input, zval *return_value, long flags TSRMLS_DC) /* {{{ */ +PHPAPI void php_pcre_grep_impl(pcre_cache_entry *pce, zval *input, zval *return_value, zend_long flags TSRMLS_DC) /* {{{ */ { zval *entry; /* An entry in the input array */ pcre_extra *extra = pce->extra;/* Holds results of studying */ @@ -1909,8 +1909,8 @@ PHPAPI void php_pcre_grep_impl(pcre_cache_entry *pce, zval *input, zval *return extra_data.flags = PCRE_EXTRA_MATCH_LIMIT | PCRE_EXTRA_MATCH_LIMIT_RECURSION; extra = &extra_data; } - extra->match_limit = PCRE_G(backtrack_limit); - extra->match_limit_recursion = PCRE_G(recursion_limit); + extra->match_limit = (unsigned long)PCRE_G(backtrack_limit); + extra->match_limit_recursion = (unsigned long)PCRE_G(recursion_limit); #ifdef PCRE_EXTRA_MARK extra->flags &= ~PCRE_EXTRA_MARK; #endif @@ -1934,7 +1934,7 @@ PHPAPI void php_pcre_grep_impl(pcre_cache_entry *pce, zval *input, zval *return /* Perform the match */ count = pcre_exec(pce->re, extra, subject_str->val, - subject_str->len, 0, + (int)subject_str->len, 0, 0, offsets, size_offsets); /* Check for too many substrings condition. */ diff --git a/ext/pcre/php_pcre.h b/ext/pcre/php_pcre.h index cd6621372ff..a8523cff9cc 100644 --- a/ext/pcre/php_pcre.h +++ b/ext/pcre/php_pcre.h @@ -57,21 +57,21 @@ typedef struct { PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex TSRMLS_DC); PHPAPI void php_pcre_match_impl( pcre_cache_entry *pce, char *subject, int subject_len, zval *return_value, - zval *subpats, int global, int use_flags, long flags, long start_offset TSRMLS_DC); + zval *subpats, int global, int use_flags, zend_long flags, zend_long start_offset TSRMLS_DC); PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, int subject_len, zval *return_value, int is_callable_replace, int limit, int *replace_count TSRMLS_DC); PHPAPI void php_pcre_split_impl( pcre_cache_entry *pce, char *subject, int subject_len, zval *return_value, - long limit_val, long flags TSRMLS_DC); + zend_long limit_val, zend_long flags TSRMLS_DC); PHPAPI void php_pcre_grep_impl( pcre_cache_entry *pce, zval *input, zval *return_value, - long flags TSRMLS_DC); + zend_long flags TSRMLS_DC); ZEND_BEGIN_MODULE_GLOBALS(pcre) HashTable pcre_cache; - long backtrack_limit; - long recursion_limit; + zend_long backtrack_limit; + zend_long recursion_limit; #ifdef PCRE_STUDY_JIT_COMPILE zend_bool jit; #endif From 110cf649b7d156f97f98cc8e894fb2d4ed8c67ff Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 29 Oct 2014 13:46:58 +0100 Subject: [PATCH 191/398] fix datatype mismatches especially spl_dual_it_object current.pos should have the same datatype as limit.offset, also this doesn't increase the struct size. --- ext/spl/spl_iterators.c | 15 +++++++++------ ext/spl/spl_iterators.h | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 8b09e3ef372..c129115eebe 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -540,7 +540,7 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla intern->iterators = emalloc(sizeof(spl_sub_iterator)); intern->level = 0; intern->mode = mode; - intern->flags = flags; + intern->flags = (int)flags; intern->max_depth = -1; intern->in_iteration = 0; intern->ce = Z_OBJCE_P(object); @@ -854,8 +854,11 @@ SPL_METHOD(RecursiveIteratorIterator, setMaxDepth) if (max_depth < -1) { zend_throw_exception(spl_ce_OutOfRangeException, "Parameter max_depth must be >= -1", 0 TSRMLS_CC); return; + } else if (max_depth > INT_MAX) { + max_depth = INT_MAX; } - object->max_depth = max_depth; + + object->max_depth = (int)max_depth; } /* }}} */ /* {{{ proto int|false RecursiveIteratorIterator::getMaxDepth() @@ -1423,9 +1426,9 @@ int spl_dual_it_call_method(char *method, INTERNAL_FUNCTION_PARAMETERS) static inline int spl_dual_it_fetch(spl_dual_it_object *intern, int check_more TSRMLS_DC); -static inline int spl_cit_check_flags(int flags) +static inline int spl_cit_check_flags(zend_long flags) { - int cnt = 0; + zend_long cnt = 0; cnt += (flags & CIT_CALL_TOSTRING) ? 1 : 0; cnt += (flags & CIT_TOSTRING_USE_KEY) ? 1 : 0; @@ -2051,10 +2054,10 @@ SPL_METHOD(RegexIterator, accept) use_copy = zend_make_printable_zval(subject_ptr, &subject_copy TSRMLS_CC); if (use_copy) { subject = Z_STRVAL(subject_copy); - subject_len = Z_STRLEN(subject_copy); + subject_len = (int)Z_STRLEN(subject_copy); } else { subject = Z_STRVAL_P(subject_ptr); - subject_len = Z_STRLEN_P(subject_ptr); + subject_len = (int)Z_STRLEN_P(subject_ptr); } use_copy = 0; diff --git a/ext/spl/spl_iterators.h b/ext/spl/spl_iterators.h index f0740275dc0..76f0b45e57a 100644 --- a/ext/spl/spl_iterators.h +++ b/ext/spl/spl_iterators.h @@ -134,7 +134,7 @@ typedef struct _spl_dual_it_object { struct { zval data; zval key; - int pos; + zend_long pos; } current; dual_it_type dit_type; union { From 1100f1b8fdffe5ba16d6785b2ba2fc91c33f4833 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 29 Oct 2014 14:09:30 +0100 Subject: [PATCH 192/398] fix datatype mismatch --- ext/spl/spl_observer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c index d3ce72aaa3b..f7f884df188 100644 --- a/ext/spl/spl_observer.c +++ b/ext/spl/spl_observer.c @@ -398,7 +398,7 @@ static int spl_object_storage_compare_info(zval *e1, zval *e2 TSRMLS_DC) /* {{{ return 1; } - return Z_LVAL(result); + return Z_LVAL(result) > 0 ? 1 : (Z_LVAL(result) < 0 ? -1 : 0); } /* }}} */ From 897695764cb88b044679562a908f2df0df52b1f0 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 29 Oct 2014 14:28:16 +0100 Subject: [PATCH 193/398] fix datatype mismatches sizeof(struct _string) doesn't increase. --- ext/reflection/php_reflection.c | 34 ++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index cc4ed54deab..3d44c35b629 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -116,7 +116,7 @@ ZEND_DECLARE_MODULE_GLOBALS(reflection) /* {{{ Smart string functions */ typedef struct _string { zend_string *buf; - int alloced; + size_t alloced; } string; static void string_init(string *str) @@ -129,16 +129,16 @@ static void string_init(string *str) static string *string_printf(string *str, const char *format, ...) { - int len; + size_t len; va_list arg; char *s_tmp; va_start(arg, format); len = zend_vspprintf(&s_tmp, 0, format, arg); if (len) { - register int nlen = (str->buf->len + 1 + len + (1024 - 1)) & ~(1024 - 1); + register size_t nlen = (str->buf->len + 1 + len + (1024 - 1)) & ~(1024 - 1); if (str->alloced < nlen) { - int old_len = str->buf->len; + size_t old_len = str->buf->len; str->alloced = nlen; str->buf = zend_string_realloc(str->buf, str->alloced, 0); str->buf->len = old_len; @@ -151,11 +151,11 @@ static string *string_printf(string *str, const char *format, ...) return str; } -static string *string_write(string *str, char *buf, int len) +static string *string_write(string *str, char *buf, size_t len) { - register int nlen = (str->buf->len + 1 + len + (1024 - 1)) & ~(1024 - 1); + register size_t nlen = (str->buf->len + 1 + len + (1024 - 1)) & ~(1024 - 1); if (str->alloced < nlen) { - int old_len = str->buf->len; + size_t old_len = str->buf->len; str->alloced = nlen; str->buf = zend_string_realloc(str->buf, str->alloced, 0); str->buf->len = old_len; @@ -603,7 +603,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in { zend_string *key; zend_ulong num_index; - uint len = mptr->common.function_name->len; + size_t len = mptr->common.function_name->len; /* Do not display old-style inherited constructors */ if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0 @@ -809,7 +809,7 @@ static void _function_string(string *str, zend_function *fptr, zend_class_entry string param_indent; zend_function *overwrites; zend_string *lc_name; - unsigned int lc_name_len; + size_t lc_name_len; /* TBD: Repair indenting of doc comment (or is this to be done in the parser?) * What's "wrong" is that any whitespace before the doc comment start is @@ -1196,7 +1196,7 @@ static void reflection_extension_factory(zval *object, const char *name_str TSRM { reflection_object *intern; zval name; - int name_len = strlen(name_str); + size_t name_len = strlen(name_str); zend_string *lcname; struct _zend_module_entry *module; @@ -2141,7 +2141,7 @@ ZEND_METHOD(reflection_parameter, __construct) /* First, find the function */ switch (Z_TYPE_P(reference)) { case IS_STRING: { - unsigned int lcname_len; + size_t lcname_len; char *lcname; lcname_len = Z_STRLEN_P(reference); @@ -2160,7 +2160,7 @@ ZEND_METHOD(reflection_parameter, __construct) case IS_ARRAY: { zval *classref; zval *method; - unsigned int lcname_len; + size_t lcname_len; char *lcname; if (((classref =zend_hash_index_find(Z_ARRVAL_P(reference), 0)) == NULL) @@ -2224,7 +2224,7 @@ ZEND_METHOD(reflection_parameter, __construct) /* Now, search for the parameter */ arg_info = fptr->common.arg_info; if (Z_TYPE_P(parameter) == IS_LONG) { - position= Z_LVAL_P(parameter); + position= (int)Z_LVAL_P(parameter); if (position < 0 || (uint32_t)position >= fptr->common.num_args) { if (fptr->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) { if (fptr->type != ZEND_OVERLOADED_FUNCTION) { @@ -3707,10 +3707,10 @@ ZEND_METHOD(reflection_class, getMethod) /* }}} */ /* {{{ _addmethod */ -static void _addmethod(zend_function *mptr, zend_class_entry *ce, zval *retval, long filter, zval *obj TSRMLS_DC) +static void _addmethod(zend_function *mptr, zend_class_entry *ce, zval *retval, zend_long filter, zval *obj TSRMLS_DC) { zval method; - uint len = mptr->common.function_name->len; + size_t len = mptr->common.function_name->len; zend_function *closure; if (mptr->common.fn_flags & filter) { if (ce == zend_ce_closure && obj && (len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) @@ -3819,7 +3819,7 @@ ZEND_METHOD(reflection_class, getProperty) zend_property_info *property_info; zend_string *name, *classname; char *tmp, *str_name; - int classname_len, str_name_len; + size_t classname_len, str_name_len; METHOD_NOTSTATIC(reflection_class_ptr); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &name) == FAILURE) { @@ -5407,7 +5407,7 @@ ZEND_METHOD(reflection_extension, getDependencies) while(dep->name) { zend_string *relation; char *rel_type; - int len = 0; + size_t len = 0; switch(dep->type) { case MODULE_DEP_REQUIRED: From 23f089a6b3586d524e8709d75262029bc8fa7ad4 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 29 Oct 2014 14:33:50 +0100 Subject: [PATCH 194/398] fix datatype mismatches --- ext/iconv/iconv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index d425f6cf1e9..a4581e9fad8 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -408,7 +408,7 @@ static int php_iconv_output_handler(void **nothing, php_output_context *output_c mimetype = SG(sapi_headers).mimetype; } else { mimetype = SG(sapi_headers).mimetype; - mimetype_len = s - SG(sapi_headers).mimetype; + mimetype_len = (int)(s - SG(sapi_headers).mimetype); } } else if (SG(sapi_headers).send_default_content_type) { mimetype = SG(default_mimetype) ? SG(default_mimetype) : SAPI_DEFAULT_MIMETYPE; @@ -423,7 +423,7 @@ static int php_iconv_output_handler(void **nothing, php_output_context *output_c } else { len = spprintf(&content_type, 0, "Content-Type:%.*s; charset=%s", mimetype_len ? mimetype_len : (size_t) strlen(mimetype), mimetype, get_output_encoding(TSRMLS_C)); } - if (content_type && SUCCESS == sapi_add_header(content_type, len, 0)) { + if (content_type && SUCCESS == sapi_add_header(content_type, (uint)len, 0)) { SG(sapi_headers).send_default_content_type = 0; php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE, NULL TSRMLS_CC); } @@ -2300,7 +2300,7 @@ PHP_FUNCTION(iconv_mime_decode) RETURN_FALSE; } - err = _php_iconv_mime_decode(&retval, encoded_str->val, encoded_str->len, charset, NULL, mode); + err = _php_iconv_mime_decode(&retval, encoded_str->val, encoded_str->len, charset, NULL, (int)mode); _php_iconv_show_error(err, charset, "???" TSRMLS_CC); if (err == PHP_ICONV_ERR_SUCCESS) { @@ -2353,7 +2353,7 @@ PHP_FUNCTION(iconv_mime_decode_headers) char *p, *limit; const char *next_pos; - if (PHP_ICONV_ERR_SUCCESS != (err = _php_iconv_mime_decode(&decoded_header, enc_str_tmp, enc_str_len_tmp, charset, &next_pos, mode))) { + if (PHP_ICONV_ERR_SUCCESS != (err = _php_iconv_mime_decode(&decoded_header, enc_str_tmp, enc_str_len_tmp, charset, &next_pos, (int)mode))) { smart_str_free(&decoded_header); break; } From 79a4339f1b23c8cb534679667f7ce781f21c5bb3 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 29 Oct 2014 19:28:21 +0100 Subject: [PATCH 195/398] fix sapi/phpdbg/config.w32 --- sapi/phpdbg/config.w32 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sapi/phpdbg/config.w32 b/sapi/phpdbg/config.w32 index 651c7e6d16a..8a685d33477 100644 --- a/sapi/phpdbg/config.w32 +++ b/sapi/phpdbg/config.w32 @@ -1,6 +1,6 @@ ARG_ENABLE('phpdbg', 'Build phpdbg', 'no'); ARG_ENABLE('phpdbgs', 'Build phpdbg shared', 'no'); -ARG_ENABLE('phpdbgwebhelper', 'Build phpdbg webhelper', 'yes'); +ARG_ENABLE('phpdbg-webhelper', 'Build phpdbg webhelper', 'yes'); PHPDBG_SOURCES='phpdbg.c phpdbg_prompt.c phpdbg_cmd.c phpdbg_info.c phpdbg_help.c phpdbg_break.c ' + 'phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c ' + @@ -16,8 +16,8 @@ if (PHP_PHPDBG == "yes") { ADD_FLAG("CFLAGS_PHPDBG", "/D YY_NO_UNISTD_H"); ADD_FLAG("LDFLAGS_PHPDBG", "/stack:8388608"); - if (PHP_PHPDBGWEBHELPER == "yes") { - EXTENSION('phpdbg-webhelper', 'phpdbg_rinit_hook.c phpdbg_webdata_compress.c'); + if (PHP_PHPDBG_WEBHELPER == "yes") { + EXTENSION('phpdbg_webhelper', 'phpdbg_rinit_hook.c phpdbg_webdata_transfer.c'); } } From fdbfcc0b51b5d78777625d5be93a282e23cc0540 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 29 Oct 2014 19:32:52 +0100 Subject: [PATCH 196/398] dll export APIs needed by phpdbg --- ext/standard/basic_functions.c | 4 ++-- ext/standard/basic_functions.h | 4 ++++ main/php_main.h | 3 --- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index ca14b28ccd2..c5392760e82 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -5051,7 +5051,7 @@ static int user_tick_function_compare(user_tick_function_entry * tick_fe1, user_ } /* }}} */ -void php_call_shutdown_functions(TSRMLS_D) /* {{{ */ +PHPAPI void php_call_shutdown_functions(TSRMLS_D) /* {{{ */ { if (BG(user_shutdown_function_names)) { zend_try { @@ -5063,7 +5063,7 @@ void php_call_shutdown_functions(TSRMLS_D) /* {{{ */ } /* }}} */ -void php_free_shutdown_functions(TSRMLS_D) /* {{{ */ +PHPAPI void php_free_shutdown_functions(TSRMLS_D) /* {{{ */ { if (BG(user_shutdown_function_names)) zend_try { diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h index 3af85b3d403..eaeb9bca839 100644 --- a/ext/standard/basic_functions.h +++ b/ext/standard/basic_functions.h @@ -261,4 +261,8 @@ PHPAPI extern zend_bool register_user_shutdown_function(char *function_name, siz PHPAPI extern zend_bool remove_user_shutdown_function(char *function_name, size_t function_len TSRMLS_DC); PHPAPI extern zend_bool append_user_shutdown_function(php_shutdown_function_entry shutdown_function_entry TSRMLS_DC); +PHPAPI void php_call_shutdown_functions(TSRMLS_D); +PHPAPI void php_free_shutdown_functions(TSRMLS_D); + + #endif /* BASIC_FUNCTIONS_H */ diff --git a/main/php_main.h b/main/php_main.h index 1325486bd97..03c89c5d6f2 100644 --- a/main/php_main.h +++ b/main/php_main.h @@ -50,9 +50,6 @@ PHPAPI int php_handle_auth_data(const char *auth TSRMLS_DC); PHPAPI void php_html_puts(const char *str, uint siz TSRMLS_DC); PHPAPI int php_stream_open_for_zend_ex(const char *filename, zend_file_handle *handle, int mode TSRMLS_DC); -extern void php_call_shutdown_functions(TSRMLS_D); -extern void php_free_shutdown_functions(TSRMLS_D); - /* environment module */ extern int php_init_environ(void); extern int php_shutdown_environ(void); From f842b8f4be9350dfd0444633c62fe7a5c76c54a5 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 29 Oct 2014 19:39:46 +0100 Subject: [PATCH 197/398] unix sockets aren't available on windows --- sapi/phpdbg/phpdbg_wait.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sapi/phpdbg/phpdbg_wait.c b/sapi/phpdbg/phpdbg_wait.c index 95024b8d77f..6f9eea90e37 100644 --- a/sapi/phpdbg/phpdbg_wait.c +++ b/sapi/phpdbg/phpdbg_wait.c @@ -365,6 +365,7 @@ void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) { PHPDBG_COMMAND(wait) /* {{{ */ { +#ifndef PHP_WIN32 struct sockaddr_un local, remote; int rlen, sr, sl; unlink(PHPDBG_G(socket_path)); @@ -414,6 +415,7 @@ PHPDBG_COMMAND(wait) /* {{{ */ efree(data); phpdbg_notice("wait", "import=\"success\"", "Successfully imported request data, stopped before executing"); +#endif return SUCCESS; } /* }}} */ From 4b8f411d313bddb0c1cd9308a7402ea20fb348b4 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 29 Oct 2014 19:49:20 +0100 Subject: [PATCH 198/398] use portable strndup implementation --- sapi/phpdbg/phpdbg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 5ebc203529b..7ca79972972 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -549,7 +549,7 @@ static int php_sapi_phpdbg_deactivate(TSRMLS_D) /* {{{ */ php_phpdbg_globals_ctor(pg); - pg->exec = strndup(PHPDBG_G(exec), PHPDBG_G(exec_len)); + pg->exec = zend_strndup(PHPDBG_G(exec), PHPDBG_G(exec_len)); pg->exec_len = PHPDBG_G(exec_len); pg->oplog = PHPDBG_G(oplog); pg->prompt[0] = PHPDBG_G(prompt)[0]; From 5d76185792d2c7c7d47838b71a0b230f9668e21c Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 29 Oct 2014 20:02:41 +0100 Subject: [PATCH 199/398] export output globals needed by phpdbg --- main/output.c | 6 +++++- main/php_output.h | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/main/output.c b/main/output.c index 1dac7179b8e..c2b7b3422dc 100644 --- a/main/output.c +++ b/main/output.c @@ -35,7 +35,11 @@ #include "zend_stack.h" #include "php_output.h" -ZEND_DECLARE_MODULE_GLOBALS(output); +#ifdef ZTS +PHPAPI int output_globals_id; +#else +PHPAPI php_output_globals output_globals; +#endif const char php_output_default_handler_name[sizeof("default output handler")] = "default output handler"; const char php_output_devnull_handler_name[sizeof("null output handler")] = "null output handler"; diff --git a/main/php_output.h b/main/php_output.h index 0312e256f80..947da2c915d 100644 --- a/main/php_output.h +++ b/main/php_output.h @@ -152,6 +152,12 @@ ZEND_BEGIN_MODULE_GLOBALS(output) int output_start_lineno; ZEND_END_MODULE_GLOBALS(output) +#ifdef ZTS +PHPAPI extern int output_globals_id; +#else +PHPAPI extern php_output_globals output_globals; +#endif + /* there should not be a need to use OG() from outside of output.c */ #ifdef ZTS # define OG(v) TSRMG(output_globals_id, zend_output_globals *, v) From fc904569ea5c5513925a69bf43820845eb3db104 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 29 Oct 2014 20:03:28 +0100 Subject: [PATCH 200/398] fix output globals importing --- sapi/phpdbg/phpdbg_frame.c | 1 - sapi/phpdbg/phpdbg_prompt.c | 1 - 2 files changed, 2 deletions(-) diff --git a/sapi/phpdbg/phpdbg_frame.c b/sapi/phpdbg/phpdbg_frame.c index 437e6d474a8..0506c305dcb 100644 --- a/sapi/phpdbg/phpdbg_frame.c +++ b/sapi/phpdbg/phpdbg_frame.c @@ -25,7 +25,6 @@ #include "phpdbg_list.h" ZEND_EXTERN_MODULE_GLOBALS(phpdbg); -ZEND_EXTERN_MODULE_GLOBALS(output); void phpdbg_restore_frame(TSRMLS_D) /* {{{ */ { diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index c1fcb59a086..915bccfa69f 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -41,7 +41,6 @@ #include "phpdbg_eol.h" ZEND_EXTERN_MODULE_GLOBALS(phpdbg); -ZEND_EXTERN_MODULE_GLOBALS(output); extern int phpdbg_startup_run; #ifdef HAVE_LIBDL From 7b4993dd169a082c2fe79f975224057d1e16c779 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Thu, 30 Oct 2014 11:42:02 +0800 Subject: [PATCH 201/398] Fixed build.... (shouldn't it be zend_output_globals?) --- main/output.c | 2 +- main/php_output.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main/output.c b/main/output.c index c2b7b3422dc..be5a2228535 100644 --- a/main/output.c +++ b/main/output.c @@ -38,7 +38,7 @@ #ifdef ZTS PHPAPI int output_globals_id; #else -PHPAPI php_output_globals output_globals; +PHPAPI zend_output_globals output_globals; #endif const char php_output_default_handler_name[sizeof("default output handler")] = "default output handler"; diff --git a/main/php_output.h b/main/php_output.h index 947da2c915d..edea0bff330 100644 --- a/main/php_output.h +++ b/main/php_output.h @@ -155,7 +155,7 @@ ZEND_END_MODULE_GLOBALS(output) #ifdef ZTS PHPAPI extern int output_globals_id; #else -PHPAPI extern php_output_globals output_globals; +PHPAPI extern zend_output_globals output_globals; #endif /* there should not be a need to use OG() from outside of output.c */ From 9e1da42af18265d007b5246f01895d3cafc78939 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Thu, 30 Oct 2014 11:52:29 +0800 Subject: [PATCH 202/398] Use macro --- main/output.c | 6 +----- main/php_output.h | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/main/output.c b/main/output.c index be5a2228535..1dac7179b8e 100644 --- a/main/output.c +++ b/main/output.c @@ -35,11 +35,7 @@ #include "zend_stack.h" #include "php_output.h" -#ifdef ZTS -PHPAPI int output_globals_id; -#else -PHPAPI zend_output_globals output_globals; -#endif +ZEND_DECLARE_MODULE_GLOBALS(output); const char php_output_default_handler_name[sizeof("default output handler")] = "default output handler"; const char php_output_devnull_handler_name[sizeof("null output handler")] = "null output handler"; diff --git a/main/php_output.h b/main/php_output.h index edea0bff330..6c4b1f7a429 100644 --- a/main/php_output.h +++ b/main/php_output.h @@ -152,11 +152,7 @@ ZEND_BEGIN_MODULE_GLOBALS(output) int output_start_lineno; ZEND_END_MODULE_GLOBALS(output) -#ifdef ZTS -PHPAPI extern int output_globals_id; -#else -PHPAPI extern zend_output_globals output_globals; -#endif +ZEND_EXTERN_MODULE_GLOBALS(output); /* there should not be a need to use OG() from outside of output.c */ #ifdef ZTS From af22cd665cbcbdfa07a3707d0651f719e023f0ec Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Thu, 30 Oct 2014 16:00:08 +0800 Subject: [PATCH 203/398] Fixed memory leak in ZEND_JMPZ_EX (op1 and result may share same slot) --- Zend/zend_vm_def.h | 5 +++-- Zend/zend_vm_execute.h | 18 +++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 72fbf7fbb40..9f2d26a2030 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -1910,13 +1910,14 @@ ZEND_VM_HANDLER(46, ZEND_JMPZ_EX, CONST|TMP|VAR|CV, ANY) } if (i_zend_is_true(val TSRMLS_CC)) { + FREE_OP1(); ZVAL_TRUE(EX_VAR(opline->result.var)); opline++; } else { + FREE_OP1(); ZVAL_FALSE(EX_VAR(opline->result.var)); opline = opline->op2.jmp_addr; } - FREE_OP1(); if (UNEXPECTED(EG(exception) != NULL)) { HANDLE_EXCEPTION(); } @@ -3773,7 +3774,7 @@ ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, VAR|CONST|UNUSED, CONST) } else if ((c = zend_quick_get_constant(opline->op2.zv + 1, opline->extended_value TSRMLS_CC)) == NULL) { if ((opline->extended_value & IS_CONSTANT_UNQUALIFIED) != 0) { char *actual = (char *)zend_memrchr(Z_STRVAL_P(opline->op2.zv), '\\', Z_STRLEN_P(opline->op2.zv)); - if(!actual) { + if (!actual) { actual = Z_STRVAL_P(opline->op2.zv); } else { actual++; diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 94466c581bc..732c3f02a25 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -2497,13 +2497,14 @@ static int ZEND_FASTCALL ZEND_JMPZ_EX_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_AR } if (i_zend_is_true(val TSRMLS_CC)) { + ZVAL_TRUE(EX_VAR(opline->result.var)); opline++; } else { + ZVAL_FALSE(EX_VAR(opline->result.var)); opline = opline->op2.jmp_addr; } - if (UNEXPECTED(EG(exception) != NULL)) { HANDLE_EXCEPTION(); } @@ -4298,7 +4299,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_CONST_CONST_HANDLER(ZEND_OPCO } else if ((c = zend_quick_get_constant(opline->op2.zv + 1, opline->extended_value TSRMLS_CC)) == NULL) { if ((opline->extended_value & IS_CONSTANT_UNQUALIFIED) != 0) { char *actual = (char *)zend_memrchr(Z_STRVAL_P(opline->op2.zv), '\\', Z_STRLEN_P(opline->op2.zv)); - if(!actual) { + if (!actual) { actual = Z_STRVAL_P(opline->op2.zv); } else { actual++; @@ -9336,13 +9337,14 @@ static int ZEND_FASTCALL ZEND_JMPZ_EX_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS } if (i_zend_is_true(val TSRMLS_CC)) { + zval_ptr_dtor_nogc(free_op1.var); ZVAL_TRUE(EX_VAR(opline->result.var)); opline++; } else { + zval_ptr_dtor_nogc(free_op1.var); ZVAL_FALSE(EX_VAR(opline->result.var)); opline = opline->op2.jmp_addr; } - zval_ptr_dtor_nogc(free_op1.var); if (UNEXPECTED(EG(exception) != NULL)) { HANDLE_EXCEPTION(); } @@ -15920,13 +15922,14 @@ static int ZEND_FASTCALL ZEND_JMPZ_EX_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS } if (i_zend_is_true(val TSRMLS_CC)) { + zval_ptr_dtor_nogc(free_op1.var); ZVAL_TRUE(EX_VAR(opline->result.var)); opline++; } else { + zval_ptr_dtor_nogc(free_op1.var); ZVAL_FALSE(EX_VAR(opline->result.var)); opline = opline->op2.jmp_addr; } - zval_ptr_dtor_nogc(free_op1.var); if (UNEXPECTED(EG(exception) != NULL)) { HANDLE_EXCEPTION(); } @@ -18946,7 +18949,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE } else if ((c = zend_quick_get_constant(opline->op2.zv + 1, opline->extended_value TSRMLS_CC)) == NULL) { if ((opline->extended_value & IS_CONSTANT_UNQUALIFIED) != 0) { char *actual = (char *)zend_memrchr(Z_STRVAL_P(opline->op2.zv), '\\', Z_STRLEN_P(opline->op2.zv)); - if(!actual) { + if (!actual) { actual = Z_STRVAL_P(opline->op2.zv); } else { actual++; @@ -28230,7 +28233,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_UNUSED_CONST_HANDLER(ZEND_OPC } else if ((c = zend_quick_get_constant(opline->op2.zv + 1, opline->extended_value TSRMLS_CC)) == NULL) { if ((opline->extended_value & IS_CONSTANT_UNQUALIFIED) != 0) { char *actual = (char *)zend_memrchr(Z_STRVAL_P(opline->op2.zv), '\\', Z_STRLEN_P(opline->op2.zv)); - if(!actual) { + if (!actual) { actual = Z_STRVAL_P(opline->op2.zv); } else { actual++; @@ -33369,13 +33372,14 @@ static int ZEND_FASTCALL ZEND_JMPZ_EX_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } if (i_zend_is_true(val TSRMLS_CC)) { + ZVAL_TRUE(EX_VAR(opline->result.var)); opline++; } else { + ZVAL_FALSE(EX_VAR(opline->result.var)); opline = opline->op2.jmp_addr; } - if (UNEXPECTED(EG(exception) != NULL)) { HANDLE_EXCEPTION(); } From fced6e614811834d4edda6c0e4af9b769177ef2c Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Thu, 30 Oct 2014 16:55:40 +0800 Subject: [PATCH 204/398] Save memory allocating --- Zend/zend_vm_def.h | 8 +++++--- Zend/zend_vm_execute.h | 24 +++++++++++++++--------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 9f2d26a2030..fad38c64287 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -3775,13 +3775,15 @@ ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, VAR|CONST|UNUSED, CONST) if ((opline->extended_value & IS_CONSTANT_UNQUALIFIED) != 0) { char *actual = (char *)zend_memrchr(Z_STRVAL_P(opline->op2.zv), '\\', Z_STRLEN_P(opline->op2.zv)); if (!actual) { - actual = Z_STRVAL_P(opline->op2.zv); + ZVAL_STR(EX_VAR(opline->result.var), zend_string_copy(Z_STR_P(opline->op2.zv))); } else { actual++; + ZVAL_STRINGL(EX_VAR(opline->result.var), + actual, Z_STRLEN_P(opline->op2.zv) - (actual - Z_STRVAL_P(opline->op2.zv))); } /* non-qualified constant - allow text substitution */ - zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", actual, actual); - ZVAL_STRINGL(EX_VAR(opline->result.var), actual, Z_STRLEN_P(opline->op2.zv)-(actual - Z_STRVAL_P(opline->op2.zv))); + zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", + Z_STRVAL_P(EX_VAR(opline->result.var)), Z_STRVAL_P(EX_VAR(opline->result.var))); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else { diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 732c3f02a25..4f305c2258a 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -4300,13 +4300,15 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_CONST_CONST_HANDLER(ZEND_OPCO if ((opline->extended_value & IS_CONSTANT_UNQUALIFIED) != 0) { char *actual = (char *)zend_memrchr(Z_STRVAL_P(opline->op2.zv), '\\', Z_STRLEN_P(opline->op2.zv)); if (!actual) { - actual = Z_STRVAL_P(opline->op2.zv); + ZVAL_STR(EX_VAR(opline->result.var), zend_string_copy(Z_STR_P(opline->op2.zv))); } else { actual++; + ZVAL_STRINGL(EX_VAR(opline->result.var), + actual, Z_STRLEN_P(opline->op2.zv) - (actual - Z_STRVAL_P(opline->op2.zv))); } /* non-qualified constant - allow text substitution */ - zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", actual, actual); - ZVAL_STRINGL(EX_VAR(opline->result.var), actual, Z_STRLEN_P(opline->op2.zv)-(actual - Z_STRVAL_P(opline->op2.zv))); + zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", + Z_STRVAL_P(EX_VAR(opline->result.var)), Z_STRVAL_P(EX_VAR(opline->result.var))); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else { @@ -18950,13 +18952,15 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE if ((opline->extended_value & IS_CONSTANT_UNQUALIFIED) != 0) { char *actual = (char *)zend_memrchr(Z_STRVAL_P(opline->op2.zv), '\\', Z_STRLEN_P(opline->op2.zv)); if (!actual) { - actual = Z_STRVAL_P(opline->op2.zv); + ZVAL_STR(EX_VAR(opline->result.var), zend_string_copy(Z_STR_P(opline->op2.zv))); } else { actual++; + ZVAL_STRINGL(EX_VAR(opline->result.var), + actual, Z_STRLEN_P(opline->op2.zv) - (actual - Z_STRVAL_P(opline->op2.zv))); } /* non-qualified constant - allow text substitution */ - zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", actual, actual); - ZVAL_STRINGL(EX_VAR(opline->result.var), actual, Z_STRLEN_P(opline->op2.zv)-(actual - Z_STRVAL_P(opline->op2.zv))); + zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", + Z_STRVAL_P(EX_VAR(opline->result.var)), Z_STRVAL_P(EX_VAR(opline->result.var))); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else { @@ -28234,13 +28238,15 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_UNUSED_CONST_HANDLER(ZEND_OPC if ((opline->extended_value & IS_CONSTANT_UNQUALIFIED) != 0) { char *actual = (char *)zend_memrchr(Z_STRVAL_P(opline->op2.zv), '\\', Z_STRLEN_P(opline->op2.zv)); if (!actual) { - actual = Z_STRVAL_P(opline->op2.zv); + ZVAL_STR(EX_VAR(opline->result.var), zend_string_copy(Z_STR_P(opline->op2.zv))); } else { actual++; + ZVAL_STRINGL(EX_VAR(opline->result.var), + actual, Z_STRLEN_P(opline->op2.zv) - (actual - Z_STRVAL_P(opline->op2.zv))); } /* non-qualified constant - allow text substitution */ - zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", actual, actual); - ZVAL_STRINGL(EX_VAR(opline->result.var), actual, Z_STRLEN_P(opline->op2.zv)-(actual - Z_STRVAL_P(opline->op2.zv))); + zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", + Z_STRVAL_P(EX_VAR(opline->result.var)), Z_STRVAL_P(EX_VAR(opline->result.var))); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else { From 73e2dd338133602825d55b29b8dfb93c3c2c9e2f Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 30 Oct 2014 10:27:20 +0100 Subject: [PATCH 205/398] add DLL export to the output globals --- main/output.c | 2 +- main/php_output.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main/output.c b/main/output.c index 1dac7179b8e..0c7212ac91f 100644 --- a/main/output.c +++ b/main/output.c @@ -35,7 +35,7 @@ #include "zend_stack.h" #include "php_output.h" -ZEND_DECLARE_MODULE_GLOBALS(output); +PHPAPI ZEND_DECLARE_MODULE_GLOBALS(output); const char php_output_default_handler_name[sizeof("default output handler")] = "default output handler"; const char php_output_devnull_handler_name[sizeof("null output handler")] = "null output handler"; diff --git a/main/php_output.h b/main/php_output.h index 6c4b1f7a429..3831478b9f5 100644 --- a/main/php_output.h +++ b/main/php_output.h @@ -152,7 +152,7 @@ ZEND_BEGIN_MODULE_GLOBALS(output) int output_start_lineno; ZEND_END_MODULE_GLOBALS(output) -ZEND_EXTERN_MODULE_GLOBALS(output); +PHPAPI ZEND_EXTERN_MODULE_GLOBALS(output); /* there should not be a need to use OG() from outside of output.c */ #ifdef ZTS From 4fd66387a9ea739fc3216ea8357e8a3f59df224c Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Thu, 30 Oct 2014 12:15:27 +0100 Subject: [PATCH 206/398] Fix uninitialized value... --- phpdbg_bp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpdbg_bp.c b/phpdbg_bp.c index 33824d4fec4..85dc12a3e5c 100644 --- a/phpdbg_bp.c +++ b/phpdbg_bp.c @@ -240,7 +240,7 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRML php_stream_statbuf ssb; char realpath[MAXPATHLEN]; const char *original_path = path; - zend_bool pending; + zend_bool pending = 0; HashTable *broken, *file_breaks = &PHPDBG_G(bp)[PHPDBG_BREAK_FILE]; phpdbg_breakfile_t new_break; From 551593707384364705cd954a52c6e4089805f0ef Mon Sep 17 00:00:00 2001 From: Ferenc Kovacs Date: Thu, 30 Oct 2014 18:12:37 +0100 Subject: [PATCH 207/398] don't try to send in the test results until we restored qa.php.net --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b2ed607cace..31cdcd07f51 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,4 +39,4 @@ before_script: - . ./travis/ext/pdo_pgsql/setup.sh # Run PHPs run-tests.php -script: ./sapi/cli/php run-tests.php -p `pwd`/sapi/cli/php -g "FAIL,XFAIL,BORK,WARN,LEAK,SKIP" --show-diff --set-timeout 120 +script: ./sapi/cli/php run-tests.php -p `pwd`/sapi/cli/php -g "FAIL,XFAIL,BORK,WARN,LEAK,SKIP" --show-diff --set-timeout 120 -s From 88d2e43db3d372b6f0c7dea142d53be36af8622d Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 30 Oct 2014 14:36:57 +0100 Subject: [PATCH 208/398] fix datatype mismatch warnings --- ext/bcmath/bcmath.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/ext/bcmath/bcmath.c b/ext/bcmath/bcmath.c index 7ef30cad5e0..5c4e8740e49 100644 --- a/ext/bcmath/bcmath.c +++ b/ext/bcmath/bcmath.c @@ -209,14 +209,14 @@ PHP_FUNCTION(bcadd) zend_long scale_param = 0; bc_num first, second, result; size_t left_len, right_len; - int scale = BCG(bc_precision), argc = ZEND_NUM_ARGS(); + int scale = (int)BCG(bc_precision), argc = ZEND_NUM_ARGS(); if (zend_parse_parameters(argc TSRMLS_CC, "ss|l", &left, &left_len, &right, &right_len, &scale_param) == FAILURE) { return; } if (argc == 3) { - scale = (int) ((int)scale_param < 0) ? 0 : scale_param; + scale = (int) (scale_param < 0 ? 0 : scale_param); } bc_init_num(&first TSRMLS_CC); @@ -246,14 +246,14 @@ PHP_FUNCTION(bcsub) size_t left_len, right_len; zend_long scale_param = 0; bc_num first, second, result; - int scale = BCG(bc_precision), argc = ZEND_NUM_ARGS(); + int scale = (int)BCG(bc_precision), argc = ZEND_NUM_ARGS(); if (zend_parse_parameters(argc TSRMLS_CC, "ss|l", &left, &left_len, &right, &right_len, &scale_param) == FAILURE) { return; } if (argc == 3) { - scale = (int) ((int)scale_param < 0) ? 0 : scale_param; + scale = (int) ((int)scale_param < 0 ? 0 : scale_param); } bc_init_num(&first TSRMLS_CC); @@ -283,14 +283,14 @@ PHP_FUNCTION(bcmul) size_t left_len, right_len; zend_long scale_param = 0; bc_num first, second, result; - int scale = BCG(bc_precision), argc = ZEND_NUM_ARGS(); + int scale = (int)BCG(bc_precision), argc = ZEND_NUM_ARGS(); if (zend_parse_parameters(argc TSRMLS_CC, "ss|l", &left, &left_len, &right, &right_len, &scale_param) == FAILURE) { return; } if (argc == 3) { - scale = (int) ((int)scale_param < 0) ? 0 : scale_param; + scale = (int) ((int)scale_param < 0 ? 0 : scale_param); } bc_init_num(&first TSRMLS_CC); @@ -320,14 +320,14 @@ PHP_FUNCTION(bcdiv) size_t left_len, right_len; zend_long scale_param = 0; bc_num first, second, result; - int scale = BCG(bc_precision), argc = ZEND_NUM_ARGS(); + int scale = (int)BCG(bc_precision), argc = ZEND_NUM_ARGS(); if (zend_parse_parameters(argc TSRMLS_CC, "ss|l", &left, &left_len, &right, &right_len, &scale_param) == FAILURE) { return; } if (argc == 3) { - scale = (int) ((int)scale_param < 0) ? 0 : scale_param; + scale = (int) ((int)scale_param < 0 ? 0 : scale_param); } bc_init_num(&first TSRMLS_CC); @@ -411,11 +411,11 @@ PHP_FUNCTION(bcpowmod) php_str2num(&second, right TSRMLS_CC); php_str2num(&mod, modulous TSRMLS_CC); - scale_int = (int) ((int)scale < 0) ? 0 : scale; + scale_int = (int) ((int)scale < 0 ? 0 : scale); if (bc_raisemod(first, second, mod, &result, scale_int TSRMLS_CC) != -1) { if (result->n_scale > scale) { - result->n_scale = scale; + result->n_scale = (int)scale; } RETVAL_STR(bc_num2str(result)); } else { @@ -438,14 +438,14 @@ PHP_FUNCTION(bcpow) size_t left_len, right_len; zend_long scale_param = 0; bc_num first, second, result; - int scale = BCG(bc_precision), argc = ZEND_NUM_ARGS(); + int scale = (int)BCG(bc_precision), argc = ZEND_NUM_ARGS(); if (zend_parse_parameters(argc TSRMLS_CC, "ss|l", &left, &left_len, &right, &right_len, &scale_param) == FAILURE) { return; } if (argc == 3) { - scale = (int) ((int)scale_param < 0) ? 0 : scale_param; + scale = (int) ((int)scale_param < 0 ? 0 : scale_param); } bc_init_num(&first TSRMLS_CC); @@ -475,14 +475,14 @@ PHP_FUNCTION(bcsqrt) size_t left_len; zend_long scale_param = 0; bc_num result; - int scale = BCG(bc_precision), argc = ZEND_NUM_ARGS(); + int scale = (int)BCG(bc_precision), argc = ZEND_NUM_ARGS(); if (zend_parse_parameters(argc TSRMLS_CC, "s|l", &left, &left_len, &scale_param) == FAILURE) { return; } if (argc == 2) { - scale = (int) ((int)scale_param < 0) ? 0 : scale_param; + scale = (int) ((int)scale_param < 0 ? 0 : scale_param); } bc_init_num(&result TSRMLS_CC); @@ -510,14 +510,14 @@ PHP_FUNCTION(bccomp) size_t left_len, right_len; zend_long scale_param = 0; bc_num first, second; - int scale = BCG(bc_precision), argc = ZEND_NUM_ARGS(); + int scale = (int)BCG(bc_precision), argc = ZEND_NUM_ARGS(); if (zend_parse_parameters(argc TSRMLS_CC, "ss|l", &left, &left_len, &right, &right_len, &scale_param) == FAILURE) { return; } if (argc == 3) { - scale = (int) ((int)scale_param < 0) ? 0 : scale_param; + scale = (int) ((int)scale_param < 0 ? 0 : scale_param); } bc_init_num(&first TSRMLS_CC); From 05bad6a95778ae0d2de5273b441b87bde2ed0dea Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 30 Oct 2014 17:18:10 +0100 Subject: [PATCH 209/398] fix some datatype mismatches in ext/bz2 Additionally, as bz2 read/write routines expect int for sizes, it could overflow. So fixed the logic. Things in compress/decompress are more complicated so they was left as they are yet. --- ext/bz2/bz2.c | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/ext/bz2/bz2.c b/ext/bz2/bz2.c index 6e6f2a95c35..d49be40d359 100644 --- a/ext/bz2/bz2.c +++ b/ext/bz2/bz2.c @@ -138,22 +138,48 @@ struct php_bz2_stream_data_t { static size_t php_bz2iop_read(php_stream *stream, char *buf, size_t count TSRMLS_DC) { struct php_bz2_stream_data_t *self = (struct php_bz2_stream_data_t *)stream->abstract; - size_t ret; + size_t ret = 0; - ret = BZ2_bzread(self->bz_file, buf, count); + do { + int just_read; + size_t remain = count - ret; + int to_read = (int)(remain <= INT_MAX ? remain : INT_MAX); - if (ret == 0) { - stream->eof = 1; - } + just_read = BZ2_bzread(self->bz_file, buf, to_read); + + if (just_read < 1) { + stream->eof = 0 == just_read; + break; + } + + ret += just_read; + } while (ret < count); return ret; } static size_t php_bz2iop_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC) { + size_t wrote = 0; struct php_bz2_stream_data_t *self = (struct php_bz2_stream_data_t *)stream->abstract; - return BZ2_bzwrite(self->bz_file, (char*)buf, count); + + do { + int just_wrote; + size_t remain = count - wrote; + int to_write = (int)(remain <= INT_MAX ? remain : INT_MAX); + + just_wrote = BZ2_bzwrite(self->bz_file, (char*)buf, to_write); + + if (just_wrote < 1) { + break; + } + + wrote += just_wrote; + + } while (wrote < count); + + return wrote; } static int php_bz2iop_close(php_stream *stream, int close_handle TSRMLS_DC) @@ -262,7 +288,7 @@ PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper, if (stream) { php_socket_t fd; if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD, (void **) &fd, REPORT_ERRORS)) { - bz_file = BZ2_bzdopen(fd, mode); + bz_file = BZ2_bzdopen((int)fd, mode); } } @@ -439,7 +465,7 @@ static PHP_FUNCTION(bzopen) RETURN_FALSE; } - bz = BZ2_bzdopen(fd, mode); + bz = BZ2_bzdopen((int)fd, mode); stream = php_stream_bz2open_from_BZFILE(bz, mode, stream); } else { @@ -554,7 +580,7 @@ static PHP_FUNCTION(bzdecompress) bzs.bzalloc = NULL; bzs.bzfree = NULL; - if (BZ2_bzDecompressInit(&bzs, 0, small) != BZ_OK) { + if (BZ2_bzDecompressInit(&bzs, 0, (int)small) != BZ_OK) { RETURN_FALSE; } From edfabf19a756bd8023698087d822e420824edfe4 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 30 Oct 2014 17:25:17 +0100 Subject: [PATCH 210/398] fix datatype mismatch warnings --- ext/bz2/bz2_filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/bz2/bz2_filter.c b/ext/bz2/bz2_filter.c index 1c1d6ccfb6b..a2a21d765bd 100644 --- a/ext/bz2/bz2_filter.c +++ b/ext/bz2/bz2_filter.c @@ -384,7 +384,7 @@ static php_stream_filter *php_bz2_filter_create(const char *filtername, zval *fi if (Z_LVAL(tmp) < 1 || Z_LVAL(tmp) > 9) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter given for number of blocks to allocate. (%pd)", Z_LVAL_P(tmpzval)); } else { - blockSize100k = Z_LVAL(tmp); + blockSize100k = (int)Z_LVAL(tmp); } } @@ -398,7 +398,7 @@ static php_stream_filter *php_bz2_filter_create(const char *filtername, zval *fi if (Z_LVAL(tmp) < 0 || Z_LVAL(tmp) > 250) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter given for work factor. (%pd)", Z_LVAL(tmp)); } else { - workFactor = Z_LVAL(tmp); + workFactor = (int)Z_LVAL(tmp); } } } From c7fa02948792a302c70e7530ee1058d6d3abefe6 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 30 Oct 2014 18:07:58 +0100 Subject: [PATCH 211/398] fix datatype mismatch warnings --- ext/ctype/ctype.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/ctype/ctype.c b/ext/ctype/ctype.c index 41d5559c676..b03afe05f07 100644 --- a/ext/ctype/ctype.c +++ b/ext/ctype/ctype.c @@ -148,9 +148,9 @@ static PHP_MINFO_FUNCTION(ctype) return; \ if (Z_TYPE_P(c) == IS_LONG) { \ if (Z_LVAL_P(c) <= 255 && Z_LVAL_P(c) >= 0) { \ - RETURN_BOOL(iswhat(Z_LVAL_P(c))); \ + RETURN_BOOL(iswhat((int)Z_LVAL_P(c))); \ } else if (Z_LVAL_P(c) >= -128 && Z_LVAL_P(c) < 0) { \ - RETURN_BOOL(iswhat(Z_LVAL_P(c) + 256)); \ + RETURN_BOOL(iswhat((int)Z_LVAL_P(c) + 256)); \ } \ tmp = *c; \ zval_copy_ctor(&tmp); \ From b0499545ee863c5173c82fe5e3e9b5289db13bf0 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 30 Oct 2014 18:37:56 +0100 Subject: [PATCH 212/398] fix datatype mismatches --- ext/date/lib/parse_date.c | 6 +++--- ext/date/lib/parse_date.re | 4 ++-- ext/date/lib/parse_iso_intervals.c | 4 ++-- ext/date/lib/parse_iso_intervals.re | 2 +- ext/date/lib/timelib.h | 6 +++--- ext/date/php_date.c | 10 +++++----- ext/date/php_date.h | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ext/date/lib/parse_date.c b/ext/date/lib/parse_date.c index 2a615559f67..f9872a5ce38 100644 --- a/ext/date/lib/parse_date.c +++ b/ext/date/lib/parse_date.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Tue Aug 26 10:40:19 2014 */ +/* Generated by re2c 0.13.5 on Thu Oct 30 18:16:16 2014 */ #line 1 "ext/date/lib/parse_date.re" /* +----------------------------------------------------------------------+ @@ -24712,7 +24712,7 @@ yy1537: #define YYMAXFILL 31 -timelib_time* timelib_strtotime(char *s, int len, struct timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper) +timelib_time* timelib_strtotime(char *s, size_t len, struct timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper) { Scanner in; int t; @@ -24823,7 +24823,7 @@ static void timelib_time_reset_unset_fields(timelib_time *time) if (time->f == TIMELIB_UNSET ) time->f = 0.0; } -timelib_time *timelib_parse_from_format(char *format, char *string, int len, timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper) +timelib_time *timelib_parse_from_format(char *format, char *string, size_t len, timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper) { char *fptr = format; char *ptr = string; diff --git a/ext/date/lib/parse_date.re b/ext/date/lib/parse_date.re index cb5df162518..7c4d1433681 100644 --- a/ext/date/lib/parse_date.re +++ b/ext/date/lib/parse_date.re @@ -1721,7 +1721,7 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of /*!max:re2c */ -timelib_time* timelib_strtotime(char *s, int len, struct timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper) +timelib_time* timelib_strtotime(char *s, size_t len, struct timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper) { Scanner in; int t; @@ -1832,7 +1832,7 @@ static void timelib_time_reset_unset_fields(timelib_time *time) if (time->f == TIMELIB_UNSET ) time->f = 0.0; } -timelib_time *timelib_parse_from_format(char *format, char *string, int len, timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper) +timelib_time *timelib_parse_from_format(char *format, char *string, size_t len, timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper) { char *fptr = format; char *ptr = string; diff --git a/ext/date/lib/parse_iso_intervals.c b/ext/date/lib/parse_iso_intervals.c index 3b7580f9d11..ffa33b06987 100644 --- a/ext/date/lib/parse_iso_intervals.c +++ b/ext/date/lib/parse_iso_intervals.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Tue Aug 26 10:39:58 2014 */ +/* Generated by re2c 0.13.5 on Thu Oct 30 18:20:16 2014 */ #line 1 "ext/date/lib/parse_iso_intervals.re" /* +----------------------------------------------------------------------+ @@ -1004,7 +1004,7 @@ yy100: #define YYMAXFILL 20 -void timelib_strtointerval(char *s, int len, +void timelib_strtointerval(char *s, size_t len, timelib_time **begin, timelib_time **end, timelib_rel_time **period, int *recurrences, struct timelib_error_container **errors) diff --git a/ext/date/lib/parse_iso_intervals.re b/ext/date/lib/parse_iso_intervals.re index 097488ec572..b400522584f 100644 --- a/ext/date/lib/parse_iso_intervals.re +++ b/ext/date/lib/parse_iso_intervals.re @@ -398,7 +398,7 @@ isoweek = year4 "-"? "W" weekofyear; /*!max:re2c */ -void timelib_strtointerval(char *s, int len, +void timelib_strtointerval(char *s, size_t len, timelib_time **begin, timelib_time **end, timelib_rel_time **period, int *recurrences, struct timelib_error_container **errors) diff --git a/ext/date/lib/timelib.h b/ext/date/lib/timelib.h index b7c49888cb2..552ec39221b 100644 --- a/ext/date/lib/timelib.h +++ b/ext/date/lib/timelib.h @@ -68,15 +68,15 @@ int timelib_valid_time(timelib_sll h, timelib_sll i, timelib_sll s); int timelib_valid_date(timelib_sll y, timelib_sll m, timelib_sll d); /* From parse_date.re */ -timelib_time *timelib_strtotime(char *s, int len, timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper); -timelib_time *timelib_parse_from_format(char *format, char *s, int len, timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper); +timelib_time *timelib_strtotime(char *s, size_t len, timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper); +timelib_time *timelib_parse_from_format(char *format, char *s, size_t len, timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper); void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options); char *timelib_timezone_id_from_abbr(const char *abbr, timelib_long gmtoffset, int isdst); const timelib_tz_lookup_table *timelib_timezone_abbreviations_list(void); timelib_long timelib_parse_tz_cor(char**); /* From parse_iso_intervals.re */ -void timelib_strtointerval(char *s, int len, +void timelib_strtointerval(char *s, size_t len, timelib_time **begin, timelib_time **end, timelib_rel_time **period, int *recurrences, struct timelib_error_container **errors); diff --git a/ext/date/php_date.c b/ext/date/php_date.c index f2ced7bd595..6146dec927d 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -1230,7 +1230,7 @@ static void php_date(INTERNAL_FUNCTION_PARAMETERS, int localtime) } /* }}} */ -PHPAPI zend_string *php_format_date(char *format, int format_len, time_t ts, int localtime TSRMLS_DC) /* {{{ */ +PHPAPI zend_string *php_format_date(char *format, size_t format_len, time_t ts, int localtime TSRMLS_DC) /* {{{ */ { timelib_time *t; timelib_tzinfo *tzi; @@ -3031,7 +3031,7 @@ PHP_FUNCTION(date_format) } /* }}} */ -static int php_date_modify(zval *object, char *modify, int modify_len TSRMLS_DC) /* {{{ */ +static int php_date_modify(zval *object, char *modify, size_t modify_len TSRMLS_DC) /* {{{ */ { php_date_obj *dateobj; timelib_time *tmp_time; @@ -3938,7 +3938,7 @@ PHP_FUNCTION(timezone_location_get) } /* }}} */ -static int date_interval_initialize(timelib_rel_time **rt, /*const*/ char *format, int format_length TSRMLS_DC) /* {{{ */ +static int date_interval_initialize(timelib_rel_time **rt, /*const*/ char *format, size_t format_length TSRMLS_DC) /* {{{ */ { timelib_time *b = NULL, *e = NULL; timelib_rel_time *p = NULL; @@ -4221,7 +4221,7 @@ PHP_FUNCTION(date_interval_create_from_date_string) /* }}} */ /* {{{ date_interval_format - */ -static zend_string *date_interval_format(char *format, int format_len, timelib_rel_time *t TSRMLS_DC) +static zend_string *date_interval_format(char *format, size_t format_len, timelib_rel_time *t TSRMLS_DC) { smart_str string = {0}; int i, length, have_format_spec = 0; @@ -4302,7 +4302,7 @@ PHP_FUNCTION(date_interval_format) } /* }}} */ -static int date_period_initialize(timelib_time **st, timelib_time **et, timelib_rel_time **d, zend_long *recurrences, /*const*/ char *format, int format_length TSRMLS_DC) /* {{{ */ +static int date_period_initialize(timelib_time **st, timelib_time **et, timelib_rel_time **d, zend_long *recurrences, /*const*/ char *format, size_t format_length TSRMLS_DC) /* {{{ */ { timelib_time *b = NULL, *e = NULL; timelib_rel_time *p = NULL; diff --git a/ext/date/php_date.h b/ext/date/php_date.h index aa46aa1b6cf..ebbf9a90271 100644 --- a/ext/date/php_date.h +++ b/ext/date/php_date.h @@ -210,7 +210,7 @@ PHPAPI int php_idate(char format, time_t ts, int localtime TSRMLS_DC); #define _php_strftime php_strftime PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gm); #endif -PHPAPI zend_string *php_format_date(char *format, int format_len, time_t ts, int localtime TSRMLS_DC); +PHPAPI zend_string *php_format_date(char *format, size_t format_len, time_t ts, int localtime TSRMLS_DC); /* Mechanism to set new TZ database */ PHPAPI void php_date_set_tzdb(timelib_tzdb *tzdb); From f6f81b6545bbb1a6c100aa5e074eda0402867d2f Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 30 Oct 2014 20:04:14 +0100 Subject: [PATCH 213/398] fix datatype mismatche warnings --- ext/filter/logical_filters.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c index b7c0b49a85d..be1c2f0d40d 100644 --- a/ext/filter/logical_filters.c +++ b/ext/filter/logical_filters.c @@ -80,7 +80,7 @@ #define FORMAT_IPV4 4 #define FORMAT_IPV6 6 -static int php_filter_parse_int(const char *str, unsigned int str_len, zend_long *ret TSRMLS_DC) { /* {{{ */ +static int php_filter_parse_int(const char *str, size_t str_len, zend_long *ret TSRMLS_DC) { /* {{{ */ zend_long ctx_value; int sign = 0, digit = 0; const char *end = str + str_len; @@ -132,7 +132,7 @@ static int php_filter_parse_int(const char *str, unsigned int str_len, zend_long } /* }}} */ -static int php_filter_parse_octal(const char *str, unsigned int str_len, zend_long *ret TSRMLS_DC) { /* {{{ */ +static int php_filter_parse_octal(const char *str, size_t str_len, zend_long *ret TSRMLS_DC) { /* {{{ */ zend_ulong ctx_value = 0; const char *end = str + str_len; @@ -155,7 +155,7 @@ static int php_filter_parse_octal(const char *str, unsigned int str_len, zend_lo } /* }}} */ -static int php_filter_parse_hex(const char *str, unsigned int str_len, zend_long *ret TSRMLS_DC) { /* {{{ */ +static int php_filter_parse_hex(const char *str, size_t str_len, zend_long *ret TSRMLS_DC) { /* {{{ */ zend_ulong ctx_value = 0; const char *end = str + str_len; zend_ulong n; @@ -188,7 +188,8 @@ void php_filter_int(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ zend_long min_range, max_range, option_flags; int min_range_set, max_range_set; int allow_octal = 0, allow_hex = 0; - int len, error = 0; + size_t len; + int error = 0; zend_long ctx_value; char *p; @@ -250,7 +251,7 @@ void php_filter_int(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ void php_filter_boolean(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ { char *str = Z_STRVAL_P(value); - int len = Z_STRLEN_P(value); + size_t len = Z_STRLEN_P(value); int ret; PHP_FILTER_TRIM_DEFAULT_EX(str, len, 0); @@ -318,12 +319,13 @@ void php_filter_boolean(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ void php_filter_float(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ { - int len; + size_t len; char *str, *end; char *num, *p; zval *option_val; char *decimal; - int decimal_set, decimal_len; + int decimal_set; + size_t decimal_len; char dec_sep = '.'; char tsd_sep[3] = "',."; @@ -400,7 +402,7 @@ void php_filter_float(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ switch (is_numeric_string(num, p - num, &lval, &dval, 0)) { case IS_LONG: zval_ptr_dtor(value); - ZVAL_DOUBLE(value, lval); + ZVAL_DOUBLE(value, (double)lval); break; case IS_DOUBLE: if ((!dval && p - num > 1 && strpbrk(num, "123456789")) || !zend_finite(dval)) { @@ -443,7 +445,7 @@ void php_filter_validate_regexp(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ if (!re) { RETURN_VALIDATION_FAILED } - matches = pcre_exec(re, NULL, Z_STRVAL_P(value), Z_STRLEN_P(value), 0, 0, ovector, 3); + matches = pcre_exec(re, NULL, Z_STRVAL_P(value), (int)Z_STRLEN_P(value), 0, 0, ovector, 3); /* 0 means that the vector is too small to hold all the captured substring offsets */ if (matches < 0) { @@ -455,7 +457,7 @@ void php_filter_validate_regexp(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ { php_url *url; - int old_len = Z_STRLEN_P(value); + int old_len = (int)Z_STRLEN_P(value); php_filter_url(value, flags, option_array, charset TSRMLS_CC); @@ -554,7 +556,7 @@ void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ RETURN_VALIDATION_FAILED } zend_string_release(sregexp); - matches = pcre_exec(re, NULL, Z_STRVAL_P(value), Z_STRLEN_P(value), 0, 0, ovector, 3); + matches = pcre_exec(re, NULL, Z_STRVAL_P(value), (int)Z_STRLEN_P(value), 0, 0, ovector, 3); /* 0 means that the vector is too small to hold all the captured substring offsets */ if (matches < 0) { @@ -564,7 +566,7 @@ void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ } /* }}} */ -static int _php_filter_validate_ipv4(char *str, int str_len, int *ip) /* {{{ */ +static int _php_filter_validate_ipv4(char *str, size_t str_len, int *ip) /* {{{ */ { const char *end = str + str_len; int num, m; @@ -599,7 +601,7 @@ static int _php_filter_validate_ipv4(char *str, int str_len, int *ip) /* {{{ */ } /* }}} */ -static int _php_filter_validate_ipv6(char *str, int str_len TSRMLS_DC) /* {{{ */ +static int _php_filter_validate_ipv6(char *str, size_t str_len TSRMLS_DC) /* {{{ */ { int compressed = 0; int blocks = 0; @@ -792,8 +794,9 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ void php_filter_validate_mac(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ { char *input = Z_STRVAL_P(value); - int input_len = Z_STRLEN_P(value); - int tokens, length, i, offset, exp_separator_set, exp_separator_len; + size_t input_len = Z_STRLEN_P(value); + int tokens, length, i, offset, exp_separator_set; + size_t exp_separator_len; char separator; char *exp_separator; zend_long ret = 0; From e0ee1fbc2699edd6ea731f1ec1a500c33a76242c Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 30 Oct 2014 20:06:12 +0100 Subject: [PATCH 214/398] fix datatype mismatches --- ext/filter/sanitizing_filters.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/filter/sanitizing_filters.c b/ext/filter/sanitizing_filters.c index 083b5382b6a..851238fe45c 100644 --- a/ext/filter/sanitizing_filters.c +++ b/ext/filter/sanitizing_filters.c @@ -30,7 +30,7 @@ typedef unsigned long filter_map[256]; static void php_filter_encode_html(zval *value, const unsigned char *chars) { smart_str str = {0}; - int len = Z_STRLEN_P(value); + size_t len = Z_STRLEN_P(value); unsigned char *s = (unsigned char *)Z_STRVAL_P(value); unsigned char *e = s + len; @@ -147,7 +147,7 @@ static void filter_map_init(filter_map *map) static void filter_map_update(filter_map *map, int flag, const unsigned char *allowed_list) { - int l, i; + size_t l, i; l = strlen((const char*)allowed_list); for (i = 0; i < l; ++i) { From 113f1fd6d5eb286c50f6cca003d18f847bc202cb Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Thu, 30 Oct 2014 23:09:57 +0100 Subject: [PATCH 215/398] Temporarily disable wait/xml protocol... --- sapi/phpdbg/phpdbg.c | 4 ++++ sapi/phpdbg/phpdbg.h | 2 ++ sapi/phpdbg/phpdbg_help.c | 2 ++ sapi/phpdbg/phpdbg_prompt.c | 2 ++ sapi/phpdbg/phpdbg_rinit_hook.c | 2 +- sapi/phpdbg/phpdbg_wait.c | 2 +- 6 files changed, 12 insertions(+), 2 deletions(-) diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 7ca79972972..6ee41b75868 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -779,7 +779,9 @@ const opt_struct OPTIONS[] = { /* {{{ */ {'S', 1, "sapi-name"}, {'l', 1, "listen"}, {'a', 1, "address-or-any"}, +#if PHPDBG_IN_DEV {'x', 0, "xml output"}, +#endif {'V', 0, "version"}, {'-', 0, NULL} }; /* }}} */ @@ -1213,8 +1215,10 @@ phpdbg_main: } else address = strdup(php_optarg); } break; +#if PHPDBG_IN_DEV case 'x': flags |= PHPDBG_WRITE_XML; +#endif break; case 'V': { diff --git a/sapi/phpdbg/phpdbg.h b/sapi/phpdbg/phpdbg.h index a9be80436e9..a0ba75e4d47 100644 --- a/sapi/phpdbg/phpdbg.h +++ b/sapi/phpdbg/phpdbg.h @@ -21,6 +21,8 @@ #ifndef PHPDBG_H #define PHPDBG_H +#define PHPDBG_IN_DEV 0 + #ifdef PHP_WIN32 # define PHPDBG_API __declspec(dllexport) #elif defined(__GNUC__) && __GNUC__ >= 4 diff --git a/sapi/phpdbg/phpdbg_help.c b/sapi/phpdbg/phpdbg_help.c index 652e1706942..d47f8c776ab 100644 --- a/sapi/phpdbg/phpdbg_help.c +++ b/sapi/phpdbg/phpdbg_help.c @@ -388,7 +388,9 @@ phpdbg_help_text_t phpdbg_help_text[] = { " **-S** **-S**cli Override SAPI name, careful!" CR " **-l** **-l**4000 Setup remote console ports" CR " **-a** **-a**192.168.0.3 Setup remote console bind address" CR +#if PHPDBG_IN_DEV " **-x** Enable xml output (instead of normal text output)" CR +#endif " **-V** Print version number" CR " **--** **--** arg1 arg2 Use to delimit phpdbg arguments and php $argv; append any $argv " "argument after it" CR CR diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index 915bccfa69f..f030654f3ba 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -82,7 +82,9 @@ const phpdbg_command_t phpdbg_prompt_commands[] = { PHPDBG_COMMAND_D(export, "export breaks to a .phpdbginit script", '>', NULL, "s", PHPDBG_ASYNC_SAFE), PHPDBG_COMMAND_D(sh, "shell a command", 0 , NULL, "i", 0), PHPDBG_COMMAND_D(quit, "exit phpdbg", 'q', NULL, 0, PHPDBG_ASYNC_SAFE), +#if PHPDBG_IN_DEV PHPDBG_COMMAND_D(wait, "wait for other process", 'W', NULL, 0, 0), +#endif PHPDBG_COMMAND_D(watch, "set watchpoint", 'w', phpdbg_watch_commands, "|ss", 0), PHPDBG_COMMAND_D(eol, "set EOL", 'E', NULL, "|s", 0), PHPDBG_END_COMMAND diff --git a/sapi/phpdbg/phpdbg_rinit_hook.c b/sapi/phpdbg/phpdbg_rinit_hook.c index acbdfb6f258..11bd5c99b19 100644 --- a/sapi/phpdbg/phpdbg_rinit_hook.c +++ b/sapi/phpdbg/phpdbg_rinit_hook.c @@ -52,7 +52,7 @@ static PHP_RINIT_FUNCTION(phpdbg_webhelper) /* {{{ */ return SUCCESS; } -#ifndef _WIN32 +#if PHPDBG_IN_DEV { struct sockaddr_un sock; int s = socket(AF_UNIX, SOCK_STREAM, 0); diff --git a/sapi/phpdbg/phpdbg_wait.c b/sapi/phpdbg/phpdbg_wait.c index 6f9eea90e37..180ae6af3d2 100644 --- a/sapi/phpdbg/phpdbg_wait.c +++ b/sapi/phpdbg/phpdbg_wait.c @@ -365,7 +365,7 @@ void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) { PHPDBG_COMMAND(wait) /* {{{ */ { -#ifndef PHP_WIN32 +#if PHPDBG_IN_DEV struct sockaddr_un local, remote; int rlen, sr, sl; unlink(PHPDBG_G(socket_path)); From 1551db8faa3c599a123b6d51cdf3063e949af737 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 30 Oct 2014 15:15:51 -0700 Subject: [PATCH 216/398] Added constant expression evaluation for "dirname(__FILE__)". Improved constant expression evaluation for function calls --- ext/opcache/Optimizer/pass1_5.c | 191 +++++++++++++++++++++----------- 1 file changed, 124 insertions(+), 67 deletions(-) diff --git a/ext/opcache/Optimizer/pass1_5.c b/ext/opcache/Optimizer/pass1_5.c index b91ac5b50f0..180482f6eed 100644 --- a/ext/opcache/Optimizer/pass1_5.c +++ b/ext/opcache/Optimizer/pass1_5.c @@ -341,28 +341,57 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx TSRML } break; - case ZEND_INIT_FCALL: - /* define("name", scalar); */ - if (collect_constants && - ZEND_OP2_TYPE(opline) == IS_CONST && - Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_STRING && - Z_STRLEN(ZEND_OP2_LITERAL(opline)) == sizeof("define")-1 && - zend_binary_strcasecmp(Z_STRVAL(ZEND_OP2_LITERAL(opline)), Z_STRLEN(ZEND_OP2_LITERAL(opline)), "define", sizeof("define")-1) == 0) { - - if ((opline+1)->opcode == ZEND_SEND_VAL && - ZEND_OP1_TYPE(opline+1) == IS_CONST && - Z_TYPE(ZEND_OP1_LITERAL(opline+1)) == IS_STRING && - (opline+2)->opcode == ZEND_SEND_VAL && - ZEND_OP1_TYPE(opline+2) == IS_CONST && - Z_TYPE(ZEND_OP1_LITERAL(opline+2)) <= IS_STRING && - (opline+3)->opcode == ZEND_DO_FCALL) { + case ZEND_DO_FCALL: { + zend_op *send1_opline = opline - 1; + zend_op *send2_opline = NULL; + zend_op *init_opline = NULL; - zend_optimizer_collect_constant(ctx, &ZEND_OP1_LITERAL(opline+1), &ZEND_OP1_LITERAL(opline+2)); + while (send1_opline->opcode == ZEND_NOP) { + send1_opline--; + } + if (send1_opline->opcode != ZEND_SEND_VAL || + ZEND_OP1_TYPE(send1_opline) != IS_CONST) { + /* don't colllect constants after unknown function call */ + collect_constants = 0; + break; + } + if (send1_opline->op2.num == 2) { + send2_opline = send1_opline; + send1_opline--; + while (send1_opline->opcode == ZEND_NOP) { + send1_opline--; + } + if (send1_opline->opcode != ZEND_SEND_VAL || + ZEND_OP1_TYPE(send1_opline) != IS_CONST) { + /* don't colllect constants after unknown function call */ + collect_constants = 0; break; } - } else { - /* don't colllect constants after any other function call */ + } + init_opline = send1_opline - 1; + while (init_opline->opcode == ZEND_NOP) { + init_opline--; + } + if (init_opline->opcode != ZEND_INIT_FCALL || + ZEND_OP2_TYPE(init_opline) != IS_CONST || + Z_TYPE(ZEND_OP2_LITERAL(init_opline)) != IS_STRING) { + /* don't colllect constants after unknown function call */ collect_constants = 0; + break; + } + + /* define("name", scalar); */ + if (collect_constants && + Z_STRLEN(ZEND_OP2_LITERAL(init_opline)) == sizeof("define")-1 && + zend_binary_strcasecmp(Z_STRVAL(ZEND_OP2_LITERAL(init_opline)), Z_STRLEN(ZEND_OP2_LITERAL(init_opline)), "define", sizeof("define")-1) == 0) { + + if (Z_TYPE(ZEND_OP1_LITERAL(send1_opline)) == IS_STRING && + send2_opline && + Z_TYPE(ZEND_OP1_LITERAL(send2_opline)) <= IS_STRING) { + + zend_optimizer_collect_constant(ctx, &ZEND_OP1_LITERAL(send1_opline), &ZEND_OP1_LITERAL(send2_opline)); + break; + } } /* pre-evaluate constant functions: @@ -372,42 +401,42 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx TSRML is_callable(x) extension_loaded(x) */ - if ((opline + 1)->opcode == ZEND_SEND_VAL && - (opline + 2)->opcode == ZEND_DO_FCALL && - ZEND_OP1_TYPE(opline + 1) == IS_CONST && Z_TYPE(ZEND_OP1_LITERAL(opline + 1)) == IS_STRING && - ZEND_OP2_TYPE(opline) == IS_CONST && Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_STRING) { - if ((Z_STRLEN(ZEND_OP2_LITERAL(opline)) == sizeof("function_exists")-1 && - !memcmp(Z_STRVAL(ZEND_OP2_LITERAL(opline)), + if (!send2_opline && + Z_TYPE(ZEND_OP1_LITERAL(send1_opline)) == IS_STRING) { + if ((Z_STRLEN(ZEND_OP2_LITERAL(init_opline)) == sizeof("function_exists")-1 && + !memcmp(Z_STRVAL(ZEND_OP2_LITERAL(init_opline)), "function_exists", sizeof("function_exists")-1)) || - (Z_STRLEN(ZEND_OP2_LITERAL(opline)) == sizeof("is_callable")-1 && - !memcmp(Z_STRVAL(ZEND_OP2_LITERAL(opline)), + (Z_STRLEN(ZEND_OP2_LITERAL(init_opline)) == sizeof("is_callable")-1 && + !memcmp(Z_STRVAL(ZEND_OP2_LITERAL(init_opline)), "is_callable", sizeof("is_callable")))) { zend_internal_function *func; char *lc_name = zend_str_tolower_dup( - Z_STRVAL(ZEND_OP1_LITERAL(opline + 1)), Z_STRLEN(ZEND_OP1_LITERAL(opline + 1))); + Z_STRVAL(ZEND_OP1_LITERAL(send1_opline)), Z_STRLEN(ZEND_OP1_LITERAL(send1_opline))); - if ((func = zend_hash_str_find_ptr(EG(function_table), lc_name, Z_STRLEN(ZEND_OP1_LITERAL(opline + 1)))) != NULL && + if ((func = zend_hash_str_find_ptr(EG(function_table), lc_name, Z_STRLEN(ZEND_OP1_LITERAL(send1_opline)))) != NULL && func->type == ZEND_INTERNAL_FUNCTION && func->module->type == MODULE_PERSISTENT) { zval t; ZVAL_BOOL(&t, 1); - if (zend_optimizer_replace_by_const(op_array, opline + 3, IS_VAR, ZEND_RESULT(opline + 2).var, &t TSRMLS_CC)) { - literal_dtor(&ZEND_OP2_LITERAL(opline)); + if (zend_optimizer_replace_by_const(op_array, opline + 1, IS_VAR, ZEND_RESULT(opline).var, &t TSRMLS_CC)) { + literal_dtor(&ZEND_OP2_LITERAL(init_opline)); + MAKE_NOP(init_opline); + literal_dtor(&ZEND_OP1_LITERAL(send1_opline)); + MAKE_NOP(send1_opline); MAKE_NOP(opline); - literal_dtor(&ZEND_OP1_LITERAL(opline + 1)); - MAKE_NOP(opline + 1); - MAKE_NOP(opline + 2); + efree(lc_name); + break; } } efree(lc_name); - } else if (Z_STRLEN(ZEND_OP2_LITERAL(opline)) == sizeof("extension_loaded")-1 && - !memcmp(Z_STRVAL(ZEND_OP2_LITERAL(opline)), + } else if (Z_STRLEN(ZEND_OP2_LITERAL(init_opline)) == sizeof("extension_loaded")-1 && + !memcmp(Z_STRVAL(ZEND_OP2_LITERAL(init_opline)), "extension_loaded", sizeof("extension_loaded")-1)) { zval t; char *lc_name = zend_str_tolower_dup( - Z_STRVAL(ZEND_OP1_LITERAL(opline + 1)), Z_STRLEN(ZEND_OP1_LITERAL(opline + 1))); + Z_STRVAL(ZEND_OP1_LITERAL(send1_opline)), Z_STRLEN(ZEND_OP1_LITERAL(send1_opline))); zend_module_entry *m = zend_hash_str_find_ptr(&module_registry, - lc_name, Z_STRLEN(ZEND_OP1_LITERAL(opline + 1))); + lc_name, Z_STRLEN(ZEND_OP1_LITERAL(send1_opline))); efree(lc_name); if (!m) { @@ -424,60 +453,89 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx TSRML } } - if (zend_optimizer_replace_by_const(op_array, opline + 3, IS_VAR, ZEND_RESULT(opline + 2).var, &t TSRMLS_CC)) { - literal_dtor(&ZEND_OP2_LITERAL(opline)); + if (zend_optimizer_replace_by_const(op_array, opline + 1, IS_VAR, ZEND_RESULT(opline).var, &t TSRMLS_CC)) { + literal_dtor(&ZEND_OP2_LITERAL(init_opline)); + MAKE_NOP(init_opline); + literal_dtor(&ZEND_OP1_LITERAL(send1_opline)); + MAKE_NOP(send1_opline); MAKE_NOP(opline); - literal_dtor(&ZEND_OP1_LITERAL(opline + 1)); - MAKE_NOP(opline + 1); - MAKE_NOP(opline + 2); + break; } - } else if (Z_STRLEN(ZEND_OP2_LITERAL(opline)) == sizeof("defined")-1 && - !memcmp(Z_STRVAL(ZEND_OP2_LITERAL(opline)), + } else if (Z_STRLEN(ZEND_OP2_LITERAL(init_opline)) == sizeof("defined")-1 && + !memcmp(Z_STRVAL(ZEND_OP2_LITERAL(init_opline)), "defined", sizeof("defined")-1)) { zval t; - if (zend_optimizer_get_persistent_constant(Z_STR(ZEND_OP1_LITERAL(opline + 1)), &t, 0 TSRMLS_CC)) { + if (zend_optimizer_get_persistent_constant(Z_STR(ZEND_OP1_LITERAL(send1_opline)), &t, 0 TSRMLS_CC)) { ZVAL_BOOL(&t, 1); - if (zend_optimizer_replace_by_const(op_array, opline + 3, IS_VAR, ZEND_RESULT(opline + 2).var, &t TSRMLS_CC)) { - literal_dtor(&ZEND_OP2_LITERAL(opline)); + if (zend_optimizer_replace_by_const(op_array, opline + 1, IS_VAR, ZEND_RESULT(opline).var, &t TSRMLS_CC)) { + literal_dtor(&ZEND_OP2_LITERAL(init_opline)); + MAKE_NOP(init_opline); + literal_dtor(&ZEND_OP1_LITERAL(send1_opline)); + MAKE_NOP(send1_opline); MAKE_NOP(opline); - literal_dtor(&ZEND_OP1_LITERAL(opline + 1)); - MAKE_NOP(opline + 1); - MAKE_NOP(opline + 2); + break; } } - } else if (Z_STRLEN(ZEND_OP2_LITERAL(opline)) == sizeof("constant")-1 && - !memcmp(Z_STRVAL(ZEND_OP2_LITERAL(opline)), + } else if (Z_STRLEN(ZEND_OP2_LITERAL(init_opline)) == sizeof("constant")-1 && + !memcmp(Z_STRVAL(ZEND_OP2_LITERAL(init_opline)), "constant", sizeof("constant")-1)) { zval t; - if (zend_optimizer_get_persistent_constant(Z_STR(ZEND_OP1_LITERAL(opline + 1)), &t, 1 TSRMLS_CC)) { - if (zend_optimizer_replace_by_const(op_array, opline + 3, IS_VAR, ZEND_RESULT(opline + 2).var, &t TSRMLS_CC)) { - literal_dtor(&ZEND_OP2_LITERAL(opline)); + if (zend_optimizer_get_persistent_constant(Z_STR(ZEND_OP1_LITERAL(send1_opline)), &t, 1 TSRMLS_CC)) { + if (zend_optimizer_replace_by_const(op_array, opline + 1, IS_VAR, ZEND_RESULT(opline).var, &t TSRMLS_CC)) { + literal_dtor(&ZEND_OP2_LITERAL(init_opline)); + MAKE_NOP(init_opline); + literal_dtor(&ZEND_OP1_LITERAL(send1_opline)); + MAKE_NOP(send1_opline); MAKE_NOP(opline); - literal_dtor(&ZEND_OP1_LITERAL(opline + 1)); - MAKE_NOP(opline + 1); - MAKE_NOP(opline + 2); + break; } } } else if ((CG(compiler_options) & ZEND_COMPILE_NO_BUILTIN_STRLEN) == 0 && - Z_STRLEN(ZEND_OP2_LITERAL(opline)) == sizeof("strlen")-1 && - !memcmp(Z_STRVAL(ZEND_OP2_LITERAL(opline)), + Z_STRLEN(ZEND_OP2_LITERAL(init_opline)) == sizeof("strlen")-1 && + !memcmp(Z_STRVAL(ZEND_OP2_LITERAL(init_opline)), "strlen", sizeof("strlen")-1)) { zval t; - ZVAL_LONG(&t, Z_STRLEN(ZEND_OP1_LITERAL(opline + 1))); - if (zend_optimizer_replace_by_const(op_array, opline + 3, IS_VAR, ZEND_RESULT(opline + 2).var, &t TSRMLS_CC)) { - literal_dtor(&ZEND_OP2_LITERAL(opline)); + ZVAL_LONG(&t, Z_STRLEN(ZEND_OP1_LITERAL(send1_opline))); + if (zend_optimizer_replace_by_const(op_array, opline + 1, IS_VAR, ZEND_RESULT(opline).var, &t TSRMLS_CC)) { + literal_dtor(&ZEND_OP2_LITERAL(init_opline)); + MAKE_NOP(init_opline); + literal_dtor(&ZEND_OP1_LITERAL(send1_opline)); + MAKE_NOP(send1_opline); MAKE_NOP(opline); - literal_dtor(&ZEND_OP1_LITERAL(opline + 1)); - MAKE_NOP(opline + 1); - MAKE_NOP(opline + 2); + break; + } + /* dirname(IS_CONST/IS_STRING) -> IS_CONST/IS_STRING */ + } else if (Z_STRLEN(ZEND_OP2_LITERAL(init_opline)) == sizeof("dirname")-1 && + !memcmp(Z_STRVAL(ZEND_OP2_LITERAL(init_opline)), + "dirname", sizeof("dirname")-1) && + IS_ABSOLUTE_PATH(Z_STRVAL(ZEND_OP1_LITERAL(send1_opline)), Z_STRLEN(ZEND_OP1_LITERAL(send1_opline)))) { + zend_string *dirname = zend_string_init(Z_STRVAL(ZEND_OP1_LITERAL(send1_opline)), Z_STRLEN(ZEND_OP1_LITERAL(send1_opline)), 0); + dirname->len = zend_dirname(dirname->val, dirname->len); + if (IS_ABSOLUTE_PATH(dirname->val, dirname->len)) { + zval t; + + ZVAL_STR(&t, dirname); + if (zend_optimizer_replace_by_const(op_array, opline + 1, IS_VAR, ZEND_RESULT(opline).var, &t TSRMLS_CC)) { + literal_dtor(&ZEND_OP2_LITERAL(init_opline)); + MAKE_NOP(init_opline); + literal_dtor(&ZEND_OP1_LITERAL(send1_opline)); + MAKE_NOP(send1_opline); + MAKE_NOP(opline); + break; + } + } else { + zend_string_release(dirname); } } } + /* don't colllect constants after any other function call */ + collect_constants = 0; break; + } case ZEND_STRLEN: if (ZEND_OP1_TYPE(opline) == IS_CONST && Z_TYPE(ZEND_OP1_LITERAL(opline)) == IS_STRING) { @@ -530,7 +588,6 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx TSRML case ZEND_FE_RESET: case ZEND_FE_FETCH: case ZEND_NEW: - case ZEND_DO_FCALL: case ZEND_JMP_SET: case ZEND_COALESCE: collect_constants = 0; From 10107db61ec1ac695bb7167cae49d0e1b7271b11 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 30 Oct 2014 16:42:39 -0700 Subject: [PATCH 217/398] Use DECLARE_CONST instruction instead of call to internal define() function when possible --- ext/opcache/Optimizer/pass1_5.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/ext/opcache/Optimizer/pass1_5.c b/ext/opcache/Optimizer/pass1_5.c index 180482f6eed..15bca2adf85 100644 --- a/ext/opcache/Optimizer/pass1_5.c +++ b/ext/opcache/Optimizer/pass1_5.c @@ -381,15 +381,33 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx TSRML } /* define("name", scalar); */ - if (collect_constants && - Z_STRLEN(ZEND_OP2_LITERAL(init_opline)) == sizeof("define")-1 && + if (Z_STRLEN(ZEND_OP2_LITERAL(init_opline)) == sizeof("define")-1 && zend_binary_strcasecmp(Z_STRVAL(ZEND_OP2_LITERAL(init_opline)), Z_STRLEN(ZEND_OP2_LITERAL(init_opline)), "define", sizeof("define")-1) == 0) { if (Z_TYPE(ZEND_OP1_LITERAL(send1_opline)) == IS_STRING && send2_opline && Z_TYPE(ZEND_OP1_LITERAL(send2_opline)) <= IS_STRING) { - zend_optimizer_collect_constant(ctx, &ZEND_OP1_LITERAL(send1_opline), &ZEND_OP1_LITERAL(send2_opline)); + if (collect_constants) { + zend_optimizer_collect_constant(ctx, &ZEND_OP1_LITERAL(send1_opline), &ZEND_OP1_LITERAL(send2_opline)); + } + + if (RESULT_UNUSED(opline) && + !zend_memnstr(Z_STRVAL(ZEND_OP1_LITERAL(send1_opline)), "::", sizeof("::") - 1, Z_STRVAL(ZEND_OP1_LITERAL(send1_opline)) + Z_STRLEN(ZEND_OP1_LITERAL(send1_opline)))) { + + opline->opcode = ZEND_DECLARE_CONST; + opline->op1_type = IS_CONST; + opline->op2_type = IS_CONST; + opline->result_type = IS_UNUSED; + opline->op1.constant = send1_opline->op1.constant; + opline->op2.constant = send2_opline->op1.constant; + opline->result.zv = NULL; + + literal_dtor(&ZEND_OP2_LITERAL(init_opline)); + MAKE_NOP(init_opline); + MAKE_NOP(send1_opline); + MAKE_NOP(send2_opline); + } break; } } From 84783ecb7ea76e88a3831b5dae3e3819347bfbcc Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Fri, 31 Oct 2014 12:25:40 +0800 Subject: [PATCH 218/398] Fixed outof memory (length == -1) --- Zend/zend_virtual_cwd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_virtual_cwd.c b/Zend/zend_virtual_cwd.c index a596b7ca064..e3409897442 100644 --- a/Zend/zend_virtual_cwd.c +++ b/Zend/zend_virtual_cwd.c @@ -1394,7 +1394,7 @@ CWD_API int virtual_chdir(const char *path TSRMLS_DC) /* {{{ */ CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path TSRMLS_DC) TSRMLS_DC) /* {{{ */ { - size_t length = strlen(path); + int length = strlen(path); char *temp; int retval; ALLOCA_FLAG(use_heap) From d9d181e5ad41128a97a6e01d14fb766ff7bf31a8 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Fri, 31 Oct 2014 17:32:23 +0800 Subject: [PATCH 219/398] Fixed Bug #68104 (Segfault while pre-evaluating a disabled function) --- NEWS | 2 ++ Zend/zend_API.c | 15 ++++++--------- ext/opcache/tests/bug68104.phpt | 13 +++++++++++++ 3 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 ext/opcache/tests/bug68104.phpt diff --git a/NEWS b/NEWS index 478fa1d26c7..0d856202596 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,8 @@ PHP NEWS ?? ??? 2014, PHP 5.6.3 - Core: + . Fixed bug #68104 (Segfault while pre-evaluating a disabled function). + (Laruence) . Implemented 64-bit format codes for pack() and unpack(). (Leigh) . Fixed bug #51800 (proc_open on Windows hangs forever). (Anatol) . Fixed bug #67633 (A foreach on an array returned from a function not doing diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 8472cd7ab17..a465721f1fe 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -2635,18 +2635,15 @@ ZEND_API ZEND_FUNCTION(display_disabled_function) } /* }}} */ -static zend_function_entry disabled_function[] = { - ZEND_FE(display_disabled_function, NULL) - ZEND_FE_END -}; - ZEND_API int zend_disable_function(char *function_name, uint function_name_length TSRMLS_DC) /* {{{ */ { - if (zend_hash_del(CG(function_table), function_name, function_name_length+1)==FAILURE) { - return FAILURE; + zend_internal_function *func; + if (zend_hash_find(CG(function_table), function_name, function_name_length+1, (void **)&func)==SUCCESS) { + func->arg_info = NULL; + func->handler = ZEND_FN(display_disabled_function); + return SUCCESS; } - disabled_function[0].fname = function_name; - return zend_register_functions(NULL, disabled_function, CG(function_table), MODULE_PERSISTENT TSRMLS_CC); + return FAILURE; } /* }}} */ diff --git a/ext/opcache/tests/bug68104.phpt b/ext/opcache/tests/bug68104.phpt new file mode 100644 index 00000000000..521486ef582 --- /dev/null +++ b/ext/opcache/tests/bug68104.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #68104 (Segfault while pre-evaluating a disabled function) +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +disable_functions=dl +--SKIPIF-- + +--FILE-- + Date: Fri, 31 Oct 2014 17:38:18 +0800 Subject: [PATCH 220/398] Update NEWS --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 56441a87914..fba96937fb1 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,8 @@ PHP NEWS . Update the MIME type list from the one shipped by Apache HTTPD. (Adam) - Core: + . Fixed bug #68104 (Segfault while pre-evaluating a disabled function). + (Laruence) . Fixed bug #68252 (segfault in Zend/zend_hash.c in function _zend_hash_del_el). (Laruence) . Added PHP_INT_MIN constant. (Andrea) From 9580fcfeddf85f6510217fec2f596f6f5169f251 Mon Sep 17 00:00:00 2001 From: Matteo Beccati Date: Fri, 31 Oct 2014 18:10:01 +0100 Subject: [PATCH 221/398] Fixed bug #67462 PDO_PGSQL::beginTransaction() wrongly throws exception when not in transaction --- NEWS | 4 ++++ ext/pdo_pgsql/pgsql_driver.c | 28 ++++++++++++++++--------- ext/pdo_pgsql/tests/bug67462.phpt | 34 +++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 10 deletions(-) create mode 100644 ext/pdo_pgsql/tests/bug67462.phpt diff --git a/NEWS b/NEWS index 9e5e1388c81..ec68e1d7304 100644 --- a/NEWS +++ b/NEWS @@ -32,6 +32,10 @@ PHP NEWS . Fixed bug #68087 (ODBC not correctly reading DATE column when preceded by a VARCHAR column) (Keyur Govande) +- PDO_pgsql: + . Fixed bug #67462 (PDO_PGSQL::beginTransaction() wrongly throws exception + when not in transaction) (Matteo) + - SPL: . Fixed bug #68128 (Regression in RecursiveRegexIterator) (Tjerk) diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index 3be9359216d..9638c72fe62 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -465,6 +465,15 @@ static int pdo_pgsql_check_liveness(pdo_dbh_t *dbh TSRMLS_DC) } /* }}} */ +static int pgsql_handle_in_transaction(pdo_dbh_t *dbh TSRMLS_DC) +{ + pdo_pgsql_db_handle *H; + + H = (pdo_pgsql_db_handle *)dbh->driver_data; + + return PQtransactionStatus(H->server) > PQTRANS_IDLE; +} + static int pdo_pgsql_transaction_cmd(const char *cmd, pdo_dbh_t *dbh TSRMLS_DC) { pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data; @@ -489,7 +498,15 @@ static int pgsql_handle_begin(pdo_dbh_t *dbh TSRMLS_DC) static int pgsql_handle_commit(pdo_dbh_t *dbh TSRMLS_DC) { - return pdo_pgsql_transaction_cmd("COMMIT", dbh TSRMLS_CC); + int ret = pdo_pgsql_transaction_cmd("COMMIT", dbh TSRMLS_CC); + + /* When deferred constraints are used the commit could + fail, and a ROLLBACK implicitly ran. See bug #67462 */ + if (!ret) { + dbh->in_txn = pgsql_handle_in_transaction(dbh); + } + + return ret; } static int pgsql_handle_rollback(pdo_dbh_t *dbh TSRMLS_DC) @@ -497,15 +514,6 @@ static int pgsql_handle_rollback(pdo_dbh_t *dbh TSRMLS_DC) return pdo_pgsql_transaction_cmd("ROLLBACK", dbh TSRMLS_CC); } -static int pgsql_handle_in_transaction(pdo_dbh_t *dbh TSRMLS_DC) -{ - pdo_pgsql_db_handle *H; - - H = (pdo_pgsql_db_handle *)dbh->driver_data; - - return PQtransactionStatus(H->server); -} - /* {{{ proto string PDO::pgsqlCopyFromArray(string $table_name , array $rows [, string $delimiter [, string $null_as ] [, string $fields]) Returns true if the copy worked fine or false if error */ static PHP_METHOD(PDO, pgsqlCopyFromArray) diff --git a/ext/pdo_pgsql/tests/bug67462.phpt b/ext/pdo_pgsql/tests/bug67462.phpt new file mode 100644 index 00000000000..888b19c2489 --- /dev/null +++ b/ext/pdo_pgsql/tests/bug67462.phpt @@ -0,0 +1,34 @@ +--TEST-- +PDO PgSQL Bug #67462 (PDO_PGSQL::beginTransaction() wrongly throws exception when not in transaction) +--SKIPIF-- + +--FILE-- +setAttribute (\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + +$pdo->beginTransaction(); + +try { + $pdo->query("CREATE TABLE b67462 (a int NOT NULL PRIMARY KEY DEFERRABLE INITIALLY DEFERRED)"); + $pdo->query("INSERT INTO b67462 VALUES (1), (1)"); + + var_dump($pdo->inTransaction()); + $pdo->commit(); // This should fail! +} catch (\Exception $e) { + var_dump($pdo->inTransaction()); + var_dump($pdo->beginTransaction()); +} + +?> +--EXPECT-- +bool(true) +bool(false) +bool(true) From 29ee69434122bcda8c904ff6fbde2b9c74332240 Mon Sep 17 00:00:00 2001 From: Matteo Beccati Date: Fri, 31 Oct 2014 18:54:16 +0100 Subject: [PATCH 222/398] Added PGSQL_TEST_CONNSTR env var support for ext/pgsql tests --- ext/pgsql/tests/config.inc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ext/pgsql/tests/config.inc b/ext/pgsql/tests/config.inc index d4bbb338249..224d0550873 100644 --- a/ext/pgsql/tests/config.inc +++ b/ext/pgsql/tests/config.inc @@ -1,12 +1,15 @@ \ No newline at end of file +?> From e3934515c4535975df573ff3588b7e8ecbd86715 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 31 Oct 2014 18:35:55 +0100 Subject: [PATCH 223/398] fix datatype mismatch warnings --- ext/mcrypt/mcrypt.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c index 82cbe72176a..4341bbe5c17 100644 --- a/ext/mcrypt/mcrypt.c +++ b/ext/mcrypt/mcrypt.c @@ -573,7 +573,7 @@ PHP_FUNCTION(mcrypt_generic_init) php_error_docref(NULL TSRMLS_CC, E_WARNING, "Key size too large; supplied length: %d, max: %d", key_len, max_key_size); key_size = max_key_size; } else { - key_size = key_len; + key_size = (int)key_len; } memcpy(key_s, key, key_len); @@ -636,12 +636,12 @@ PHP_FUNCTION(mcrypt_generic) /* Check blocksize */ if (mcrypt_enc_is_block_mode(pm->td) == 1) { /* It's a block algorithm */ block_size = mcrypt_enc_get_block_size(pm->td); - data_size = (((data_len - 1) / block_size) + 1) * block_size; + data_size = ((((int)data_len - 1) / block_size) + 1) * block_size; data_s = emalloc(data_size + 1); memset(data_s, 0, data_size); memcpy(data_s, data, data_len); } else { /* It's not a block algorithm */ - data_size = data_len; + data_size = (int)data_len; data_s = emalloc(data_size + 1); memset(data_s, 0, data_size); memcpy(data_s, data, data_len); @@ -681,12 +681,12 @@ PHP_FUNCTION(mdecrypt_generic) /* Check blocksize */ if (mcrypt_enc_is_block_mode(pm->td) == 1) { /* It's a block algorithm */ block_size = mcrypt_enc_get_block_size(pm->td); - data_size = (((data_len - 1) / block_size) + 1) * block_size; + data_size = ((((int)data_len - 1) / block_size) + 1) * block_size; data_s = emalloc(data_size + 1); memset(data_s, 0, data_size); memcpy(data_s, data, data_len); } else { /* It's not a block algorithm */ - data_size = data_len; + data_size = (int)data_len; data_s = emalloc(data_size + 1); memset(data_s, 0, data_size); memcpy(data_s, data, data_len); @@ -1238,7 +1238,7 @@ static int php_mcrypt_ensure_valid_iv(MCRYPT td, const char *iv, int iv_size TSR } /* }}} */ -static void php_mcrypt_do_crypt(char* cipher, const char *key, int key_len, const char *data, int data_len, char *mode, const char *iv, size_t iv_len, size_t dencrypt, zval* return_value TSRMLS_DC) /* {{{ */ +static void php_mcrypt_do_crypt(char* cipher, const char *key, size_t key_len, const char *data, size_t data_len, char *mode, const char *iv, size_t iv_len, size_t dencrypt, zval* return_value TSRMLS_DC) /* {{{ */ { char *cipher_dir_string; char *module_dir_string; @@ -1254,12 +1254,12 @@ static void php_mcrypt_do_crypt(char* cipher, const char *key, int key_len, cons RETURN_FALSE; } - if (php_mcrypt_ensure_valid_key_size(td, key_len TSRMLS_CC) == FAILURE) { + if (php_mcrypt_ensure_valid_key_size(td, (int)key_len TSRMLS_CC) == FAILURE) { mcrypt_module_close(td); RETURN_FALSE; } - if (php_mcrypt_ensure_valid_iv(td, iv, iv_len TSRMLS_CC) == FAILURE) { + if (php_mcrypt_ensure_valid_iv(td, iv, (int)iv_len TSRMLS_CC) == FAILURE) { mcrypt_module_close(td); RETURN_FALSE; } @@ -1267,7 +1267,7 @@ static void php_mcrypt_do_crypt(char* cipher, const char *key, int key_len, cons /* Check blocksize */ if (mcrypt_enc_is_block_mode(td) == 1) { /* It's a block algorithm */ int block_size = mcrypt_enc_get_block_size(td); - data_size = (((data_len - 1) / block_size) + 1) * block_size; + data_size = ((((zend_long)data_len - 1) / block_size) + 1) * block_size; data_s = emalloc(data_size + 1); memset(data_s, 0, data_size); memcpy(data_s, data, data_len); @@ -1277,16 +1277,16 @@ static void php_mcrypt_do_crypt(char* cipher, const char *key, int key_len, cons memcpy(data_s, data, data_len); } - if (mcrypt_generic_init(td, (void *) key, key_len, (void *) iv) < 0) { + if (mcrypt_generic_init(td, (void *) key, (int)key_len, (void *) iv) < 0) { php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Mcrypt initialisation failed"); mcrypt_module_close(td); RETURN_FALSE; } if (dencrypt == MCRYPT_ENCRYPT) { - mcrypt_generic(td, data_s, data_size); + mcrypt_generic(td, data_s, (int)data_size); } else { - mdecrypt_generic(td, data_s, data_size); + mdecrypt_generic(td, data_s, (int)data_size); } data_s[data_size] = 0; @@ -1424,7 +1424,7 @@ PHP_FUNCTION(mcrypt_create_iv) php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not gather sufficient random data"); RETURN_FALSE; } - n = size; + n = (int)size; #else int fd; size_t read_bytes = 0; @@ -1451,7 +1451,7 @@ PHP_FUNCTION(mcrypt_create_iv) } #endif } else { - n = size; + n = (int)size; while (size) { iv[--size] = (char) (255.0 * php_rand(TSRMLS_C) / RAND_MAX); } From a6ebaa142e9f2d184b5a64653ce9f2d19092b56f Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 31 Oct 2014 18:41:41 +0100 Subject: [PATCH 224/398] fix datatype mismatch warnings --- ext/mcrypt/mcrypt_filter.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ext/mcrypt/mcrypt_filter.c b/ext/mcrypt/mcrypt_filter.c index 26f3dceba74..c36e9494e3c 100644 --- a/ext/mcrypt/mcrypt_filter.c +++ b/ext/mcrypt/mcrypt_filter.c @@ -60,7 +60,7 @@ static php_stream_filter_status_t php_mcrypt_filter( if (data->blocksize) { /* Blockmode cipher */ char *outchunk; - int chunklen = bucket->buflen + data->block_used, n; + int chunklen = (int)(bucket->buflen + data->block_used), n; php_stream_bucket *newbucket; outchunk = pemalloc(chunklen, data->persistent); @@ -91,9 +91,9 @@ static php_stream_filter_status_t php_mcrypt_filter( /* Stream cipher */ php_stream_bucket_make_writeable(bucket TSRMLS_CC); if (data->encrypt) { - mcrypt_generic(data->module, bucket->buf, bucket->buflen); + mcrypt_generic(data->module, bucket->buf, (int)bucket->buflen); } else { - mdecrypt_generic(data->module, bucket->buf, bucket->buflen); + mdecrypt_generic(data->module, bucket->buf, (int)bucket->buflen); } php_stream_bucket_append(buckets_out, bucket TSRMLS_CC); @@ -201,13 +201,13 @@ static php_stream_filter *php_mcrypt_filter_create(const char *filtername, zval if ((tmpzval = zend_hash_str_find(HASH_OF(filterparams), ZEND_STRL("key"))) && Z_TYPE_P(tmpzval) == IS_STRING) { key = Z_STRVAL_P(tmpzval); - key_len = Z_STRLEN_P(tmpzval); + key_len = (int)Z_STRLEN_P(tmpzval); } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "key not specified or is not a string"); return NULL; } - mcrypt_module = mcrypt_module_open(cipher, algo_dir, mode, mode_dir); + mcrypt_module = mcrypt_module_open((char *)cipher, algo_dir, mode, mode_dir); if (mcrypt_module == MCRYPT_FAILED) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not open encryption module"); return NULL; From cd574ca4677a101a51636cda26660fe2b74e3fa1 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 31 Oct 2014 18:46:38 +0100 Subject: [PATCH 225/398] fix datatype mismatch warning --- Zend/zend_virtual_cwd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_virtual_cwd.c b/Zend/zend_virtual_cwd.c index e3409897442..385df393bf5 100644 --- a/Zend/zend_virtual_cwd.c +++ b/Zend/zend_virtual_cwd.c @@ -1394,7 +1394,7 @@ CWD_API int virtual_chdir(const char *path TSRMLS_DC) /* {{{ */ CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path TSRMLS_DC) TSRMLS_DC) /* {{{ */ { - int length = strlen(path); + int length = (int)strlen(path); char *temp; int retval; ALLOCA_FLAG(use_heap) From 073c5e09976043890d81a2d0432b9cd5eef1afec Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 31 Oct 2014 18:49:29 +0100 Subject: [PATCH 226/398] fix warning not all control paths return a value --- Zend/zend_compile.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 78c42f333d1..babf39ff403 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -4639,6 +4639,8 @@ static HashTable *zend_get_import_ht(uint32_t type TSRMLS_DC) /* {{{ */ return CG(current_import_const); EMPTY_SWITCH_DEFAULT_CASE() } + + return NULL; } /* }}} */ @@ -4653,6 +4655,8 @@ static char *zend_get_use_type_str(uint32_t type) /* {{{ */ return " const"; EMPTY_SWITCH_DEFAULT_CASE() } + + return " unknown"; } /* }}} */ From 6498126afa33870b7434225131e91da989d9ce9d Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 31 Oct 2014 19:11:34 +0100 Subject: [PATCH 227/398] fix datatype mismatches --- ext/pgsql/pgsql.c | 56 ++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 207764b1651..0bc6fd263de 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -87,6 +87,7 @@ #endif #define CHECK_DEFAULT_LINK(x) if ((x) == -1) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "No PostgreSQL link opened yet"); } +#define FETCH_DEFAULT_LINK() PGG(default_link) ? (int)PGG(default_link)->handle : -1 #ifndef HAVE_PQFREEMEM #define PQfreemem free @@ -1272,7 +1273,8 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) PGconn *pgsql; smart_str str = {0}; zval *args; - int i, connect_type = 0; + uint32_t i; + int connect_type = 0; PGresult *pg_result; args = (zval *)safe_emalloc(ZEND_NUM_ARGS(), sizeof(zval), 0); @@ -1307,7 +1309,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) } else if (ZEND_NUM_ARGS() == 2 ) { /* Safe to add conntype_option, since 2 args was illegal */ connstring = Z_STRVAL(args[0]); convert_to_long_ex(&args[1]); - connect_type = Z_LVAL(args[1]); + connect_type = (int)Z_LVAL(args[1]); } else { host = Z_STRVAL(args[0]); port = Z_STRVAL(args[1]); @@ -1560,7 +1562,7 @@ PHP_FUNCTION(pg_close) } if (argc == 0) { - id = PGG(default_link)? PGG(default_link)->handle : -1; + id = FETCH_DEFAULT_LINK(); CHECK_DEFAULT_LINK(id); } @@ -1607,7 +1609,7 @@ static void php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type } if (argc == 0) { - id = PGG(default_link)? PGG(default_link)->handle : -1; + id = FETCH_DEFAULT_LINK(); CHECK_DEFAULT_LINK(id); } @@ -1830,7 +1832,7 @@ PHP_FUNCTION(pg_query) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &query, &query_len) == FAILURE) { return; } - id = PGG(default_link)? PGG(default_link)->handle : -1; + id = FETCH_DEFAULT_LINK(); CHECK_DEFAULT_LINK(id); } else { if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pgsql_link, &query, &query_len) == FAILURE) { @@ -1933,7 +1935,7 @@ PHP_FUNCTION(pg_query_params) if (zend_parse_parameters(argc TSRMLS_CC, "sa", &query, &query_len, &pv_param_arr) == FAILURE) { return; } - id = PGG(default_link)? PGG(default_link)->handle : -1; + id = FETCH_DEFAULT_LINK(); CHECK_DEFAULT_LINK(id); } else { if (zend_parse_parameters(argc TSRMLS_CC, "rsa", &pgsql_link, &query, &query_len, &pv_param_arr) == FAILURE) { @@ -2049,7 +2051,7 @@ PHP_FUNCTION(pg_prepare) if (zend_parse_parameters(argc TSRMLS_CC, "ss", &stmtname, &stmtname_len, &query, &query_len) == FAILURE) { return; } - id = PGG(default_link)? PGG(default_link)->handle : -1; + id = FETCH_DEFAULT_LINK(); CHECK_DEFAULT_LINK(id); } else { if (zend_parse_parameters(argc TSRMLS_CC, "rss", &pgsql_link, &stmtname, &stmtname_len, &query, &query_len) == FAILURE) { @@ -2136,7 +2138,7 @@ PHP_FUNCTION(pg_execute) if (zend_parse_parameters(argc TSRMLS_CC, "sa/", &stmtname, &stmtname_len, &pv_param_arr)==FAILURE) { return; } - id = PGG(default_link)? PGG(default_link)->handle : -1; + id = FETCH_DEFAULT_LINK(); CHECK_DEFAULT_LINK(id); } else { if (zend_parse_parameters(argc TSRMLS_CC, "rsa/", &pgsql_link, &stmtname, &stmtname_len, &pv_param_arr) == FAILURE) { @@ -2898,7 +2900,7 @@ PHP_FUNCTION(pg_fetch_all_columns) pgsql_result = pg_result->result; num_fields = PQnfields(pgsql_result); - if (colno >= num_fields || colno < 0) { + if (colno >= (zend_long)num_fields || colno < 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid column number '%pd'", colno); RETURN_FALSE; } @@ -2938,7 +2940,7 @@ PHP_FUNCTION(pg_result_seek) } /* seek to offset */ - pg_result->row = row; + pg_result->row = (int)row; RETURN_TRUE; } /* }}} */ @@ -3092,7 +3094,7 @@ PHP_FUNCTION(pg_trace) PGconn *pgsql; FILE *fp = NULL; php_stream *stream; - id = PGG(default_link)? PGG(default_link)->handle : -1; + id = FETCH_DEFAULT_LINK(); if (zend_parse_parameters(argc TSRMLS_CC, "s|sr", &z_filename, &z_filename_len, &mode, &mode_len, &pgsql_link) == FAILURE) { return; @@ -3137,7 +3139,7 @@ PHP_FUNCTION(pg_untrace) } if (argc == 0) { - id = PGG(default_link)? PGG(default_link)->handle : -1; + id = FETCH_DEFAULT_LINK(); CHECK_DEFAULT_LINK(id); } @@ -3170,7 +3172,7 @@ PHP_FUNCTION(pg_lo_create) } if (pgsql_link == NULL) { - id = PGG(default_link)? PGG(default_link)->handle : -1; + id = FETCH_DEFAULT_LINK(); CHECK_DEFAULT_LINK(id); if (id == -1) { RETURN_FALSE; @@ -3263,7 +3265,7 @@ PHP_FUNCTION(pg_lo_unlink) php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Wrong OID value passed"); RETURN_FALSE; } - id = PGG(default_link)? PGG(default_link)->handle : -1; + id = FETCH_DEFAULT_LINK(); CHECK_DEFAULT_LINK(id); } else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, @@ -3273,7 +3275,7 @@ PHP_FUNCTION(pg_lo_unlink) RETURN_FALSE; } oid = (Oid)oid_long; - id = PGG(default_link)? PGG(default_link)->handle : -1; + id = FETCH_DEFAULT_LINK(); CHECK_DEFAULT_LINK(id); } else { @@ -3335,7 +3337,7 @@ PHP_FUNCTION(pg_lo_open) php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Wrong OID value passed"); RETURN_FALSE; } - id = PGG(default_link)? PGG(default_link)->handle : -1; + id = FETCH_DEFAULT_LINK(); CHECK_DEFAULT_LINK(id); } else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, @@ -3345,7 +3347,7 @@ PHP_FUNCTION(pg_lo_open) RETURN_FALSE; } oid = (Oid)oid_long; - id = PGG(default_link)? PGG(default_link)->handle : -1; + id = FETCH_DEFAULT_LINK(); CHECK_DEFAULT_LINK(id); } else { @@ -3490,7 +3492,7 @@ PHP_FUNCTION(pg_lo_write) } if (argc > 2) { - if (z_len > str_len) { + if (z_len > (zend_long)str_len) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot write more than buffer size %d. Tried to write %pd", str_len, z_len); RETURN_FALSE; } @@ -3557,7 +3559,7 @@ PHP_FUNCTION(pg_lo_import) } else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, "p|z", &file_in, &name_len, &oid) == SUCCESS) { - id = PGG(default_link)? PGG(default_link)->handle : -1; + id = FETCH_DEFAULT_LINK(); CHECK_DEFAULT_LINK(id); } /* old calling convention, deprecated since PHP 4.2 */ @@ -3666,7 +3668,7 @@ PHP_FUNCTION(pg_lo_export) RETURN_FALSE; } oid = (Oid)oid_long; - id = PGG(default_link)? PGG(default_link)->handle : -1; + id = FETCH_DEFAULT_LINK(); CHECK_DEFAULT_LINK(id); } else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, @@ -3677,7 +3679,7 @@ PHP_FUNCTION(pg_lo_export) php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Wrong OID value passed"); RETURN_FALSE; } - id = PGG(default_link)? PGG(default_link)->handle : -1; + id = FETCH_DEFAULT_LINK(); CHECK_DEFAULT_LINK(id); } else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, @@ -3833,7 +3835,7 @@ PHP_FUNCTION(pg_set_error_verbosity) if (zend_parse_parameters(argc TSRMLS_CC, "l", &verbosity) == FAILURE) { return; } - id = PGG(default_link)? PGG(default_link)->handle : -1; + id = FETCH_DEFAULT_LINK(); CHECK_DEFAULT_LINK(id); } else { if (zend_parse_parameters(argc TSRMLS_CC, "rl", &pgsql_link, &verbosity) == FAILURE) { @@ -3871,7 +3873,7 @@ PHP_FUNCTION(pg_set_client_encoding) if (zend_parse_parameters(argc TSRMLS_CC, "s", &encoding, &encoding_len) == FAILURE) { return; } - id = PGG(default_link)? PGG(default_link)->handle : -1; + id = FETCH_DEFAULT_LINK(); CHECK_DEFAULT_LINK(id); } else { if (zend_parse_parameters(argc TSRMLS_CC, "rs", &pgsql_link, &encoding, &encoding_len) == FAILURE) { @@ -3902,7 +3904,7 @@ PHP_FUNCTION(pg_client_encoding) } if (argc == 0) { - id = PGG(default_link)? PGG(default_link)->handle : -1; + id = FETCH_DEFAULT_LINK(); CHECK_DEFAULT_LINK(id); } @@ -3937,7 +3939,7 @@ PHP_FUNCTION(pg_end_copy) } if (argc == 0) { - id = PGG(default_link)? PGG(default_link)->handle : -1; + id = FETCH_DEFAULT_LINK(); CHECK_DEFAULT_LINK(id); } @@ -3972,7 +3974,7 @@ PHP_FUNCTION(pg_put_line) if (zend_parse_parameters(argc TSRMLS_CC, "s", &query, &query_len) == FAILURE) { return; } - id = PGG(default_link) ? PGG(default_link)->handle : -1; + id = FETCH_DEFAULT_LINK(); CHECK_DEFAULT_LINK(id); } else { if (zend_parse_parameters(argc TSRMLS_CC, "rs", &pgsql_link, &query, &query_len) == FAILURE) { @@ -4598,7 +4600,7 @@ PHP_FUNCTION(pg_result_error_field) #endif |PG_DIAG_CONTEXT|PG_DIAG_SOURCE_FILE|PG_DIAG_SOURCE_LINE |PG_DIAG_SOURCE_FUNCTION)) { - field = (char *)PQresultErrorField(pgsql_result, fieldcode); + field = (char *)PQresultErrorField(pgsql_result, (int)fieldcode); if (field == NULL) { RETURN_NULL(); } else { From ed9ada5fa124cbdc0fa7d7845ef61b4eb7c31798 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 31 Oct 2014 19:35:51 +0100 Subject: [PATCH 228/398] fix datatype mismatches --- ext/pgsql/pgsql.c | 77 ++++++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 34 deletions(-) diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 0bc6fd263de..4b1cc31cc81 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -1756,7 +1756,7 @@ PHP_FUNCTION(pg_parameter_status) id = -1; } else if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m, &len) == SUCCESS) { pgsql_link = NULL; - id = PGG(default_link)? PGG(default_link)->handle : -1; + id = FETCH_DEFAULT_LINK(); } else { RETURN_FALSE; } @@ -1789,7 +1789,7 @@ PHP_FUNCTION(pg_ping) id = -1; } else { pgsql_link = NULL; - id = PGG(default_link)? PGG(default_link)->handle : -1; + id = FETCH_DEFAULT_LINK(); } if (pgsql_link == NULL && id == -1) { RETURN_FALSE; @@ -2416,7 +2416,7 @@ PHP_FUNCTION(pg_field_table) RETURN_FALSE; } - oid = PQftable(pg_result->result, fnum); + oid = PQftable(pg_result->result, (int)fnum); if (InvalidOid == oid) { RETURN_FALSE; @@ -2511,20 +2511,20 @@ static void php_pgsql_get_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_typ switch (entry_type) { case PHP_PG_FIELD_NAME: - RETURN_STRING(PQfname(pgsql_result, field)); + RETURN_STRING(PQfname(pgsql_result, (int)field)); break; case PHP_PG_FIELD_SIZE: - RETURN_LONG(PQfsize(pgsql_result, field)); + RETURN_LONG(PQfsize(pgsql_result, (int)field)); break; case PHP_PG_FIELD_TYPE: { - char *name = get_field_name(pg_result->conn, PQftype(pgsql_result, field), &EG(regular_list) TSRMLS_CC); + char *name = get_field_name(pg_result->conn, PQftype(pgsql_result, (int)field), &EG(regular_list) TSRMLS_CC); RETVAL_STRING(name); efree(name); } break; case PHP_PG_FIELD_TYPE_OID: - oid = PQftype(pgsql_result, field); + oid = PQftype(pgsql_result, (int)field); #if UINT_MAX > ZEND_LONG_MAX if (oid > ZEND_LONG_MAX) { smart_str s = {0}; @@ -2629,26 +2629,30 @@ PHP_FUNCTION(pg_fetch_result) RETURN_FALSE; } } else { - pgsql_row = row; - if (pgsql_row < 0 || pgsql_row >= PQntuples(pgsql_result)) { + if (row < 0 || row >= PQntuples(pgsql_result)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to jump to row %pd on PostgreSQL result index %pd", row, Z_LVAL_P(result)); RETURN_FALSE; } + pgsql_row = (int)row; } switch (Z_TYPE_P(field)) { case IS_STRING: field_offset = PQfnumber(pgsql_result, Z_STRVAL_P(field)); + if (field_offset < 0 || field_offset >= PQnfields(pgsql_result)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad column offset specified"); + RETURN_FALSE; + } break; default: convert_to_long_ex(field); - field_offset = Z_LVAL_P(field); + if (Z_LVAL_P(field) < 0 || Z_LVAL_P(field) >= PQnfields(pgsql_result)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad column offset specified"); + RETURN_FALSE; + } + field_offset = (int)Z_LVAL_P(field); break; } - if (field_offset < 0 || field_offset >= PQnfields(pgsql_result)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad column offset specified"); - RETURN_FALSE; - } if (PQgetisnull(pgsql_result, pgsql_row, field_offset)) { RETVAL_NULL(); @@ -2714,13 +2718,13 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, zend_long result_ pgsql_result = pg_result->result; if (use_row) { - pgsql_row = row; - pg_result->row = pgsql_row; - if (pgsql_row < 0 || pgsql_row >= PQntuples(pgsql_result)) { + if (row < 0 || row >= PQntuples(pgsql_result)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to jump to row %pd on PostgreSQL result index %pd", row, Z_LVAL_P(result)); RETURN_FALSE; } + pgsql_row = (int)row; + pg_result->row = pgsql_row; } else { /* If 2nd param is NULL, use internal row counter to access next row */ pgsql_row = pg_result->row; @@ -2912,10 +2916,10 @@ PHP_FUNCTION(pg_fetch_all_columns) } for (pg_row = 0; pg_row < pg_numrows; pg_row++) { - if (PQgetisnull(pgsql_result, pg_row, colno)) { + if (PQgetisnull(pgsql_result, pg_row, (int)colno)) { add_next_index_null(return_value); } else { - add_next_index_string(return_value, PQgetvalue(pgsql_result, pg_row, colno)); + add_next_index_string(return_value, PQgetvalue(pgsql_result, pg_row, (int)colno)); } } } @@ -2980,28 +2984,32 @@ static void php_pgsql_data_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type) RETURN_FALSE; } } else { - pgsql_row = row; - if (pgsql_row < 0 || pgsql_row >= PQntuples(pgsql_result)) { + if (row < 0 || row >= PQntuples(pgsql_result)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to jump to row %pd on PostgreSQL result index %pd", row, Z_LVAL_P(result)); RETURN_FALSE; } + pgsql_row = (int)row; } switch (Z_TYPE_P(field)) { case IS_STRING: convert_to_string_ex(field); field_offset = PQfnumber(pgsql_result, Z_STRVAL_P(field)); + if (field_offset < 0 || field_offset >= PQnfields(pgsql_result)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad column offset specified"); + RETURN_FALSE; + } break; default: convert_to_long_ex(field); - field_offset = Z_LVAL_P(field); + if (Z_LVAL_P(field) < 0 || Z_LVAL_P(field) >= PQnfields(pgsql_result)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad column offset specified"); + RETURN_FALSE; + } + field_offset = (int)Z_LVAL_P(field); break; } - if (field_offset < 0 || field_offset >= PQnfields(pgsql_result)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad column offset specified"); - RETURN_FALSE; - } switch (entry_type) { case PHP_PG_DATA_LENGTH: @@ -3449,7 +3457,8 @@ PHP_FUNCTION(pg_lo_read) { zval *pgsql_id; zend_long len; - int buf_len = PGSQL_LO_READ_BUF_SIZE, nbytes, argc = ZEND_NUM_ARGS(); + size_t buf_len = PGSQL_LO_READ_BUF_SIZE; + int nbytes, argc = ZEND_NUM_ARGS(); zend_string *buf; pgLofp *pgsql; @@ -3460,7 +3469,7 @@ PHP_FUNCTION(pg_lo_read) ZEND_FETCH_RESOURCE(pgsql, pgLofp *, pgsql_id, -1, "PostgreSQL large object", le_lofp); if (argc > 1) { - buf_len = len; + buf_len = len < 0 ? 0 : len; } buf = zend_string_alloc(buf_len, 0); @@ -3743,9 +3752,9 @@ PHP_FUNCTION(pg_lo_seek) #if HAVE_PG_LO64 if (PQserverVersion((PGconn *)pgsql->conn) >= 90300) { - result = lo_lseek64((PGconn *)pgsql->conn, pgsql->lofd, offset, whence); + result = lo_lseek64((PGconn *)pgsql->conn, pgsql->lofd, offset, (int)whence); } else { - result = lo_lseek((PGconn *)pgsql->conn, pgsql->lofd, offset, whence); + result = lo_lseek((PGconn *)pgsql->conn, pgsql->lofd, (int)offset, (int)whence); } #else result = lo_lseek((PGconn *)pgsql->conn, pgsql->lofd, offset, whence); @@ -4194,7 +4203,7 @@ PHP_FUNCTION(pg_copy_from) if(Z_STRLEN_P(tmp) > 0 && *(query + Z_STRLEN_P(tmp) - 1) != '\n') { strlcat(query, "\n", Z_STRLEN_P(tmp) + 2); } - if (PQputCopyData(pgsql, query, strlen(query)) != 1) { + if (PQputCopyData(pgsql, query, (int)strlen(query)) != 1) { efree(query); PHP_PQ_ERROR("copy failed: %s", pgsql); RETURN_FALSE; @@ -4272,7 +4281,7 @@ PHP_FUNCTION(pg_escape_string) return; } pgsql_link = NULL; - id = PGG(default_link)? PGG(default_link)->handle : -1; + id = FETCH_DEFAULT_LINK(); break; default: @@ -4317,7 +4326,7 @@ PHP_FUNCTION(pg_escape_bytea) return; } pgsql_link = NULL; - id = PGG(default_link)? PGG(default_link)->handle : -1; + id = FETCH_DEFAULT_LINK(); break; default: @@ -4490,7 +4499,7 @@ static void php_pgsql_escape_internal(INTERNAL_FUNCTION_PARAMETERS, int escape_l return; } pgsql_link = NULL; - id = PGG(default_link)? PGG(default_link)->handle : - 1; + id = FETCH_DEFAULT_LINK(); break; default: From 1fc80d0ca7f4fbf826d11dbcaa1b3cd79e8351a0 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 31 Oct 2014 19:53:16 +0100 Subject: [PATCH 229/398] fix ZTS build --- ext/pdo_pgsql/pgsql_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index 9638c72fe62..17757a7b2d2 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -503,7 +503,7 @@ static int pgsql_handle_commit(pdo_dbh_t *dbh TSRMLS_DC) /* When deferred constraints are used the commit could fail, and a ROLLBACK implicitly ran. See bug #67462 */ if (!ret) { - dbh->in_txn = pgsql_handle_in_transaction(dbh); + dbh->in_txn = pgsql_handle_in_transaction(dbh TSRMLS_CC); } return ret; From 00b50850ebcb2ecc4bd4be053f31556567efa28d Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Sat, 1 Nov 2014 22:29:55 +0800 Subject: [PATCH 230/398] Add credit --- ext/opcache/tests/bug68104.phpt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ext/opcache/tests/bug68104.phpt b/ext/opcache/tests/bug68104.phpt index 89439ef68e1..8d3bf70a4d0 100644 --- a/ext/opcache/tests/bug68104.phpt +++ b/ext/opcache/tests/bug68104.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #68104 (Segfault while pre-evaluating a disabled function) +--CREDITS-- +manuel --INI-- opcache.enable=1 opcache.enable_cli=1 From 69f6aee35c5da6983a1bb5bb00ecf0ab776379d9 Mon Sep 17 00:00:00 2001 From: Matteo Beccati Date: Sat, 1 Nov 2014 19:11:43 +0100 Subject: [PATCH 231/398] Fixed bug #66584 Segmentation fault on statement deallocation --- NEWS | 1 + ext/pdo_pgsql/pgsql_statement.c | 2 +- ext/pdo_pgsql/tests/bug66584.phpt | 66 +++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 ext/pdo_pgsql/tests/bug66584.phpt diff --git a/NEWS b/NEWS index ec68e1d7304..ef4195132b9 100644 --- a/NEWS +++ b/NEWS @@ -33,6 +33,7 @@ PHP NEWS a VARCHAR column) (Keyur Govande) - PDO_pgsql: + . Fixed bug #66584 (Segmentation fault on statement deallocation) (Matteo) . Fixed bug #67462 (PDO_PGSQL::beginTransaction() wrongly throws exception when not in transaction) (Matteo) diff --git a/ext/pdo_pgsql/pgsql_statement.c b/ext/pdo_pgsql/pgsql_statement.c index ea5a67633e6..1fa7ce4777a 100644 --- a/ext/pdo_pgsql/pgsql_statement.c +++ b/ext/pdo_pgsql/pgsql_statement.c @@ -294,7 +294,7 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data * sizeof(Oid)); } if (param->paramno >= 0) { - if (param->paramno > zend_hash_num_elements(stmt->bound_param_map)) { + if (param->paramno >= zend_hash_num_elements(stmt->bound_param_map)) { pdo_pgsql_error_stmt(stmt, PGRES_FATAL_ERROR, "HY105"); return 0; } diff --git a/ext/pdo_pgsql/tests/bug66584.phpt b/ext/pdo_pgsql/tests/bug66584.phpt new file mode 100644 index 00000000000..07742bca798 --- /dev/null +++ b/ext/pdo_pgsql/tests/bug66584.phpt @@ -0,0 +1,66 @@ +--TEST-- +PDO PgSQL Bug #66584 (Segmentation fault on statement deallocation) +--SKIPIF-- + +--FILE-- +setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + +$pdo->beginTransaction(); + +$pdo->query("CREATE TABLE b66584 (a int)"); +$pdo->query("INSERT INTO b66584 VALUES (165)"); + +for ($i = 1; $i >= 0; $i--) { + $pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, (bool)$i); + + try { + run($pdo, [0 => 1, 2 => 165, 5 => 3]); + } catch (\Exception $e) { + var_dump($e->getMessage()); + } + + try { + run($pdo, json_decode('{"0":234,"1":165,"2":221,"3":207,"4":188,"5":216,"6":1150,"7":916,"8":967,"9":987,"10":951,"11":990,"12":959,"13":896,"14":947,"15":877,"16":1000,"17":1023,"18":904,"19":856,"20":860,"21":866,"22":930,"23":974,"24":1032,"25":1016,"26":1050,"27":1059,"28":1040,"29":1064,"30":1004,"31":214,"32":189,"33":166,"34":1002,"35":167,"36":191,"37":859,"38":204,"39":181,"40":1001,"42":208,"43":198,"44":177,"45":1003,"46":858,"47":190,"48":162,"49":210,"50":171,"51":197,"52":168,"53":194,"54":209,"55":200,"56":192,"57":180,"58":232,"59":222,"60":163,"61":196,"62":217,"64":176,"65":193,"66":172,"67":195,"68":170,"69":173,"70":233,"71":223,"72":218,"73":186,"74":175,"75":224,"76":205,"77":211,"78":235,"79":1101,"80":225,"81":236,"82":1102,"83":1164,"84":1083,"85":1005,"86":861,"87":1179,"88":960,"89":991,"90":1187,"91":880,"92":1149,"93":1033,"94":931,"95":1006,"96":862,"97":1151,"98":917,"99":881,"100":1148,"101":1065,"102":867,"103":952,"104":1152,"105":918,"106":961,"107":1180,"108":992,"109":1188,"110":932,"111":933,"112":968,"113":868,"114":882,"115":1147,"116":1017,"117":1131,"118":1174,"119":1178,"120":1186,"121":869,"122":1051,"123":934,"124":969,"125":975,"126":1066,"127":237,"128":953,"129":1024,"130":1146,"131":883,"132":1145,"133":884,"134":885,"135":1144,"136":886,"137":1143,"138":1025,"139":897,"140":898,"141":899,"142":1026,"143":1142,"144":887,"145":1141,"146":888,"147":889,"148":1140,"149":1189,"150":993,"151":1139,"152":890,"153":1138,"154":891,"155":900,"156":892,"157":1137,"158":1027,"159":901,"160":1136,"161":893,"162":870,"163":1052,"164":954,"165":1041,"166":1018,"167":1165,"168":1084,"169":962,"170":1181,"171":994,"172":1190,"173":1042,"174":935,"175":226,"176":871,"177":1191,"178":995,"179":977,"180":948,"181":1175,"182":1053,"183":955,"184":1182,"185":963,"186":1067,"187":919,"188":1153,"189":920,"190":1154,"191":1055,"192":1054,"193":1056,"194":863,"195":872,"196":1028,"197":921,"198":1155,"199":936,"200":970,"201":1019,"202":1166,"203":1085,"204":1135,"205":894,"206":1034,"207":905,"208":873,"209":937,"210":902,"211":1029,"212":1007,"213":864,"214":1043,"215":1057,"216":956,"217":957,"218":939,"219":1086,"220":1167,"221":1087,"222":1168,"223":1173,"224":1108,"225":978,"226":1044,"227":1183,"228":964,"229":965,"230":1184,"231":1045,"232":874,"233":940,"234":1046,"235":979,"236":903,"237":980,"238":1156,"239":922,"240":1035,"241":906,"242":971,"243":972,"244":878,"245":1134,"246":879,"247":1133,"248":907,"249":1036,"250":908,"251":1132,"252":895,"253":909,"254":1060,"255":981,"256":1068,"257":996,"258":1192,"259":941,"260":865,"261":1008,"262":910,"263":997,"264":1193,"265":982,"266":942,"267":1020,"268":983,"269":1061,"270":949,"271":1176,"272":875,"273":911,"274":1069,"275":1157,"276":923,"277":1158,"278":924,"279":988,"280":984,"281":925,"282":1159,"283":1062,"284":1047,"285":1194,"286":998,"287":1021,"288":1030,"289":1031,"290":1070,"291":1088,"292":1169,"293":958,"294":1195,"295":999,"296":966,"297":1185,"298":944,"299":945,"300":1022,"301":1103,"302":220,"303":1099,"304":1048,"305":927,"306":1161,"307":989,"308":973,"309":1071,"310":1074,"311":1072,"312":1073,"313":912,"314":1037,"315":913,"316":914,"317":1177,"318":950,"319":1049,"320":876,"321":985,"322":915,"323":1038,"324":946,"325":1089,"326":1170,"327":1090,"328":1171,"329":1091,"330":1172,"331":1063,"332":986,"333":928,"334":1162,"335":929,"336":1163,"337":976,"338":231,"339":201,"340":1098,"341":215}', true)); + } catch (\Exception $e) { + var_dump($e->getMessage()); + } +} + +try { + $pdo->query("DROP TABLE b66584"); + $pdo->rollback(); +} catch (\Exception $e) { +} + +function run($pdo, $data) +{ + $bind = join(', ', array_fill(0, count($data), '?')); + + $stmt = $pdo->prepare("SELECT COUNT(*) FROM b66584 WHERE a IN ({$bind})"); + + var_dump(count($data)); + + $stmt->execute($data); + + var_dump($stmt->fetchColumn()); +} + +?> +--EXPECTF-- +int(3) +string(%d) "SQLSTATE%s" +int(340) +string(%d) "SQLSTATE%s" +int(3) +string(%d) "SQLSTATE%s" +int(340) +string(%d) "SQLSTATE%s" From 1a2ec3fc60e428c47fd59c9dd7966c71ca44024d Mon Sep 17 00:00:00 2001 From: George Wang Date: Mon, 3 Nov 2014 11:42:01 -0500 Subject: [PATCH 232/398] set default response code to 200 --- sapi/litespeed/lsapi_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sapi/litespeed/lsapi_main.c b/sapi/litespeed/lsapi_main.c index 425d638f9ef..6bdf9b7d0c0 100644 --- a/sapi/litespeed/lsapi_main.c +++ b/sapi/litespeed/lsapi_main.c @@ -478,8 +478,8 @@ static int init_request_info( TSRMLS_D ) SG(request_info).content_length = LSAPI_GetReqBodyLen(); SG(request_info).path_translated = estrdup( LSAPI_GetScriptFileName()); - /* It is not reset by zend engine, set it to 0. */ - SG(sapi_headers).http_response_code = 0; + /* It is not reset by zend engine, set it to 200. */ + SG(sapi_headers).http_response_code = 200; pAuth = LSAPI_GetHeader( H_AUTHORIZATION ); php_handle_auth_data(pAuth TSRMLS_CC); From 19f3f4b155754aada4de4b03996c1dc6ad020726 Mon Sep 17 00:00:00 2001 From: George Wang Date: Mon, 3 Nov 2014 11:42:01 -0500 Subject: [PATCH 233/398] set default response code to 200 --- sapi/litespeed/lsapi_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sapi/litespeed/lsapi_main.c b/sapi/litespeed/lsapi_main.c index 425d638f9ef..6bdf9b7d0c0 100644 --- a/sapi/litespeed/lsapi_main.c +++ b/sapi/litespeed/lsapi_main.c @@ -478,8 +478,8 @@ static int init_request_info( TSRMLS_D ) SG(request_info).content_length = LSAPI_GetReqBodyLen(); SG(request_info).path_translated = estrdup( LSAPI_GetScriptFileName()); - /* It is not reset by zend engine, set it to 0. */ - SG(sapi_headers).http_response_code = 0; + /* It is not reset by zend engine, set it to 200. */ + SG(sapi_headers).http_response_code = 200; pAuth = LSAPI_GetHeader( H_AUTHORIZATION ); php_handle_auth_data(pAuth TSRMLS_CC); From 4435161456740f8709fe0d5592bc195bb5be04ba Mon Sep 17 00:00:00 2001 From: George Wang Date: Mon, 3 Nov 2014 11:42:01 -0500 Subject: [PATCH 234/398] set default response code to 200 --- sapi/litespeed/lsapi_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sapi/litespeed/lsapi_main.c b/sapi/litespeed/lsapi_main.c index 425d638f9ef..6bdf9b7d0c0 100644 --- a/sapi/litespeed/lsapi_main.c +++ b/sapi/litespeed/lsapi_main.c @@ -478,8 +478,8 @@ static int init_request_info( TSRMLS_D ) SG(request_info).content_length = LSAPI_GetReqBodyLen(); SG(request_info).path_translated = estrdup( LSAPI_GetScriptFileName()); - /* It is not reset by zend engine, set it to 0. */ - SG(sapi_headers).http_response_code = 0; + /* It is not reset by zend engine, set it to 200. */ + SG(sapi_headers).http_response_code = 200; pAuth = LSAPI_GetHeader( H_AUTHORIZATION ); php_handle_auth_data(pAuth TSRMLS_CC); From 79de59e86295f91a9f4709b43be6e85fcc002199 Mon Sep 17 00:00:00 2001 From: George Wang Date: Mon, 3 Nov 2014 11:42:01 -0500 Subject: [PATCH 235/398] set default response code to 200 --- sapi/litespeed/lsapi_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sapi/litespeed/lsapi_main.c b/sapi/litespeed/lsapi_main.c index 13439460aed..a9f27fcea1d 100644 --- a/sapi/litespeed/lsapi_main.c +++ b/sapi/litespeed/lsapi_main.c @@ -478,8 +478,8 @@ static int init_request_info( TSRMLS_D ) SG(request_info).content_length = LSAPI_GetReqBodyLen(); SG(request_info).path_translated = estrdup( LSAPI_GetScriptFileName()); - /* It is not reset by zend engine, set it to 0. */ - SG(sapi_headers).http_response_code = 0; + /* It is not reset by zend engine, set it to 200. */ + SG(sapi_headers).http_response_code = 200; pAuth = LSAPI_GetHeader( H_AUTHORIZATION ); php_handle_auth_data(pAuth TSRMLS_CC); From c351b47ce85a3a147cfa801fa9f0149ab4160834 Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Sun, 2 Nov 2014 16:04:00 -0800 Subject: [PATCH 236/398] Initialize the offset table - PCRE may sometimes miss offsets --- ext/pcre/php_pcre.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index bd93f723d62..d7a4309b24d 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -640,7 +640,7 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, int subjec } offsets = (int *)safe_emalloc(size_offsets, sizeof(int), 0); - + memset(offsets, 0, size_offsets*sizeof(int)); /* Allocate match sets array and initialize the values. */ if (global && subpats && subpats_order == PREG_PATTERN_ORDER) { match_sets = (zval **)safe_emalloc(num_subpats, sizeof(zval *), 0); From 7740edae36fea4e831afc6f1e37eb559dcf597f0 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 27 Oct 2014 07:45:34 +0100 Subject: [PATCH 237/398] Fix bug #63595 GMP memory management conflicts with other libraries using GMP Drop use of php memory allocators as this raise various conflicts with other extensions and libraries which use libgmp. No other solution found. We cannot for ensure correct use of allocator with shared lib. Some memory can allocated before php init Some memory can be freed after php shutdown Known broken run cases - php + curl + gnutls + gmp - mod_gnutls + mod_php + gnutls + gmp - php + freetds + gnutls + gmp - php + odbc + freetds + gnutls + gmp - php + php-mapi (zarafa) + gnutls + gmp --- ext/gmp/gmp.c | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index f51bd8c59c0..b1553fa16f0 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -324,30 +324,6 @@ static void _php_gmpnum_free(zend_rsrc_list_entry *rsrc TSRMLS_DC); # define MAX_BASE 36 #endif -/* {{{ gmp_emalloc - */ -static void *gmp_emalloc(size_t size) -{ - return emalloc(size); -} -/* }}} */ - -/* {{{ gmp_erealloc - */ -static void *gmp_erealloc(void *ptr, size_t old_size, size_t new_size) -{ - return erealloc(ptr, new_size); -} -/* }}} */ - -/* {{{ gmp_efree - */ -static void gmp_efree(void *ptr, size_t size) -{ - efree(ptr); -} -/* }}} */ - /* {{{ ZEND_GINIT_FUNCTION */ static ZEND_GINIT_FUNCTION(gmp) @@ -369,8 +345,6 @@ ZEND_MODULE_STARTUP_D(gmp) #endif REGISTER_STRING_CONSTANT("GMP_VERSION", (char *)gmp_version, CONST_CS | CONST_PERSISTENT); - mp_set_memory_functions(gmp_emalloc, gmp_erealloc, gmp_efree); - return SUCCESS; } /* }}} */ From 0ddcf2a919a24cccb36bd0a69b05e6bbfc0bf883 Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Mon, 3 Nov 2014 11:43:15 -0800 Subject: [PATCH 238/398] update NEWS --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 8f8cd49e7ae..53d047215ff 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,10 @@ PHP NEWS . Fixed bug #68283 (fileinfo: out-of-bounds read in elf note headers). (CVE-2014-3710) (Remi) +- GMP: + . Fixed bug #63595 (GMP memory management conflicts with other libraries + using GMP). (Remi) + 16 Oct 2014, PHP 5.4.34 - Fileinfo: From faa4c6155ef384b7ffdd6de3b146fef79f8ba35c Mon Sep 17 00:00:00 2001 From: Andrea Faulds Date: Tue, 4 Nov 2014 00:15:26 +0000 Subject: [PATCH 239/398] Respect flags when fetching class by name --- Zend/zend_vm_def.h | 2 +- Zend/zend_vm_execute.h | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index fad38c64287..60983e516f9 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -2070,7 +2070,7 @@ ZEND_VM_HANDLER(109, ZEND_FETCH_CLASS, ANY, CONST|TMP|VAR|UNUSED|CV) if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) { Z_CE_P(EX_VAR(opline->result.var)) = CACHED_PTR(Z_CACHE_SLOT_P(class_name)); } else { - Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, 0 TSRMLS_CC); + Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, opline->extended_value TSRMLS_CC); CACHE_PTR(Z_CACHE_SLOT_P(class_name), Z_CE_P(EX_VAR(opline->result.var))); } } else if (Z_TYPE_P(class_name) == IS_OBJECT) { diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 4f305c2258a..c4d4b135d92 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -1423,7 +1423,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLE if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) { Z_CE_P(EX_VAR(opline->result.var)) = CACHED_PTR(Z_CACHE_SLOT_P(class_name)); } else { - Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, 0 TSRMLS_CC); + Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, opline->extended_value TSRMLS_CC); CACHE_PTR(Z_CACHE_SLOT_P(class_name), Z_CE_P(EX_VAR(opline->result.var))); } } else if (Z_TYPE_P(class_name) == IS_OBJECT) { @@ -1758,7 +1758,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) { Z_CE_P(EX_VAR(opline->result.var)) = CACHED_PTR(Z_CACHE_SLOT_P(class_name)); } else { - Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, 0 TSRMLS_CC); + Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, opline->extended_value TSRMLS_CC); CACHE_PTR(Z_CACHE_SLOT_P(class_name), Z_CE_P(EX_VAR(opline->result.var))); } } else if (Z_TYPE_P(class_name) == IS_OBJECT) { @@ -1944,7 +1944,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) { Z_CE_P(EX_VAR(opline->result.var)) = CACHED_PTR(Z_CACHE_SLOT_P(class_name)); } else { - Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, 0 TSRMLS_CC); + Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, opline->extended_value TSRMLS_CC); CACHE_PTR(Z_CACHE_SLOT_P(class_name), Z_CE_P(EX_VAR(opline->result.var))); } } else if (Z_TYPE_P(class_name) == IS_OBJECT) { @@ -2130,7 +2130,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_UNUSED_HANDLER(ZEND_OPCODE_HANDL if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) { Z_CE_P(EX_VAR(opline->result.var)) = CACHED_PTR(Z_CACHE_SLOT_P(class_name)); } else { - Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, 0 TSRMLS_CC); + Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, opline->extended_value TSRMLS_CC); CACHE_PTR(Z_CACHE_SLOT_P(class_name), Z_CE_P(EX_VAR(opline->result.var))); } } else if (Z_TYPE_P(class_name) == IS_OBJECT) { @@ -2169,7 +2169,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_A if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) { Z_CE_P(EX_VAR(opline->result.var)) = CACHED_PTR(Z_CACHE_SLOT_P(class_name)); } else { - Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, 0 TSRMLS_CC); + Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, opline->extended_value TSRMLS_CC); CACHE_PTR(Z_CACHE_SLOT_P(class_name), Z_CE_P(EX_VAR(opline->result.var))); } } else if (Z_TYPE_P(class_name) == IS_OBJECT) { From 3b6cd5fe4ce81d3d219887339f3915140214708c Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 4 Nov 2014 10:07:44 +0100 Subject: [PATCH 240/398] improved the ZEND_FASTCALL convention for vc12+ --- Zend/zend_portability.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index 1705965c6be..c159fdc77b4 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -196,8 +196,10 @@ char *alloca(); #if defined(__GNUC__) && ZEND_GCC_VERSION >= 3004 && defined(__i386__) # define ZEND_FASTCALL __attribute__((fastcall)) -#elif defined(_MSC_VER) && defined(_M_IX86) +#elif defined(_MSC_VER) && defined(_M_IX86) && _MSC_VER <= 1700 # define ZEND_FASTCALL __fastcall +#elif defined(_MSC_VER) && _MSC_VER >= 1800 +# define ZEND_FASTCALL __vectorcall #else # define ZEND_FASTCALL #endif From 342d56b23d05dcafa5019efc401a78592d823b49 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 4 Nov 2014 16:58:32 +0100 Subject: [PATCH 241/398] arg1-3 are not variable names to use; removed useless buffer variable --- ext/standard/file.c | 114 +++++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 59 deletions(-) diff --git a/ext/standard/file.c b/ext/standard/file.c index 10ed693f012..a2b4db154a6 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -339,16 +339,16 @@ static int flock_values[] = { LOCK_SH, LOCK_EX, LOCK_UN }; Portable file locking */ PHP_FUNCTION(flock) { - zval *arg1, *arg3 = NULL; + zval *res, *wouldblock = NULL; int act; php_stream *stream; long operation = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|z", &arg1, &operation, &arg3) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|z", &res, &operation, &wouldblock) == FAILURE) { return; } - PHP_STREAM_TO_ZVAL(stream, &arg1); + PHP_STREAM_TO_ZVAL(stream, &res); act = operation & 3; if (act < 1 || act > 3) { @@ -356,16 +356,16 @@ PHP_FUNCTION(flock) RETURN_FALSE; } - if (arg3 && PZVAL_IS_REF(arg3)) { - convert_to_long_ex(&arg3); - Z_LVAL_P(arg3) = 0; + if (wouldblock && PZVAL_IS_REF(wouldblock)) { + convert_to_long_ex(&wouldblock); + Z_LVAL_P(wouldblock) = 0; } /* flock_values contains all possible actions if (operation & 4) we won't block on the lock */ act = flock_values[act - 1] | (operation & PHP_LOCK_NB ? LOCK_NB : 0); if (php_stream_lock(stream, act)) { - if (operation && errno == EWOULDBLOCK && arg3 && PZVAL_IS_REF(arg3)) { - Z_LVAL_P(arg3) = 1; + if (operation && errno == EWOULDBLOCK && wouldblock && PZVAL_IS_REF(wouldblock)) { + Z_LVAL_P(wouldblock) = 1; } RETURN_FALSE; } @@ -896,14 +896,14 @@ PHP_NAMED_FUNCTION(php_if_fopen) Close an open file pointer */ PHPAPI PHP_FUNCTION(fclose) { - zval *arg1; + zval *res; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &res) == FAILURE) { RETURN_FALSE; } - PHP_STREAM_TO_ZVAL(stream, &arg1); + PHP_STREAM_TO_ZVAL(stream, &res); if ((stream->flags & PHP_STREAM_FLAG_NO_FCLOSE) != 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a valid stream resource", stream->rsrc_id); @@ -968,14 +968,14 @@ PHP_FUNCTION(popen) Close a file pointer opened by popen() */ PHP_FUNCTION(pclose) { - zval *arg1; + zval *res; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &res) == FAILURE) { RETURN_FALSE; } - PHP_STREAM_TO_ZVAL(stream, &arg1); + PHP_STREAM_TO_ZVAL(stream, &res); FG(pclose_wait) = 1; zend_list_delete(stream->rsrc_id); @@ -988,14 +988,14 @@ PHP_FUNCTION(pclose) Test for end-of-file on a file pointer */ PHPAPI PHP_FUNCTION(feof) { - zval *arg1; + zval *res; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &res) == FAILURE) { RETURN_FALSE; } - PHP_STREAM_TO_ZVAL(stream, &arg1); + PHP_STREAM_TO_ZVAL(stream, &res); if (php_stream_eof(stream)) { RETURN_TRUE; @@ -1009,18 +1009,18 @@ PHPAPI PHP_FUNCTION(feof) Get a line from file pointer */ PHPAPI PHP_FUNCTION(fgets) { - zval *arg1; + zval *res; long len = 1024; char *buf = NULL; int argc = ZEND_NUM_ARGS(); size_t line_len = 0; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &arg1, &len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &res, &len) == FAILURE) { RETURN_FALSE; } - PHP_STREAM_TO_ZVAL(stream, &arg1); + PHP_STREAM_TO_ZVAL(stream, &res); if (argc == 1) { /* ask streams to give us a buffer of an appropriate size */ @@ -1060,16 +1060,16 @@ exit_failed: Get a character from file pointer */ PHPAPI PHP_FUNCTION(fgetc) { - zval *arg1; + zval *res; char buf[2]; int result; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &res) == FAILURE) { RETURN_FALSE; } - PHP_STREAM_TO_ZVAL(stream, &arg1); + PHP_STREAM_TO_ZVAL(stream, &res); result = php_stream_getc(stream); @@ -1180,35 +1180,31 @@ PHP_FUNCTION(fscanf) Binary-safe file write */ PHPAPI PHP_FUNCTION(fwrite) { - zval *arg1; - char *arg2; - int arg2len; + zval *res; + char *input; + int inputlen; int ret; int num_bytes; - long arg3 = 0; - char *buffer = NULL; + long maxlen = 0; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|l", &arg1, &arg2, &arg2len, &arg3) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|l", &res, &input, &inputlen, &maxlen) == FAILURE) { RETURN_FALSE; } if (ZEND_NUM_ARGS() == 2) { - num_bytes = arg2len; + num_bytes = inputlen; } else { - num_bytes = MAX(0, MIN((int)arg3, arg2len)); + num_bytes = MAX(0, MIN((int) maxlen, inputlen)); } if (!num_bytes) { RETURN_LONG(0); } - PHP_STREAM_TO_ZVAL(stream, &arg1); + PHP_STREAM_TO_ZVAL(stream, &res); - ret = php_stream_write(stream, buffer ? buffer : arg2, num_bytes); - if (buffer) { - efree(buffer); - } + ret = php_stream_write(stream, input, num_bytes); RETURN_LONG(ret); } @@ -1218,15 +1214,15 @@ PHPAPI PHP_FUNCTION(fwrite) Flushes output */ PHPAPI PHP_FUNCTION(fflush) { - zval *arg1; + zval *res; int ret; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &res) == FAILURE) { RETURN_FALSE; } - PHP_STREAM_TO_ZVAL(stream, &arg1); + PHP_STREAM_TO_ZVAL(stream, &res); ret = php_stream_flush(stream); if (ret) { @@ -1240,14 +1236,14 @@ PHPAPI PHP_FUNCTION(fflush) Rewind the position of a file pointer */ PHPAPI PHP_FUNCTION(rewind) { - zval *arg1; + zval *res; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &res) == FAILURE) { RETURN_FALSE; } - PHP_STREAM_TO_ZVAL(stream, &arg1); + PHP_STREAM_TO_ZVAL(stream, &res); if (-1 == php_stream_rewind(stream)) { RETURN_FALSE; @@ -1260,15 +1256,15 @@ PHPAPI PHP_FUNCTION(rewind) Get file pointer's read/write position */ PHPAPI PHP_FUNCTION(ftell) { - zval *arg1; + zval *res; long ret; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &res) == FAILURE) { RETURN_FALSE; } - PHP_STREAM_TO_ZVAL(stream, &arg1); + PHP_STREAM_TO_ZVAL(stream, &res); ret = php_stream_tell(stream); if (ret == -1) { @@ -1282,17 +1278,17 @@ PHPAPI PHP_FUNCTION(ftell) Seek on a file pointer */ PHPAPI PHP_FUNCTION(fseek) { - zval *arg1; - long arg2, whence = SEEK_SET; + zval *res; + long offset, whence = SEEK_SET; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|l", &arg1, &arg2, &whence) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|l", &res, &offset, &whence) == FAILURE) { RETURN_FALSE; } - PHP_STREAM_TO_ZVAL(stream, &arg1); + PHP_STREAM_TO_ZVAL(stream, &res); - RETURN_LONG(php_stream_seek(stream, arg2, whence)); + RETURN_LONG(php_stream_seek(stream, offset, whence)); } /* }}} */ @@ -1394,7 +1390,7 @@ PHP_FUNCTION(readfile) Return or change the umask */ PHP_FUNCTION(umask) { - long arg1 = 0; + long mask = 0; int oldumask; oldumask = umask(077); @@ -1403,14 +1399,14 @@ PHP_FUNCTION(umask) BG(umask) = oldumask; } - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &arg1) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &mask) == FAILURE) { RETURN_FALSE; } if (ZEND_NUM_ARGS() == 0) { umask(oldumask); } else { - umask(arg1); + umask(mask); } RETURN_LONG(oldumask); @@ -1421,15 +1417,15 @@ PHP_FUNCTION(umask) Output all remaining data from a file pointer */ PHPAPI PHP_FUNCTION(fpassthru) { - zval *arg1; + zval *res; int size; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &res) == FAILURE) { RETURN_FALSE; } - PHP_STREAM_TO_ZVAL(stream, &arg1); + PHP_STREAM_TO_ZVAL(stream, &res); size = php_stream_passthru(stream); RETURN_LONG(size); @@ -1751,15 +1747,15 @@ safe_to_copy: Binary-safe file read */ PHPAPI PHP_FUNCTION(fread) { - zval *arg1; + zval *res; long len; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &arg1, &len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &res, &len) == FAILURE) { RETURN_FALSE; } - PHP_STREAM_TO_ZVAL(stream, &arg1); + PHP_STREAM_TO_ZVAL(stream, &res); if (len <= 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length parameter must be greater than 0"); From 90b4ec51adad6791b508d65b81e45233d687c23f Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 4 Nov 2014 18:23:20 +0100 Subject: [PATCH 242/398] Fix bad merge --- ext/standard/file.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ext/standard/file.c b/ext/standard/file.c index 97ffe694535..4804e49338b 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -344,7 +344,7 @@ PHP_FUNCTION(flock) php_stream *stream; zend_long operation = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|z", &res, &operation, &wouldblock) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|z/", &res, &operation, &wouldblock) == FAILURE) { return; } @@ -1207,8 +1207,10 @@ PHPAPI PHP_FUNCTION(fwrite) if (ZEND_NUM_ARGS() == 2) { num_bytes = inputlen; + } else if (maxlen <= 0) { + num_bytes = 0; } else { - num_bytes = MAX(0, MIN((size_t) maxlen, inputlen)); + num_bytes = MIN((size_t) maxlen, inputlen); } if (!num_bytes) { From 53266476e63608e4ce03c6d584864755806b28fe Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 5 Nov 2014 15:42:45 +0100 Subject: [PATCH 243/398] fix dir separator in test --- ext/curl/tests/bug68089.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/curl/tests/bug68089.phpt b/ext/curl/tests/bug68089.phpt index 3bd5889709b..d65441b2ccb 100644 --- a/ext/curl/tests/bug68089.phpt +++ b/ext/curl/tests/bug68089.phpt @@ -13,6 +13,6 @@ var_dump(curl_setopt($ch, CURLOPT_URL, $url)); ?> Done --EXPECTF-- -Warning: curl_setopt(): Curl option contains invalid characters (\0) in %s/bug68089.php on line 4 +Warning: curl_setopt(): Curl option contains invalid characters (\0) in %s%ebug68089.php on line 4 bool(false) Done From 6b0eca060f4e4885b4484ef9b16abf984da245d4 Mon Sep 17 00:00:00 2001 From: Chris Tankersley Date: Thu, 2 Oct 2014 11:05:31 -0700 Subject: [PATCH 244/398] Various fixes to allow support for new VS2014 features - Added some typeof checks to handle JS errors introduced in VS2014 - Added VS2014 to the list of compilers - Changed to use stdint.h if we are using VS2014 or higher - Skip defining timespec if we're using VS2014 or higher - Moved u_char typedef out to always be defined regardless of VS version --- Zend/zend_config.w32.h | 2 ++ win32/build/confutils.js | 18 ++++++++++++------ win32/php_stdint.h | 15 ++++++++++++--- win32/time.h | 2 ++ 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/Zend/zend_config.w32.h b/Zend/zend_config.w32.h index 6ea67602b49..5353064be17 100644 --- a/Zend/zend_config.w32.h +++ b/Zend/zend_config.w32.h @@ -47,7 +47,9 @@ typedef unsigned int uint; #define HAVE_CLASS_ISTDIOSTREAM #define istdiostream stdiostream +#if _MSC_VER < 1900 #define snprintf _snprintf +#endif #if _MSC_VER < 1500 #define vsnprintf _vsnprintf #endif diff --git a/win32/build/confutils.js b/win32/build/confutils.js index ae668fee260..c54ff68f841 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -49,6 +49,7 @@ VC_VERSIONS[1500] = 'MSVC9 (Visual C++ 2008)'; VC_VERSIONS[1600] = 'MSVC10 (Visual C++ 2010)'; VC_VERSIONS[1700] = 'MSVC11 (Visual C++ 2012)'; VC_VERSIONS[1800] = 'MSVC12 (Visual C++ 2013)'; +VC_VERSIONS[1900] = 'MSVC14 (Visual C++ 2014)'; var VC_VERSIONS_SHORT = new Array(); VC_VERSIONS_SHORT[1200] = 'VC6'; @@ -59,6 +60,7 @@ VC_VERSIONS_SHORT[1500] = 'VC9'; VC_VERSIONS_SHORT[1600] = 'VC10'; VC_VERSIONS_SHORT[1700] = 'VC11'; VC_VERSIONS_SHORT[1800] = 'VC12'; +VC_VERSIONS_SHORT[1900] = 'VC14'; if (PROGRAM_FILES == null) { PROGRAM_FILES = "C:\\Program Files"; @@ -1531,9 +1533,11 @@ function output_as_table(header, ar_out) tmin = 0; tmax = 0; for (k = 0; k < ar_out.length; k++) { - var t = ar_out[k][j].length; - if (t > tmax) tmax = t; - else if (t < tmin) tmin = t; + if(typeof ar_out[k][j] != 'undefined') { + var t = ar_out[k][j].length; + if (t > tmax) tmax = t; + else if (t < tmin) tmin = t; + } } if (tmax > header[j].length) { max[j] = tmax; @@ -1574,8 +1578,10 @@ function output_as_table(header, ar_out) line = ar_out[i]; for (j=0; j < l; j++) { out += " " + line[j]; - for (var k = 0; k < (max[j] - line[j].length); k++){ - out += " "; + if(typeof line[j] != 'undefined') { + for (var k = 0; k < (max[j] - line[j].length); k++){ + out += " "; + } } out += " |"; } @@ -2052,7 +2058,7 @@ function AC_DEFINE(name, value, comment, quote) } if (quote && typeof(value) == "string") { value = '"' + value.replace(new RegExp('(["\\\\])', "g"), '\\$1') + '"'; - } else if (value.length == 0) { + } else if (typeof(value) != "undefined" && value.length == 0) { value = '""'; } var item = new Array(value, comment); diff --git a/win32/php_stdint.h b/win32/php_stdint.h index 71aec2a3580..d5b90ebe265 100644 --- a/win32/php_stdint.h +++ b/win32/php_stdint.h @@ -33,6 +33,10 @@ #error "Use this header only with Microsoft Visual C++ compilers!" #endif // _MSC_VER ] +// Starting with VS2014, many of the C11 features are now included, so we only +// need many of these typedefs and defines for older VS suites +#if _MSC_VER < 1900 + #ifndef _MSC_STDINT_H_ // [ #define _MSC_STDINT_H_ @@ -85,9 +89,6 @@ typedef __int64 int64_t; #ifndef uint8_t typedef unsigned __int8 uint8_t; #endif -#ifndef u_char -typedef unsigned __int8 u_char; -#endif typedef unsigned __int16 uint16_t; #ifndef uint32_t typedef unsigned __int32 uint32_t; @@ -254,3 +255,11 @@ static __inline int64_t llabs(int64_t i) #endif // _MSC_STDINT_H_ ] + +#else +#include +#endif + +#ifndef u_char +typedef unsigned __int8 u_char; +#endif diff --git a/win32/time.h b/win32/time.h index d5d86eb1ed7..c6679b6d9a4 100644 --- a/win32/time.h +++ b/win32/time.h @@ -29,12 +29,14 @@ struct itimerval { }; #ifndef timespec +#if _MSC_VER < 1900 struct timespec { time_t tv_sec; /* seconds */ long tv_nsec; /* nanoseconds */ }; #endif +#endif #define ITIMER_REAL 0 /*generates sigalrm */ #define ITIMER_VIRTUAL 1 /*generates sigvtalrm */ From 4dd3fbfcd28f8a3826361c5c4b7aa4c4da592b22 Mon Sep 17 00:00:00 2001 From: Yasuo Ohgaki Date: Thu, 6 Nov 2014 13:06:29 +0900 Subject: [PATCH 245/398] Fixed bug #68331 - This was partial patch for https://wiki.php.net/rfc/session-lock-ini --- ext/session/session.c | 17 +---------------- ...on_set_save_handler_write_short_circuit.phpt | 1 + 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/ext/session/session.c b/ext/session/session.c index d440e6fdd90..edc8f15d5bd 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -514,17 +514,8 @@ static void php_session_initialize(TSRMLS_D) /* {{{ */ PS(session_status) = php_session_active; } if (val) { - PHP_MD5_CTX context; - - /* Store read data's MD5 hash */ - PHP_MD5Init(&context); - PHP_MD5Update(&context, val, vallen); - PHP_MD5Final(PS(session_data_hash), &context); - php_session_decode(val, vallen TSRMLS_CC); str_efree(val); - } else { - memset(PS(session_data_hash),'\0', 16); } if (!PS(use_cookies) && PS(send_cookie)) { @@ -554,12 +545,7 @@ static void php_session_save_current_state(TSRMLS_D) /* {{{ */ PHP_MD5Init(&context); PHP_MD5Update(&context, val, vallen); PHP_MD5Final(digest, &context); - /* Write only when save is required */ - if (memcmp(digest, PS(session_data_hash), 16)) { - ret = PS(mod)->s_write(&PS(mod_data), PS(id), val, vallen TSRMLS_CC); - } else { - ret = SUCCESS; - } + ret = PS(mod)->s_write(&PS(mod_data), PS(id), val, vallen TSRMLS_CC); efree(val); } else { ret = PS(mod)->s_write(&PS(mod_data), PS(id), "", 0 TSRMLS_CC); @@ -1994,7 +1980,6 @@ static PHP_FUNCTION(session_regenerate_id) RETURN_FALSE; } efree(PS(id)); - memset(PS(session_data_hash),'\0', 16); } PS(id) = PS(mod)->s_create_sid(&PS(mod_data), NULL TSRMLS_CC); diff --git a/ext/session/tests/session_set_save_handler_write_short_circuit.phpt b/ext/session/tests/session_set_save_handler_write_short_circuit.phpt index 02ca182ec6b..08da29a8fde 100644 --- a/ext/session/tests/session_set_save_handler_write_short_circuit.phpt +++ b/ext/session/tests/session_set_save_handler_write_short_circuit.phpt @@ -5,6 +5,7 @@ session.save_path= session.name=PHPSESSID --SKIPIF-- +skip - Waiting RFC patch merge --FILE-- Date: Thu, 6 Nov 2014 13:54:16 +0900 Subject: [PATCH 246/398] Update NEWS --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 0d856202596..b02976cb0f1 100644 --- a/NEWS +++ b/NEWS @@ -63,6 +63,10 @@ PHP NEWS . Fixed bug #68087 (ODBC not correctly reading DATE column when preceded by a VARCHAR column) (Keyur Govande) +- Session: + . Fixed bug #68331 (Session custom storage callable functions not being called) + (Yasuo Ohgaki) + - SPL: . Fixed bug #68128 (Regression in RecursiveRegexIterator) (Tjerk) From 75041379a6e73b22c094c3c9c7878a1c4e439725 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 6 Nov 2014 14:50:03 +0300 Subject: [PATCH 247/398] Improved object property access. --- Zend/zend_API.c | 23 +- Zend/zend_builtin_functions.c | 10 +- Zend/zend_compile.h | 12 +- Zend/zend_execute.c | 22 +- Zend/zend_inheritance.c | 17 +- Zend/zend_object_handlers.c | 78 +- Zend/zend_vm_def.h | 70 +- Zend/zend_vm_execute.h | 1352 ++++++++++++++++++++++++++----- ext/reflection/php_reflection.c | 2 +- 9 files changed, 1290 insertions(+), 296 deletions(-) diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 3643bfc8e2e..e22b5574512 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -1207,7 +1207,7 @@ ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC for (i = 0; i < class_type->default_properties_count; i++) { if (Z_TYPE(class_type->default_properties_table[i]) != IS_UNDEF) { - zval_update_class_constant(&class_type->default_properties_table[i], 0, i TSRMLS_CC); + zval_update_class_constant(&class_type->default_properties_table[i], 0, OBJ_PROP_TO_OFFSET(i) TSRMLS_CC); } } @@ -1251,8 +1251,9 @@ ZEND_API void object_properties_init_ex(zend_object *object, HashTable *properti if (property_info != ZEND_WRONG_PROPERTY_INFO && property_info && (property_info->flags & ZEND_ACC_STATIC) == 0) { - ZVAL_COPY_VALUE(&object->properties_table[property_info->offset], prop); - ZVAL_INDIRECT(prop, &object->properties_table[property_info->offset]); + zval *slot = OBJ_PROP(object, property_info->offset); + ZVAL_COPY_VALUE(slot, prop); + ZVAL_INDIRECT(prop, slot); } } ZEND_HASH_FOREACH_END(); } @@ -1270,11 +1271,12 @@ ZEND_API void object_properties_load(zend_object *object, HashTable *properties if (property_info != ZEND_WRONG_PROPERTY_INFO && property_info && (property_info->flags & ZEND_ACC_STATIC) == 0) { - zval_ptr_dtor(&object->properties_table[property_info->offset]); - ZVAL_COPY_VALUE(&object->properties_table[property_info->offset], prop); - zval_add_ref(&object->properties_table[property_info->offset]); + zval *slot = OBJ_PROP(object, property_info->offset); + zval_ptr_dtor(slot); + ZVAL_COPY_VALUE(slot, prop); + zval_add_ref(slot); if (object->properties) { - ZVAL_INDIRECT(&tmp, &object->properties_table[property_info->offset]); + ZVAL_INDIRECT(&tmp, slot); zend_hash_update(object->properties, key, &tmp); } } else { @@ -3618,13 +3620,14 @@ ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, z if ((property_info_ptr = zend_hash_find_ptr(&ce->properties_info, name)) != NULL && (property_info_ptr->flags & ZEND_ACC_STATIC) == 0) { property_info->offset = property_info_ptr->offset; - zval_ptr_dtor(&ce->default_properties_table[property_info->offset]); + zval_ptr_dtor(&ce->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)]); zend_hash_del(&ce->properties_info, name); } else { - property_info->offset = ce->default_properties_count++; + property_info->offset = OBJ_PROP_TO_OFFSET(ce->default_properties_count); + ce->default_properties_count++; ce->default_properties_table = perealloc(ce->default_properties_table, sizeof(zval) * ce->default_properties_count, ce->type == ZEND_INTERNAL_CLASS); } - ZVAL_COPY_VALUE(&ce->default_properties_table[property_info->offset], property); + ZVAL_COPY_VALUE(&ce->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)], property); } if (ce->type & ZEND_INTERNAL_CLASS) { switch(Z_TYPE_P(property)) { diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index ddec6a7ddbb..ecb8f4e0d1d 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -954,12 +954,10 @@ static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value continue; } prop = NULL; - if (prop_info->offset >= 0) { - if (statics && (prop_info->flags & ZEND_ACC_STATIC) != 0) { - prop = &ce->default_static_members_table[prop_info->offset]; - } else if (!statics && (prop_info->flags & ZEND_ACC_STATIC) == 0) { - prop = &ce->default_properties_table[prop_info->offset]; - } + if (statics && (prop_info->flags & ZEND_ACC_STATIC) != 0) { + prop = &ce->default_static_members_table[prop_info->offset]; + } else if (!statics && (prop_info->flags & ZEND_ACC_STATIC) == 0) { + prop = &ce->default_properties_table[OBJ_PROP_TO_NUM(prop_info->offset)]; } if (!prop || Z_TYPE_P(prop) == IS_UNDEF) { continue; diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index bc9b88227f6..f9a66a37d80 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -227,13 +227,23 @@ typedef struct _zend_try_catch_element { char *zend_visibility_string(uint32_t fn_flags); typedef struct _zend_property_info { + uint32_t offset; /* property offset for object properties or + property index for static properties */ uint32_t flags; - int offset; zend_string *name; zend_string *doc_comment; zend_class_entry *ce; } zend_property_info; +#define OBJ_PROP(obj, offset) \ + ((zval*)((char*)(obj) + offset)) +#define OBJ_PROP_NUM(obj, num) \ + (&(obj)->properties_table[(num)]) +#define OBJ_PROP_TO_OFFSET(num) \ + ((uint32_t)(zend_uintptr_t)OBJ_PROP_NUM(((zend_object*)NULL), num)) +#define OBJ_PROP_TO_NUM(offset) \ + ((offset - OBJ_PROP_TO_OFFSET(0)) / sizeof(zval)) + typedef struct _zend_arg_info { const char *name; // TODO: convert into zend_string ??? uint32_t name_len; diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 61a605971e8..1551789c481 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1292,7 +1292,7 @@ ZEND_API void zend_fetch_dimension_by_zval(zval *result, zval *container, zval * zend_fetch_dimension_address_read_R(result, container, dim, IS_TMP_VAR TSRMLS_CC); } -static zend_always_inline void zend_fetch_property_address(zval *result, zval *container, uint32_t container_op_type, zval *prop_ptr, void **cache_slot, int type TSRMLS_DC) +static zend_always_inline void zend_fetch_property_address(zval *result, zval *container, uint32_t container_op_type, zval *prop_ptr, uint32_t prop_op_type, void **cache_slot, int type TSRMLS_DC) { if (container_op_type != IS_UNUSED) { ZVAL_DEREF(container); @@ -1316,6 +1316,26 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c } } } + if (prop_op_type == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR_EX(cache_slot))) { + zend_property_info *prop_info = CACHED_PTR_EX(cache_slot + 1); + zend_object *zobj = Z_OBJ_P(container); + zval *retval; + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_INDIRECT(result, retval); + return; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(prop_ptr)); + if (EXPECTED(retval)) { + ZVAL_INDIRECT(result, retval); + return; + } + } + } if (EXPECTED(Z_OBJ_HT_P(container)->get_property_ptr_ptr)) { zval *ptr = Z_OBJ_HT_P(container)->get_property_ptr_ptr(container, prop_ptr, type, cache_slot TSRMLS_CC); if (NULL == ptr) { diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index c6f8c6ae158..7d9d1aade89 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -602,9 +602,12 @@ static zend_bool do_inherit_property_access_check(HashTable *target_ht, zend_pro if ((child_info->flags & ZEND_ACC_PPP_MASK) > (parent_info->flags & ZEND_ACC_PPP_MASK)) { zend_error_noreturn(E_COMPILE_ERROR, "Access level to %s::$%s must be %s (as in class %s)%s", ce->name->val, key->val, zend_visibility_string(parent_info->flags), parent_ce->name->val, (parent_info->flags&ZEND_ACC_PUBLIC) ? "" : " or weaker"); } else if ((child_info->flags & ZEND_ACC_STATIC) == 0) { - zval_ptr_dtor(&(ce->default_properties_table[parent_info->offset])); - ce->default_properties_table[parent_info->offset] = ce->default_properties_table[child_info->offset]; - ZVAL_UNDEF(&ce->default_properties_table[child_info->offset]); + int parent_num = OBJ_PROP_TO_NUM(parent_info->offset); + int child_num = OBJ_PROP_TO_NUM(child_info->offset); + + zval_ptr_dtor(&(ce->default_properties_table[parent_num])); + ce->default_properties_table[parent_num] = ce->default_properties_table[child_num]; + ZVAL_UNDEF(&ce->default_properties_table[child_num]); child_info->offset = parent_info->offset; } return 0; /* Don't copy from parent */ @@ -797,7 +800,7 @@ ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent if (property_info->flags & ZEND_ACC_STATIC) { property_info->offset += parent_ce->default_static_members_count; } else { - property_info->offset += parent_ce->default_properties_count; + property_info->offset += parent_ce->default_properties_count * sizeof(zval); } } } ZEND_HASH_FOREACH_END(); @@ -1421,8 +1424,8 @@ static void zend_do_traits_property_binding(zend_class_entry *ce TSRMLS_DC) /* { || (Z_LVAL(compare_result) != 0); } else { not_compatible = (FAILURE == compare_function(&compare_result, - &ce->default_properties_table[coliding_prop->offset], - &ce->traits[i]->default_properties_table[property_info->offset] TSRMLS_CC)) + &ce->default_properties_table[OBJ_PROP_TO_NUM(coliding_prop->offset)], + &ce->traits[i]->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)] TSRMLS_CC)) || (Z_LVAL(compare_result) != 0); } } else { @@ -1454,7 +1457,7 @@ static void zend_do_traits_property_binding(zend_class_entry *ce TSRMLS_DC) /* { if (flags & ZEND_ACC_STATIC) { prop_value = &ce->traits[i]->default_static_members_table[property_info->offset]; } else { - prop_value = &ce->traits[i]->default_properties_table[property_info->offset]; + prop_value = &ce->traits[i]->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)]; } if (Z_REFCOUNTED_P(prop_value)) Z_ADDREF_P(prop_value); diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 6b4e8f1a973..12a9562c0a1 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -80,11 +80,10 @@ ZEND_API void rebuild_object_properties(zend_object *zobj) /* {{{ */ ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop_info) { if (/*prop_info->ce == ce &&*/ (prop_info->flags & ZEND_ACC_STATIC) == 0 && - prop_info->offset >= 0 && - Z_TYPE(zobj->properties_table[prop_info->offset]) != IS_UNDEF) { + Z_TYPE_P(OBJ_PROP(zobj, prop_info->offset)) != IS_UNDEF) { zval zv; - ZVAL_INDIRECT(&zv, &zobj->properties_table[prop_info->offset]); + ZVAL_INDIRECT(&zv, OBJ_PROP(zobj, prop_info->offset)); zend_hash_add_new(zobj->properties, prop_info->name, &zv); } } ZEND_HASH_FOREACH_END(); @@ -94,11 +93,10 @@ ZEND_API void rebuild_object_properties(zend_object *zobj) /* {{{ */ if (prop_info->ce == ce && (prop_info->flags & ZEND_ACC_STATIC) == 0 && (prop_info->flags & ZEND_ACC_PRIVATE) != 0 && - prop_info->offset >= 0 && - Z_TYPE(zobj->properties_table[prop_info->offset]) != IS_UNDEF) { + Z_TYPE_P(OBJ_PROP(zobj, prop_info->offset)) != IS_UNDEF) { zval zv; - ZVAL_INDIRECT(&zv, &zobj->properties_table[prop_info->offset]); + ZVAL_INDIRECT(&zv, OBJ_PROP(zobj, prop_info->offset)); zend_hash_add(zobj->properties, prop_info->name, &zv); } } ZEND_HASH_FOREACH_END(); @@ -288,7 +286,7 @@ static zend_always_inline zend_bool is_derived_class(zend_class_entry *child_cla } /* }}} */ -static zend_always_inline zend_property_info *zend_get_property_info_quick(zend_class_entry *ce, zend_string *member, int silent, void **cache_slot TSRMLS_DC) /* {{{ */ +static zend_always_inline zend_property_info *zend_get_property_info_quick(zend_class_entry *ce, zend_string *member, int silent, int allow_static, void **cache_slot TSRMLS_DC) /* {{{ */ { zval *zv; zend_property_info *property_info = NULL; @@ -324,8 +322,13 @@ static zend_always_inline zend_property_info *zend_get_property_info_quick(zend_ if (EXPECTED(zend_verify_property_access(property_info, ce TSRMLS_CC) != 0)) { if (UNEXPECTED(!(flags & ZEND_ACC_CHANGED)) || UNEXPECTED((flags & ZEND_ACC_PRIVATE))) { - if (UNEXPECTED((flags & ZEND_ACC_STATIC) != 0) && !silent) { - zend_error(E_STRICT, "Accessing static property %s::$%s as non static", ce->name->val, member->val); + if (UNEXPECTED((flags & ZEND_ACC_STATIC) != 0)) { + if (!silent) { + zend_error(E_STRICT, "Accessing static property %s::$%s as non static", ce->name->val, member->val); + } + if (!allow_static) { + return NULL; + } } goto exit; } @@ -342,7 +345,9 @@ static zend_always_inline zend_property_info *zend_get_property_info_quick(zend_ && (zv = zend_hash_find(&EG(scope)->properties_info, member)) != NULL && ((zend_property_info*)Z_PTR_P(zv))->flags & ZEND_ACC_PRIVATE) { property_info = (zend_property_info*)Z_PTR_P(zv); - goto exit; + if (!allow_static && UNEXPECTED((property_info->flags & ZEND_ACC_STATIC) != 0)) { + return NULL; + } } else if (UNEXPECTED(property_info == NULL)) { exit_dynamic: if (cache_slot) { @@ -354,9 +359,6 @@ exit_dynamic: if (!silent) { zend_error_noreturn(E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(flags), ce->name->val, member->val); } - if (cache_slot) { - CACHE_POLYMORPHIC_PTR_EX(cache_slot, ce, ZEND_WRONG_PROPERTY_INFO); - } return ZEND_WRONG_PROPERTY_INFO; } @@ -370,7 +372,7 @@ exit: ZEND_API zend_property_info *zend_get_property_info(zend_class_entry *ce, zend_string *member, int silent TSRMLS_DC) /* {{{ */ { - return zend_get_property_info_quick(ce, member, silent, NULL TSRMLS_CC); + return zend_get_property_info_quick(ce, member, silent, 1, NULL TSRMLS_CC); } /* }}} */ @@ -388,7 +390,7 @@ ZEND_API int zend_check_property_access(zend_object *zobj, zend_string *prop_inf } else { member = zend_string_copy(prop_info_name); } - property_info = zend_get_property_info_quick(zobj->ce, member, 1, NULL TSRMLS_CC); + property_info = zend_get_property_info_quick(zobj->ce, member, 1, 1, NULL TSRMLS_CC); zend_string_release(member); if (property_info == NULL) { /* undefined public property */ @@ -451,13 +453,11 @@ zval *zend_std_read_property(zval *object, zval *member, int type, void **cache_ #endif /* make zend_get_property_info silent if we have getter - we may want to use it */ - property_info = zend_get_property_info_quick(zobj->ce, Z_STR_P(member), (type == BP_VAR_IS) || (zobj->ce->__get != NULL), cache_slot TSRMLS_CC); + property_info = zend_get_property_info_quick(zobj->ce, Z_STR_P(member), (type == BP_VAR_IS) || (zobj->ce->__get != NULL), 0, cache_slot TSRMLS_CC); if (EXPECTED(property_info != ZEND_WRONG_PROPERTY_INFO)) { - if (EXPECTED(property_info != NULL) && - EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0)) { - - retval = &zobj->properties_table[property_info->offset]; + if (EXPECTED(property_info != NULL)) { + retval = OBJ_PROP(zobj, property_info->offset); if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { goto exit; } @@ -534,13 +534,11 @@ ZEND_API void zend_std_write_property(zval *object, zval *member, zval *value, v cache_slot = NULL; } - property_info = zend_get_property_info_quick(zobj->ce, Z_STR_P(member), (zobj->ce->__set != NULL), cache_slot TSRMLS_CC); + property_info = zend_get_property_info_quick(zobj->ce, Z_STR_P(member), (zobj->ce->__set != NULL), 0, cache_slot TSRMLS_CC); if (EXPECTED(property_info != ZEND_WRONG_PROPERTY_INFO)) { - if (EXPECTED(property_info != NULL) && - EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0)) { - - variable_ptr = &zobj->properties_table[property_info->offset]; + if (EXPECTED(property_info != NULL)) { + variable_ptr = OBJ_PROP(zobj, property_info->offset); if (Z_TYPE_P(variable_ptr) != IS_UNDEF) { goto found; } @@ -638,7 +636,7 @@ write_std_property: if (EXPECTED(property_info != NULL) && EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0)) { - ZVAL_COPY_VALUE(&zobj->properties_table[property_info->offset], value); + ZVAL_COPY_VALUE(OBJ_PROP(zobj, property_info->offset), value); } else { if (!zobj->properties) { rebuild_object_properties(zobj); @@ -754,13 +752,11 @@ static zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int type, fprintf(stderr, "Ptr object #%d property: %s\n", Z_OBJ_HANDLE_P(object), name->val); #endif - property_info = zend_get_property_info_quick(zobj->ce, name, (zobj->ce->__get != NULL), cache_slot TSRMLS_CC); + property_info = zend_get_property_info_quick(zobj->ce, name, (zobj->ce->__get != NULL), 0, cache_slot TSRMLS_CC); if (EXPECTED(property_info != ZEND_WRONG_PROPERTY_INFO)) { - if (EXPECTED(property_info != NULL) && - EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0)) { - - retval = &zobj->properties_table[property_info->offset]; + if (EXPECTED(property_info != NULL)) { + retval = OBJ_PROP(zobj, property_info->offset); if (UNEXPECTED(Z_TYPE_P(retval) == IS_UNDEF)) { if (EXPECTED(!zobj->ce->__get) || UNEXPECTED((*zend_get_property_guard(zobj, name)) & IN_GET)) { @@ -816,15 +812,15 @@ static void zend_std_unset_property(zval *object, zval *member, void **cache_slo cache_slot = NULL; } - property_info = zend_get_property_info_quick(zobj->ce, Z_STR_P(member), (zobj->ce->__unset != NULL), cache_slot TSRMLS_CC); + property_info = zend_get_property_info_quick(zobj->ce, Z_STR_P(member), (zobj->ce->__unset != NULL), 0, cache_slot TSRMLS_CC); if (EXPECTED(property_info != ZEND_WRONG_PROPERTY_INFO)) { - if (EXPECTED(property_info != NULL) && - EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0)) { + if (EXPECTED(property_info != NULL)) { + zval *slot = OBJ_PROP(zobj, property_info->offset); - if (Z_TYPE(zobj->properties_table[property_info->offset]) != IS_UNDEF) { - zval_ptr_dtor(&zobj->properties_table[property_info->offset]); - ZVAL_UNDEF(&zobj->properties_table[property_info->offset]); + if (Z_TYPE_P(slot) != IS_UNDEF) { + zval_ptr_dtor(slot); + ZVAL_UNDEF(slot); goto exit; } } else if (EXPECTED(zobj->properties != NULL) && @@ -1413,13 +1409,11 @@ static int zend_std_has_property(zval *object, zval *member, int has_set_exists, cache_slot = NULL; } - property_info = zend_get_property_info_quick(zobj->ce, Z_STR_P(member), 1, cache_slot TSRMLS_CC); + property_info = zend_get_property_info_quick(zobj->ce, Z_STR_P(member), 1, 0, cache_slot TSRMLS_CC); if (EXPECTED(property_info != ZEND_WRONG_PROPERTY_INFO)) { - if (EXPECTED(property_info != NULL) && - EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0)) { - - value = &zobj->properties_table[property_info->offset]; + if (EXPECTED(property_info != NULL)) { + value = OBJ_PROP(zobj, property_info->offset); if (Z_TYPE_P(value) != IS_UNDEF) { goto found; } diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 60983e516f9..b6d2b82cdea 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -1324,11 +1324,33 @@ ZEND_VM_HANDLER(82, ZEND_FETCH_OBJ_R, CONST|TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV) zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (OP2_TYPE == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } FREE_OP2(); @@ -1352,7 +1374,7 @@ ZEND_VM_HANDLER(85, ZEND_FETCH_OBJ_W, VAR|UNUSED|CV, CONST|TMP|VAR|CV) zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, OP2_TYPE, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); FREE_OP2(); if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -1376,7 +1398,7 @@ ZEND_VM_HANDLER(88, ZEND_FETCH_OBJ_RW, VAR|UNUSED|CV, CONST|TMP|VAR|CV) if (OP1_TYPE == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, OP2_TYPE, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); FREE_OP2(); if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -1393,6 +1415,8 @@ ZEND_VM_HANDLER(91, ZEND_FETCH_OBJ_IS, CONST|TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV zval *container; zend_free_op free_op2; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = GET_OP1_OBJ_ZVAL_PTR_DEREF(BP_VAR_IS); @@ -1405,11 +1429,33 @@ ZEND_VM_HANDLER(91, ZEND_FETCH_OBJ_IS, CONST|TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (OP2_TYPE == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } FREE_OP2(); @@ -1438,7 +1484,7 @@ ZEND_VM_HANDLER(94, ZEND_FETCH_OBJ_FUNC_ARG, CONST|TMP|VAR|UNUSED|CV, CONST|TMP| if (OP1_TYPE == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, OP2_TYPE, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); FREE_OP2(); if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -1464,7 +1510,7 @@ ZEND_VM_HANDLER(97, ZEND_FETCH_OBJ_UNSET, VAR|UNUSED|CV, CONST|TMP|VAR|CV) if (OP1_TYPE == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, OP2_TYPE, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); FREE_OP2(); if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index c4d4b135d92..8257789cd20 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -3984,11 +3984,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_ zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CONST == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } @@ -4003,6 +4025,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE zval *container; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = opline->op1.zv; @@ -4015,11 +4039,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CONST == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } @@ -4047,7 +4093,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CONST_CONST_HANDLER(ZEND_ if (IS_CONST == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CONST, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CONST, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -5332,11 +5378,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HA zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_TMP_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -5352,6 +5420,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_H zval *container; zend_free_op free_op2; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = opline->op1.zv; @@ -5364,11 +5434,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_H zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_TMP_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -5397,7 +5489,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CONST_TMP_HANDLER(ZEND_OP if (IS_CONST == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CONST, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CONST, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -6525,11 +6617,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HA zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -6545,6 +6659,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_H zval *container; zend_free_op free_op2; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = opline->op1.zv; @@ -6557,11 +6673,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_H zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -6590,7 +6728,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CONST_VAR_HANDLER(ZEND_OP if (IS_CONST == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CONST, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CONST, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -8443,11 +8581,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HAN zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CV == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } @@ -8462,6 +8622,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HA zval *container; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = opline->op1.zv; @@ -8474,11 +8636,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HA zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CV == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } @@ -8506,7 +8690,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CONST_CV_HANDLER(ZEND_OPC if (IS_CONST == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CONST, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CONST, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -10770,11 +10954,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HA zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CONST == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op1.var); @@ -10789,6 +10995,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_H zval *container; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -10801,11 +11009,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_H zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CONST == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op1.var); @@ -10833,7 +11063,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_TMP_CONST_HANDLER(ZEND_OP if (IS_TMP_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_TMP_VAR, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_TMP_VAR, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -11994,11 +12224,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HAND zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_TMP_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -12014,6 +12266,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HAN zval *container; zend_free_op free_op2; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -12026,11 +12280,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HAN zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_TMP_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -12059,7 +12335,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_TMP_TMP_HANDLER(ZEND_OPCO if (IS_TMP_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_TMP_VAR, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_TMP_VAR, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -13160,11 +13436,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HAND zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -13180,6 +13478,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HAN zval *container; zend_free_op free_op2; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -13192,11 +13492,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HAN zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -13225,7 +13547,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_TMP_VAR_HANDLER(ZEND_OPCO if (IS_TMP_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_TMP_VAR, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_TMP_VAR, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -14943,11 +15265,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDL zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CV == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op1.var); @@ -14962,6 +15306,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HAND zval *container; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -14974,11 +15320,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HAND zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CV == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op1.var); @@ -15006,7 +15374,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_TMP_CV_HANDLER(ZEND_OPCOD if (IS_TMP_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_TMP_VAR, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_TMP_VAR, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -18392,11 +18760,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HA zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CONST == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op1.var); @@ -18419,7 +18809,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HA zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -18443,7 +18833,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_H if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -18460,6 +18850,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_H zval *container; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -18472,11 +18864,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_H zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CONST == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op1.var); @@ -18504,7 +18918,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_VAR_CONST_HANDLER(ZEND_OP if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -18530,7 +18944,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_VAR_CONST_HANDLER(ZEND_OPCOD if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -20684,11 +21098,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAND zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_TMP_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -20712,7 +21148,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAND zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -20736,7 +21172,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAN if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -20753,6 +21189,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAN zval *container; zend_free_op free_op2; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -20765,11 +21203,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAN zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_TMP_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -20798,7 +21258,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_VAR_TMP_HANDLER(ZEND_OPCO if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -20824,7 +21284,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_ if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -22814,11 +23274,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAND zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -22842,7 +23324,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAND zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -22866,7 +23348,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAN if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -22883,6 +23365,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAN zval *container; zend_free_op free_op2; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -22895,11 +23379,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAN zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -22928,7 +23434,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_VAR_VAR_HANDLER(ZEND_OPCO if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -22954,7 +23460,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_ if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -26204,11 +26710,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDL zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CV == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op1.var); @@ -26231,7 +26759,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDL zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -26255,7 +26783,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HAND if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -26272,6 +26800,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HAND zval *container; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -26284,11 +26814,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HAND zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CV == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op1.var); @@ -26316,7 +26868,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_VAR_CV_HANDLER(ZEND_OPCOD if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -26342,7 +26894,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_H if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -27908,11 +28460,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CONST == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } @@ -27935,7 +28509,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -27959,7 +28533,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCOD if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -27976,6 +28550,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCOD zval *container; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); @@ -27988,11 +28564,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCOD zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CONST == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } @@ -28020,7 +28618,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_UNUSED_CONST_HANDLER(ZEND if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -28046,7 +28644,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_UNUSED_CONST_HANDLER(ZEND_OP if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -29270,11 +29868,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_H zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_TMP_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -29298,7 +29918,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_H zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -29322,7 +29942,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_ if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -29339,6 +29959,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_ zval *container; zend_free_op free_op2; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); @@ -29351,11 +29973,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_ zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_TMP_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -29384,7 +30028,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_UNUSED_TMP_HANDLER(ZEND_O if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -29410,7 +30054,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCO if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -30545,11 +31189,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_H zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -30573,7 +31239,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_H zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -30597,7 +31263,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_ if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -30614,6 +31280,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_ zval *container; zend_free_op free_op2; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); @@ -30626,11 +31294,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_ zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -30659,7 +31349,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_UNUSED_VAR_HANDLER(ZEND_O if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -30685,7 +31375,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCO if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -32307,11 +32997,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HA zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CV == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } @@ -32334,7 +33046,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HA zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -32358,7 +33070,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_H if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -32375,6 +33087,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_H zval *container; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); @@ -32387,11 +33101,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_H zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CV == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } @@ -32419,7 +33155,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_UNUSED_CV_HANDLER(ZEND_OP if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -32445,7 +33181,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_UNUSED_CV_HANDLER(ZEND_OPCOD if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -35510,11 +36246,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HAN zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CONST == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } @@ -35537,7 +36295,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HAN zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -35561,7 +36319,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HA if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -35578,6 +36336,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HA zval *container; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_cv_deref_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); @@ -35590,11 +36350,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HA zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CONST == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } @@ -35622,7 +36404,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CV_CONST_HANDLER(ZEND_OPC if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -35648,7 +36430,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_CV_CONST_HANDLER(ZEND_OPCODE if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -37632,11 +38414,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDL zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_TMP_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -37660,7 +38464,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDL zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -37684,7 +38488,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HAND if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -37701,6 +38505,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HAND zval *container; zend_free_op free_op2; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_cv_deref_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); @@ -37713,11 +38519,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HAND zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_TMP_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -37746,7 +38574,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CV_TMP_HANDLER(ZEND_OPCOD if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -37772,7 +38600,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_H if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -39634,11 +40462,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDL zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -39662,7 +40512,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDL zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -39686,7 +40536,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HAND if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -39703,6 +40553,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HAND zval *container; zend_free_op free_op2; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_cv_deref_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); @@ -39715,11 +40567,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HAND zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -39748,7 +40622,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CV_VAR_HANDLER(ZEND_OPCOD if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -39774,7 +40648,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_H if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -42749,11 +43623,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLE zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CV == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } @@ -42776,7 +43672,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLE zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -42800,7 +43696,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDL if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -42817,6 +43713,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDL zval *container; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_cv_deref_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); @@ -42829,11 +43727,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDL zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CV == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } + + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } @@ -42861,7 +43781,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CV_CV_HANDLER(ZEND_OPCODE if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -42887,7 +43807,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HA if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 3d44c35b629..b972c2899c7 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -3363,7 +3363,7 @@ static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value if (statics && (prop_info->flags & ZEND_ACC_STATIC) != 0) { prop = &ce->default_static_members_table[prop_info->offset]; } else if (!statics && (prop_info->flags & ZEND_ACC_STATIC) == 0) { - prop = &ce->default_properties_table[prop_info->offset]; + prop = &ce->default_properties_table[OBJ_PROP_TO_NUM(prop_info->offset)]; } } if (!prop) { From f5092bd304b481da45de95e3b25a96fa6b05bc29 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 6 Nov 2014 13:50:19 +0100 Subject: [PATCH 248/398] final name for vc14 isn't yet set --- win32/build/confutils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 893b3cf3014..e40a8e2a105 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -49,7 +49,8 @@ VC_VERSIONS[1500] = 'MSVC9 (Visual C++ 2008)'; VC_VERSIONS[1600] = 'MSVC10 (Visual C++ 2010)'; VC_VERSIONS[1700] = 'MSVC11 (Visual C++ 2012)'; VC_VERSIONS[1800] = 'MSVC12 (Visual C++ 2013)'; -VC_VERSIONS[1900] = 'MSVC14 (Visual C++ 2014)'; +/* XXX update after the final rename */ +VC_VERSIONS[1900] = 'MSVC14 (Visual C++ CTP14)'; var VC_VERSIONS_SHORT = new Array(); VC_VERSIONS_SHORT[1200] = 'VC6'; From bea7d06b79187692a3c4ec7f34e41e017b359e5d Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 6 Nov 2014 13:55:58 +0100 Subject: [PATCH 249/398] fix comment --- win32/php_stdint.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win32/php_stdint.h b/win32/php_stdint.h index d5b90ebe265..e5e0efbb1d5 100644 --- a/win32/php_stdint.h +++ b/win32/php_stdint.h @@ -33,7 +33,7 @@ #error "Use this header only with Microsoft Visual C++ compilers!" #endif // _MSC_VER ] -// Starting with VS2014, many of the C11 features are now included, so we only +// Starting with vc14, many of the C11 features are now included, so we only // need many of these typedefs and defines for older VS suites #if _MSC_VER < 1900 From f2ad1fb3c9ba90217cfc00dc57a2b5a99c21fdff Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 6 Nov 2014 14:03:42 +0100 Subject: [PATCH 250/398] fix preprocessor conditions --- win32/time.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/win32/time.h b/win32/time.h index c6679b6d9a4..8f39c0481c2 100644 --- a/win32/time.h +++ b/win32/time.h @@ -28,15 +28,13 @@ struct itimerval { struct timeval it_value; /* current value */ }; -#ifndef timespec -#if _MSC_VER < 1900 +#if !defined(timespec) && _MSC_VER < 1900 struct timespec { time_t tv_sec; /* seconds */ long tv_nsec; /* nanoseconds */ }; #endif -#endif #define ITIMER_REAL 0 /*generates sigalrm */ #define ITIMER_VIRTUAL 1 /*generates sigvtalrm */ From 53a437d3c3a69012fc51b8c0d3800c66172f7ca9 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 6 Nov 2014 17:45:14 +0300 Subject: [PATCH 251/398] Use better function --- Zend/zend_object_handlers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 12a9562c0a1..ad5a55510bf 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -641,7 +641,7 @@ write_std_property: if (!zobj->properties) { rebuild_object_properties(zobj); } - zend_hash_update(zobj->properties, Z_STR_P(member), value); + zend_hash_add_new(zobj->properties, Z_STR_P(member), value); } } From 4f3763e2027dc0f2a1209651eaf85a2adb4e6cfb Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 6 Nov 2014 17:45:41 +0300 Subject: [PATCH 252/398] Micro optimizations --- Zend/zend_hash.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index 6dc0941c6f6..3cd5d6aa5f9 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -269,14 +269,12 @@ static zend_always_inline zval *_zend_hash_add_or_update_i(HashTable *ht, zend_s IS_CONSISTENT(ht); - CHECK_INIT(ht, 0); - if (ht->u.flags & HASH_FLAG_PACKED) { + if (UNEXPECTED(ht->nTableMask == 0)) { + CHECK_INIT(ht, 0); + goto add_to_hash; + } else if (ht->u.flags & HASH_FLAG_PACKED) { zend_hash_packed_to_hash(ht); - } - - h = zend_string_hash_val(key); - - if ((flag & HASH_ADD_NEW) == 0) { + } else if ((flag & HASH_ADD_NEW) == 0) { p = zend_hash_find_bucket(ht, key); if (p) { @@ -302,6 +300,7 @@ static zend_always_inline zval *_zend_hash_add_or_update_i(HashTable *ht, zend_s ZEND_HASH_IF_FULL_DO_RESIZE(ht); /* If the Hash table is full, resize it */ +add_to_hash: HANDLE_BLOCK_INTERRUPTIONS(); idx = ht->nNumUsed++; ht->nNumOfElements++; @@ -309,7 +308,7 @@ static zend_always_inline zval *_zend_hash_add_or_update_i(HashTable *ht, zend_s ht->nInternalPointer = idx; } p = ht->arData + idx; - p->h = h; + p->h = h = zend_string_hash_val(key); p->key = key; zend_string_addref(key); ZVAL_COPY_VALUE(&p->val, pData); @@ -423,9 +422,15 @@ static zend_always_inline zval *_zend_hash_index_add_or_update_i(HashTable *ht, #endif IS_CONSISTENT(ht); - CHECK_INIT(ht, h < ht->nTableSize); - if (ht->u.flags & HASH_FLAG_PACKED) { + if (UNEXPECTED(ht->nTableMask == 0)) { + CHECK_INIT(ht, h < ht->nTableSize); + if (h < ht->nTableSize) { + p = ht->arData + h; + goto add_to_packed; + } + goto add_to_hash; + } else if (ht->u.flags & HASH_FLAG_PACKED) { if (h < ht->nNumUsed) { p = ht->arData + h; if (Z_TYPE(p->val) != IS_UNDEF) { @@ -453,6 +458,7 @@ static zend_always_inline zval *_zend_hash_index_add_or_update_i(HashTable *ht, goto convert_to_hash; } +add_to_packed: HANDLE_BLOCK_INTERRUPTIONS(); /* incremental initialization of empty Buckets */ if ((flag & (HASH_ADD_NEW|HASH_ADD_NEXT)) == (HASH_ADD_NEW|HASH_ADD_NEXT)) { @@ -477,7 +483,6 @@ static zend_always_inline zval *_zend_hash_index_add_or_update_i(HashTable *ht, p->h = h; p->key = NULL; ZVAL_COPY_VALUE(&p->val, pData); - Z_NEXT(p->val) = INVALID_IDX; HANDLE_UNBLOCK_INTERRUPTIONS(); @@ -485,9 +490,7 @@ static zend_always_inline zval *_zend_hash_index_add_or_update_i(HashTable *ht, convert_to_hash: zend_hash_packed_to_hash(ht); - } - - if ((flag & HASH_ADD_NEW) == 0) { + } else if ((flag & HASH_ADD_NEW) == 0) { p = zend_hash_index_find_bucket(ht, h); if (p) { if (flag & HASH_ADD) { @@ -509,6 +512,7 @@ convert_to_hash: ZEND_HASH_IF_FULL_DO_RESIZE(ht); /* If the Hash table is full, resize it */ +add_to_hash: HANDLE_BLOCK_INTERRUPTIONS(); idx = ht->nNumUsed++; ht->nNumOfElements++; From 8fdc4d8797e176f9bb8d9f9509a45346478d9cc1 Mon Sep 17 00:00:00 2001 From: Matteo Beccati Date: Thu, 6 Nov 2014 15:46:49 +0100 Subject: [PATCH 253/398] Fixed bug #68351 (PDO::PARAM_BOOL and ATTR_EMULATE_PREPARES misbehaving) --- NEWS | 2 ++ ext/pdo_pgsql/pgsql_statement.c | 1 + ext/pdo_pgsql/tests/bug62593.phpt | 15 +++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/NEWS b/NEWS index ef4195132b9..2340bea13d4 100644 --- a/NEWS +++ b/NEWS @@ -36,6 +36,8 @@ PHP NEWS . Fixed bug #66584 (Segmentation fault on statement deallocation) (Matteo) . Fixed bug #67462 (PDO_PGSQL::beginTransaction() wrongly throws exception when not in transaction) (Matteo) + . Fixed bug #68351 (PDO::PARAM_BOOL and ATTR_EMULATE_PREPARES misbehaving) + (Matteo) - SPL: . Fixed bug #68128 (Regression in RecursiveRegexIterator) (Tjerk) diff --git a/ext/pdo_pgsql/pgsql_statement.c b/ext/pdo_pgsql/pgsql_statement.c index 1fa7ce4777a..4e183311e2d 100644 --- a/ext/pdo_pgsql/pgsql_statement.c +++ b/ext/pdo_pgsql/pgsql_statement.c @@ -370,6 +370,7 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data * ((param->param_type & PDO_PARAM_INPUT_OUTPUT) != PDO_PARAM_INPUT_OUTPUT)) { SEPARATE_ZVAL(¶m->parameter); param->param_type = PDO_PARAM_STR; + convert_to_boolean(param->parameter); ZVAL_STRINGL(param->parameter, Z_BVAL_P(param->parameter) ? "t" : "f", 1, 1); } } diff --git a/ext/pdo_pgsql/tests/bug62593.phpt b/ext/pdo_pgsql/tests/bug62593.phpt index e3ebf46ed53..4ab4566f001 100644 --- a/ext/pdo_pgsql/tests/bug62593.phpt +++ b/ext/pdo_pgsql/tests/bug62593.phpt @@ -34,6 +34,19 @@ $query->execute(); $errors[] = $query->errorInfo(); var_dump($value); +// Try with strings - Bug #68351 +$value = '0'; +$query->bindParam(':foo', $value, PDO::PARAM_BOOL); +$query->execute(); +$errors[] = $query->errorInfo(); +var_dump($query->fetchColumn()); + +$value = "abc"; +$query->bindParam(':foo', $value, PDO::PARAM_BOOL); +$query->execute(); +$errors[] = $query->errorInfo(); +var_dump($query->fetchColumn()); + $expect = 'No errors found'; foreach ($errors as $error) @@ -48,4 +61,6 @@ echo $expect; --EXPECTF-- bool(true) bool(false) +bool(true) +bool(false) No errors found From 8fccf0bac9eab67412612b2df14da58b9129c6b2 Mon Sep 17 00:00:00 2001 From: Matteo Beccati Date: Thu, 6 Nov 2014 15:46:49 +0100 Subject: [PATCH 254/398] Fixed bug #68351 (PDO::PARAM_BOOL and ATTR_EMULATE_PREPARES misbehaving) --- ext/pdo_pgsql/pgsql_statement.c | 1 + ext/pdo_pgsql/tests/bug62593.phpt | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/ext/pdo_pgsql/pgsql_statement.c b/ext/pdo_pgsql/pgsql_statement.c index 7da130d52b0..2656586856b 100644 --- a/ext/pdo_pgsql/pgsql_statement.c +++ b/ext/pdo_pgsql/pgsql_statement.c @@ -371,6 +371,7 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data * ((param->param_type & PDO_PARAM_INPUT_OUTPUT) != PDO_PARAM_INPUT_OUTPUT)) { SEPARATE_ZVAL(¶m->parameter); param->param_type = PDO_PARAM_STR; + convert_to_boolean(param->parameter); ZVAL_STRINGL(param->parameter, Z_BVAL_P(param->parameter) ? "t" : "f", 1, 1); } } diff --git a/ext/pdo_pgsql/tests/bug62593.phpt b/ext/pdo_pgsql/tests/bug62593.phpt index e3ebf46ed53..4ab4566f001 100644 --- a/ext/pdo_pgsql/tests/bug62593.phpt +++ b/ext/pdo_pgsql/tests/bug62593.phpt @@ -34,6 +34,19 @@ $query->execute(); $errors[] = $query->errorInfo(); var_dump($value); +// Try with strings - Bug #68351 +$value = '0'; +$query->bindParam(':foo', $value, PDO::PARAM_BOOL); +$query->execute(); +$errors[] = $query->errorInfo(); +var_dump($query->fetchColumn()); + +$value = "abc"; +$query->bindParam(':foo', $value, PDO::PARAM_BOOL); +$query->execute(); +$errors[] = $query->errorInfo(); +var_dump($query->fetchColumn()); + $expect = 'No errors found'; foreach ($errors as $error) @@ -48,4 +61,6 @@ echo $expect; --EXPECTF-- bool(true) bool(false) +bool(true) +bool(false) No errors found From f5130c3058133c6919673b5e0eb4f59a98921946 Mon Sep 17 00:00:00 2001 From: Matteo Beccati Date: Thu, 6 Nov 2014 15:46:49 +0100 Subject: [PATCH 255/398] Fixed bug #68351 (PDO::PARAM_BOOL and ATTR_EMULATE_PREPARES misbehaving) --- ext/pdo_pgsql/pgsql_statement.c | 9 ++------- ext/pdo_pgsql/tests/bug62593.phpt | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/ext/pdo_pgsql/pgsql_statement.c b/ext/pdo_pgsql/pgsql_statement.c index 9e8fc746fa9..c274324b083 100644 --- a/ext/pdo_pgsql/pgsql_statement.c +++ b/ext/pdo_pgsql/pgsql_statement.c @@ -376,15 +376,10 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data * /* We need to manually convert to a pg native boolean value */ if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_BOOL && ((param->param_type & PDO_PARAM_INPUT_OUTPUT) != PDO_PARAM_INPUT_OUTPUT)) { - zval *parameter; - if (Z_ISREF(param->parameter)) { - parameter = Z_REFVAL(param->parameter); - } else { - parameter = ¶m->parameter; - } SEPARATE_ZVAL(¶m->parameter); param->param_type = PDO_PARAM_STR; - ZVAL_STRINGL(parameter, Z_TYPE_P(parameter) == IS_TRUE ? "t" : "f", 1); + convert_to_boolean(param->parameter); + ZVAL_STRINGL(¶m->parameter, Z_TYPE_P(¶m->parameter) == IS_TRUE ? "t" : "f", 1); } } return 1; diff --git a/ext/pdo_pgsql/tests/bug62593.phpt b/ext/pdo_pgsql/tests/bug62593.phpt index e3ebf46ed53..4ab4566f001 100644 --- a/ext/pdo_pgsql/tests/bug62593.phpt +++ b/ext/pdo_pgsql/tests/bug62593.phpt @@ -34,6 +34,19 @@ $query->execute(); $errors[] = $query->errorInfo(); var_dump($value); +// Try with strings - Bug #68351 +$value = '0'; +$query->bindParam(':foo', $value, PDO::PARAM_BOOL); +$query->execute(); +$errors[] = $query->errorInfo(); +var_dump($query->fetchColumn()); + +$value = "abc"; +$query->bindParam(':foo', $value, PDO::PARAM_BOOL); +$query->execute(); +$errors[] = $query->errorInfo(); +var_dump($query->fetchColumn()); + $expect = 'No errors found'; foreach ($errors as $error) @@ -48,4 +61,6 @@ echo $expect; --EXPECTF-- bool(true) bool(false) +bool(true) +bool(false) No errors found From 9dfa843a386b65b18353c510f032e322004d0bb7 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 7 Nov 2014 09:46:49 +0300 Subject: [PATCH 256/398] Partial fix for bug #68365 (zend_mm_heap corrupted after memory overflow in zend_hash_copy) --- Zend/zend_variables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_variables.c b/Zend/zend_variables.c index 9674de52463..cc73c379a7a 100644 --- a/Zend/zend_variables.c +++ b/Zend/zend_variables.c @@ -135,9 +135,9 @@ ZEND_API void _zval_copy_ctor_func(zval *zvalue ZEND_FILE_LINE_DC) } ALLOC_HASHTABLE_REL(tmp_ht); zend_hash_init(tmp_ht, zend_hash_num_elements(original_ht), NULL, ZVAL_PTR_DTOR, 0); + zvalue->value.ht = tmp_ht; zend_hash_copy(tmp_ht, original_ht, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); tmp_ht->nNextFreeElement = original_ht->nNextFreeElement; - zvalue->value.ht = tmp_ht; } break; case IS_OBJECT: From 45719aee26f250e59c7d917a8f913c2fce48b146 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 7 Nov 2014 09:55:13 +0300 Subject: [PATCH 257/398] fixed compilation error --- ext/pdo_pgsql/pgsql_statement.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/pdo_pgsql/pgsql_statement.c b/ext/pdo_pgsql/pgsql_statement.c index c274324b083..49fbc637450 100644 --- a/ext/pdo_pgsql/pgsql_statement.c +++ b/ext/pdo_pgsql/pgsql_statement.c @@ -378,7 +378,7 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data * ((param->param_type & PDO_PARAM_INPUT_OUTPUT) != PDO_PARAM_INPUT_OUTPUT)) { SEPARATE_ZVAL(¶m->parameter); param->param_type = PDO_PARAM_STR; - convert_to_boolean(param->parameter); + convert_to_boolean(¶m->parameter); ZVAL_STRINGL(¶m->parameter, Z_TYPE_P(¶m->parameter) == IS_TRUE ? "t" : "f", 1); } } From 033abd6d7783a8c98e8fc3612aa100de72408363 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 7 Nov 2014 10:16:25 +0300 Subject: [PATCH 258/398] Fix opcache.revalidate_freq per-request behavior --- ext/opcache/ZendAccelerator.c | 17 +++-------------- ext/opcache/ZendAccelerator.h | 1 - 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 44064004f88..1d3bd959fff 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -881,12 +881,12 @@ static inline int do_validate_timestamps(zend_persistent_script *persistent_scri int validate_timestamp_and_record(zend_persistent_script *persistent_script, zend_file_handle *file_handle TSRMLS_DC) { if (ZCG(accel_directives).revalidate_freq && - (persistent_script->dynamic_members.revalidate >= ZCSG(revalidate_at))) { + persistent_script->dynamic_members.revalidate >= ZCG(request_time)) { return SUCCESS; } else if (do_validate_timestamps(persistent_script, file_handle TSRMLS_CC) == FAILURE) { return FAILURE; } else { - persistent_script->dynamic_members.revalidate = ZCSG(revalidate_at); + persistent_script->dynamic_members.revalidate = ZCG(request_time) + ZCG(accel_directives).revalidate_freq; return SUCCESS; } } @@ -1449,7 +1449,7 @@ static zend_persistent_script *compile_and_cache_file(zend_file_handle *file_han * otherwise we have a race-condition. */ new_persistent_script->timestamp = timestamp; - new_persistent_script->dynamic_members.revalidate = ZCSG(revalidate_at); + new_persistent_script->dynamic_members.revalidate = ZCG(request_time) + ZCG(accel_directives).revalidate_freq; } if (file_handle->opened_path) { @@ -2155,13 +2155,6 @@ static void accel_activate(void) zend_accel_error(ACCEL_LOG_WARNING, "Internal functions count changed - was %d, now %d", ZCG(internal_functions_count), zend_hash_num_elements(&ZCG(function_table))); } - if (ZCG(accel_directives).validate_timestamps) { - time_t now = ZCG(request_time); - if (now > ZCSG(revalidate_at) + (time_t)ZCG(accel_directives).revalidate_freq) { - ZCSG(revalidate_at) = now; - } - } - ZCG(cwd) = NULL; SHM_PROTECT(); @@ -2622,10 +2615,6 @@ static int accel_startup(zend_extension *extension) zend_resolve_path = persistent_zend_resolve_path; #endif - if (ZCG(accel_directives).validate_timestamps) { - ZCSG(revalidate_at) = zend_accel_get_time() + ZCG(accel_directives).revalidate_freq; - } - /* Override chdir() function */ if (zend_hash_find(CG(function_table), "chdir", sizeof("chdir"), (void**)&func) == SUCCESS && func->type == ZEND_INTERNAL_FUNCTION) { diff --git a/ext/opcache/ZendAccelerator.h b/ext/opcache/ZendAccelerator.h index bba36316d94..547e3158232 100644 --- a/ext/opcache/ZendAccelerator.h +++ b/ext/opcache/ZendAccelerator.h @@ -297,7 +297,6 @@ typedef struct _zend_accel_shared_globals { unsigned long restart_in; #endif zend_bool restart_in_progress; - time_t revalidate_at; #if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO /* Interned Strings Support */ char *interned_strings_start; From b9f1daa97608294064e393ed0d15bcceb21d926e Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 6 Nov 2014 20:42:46 +0100 Subject: [PATCH 259/398] basic clang compatibility on windows --- Zend/zend_hash.c | 2 +- Zend/zend_portability.h | 4 ++++ ext/standard/basic_functions.h | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index 3cd5d6aa5f9..5577194b0c7 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -100,7 +100,7 @@ static const uint32_t uninitialized_bucket = {INVALID_IDX}; ZEND_API void _zend_hash_init(HashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC) { /* Use big enough power of 2 */ -#ifdef PHP_WIN32 +#if defined(PHP_WIN32) && !defined(__clang__) if (nSize <= 8) { ht->nTableSize = 8; } else if (nSize >= 0x80000000) { diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index c159fdc77b4..a6dac42b5a2 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -74,6 +74,10 @@ # include #endif +#if defined(ZEND_WIN32) +#include +#endif + /* Only use this macro if you know for sure that all of the switches values are covered by its case statements */ #if ZEND_DEBUG diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h index ee0e025c5df..5adc9a9a118 100644 --- a/ext/standard/basic_functions.h +++ b/ext/standard/basic_functions.h @@ -34,6 +34,10 @@ #include "url_scanner_ex.h" +#if defined(_WIN32) && defined(__clang__) +#include +#endif + extern zend_module_entry basic_functions_module; #define basic_functions_module_ptr &basic_functions_module From 876c7c451c69b2df9ed368bcdc8532fc1c2bceca Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 6 Nov 2014 20:44:57 +0100 Subject: [PATCH 260/398] build system to support clang --- win32/build/config.w32 | 117 +- win32/build/confutils.js | 4677 +++++++++++++++++++------------------- 2 files changed, 2473 insertions(+), 2321 deletions(-) diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 358ff4e0cef..c06ae509b7a 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -3,33 +3,66 @@ // "Master" config file; think of it as a configure.in // equivalent. +ARG_WITH("toolset", "Toolset to use for the compilation, supported: vs, clang", "vs"); +if ("clang" == PHP_TOOLSET) { + VS_TOOLSET = false; + CLANG_TOOLSET = true; + INTEL_TOOLSET = false; +} else { + /* Visual Studio is the default toolset. */ + PHP_TOOLSET = "no" == PHP_TOOLSET ? "vs" : PHP_TOOLSET; + if (!!PHP_TOOLSET && "vs" != PHP_TOOLSET) { + ERROR("Unsupported toolset name '" + PHP_TOOLSET + "'"); + } + VS_TOOLSET = true; + CLANG_TOOLSET = false; + INTEL_TOOLSET = false; +} + + ARG_WITH('cygwin', 'Path to cygwin utilities on your system', '\\cygwin'); -PHP_CL = PATH_PROG('cl', null, 'PHP_CL'); + +PHP_CL = toolset_get_compiler(); if (!PHP_CL) { ERROR("MS C++ compiler is required"); } -/* For the record here: */ -// 1200 is VC6 -// 1300 is vs.net 2002 -// 1310 is vs.net 2003 -// 1400 is vs.net 2005 -// 1500 is vs.net 2008 -// 1600 is vs.net 2010 -// Which version of the compiler do we have? -VCVERS = probe_binary(PHP_CL).substr(0, 5).replace('.', ''); -STDOUT.WriteLine(" Detected compiler " + VC_VERSIONS[VCVERS]); +COMPILER_NUMERIC_VERSION = toolset_get_compiler_version(); +COMPILER_NAME = toolset_get_compiler_name(); -if (VCVERS < 1500) { - ERROR("Unsupported MS C++ Compiler, VC9 (2008) minimum is required"); +if (VS_TOOLSET) { + /* For the record here: */ + // 1200 is VC6 + // 1300 is vs.net 2002 + // 1310 is vs.net 2003 + // 1400 is vs.net 2005 + // 1500 is vs.net 2008 + // 1600 is vs.net 2010 + // Which version of the compiler do we have? + VCVERS = COMPILER_NUMERIC_VERSION; + + if (VCVERS < 1500) { + ERROR("Unsupported MS C++ Compiler, VC9 (2008) minimum is required"); + } + + AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version"); + DEFINE("PHP_COMPILER_SHORT", VC_VERSIONS_SHORT[VCVERS]); + AC_DEFINE('PHP_COMPILER_ID', VC_VERSIONS_SHORT[VCVERS], "Compiler compatibility ID"); +} else if (CLANG_TOOLSET) { + CLANGVERS = COMPILER_NUMERIC_VERSION; + + AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version"); + DEFINE("PHP_COMPILER_SHORT", "clang"); + AC_DEFINE('PHP_COMPILER_ID', "clang"); /* XXX something better were to write here */ + +} else if (INTEL_TOOLSET) { + //INTELVERS = compiler_ver; + // .... } - -AC_DEFINE('COMPILER', VC_VERSIONS[VCVERS], "Detected compiler version"); -DEFINE("PHP_COMPILER_SHORT", VC_VERSIONS_SHORT[VCVERS]); -AC_DEFINE('PHP_COMPILER_ID', VC_VERSIONS_SHORT[VCVERS], "Compiler compatibility ID"); +STDOUT.WriteLine(" Detected compiler " + COMPILER_NAME); // do we use x64 or 80x86 version of compiler? -X64 = probe_binary(PHP_CL, 64, null, 'PHP_CL'); +X64 = toolset_is_64(); if (X64) { STDOUT.WriteLine(" Detected 64-bit compiler"); } else { @@ -40,7 +73,8 @@ DEFINE("PHP_ARCHITECTURE", X64 ? 'x64' : 'x86'); // cygwin now ships with link.exe. Avoid searching the cygwin path // for this, as we want the MS linker, not the fileutil -PATH_PROG('link', WshShell.Environment("Process").Item("PATH")); +toolset_get_linker(); + PATH_PROG('nmake'); // we don't want to define LIB, as that will override the default library path @@ -81,7 +115,7 @@ PATH_PROG('lemon'); PATH_PROG('mc', WshShell.Environment("Process").Item("PATH")); // Try locating manifest tool -if (VCVERS > 1200) { +if (VS_TOOLSET && VCVERS > 1200) { PATH_PROG('mt', WshShell.Environment("Process").Item("PATH")); } @@ -137,10 +171,17 @@ DEFINE("CFLAGS_PHP", "/D _USRDLL /D PHP7DLLTS_EXPORTS /D PHP_EXPORTS \ DEFINE('CFLAGS_PHP_OBJ', '$(CFLAGS_PHP) $(STATIC_EXT_CFLAGS)'); // General CFLAGS for building objects -DEFINE("CFLAGS", "/nologo /FD $(BASE_INCLUDES) /D _WINDOWS \ +DEFINE("CFLAGS", "/nologo $(BASE_INCLUDES) /D _WINDOWS \ /D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /W3 "); +if (CLANG_TOOLSET) { + if (X64) { + ADD_FLAG('CFLAGS', ' -m64 '); + } else { + ADD_FLAG('CFLAGS', ' -m32 '); + } +} -if (VCVERS < 1400) { +if (VS_TOOLSET && VCVERS < 1400) { // Enable automatic precompiled headers ADD_FLAG('CFLAGS', ' /YX '); @@ -150,7 +191,7 @@ if (VCVERS < 1400) { } } -if (VCVERS >= 1400) { +if (VS_TOOLSET && VCVERS >= 1400) { // fun stuff: MS deprecated ANSI stdio and similar functions // disable annoying warnings. In addition, time_t defaults // to 64-bit. Ask for 32-bit. @@ -168,7 +209,7 @@ if (VCVERS >= 1400) { ARG_WITH('mp', 'Tell Visual Studio use up to [n,auto,disable] processes for compilation', 'auto'); var PHP_MP_DISABLED = true; -if (VCVERS >= 1500 && PHP_MP != 'disable') { +if (VS_TOOLSET && VCVERS >= 1500 && PHP_MP != 'disable') { // no from disable-all if(PHP_MP == 'auto' || PHP_MP == 'no') { ADD_FLAG('CFLAGS', ' /MP '); @@ -185,11 +226,13 @@ if (VCVERS >= 1500 && PHP_MP != 'disable') { // General link flags -if (VCVERS >= 1700) { - DEFINE("LDFLAGS", "/nologo "); -} else { - DEFINE("LDFLAGS", "/nologo /version:" + - PHP_VERSION + "." + PHP_MINOR_VERSION + "." + PHP_RELEASE_VERSION); +if (VS_TOOLSET || CLANG_TOOLSET) { + if (VCVERS >= 1700) { + DEFINE("LDFLAGS", "/nologo "); + } else { + DEFINE("LDFLAGS", "/nologo /version:" + + PHP_VERSION + "." + PHP_MINOR_VERSION + "." + PHP_RELEASE_VERSION); + } } // General DLL link flags @@ -334,10 +377,12 @@ function add_extra_dirs() for (i = 0; i < path.length; i++) { f = FSO.GetAbsolutePathName(path[i]); if (FSO.FolderExists(f)) { - if (VCVERS <= 1200 && f.indexOf(" ") >= 0) { - ADD_FLAG("LDFLAGS", '/libpath:"\\"' + f + '\\"" '); - } else { - ADD_FLAG("LDFLAGS", '/libpath:"' + f + '" '); + if (VS_TOOLSET) { + if (VCVERS <= 1200 && f.indexOf(" ") >= 0) { + ADD_FLAG("LDFLAGS", '/libpath:"\\"' + f + '\\"" '); + } else { + ADD_FLAG("LDFLAGS", '/libpath:"' + f + '" '); + } } } } @@ -368,7 +413,7 @@ ADD_SOURCES("Zend", "zend_language_parser.c zend_language_scanner.c \ zend_float.c zend_string.c zend_generators.c zend_virtual_cwd.c zend_ast.c \ zend_inheritance.c"); -if (VCVERS == 1200) { +if (VS_TOOLSET && VCVERS == 1200) { AC_DEFINE('ZEND_DVAL_TO_LVAL_CAST_OK', 1); } @@ -379,10 +424,10 @@ ADD_SOURCES("main", "main.c snprintf.c spprintf.c getopt.c fopen_wrappers.c \ ADD_SOURCES("win32", "inet.c fnmatch.c sockets.c"); // Newer versions have it -if (VCVERS <= 1300) { +if (VS_TOOLSET && VCVERS <= 1300) { ADD_SOURCES("win32", "strtoi64.c"); } -if (VCVERS >= 1400) { +if (VS_TOOLSET && VCVERS >= 1400) { AC_DEFINE('HAVE_STRNLEN', 1); } diff --git a/win32/build/confutils.js b/win32/build/confutils.js index e40a8e2a105..33fcf7ce738 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -1,2285 +1,2392 @@ -// Utils for configure script -/* - +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Wez Furlong | - +----------------------------------------------------------------------+ -*/ - -// $Id: confutils.js,v 1.60.2.1.2.8.2.33 2009-05-29 07:43:07 kalle Exp $ - -var STDOUT = WScript.StdOut; -var STDERR = WScript.StdErr; -var WshShell = WScript.CreateObject("WScript.Shell"); -var FSO = WScript.CreateObject("Scripting.FileSystemObject"); -var MFO = null; -var SYSTEM_DRIVE = WshShell.Environment("Process").Item("SystemDrive"); -var PROGRAM_FILES = WshShell.Environment("Process").Item("ProgramFiles"); -var PROGRAM_FILESx86 = WshShell.Environment("Process").Item("ProgramFiles(x86)"); -var VCINSTALLDIR = WshShell.Environment("Process").Item("VCINSTALLDIR"); -var PHP_SRC_DIR=FSO.GetParentFolderName(WScript.ScriptFullName); - -/* Store the enabled extensions (summary + QA check) */ -var extensions_enabled = new Array(); - -/* Store the SAPI enabled (summary + QA check) */ -var sapi_enabled = new Array(); - -/* Store the headers to install */ -var headers_install = new Array(); - -/* Mapping CL version > human readable name */ -var VC_VERSIONS = new Array(); -VC_VERSIONS[1200] = 'MSVC6 (Visual C++ 6.0)'; -VC_VERSIONS[1300] = 'MSVC7 (Visual C++ 2002)'; -VC_VERSIONS[1310] = 'MSVC7.1 (Visual C++ 2003)'; -VC_VERSIONS[1400] = 'MSVC8 (Visual C++ 2005)'; -VC_VERSIONS[1500] = 'MSVC9 (Visual C++ 2008)'; -VC_VERSIONS[1600] = 'MSVC10 (Visual C++ 2010)'; -VC_VERSIONS[1700] = 'MSVC11 (Visual C++ 2012)'; -VC_VERSIONS[1800] = 'MSVC12 (Visual C++ 2013)'; -/* XXX update after the final rename */ -VC_VERSIONS[1900] = 'MSVC14 (Visual C++ CTP14)'; - -var VC_VERSIONS_SHORT = new Array(); -VC_VERSIONS_SHORT[1200] = 'VC6'; -VC_VERSIONS_SHORT[1300] = 'VC7'; -VC_VERSIONS_SHORT[1310] = 'VC7.1'; -VC_VERSIONS_SHORT[1400] = 'VC8'; -VC_VERSIONS_SHORT[1500] = 'VC9'; -VC_VERSIONS_SHORT[1600] = 'VC10'; -VC_VERSIONS_SHORT[1700] = 'VC11'; -VC_VERSIONS_SHORT[1800] = 'VC12'; -VC_VERSIONS_SHORT[1900] = 'VC14'; - -if (PROGRAM_FILES == null) { - PROGRAM_FILES = "C:\\Program Files"; -} - -if (MODE_PHPIZE) { - if (!FSO.FileExists("config.w32")) { - STDERR.WriteLine("Must be run from the root of the extension source"); - WScript.Quit(10); - } -} else { - if (!FSO.FileExists("README.GIT-RULES")) { - STDERR.WriteLine("Must be run from the root of the php source"); - WScript.Quit(10); - } -} - -var CWD = WshShell.CurrentDirectory; - -if (typeof(CWD) == "undefined") { - CWD = FSO.GetParentFolderName(FSO.GetAbsolutePathName("README.GIT-RULES")); -} - -/* defaults; we pick up the precise versions from configure.in */ -var PHP_VERSION = 5; -var PHP_MINOR_VERSION = 0; -var PHP_RELEASE_VERSION = 0; -var PHP_EXTRA_VERSION = ""; -var PHP_VERSION_STRING = "5.0.0"; - -function get_version_numbers() -{ - var cin = file_get_contents("configure.in"); - - if (cin.match(new RegExp("PHP_MAJOR_VERSION=(\\d+)"))) { - PHP_VERSION = RegExp.$1; - } - if (cin.match(new RegExp("PHP_MINOR_VERSION=(\\d+)"))) { - PHP_MINOR_VERSION = RegExp.$1; - } - if (cin.match(new RegExp("PHP_RELEASE_VERSION=(\\d+)"))) { - PHP_RELEASE_VERSION = RegExp.$1; - } - PHP_VERSION_STRING = PHP_VERSION + "." + PHP_MINOR_VERSION + "." + PHP_RELEASE_VERSION; - - if (cin.match(new RegExp("PHP_EXTRA_VERSION=\"([^\"]+)\""))) { - PHP_EXTRA_VERSION = RegExp.$1; - if (PHP_EXTRA_VERSION.length) { - PHP_VERSION_STRING += PHP_EXTRA_VERSION; - } - } - DEFINE('PHP_VERSION_STRING', PHP_VERSION_STRING); -} - -configure_args = new Array(); -configure_subst = WScript.CreateObject("Scripting.Dictionary"); - -configure_hdr = WScript.CreateObject("Scripting.Dictionary"); -build_dirs = new Array(); - -extension_include_code = ""; -extension_module_ptrs = ""; - -if (!MODE_PHPIZE) { - get_version_numbers(); -} - -/* execute a command and return the output as a string */ -function execute(command_line) -{ - var e = WshShell.Exec(command_line); - var ret = ""; - - ret = e.StdOut.ReadAll(); - -//STDOUT.WriteLine("command " + command_line); -//STDOUT.WriteLine(ret); - - return ret; -} - -function probe_binary(EXE, what) -{ - // tricky escapes to get stderr redirection to work - var command = 'cmd /c ""' + EXE; - if (what == "version") { - command = command + '" -v"'; - } - var version = execute(command + '" 2>&1"'); - - if (what == "64") { - if (version.match(/x64/)) { - return 1; - } - } else { - if (version.match(/(\d+\.\d+(\.\d+)?(\.\d+)?)/)) { - return RegExp.$1; - } - } - return 0; -} - -function condense_path(path) -{ - path = FSO.GetAbsolutePathName(path); - - if (path.substr(0, CWD.length).toLowerCase() - == CWD.toLowerCase() && - (path.charCodeAt(CWD.length) == 92 || path.charCodeAt(CWD.length) == 47)) { - return path.substr(CWD.length + 1); - } - - var a = CWD.split("\\"); - var b = path.split("\\"); - var i, j; - - for (i = 0; i < b.length; i++) { - if (a[i].toLowerCase() == b[i].toLowerCase()) - continue; - if (i > 0) { - /* first difference found */ - path = ""; - for (j = 0; j < a.length - i; j++) { - path += "..\\"; - } - for (j = i; j < b.length; j++) { - path += b[j]; - if (j < b.length - 1) - path += "\\"; - } - return path; - } - /* on a different drive */ - break; - } - - return path; -} - -function ConfigureArg(type, optname, helptext, defval) -{ - var opptype = type == "enable" ? "disable" : "without"; - - if (defval == "yes" || defval == "yes,shared") { - this.arg = "--" + opptype + "-" + optname; - this.imparg = "--" + type + "-" + optname; - } else { - this.arg = "--" + type + "-" + optname; - this.imparg = "--" + opptype + "-" + optname; - } - - this.optname = optname; - this.helptext = helptext; - this.defval = defval; - this.symval = optname.toUpperCase().replace(new RegExp("-", "g"), "_"); - this.seen = false; - this.argval = defval; -} - -function ARG_WITH(optname, helptext, defval) -{ - configure_args[configure_args.length] = new ConfigureArg("with", optname, helptext, defval); -} - -function ARG_ENABLE(optname, helptext, defval) -{ - configure_args[configure_args.length] = new ConfigureArg("enable", optname, helptext, defval); -} - -function analyze_arg(argval) -{ - var ret = new Array(); - var shared = false; - - if (argval == "shared") { - shared = true; - argval = "yes"; - } else if (argval == null) { - /* nothing */ - } else if (arg_match = argval.match(new RegExp("^shared,(.*)"))) { - shared = true; - argval = arg_match[1]; - } else if (arg_match = argval.match(new RegExp("^(.*),shared$"))) { - shared = true; - argval = arg_match[1]; - } - - ret[0] = shared; - ret[1] = argval; - return ret; -} - -function word_wrap_and_indent(indent, text, line_suffix, indent_char) -{ - if (text == null) { - return ""; - } - - var words = text.split(new RegExp("\\s+", "g")); - var i = 0; - var ret_text = ""; - var this_line = ""; - var t; - var space = ""; - var lines = 0; - - if (line_suffix == null) { - line_suffix = ""; - } - - if (indent_char == null) { - indent_char = " "; - } - - for (i = 0; i < indent; i++) { - space += indent_char; - } - - for (i = 0; i < words.length; i++) { - if (this_line.length) { - t = this_line + " " + words[i]; - } else { - t = words[i]; - } - - if (t.length + indent > 78) { - if (lines++) { - ret_text += space; - } - ret_text += this_line + line_suffix + "\r\n"; - this_line = ""; - } - - if (this_line.length) { - this_line += " " + words[i]; - } else { - this_line = words[i]; - } - } - - if (this_line.length) { - if (lines) - ret_text += space; - ret_text += this_line; - } - - return ret_text; -} - -function conf_process_args() -{ - var i, j; - var configure_help_mode = false; - var analyzed = false; - var nice = "cscript /nologo configure.js "; - var disable_all = false; - - args = WScript.Arguments; - for (i = 0; i < args.length; i++) { - arg = args(i); - nice += ' "' + arg + '"'; - if (arg == "--help") { - configure_help_mode = true; - break; - } - if (arg == "--disable-all") { - disable_all = true; - continue; - } - - // If it is --foo=bar, split on the equals sign - arg = arg.split("=", 2); - argname = arg[0]; - if (arg.length > 1) { - argval = arg[1]; - } else { - argval = null; - } - - // Find the arg - found = false; - for (j = 0; j < configure_args.length; j++) { - if (argname == configure_args[j].imparg || argname == configure_args[j].arg) { - found = true; - - arg = configure_args[j]; - arg.seen = true; - - analyzed = analyze_arg(argval); - - /* Force shared when called after phpize */ - if (MODE_PHPIZE) { - shared = "shared"; - } else { - shared = analyzed[0]; - } - argval = analyzed[1]; - - if (argname == arg.imparg) { - /* we matched the implicit, or default arg */ - if (argval == null) { - argval = arg.defval; - } - } else { - /* we matched the non-default arg */ - if (argval == null) { - argval = arg.defval == "no" ? "yes" : "no"; - } - } - - arg.argval = argval; - eval("PHP_" + arg.symval + " = argval;"); - eval("PHP_" + arg.symval + "_SHARED = shared;"); - break; - } - } - if (!found) { - STDERR.WriteLine("Unknown option " + argname + "; please try configure.js --help for a list of valid options"); - WScript.Quit(2); - } - } - - if (configure_help_mode) { - STDOUT.WriteLine(word_wrap_and_indent(0, -"Options that enable extensions and SAPI will accept \ -'yes' or 'no' as a parameter. They also accept 'shared' \ -as a synonym for 'yes' and request a shared build of that \ -module. Not all modules can be built as shared modules; \ -configure will display [shared] after the module name if \ -can be built that way. \ -" - )); - STDOUT.WriteBlankLines(1); - - // Measure width to pretty-print the output - max_width = 0; - for (i = 0; i < configure_args.length; i++) { - arg = configure_args[i]; - if (arg.arg.length > max_width) - max_width = arg.arg.length; - } - - for (i = 0; i < configure_args.length; i++) { - arg = configure_args[i]; - - n = max_width - arg.arg.length; - pad = " "; - for (j = 0; j < n; j++) { - pad += " "; - } - STDOUT.WriteLine(" " + arg.arg + pad + word_wrap_and_indent(max_width + 5, arg.helptext)); - } - WScript.Quit(1); - } - - var snapshot_build_exclusions = new Array( - 'debug', 'crt-debug', 'lzf-better-compression', - 'php-build', 'snapshot-template', 'ereg', - 'pcre-regex', 'fastcgi', 'force-cgi-redirect', - 'path-info-check', 'zts', 'ipv6', 'memory-limit', - 'zend-multibyte', 'fd-setsize', 'memory-manager', - 't1lib', 'pgi', 'pgo' - ); - var force; - - // Now set any defaults we might have missed out earlier - for (i = 0; i < configure_args.length; i++) { - arg = configure_args[i]; - if (arg.seen) - continue; - analyzed = analyze_arg(arg.defval); - shared = analyzed[0]; - argval = analyzed[1]; - - // Don't trust a default "yes" answer for a non-core module - // in a snapshot build - if (PHP_SNAPSHOT_BUILD != "no" && argval == "yes" && !shared) { - - force = true; - for (j = 0; j < snapshot_build_exclusions.length; j++) { - if (snapshot_build_exclusions[j] == arg.optname) { - force = false; - break; - } - } - - if (force) { - /* now check if it is a core module */ - force = false; - for (j = 0; j < core_module_list.length; j++) { - if (core_module_list[j] == arg.optname) { - force = true; - break; - } - } - - if (!force) { - STDOUT.WriteLine("snapshot: forcing " + arg.arg + " shared"); - shared = true; - } - } - } - - if (PHP_SNAPSHOT_BUILD != "no" && argval == "no") { - force = true; - for (j = 0; j < snapshot_build_exclusions.length; j++) { - if (snapshot_build_exclusions[j] == arg.optname) { - force = false; - break; - } - } - if (force) { - STDOUT.WriteLine("snapshot: forcing " + arg.optname + " on"); - argval = "yes"; - shared = true; - } - } - - if (disable_all) { - force = true; - for (j = 0; j < snapshot_build_exclusions.length; j++) { - if (snapshot_build_exclusions[j] == arg.optname) { - force = false; - break; - } - } - if (force) { - if (arg.defval == '') { - argval = ''; - } else { - argval = "no"; - } - shared = false; - } - } - - eval("PHP_" + arg.symval + " = argval;"); - eval("PHP_" + arg.symval + "_SHARED = shared;"); - } - - MFO = FSO.CreateTextFile("Makefile.objects", true); - - STDOUT.WriteLine("Saving configure options to config.nice.bat"); - var nicefile = FSO.CreateTextFile("config.nice.bat", true); - nicefile.WriteLine(nice + " %*"); - nicefile.Close(); - - AC_DEFINE('CONFIGURE_COMMAND', nice, "Configure line"); -} - -function DEFINE(name, value) -{ - if (configure_subst.Exists(name)) { - configure_subst.Remove(name); - } - configure_subst.Add(name, value); -} - -// Searches a set of paths for a file; -// returns the dir in which the file was found, -// true if it was found in the default env path, -// or false if it was not found at all. -// env_name is the optional name of an env var -// specifying the default path to search -function search_paths(thing_to_find, explicit_path, env_name) -{ - var i, found = false, place = false, file, env; - - STDOUT.Write("Checking for " + thing_to_find + " ... "); - - thing_to_find = thing_to_find.replace(new RegExp("/", "g"), "\\"); - - if (explicit_path != null) { - if (typeof(explicit_path) == "string") { - explicit_path = explicit_path.split(";"); - } - - for (i = 0; i < explicit_path.length; i++) { - file = glob(explicit_path[i] + "\\" + thing_to_find); - if (file) { - found = true; - place = file[0]; - place = place.substr(0, place.length - thing_to_find.length - 1); - break; - } - } - } - - if (!found && env_name != null) { - env = WshShell.Environment("Process").Item(env_name); - env = env.split(";"); - for (i = 0; i < env.length; i++) { - file = glob(env[i] + "\\" + thing_to_find); - if (file) { - found = true; - place = true; - break; - } - } - } - - if (found && place == true) { - STDOUT.WriteLine(" "); - } else if (found) { - STDOUT.WriteLine(" " + place); - } else { - STDOUT.WriteLine(" "); - } - return place; -} - -function PATH_PROG(progname, additional_paths, symbol) -{ - var exe; - var place; - var cyg_path = PHP_CYGWIN + "\\bin;" + PHP_CYGWIN + "\\usr\\local\\bin"; - var php_build_bin_path = PHP_PHP_BUILD + "\\bin" - - exe = progname + ".exe"; - - if (additional_paths == null) { - additional_paths = cyg_path; - } else { - additional_paths += ";" + cyg_path; - } - - additional_paths = additional_paths + ";" + php_build_bin_path; - - place = search_paths(exe, additional_paths, "PATH"); - - if (place == true) { - place = exe; - } else if (place != false) { - place = place + "\\" + exe; - } - - if (place) { - if (symbol == null) { - symbol = progname.toUpperCase(); - } - DEFINE(symbol, place); - } - return place; -} - -function find_pattern_in_path(pattern, path) -{ - if (path == null) { - return false; - } - - var dirs = path.split(';'); - var i; - var items; - - for (i = 0; i < dirs.length; i++) { - items = glob(dirs[i] + "\\" + pattern); - if (items) { - return condense_path(items[0]); - } - } - return false; -} - -function CHECK_LIB(libnames, target, path_to_check, common_name) -{ - STDOUT.Write("Checking for library " + libnames + " ... "); - - if (common_name == null && target != null) { - common_name = target; - } - - if (path_to_check == null) { - path_to_check = ""; - } - - // if they specified a common name for the package that contains - // the library, tag some useful defaults on to the end of the - // path to be searched - if (common_name != null) { - path_to_check += ";" + PHP_PHP_BUILD + "\\" + common_name + "*"; - path_to_check += ";" + PHP_PHP_BUILD + "\\lib\\" + common_name + "*"; - path_to_check += ";..\\" + common_name + "*"; - } - - // Determine target for build flags - if (target == null) { - target = ""; - } else { - target = "_" + target.toUpperCase(); - } - - // Expand path to include general dirs - path_to_check += ";" + php_usual_lib_suspects; - - // It is common practice to put libs under one of these dir names - var subdirs = new Array(PHP_DEBUG == "yes" ? "Debug" : (PHP_DEBUG_PACK == "yes"?"Release_Dbg":"Release"), "lib", "libs", "libexec"); - - // libnames can be ; separated list of accepted library names - libnames = libnames.split(';'); - - // for debug builds, lib may have _debug appended, we want that first - if (PHP_DEBUG == "yes") { - var length = libnames.length; - for (var i = 0; i < length; i++) { - var name = new String(libnames[i]); - rExp = /.lib$/i; - name = name.replace(rExp,"_debug.lib"); - libnames.unshift(name); - } - } - - var i, j, k, libname; - var location = false; - var path = path_to_check.split(';'); - - for (i = 0; i < libnames.length; i++) { - libname = libnames[i]; - - for (k = 0; k < path.length; k++) { - location = glob(path[k] + "\\" + libname); - if (location) { - location = location[0]; - break; - } - for (j = 0; j < subdirs.length; j++) { - location = glob(path[k] + "\\" + subdirs[j] + "\\" + libname); - if (location) { - location = location[0]; - break; - } - } - if (location) - break; - } - - if (location) { - location = condense_path(location); - var libdir = FSO.GetParentFolderName(location); - libname = FSO.GetFileName(location); - ADD_FLAG("LDFLAGS" + target, '/libpath:"' + libdir + '" '); - ADD_FLAG("LIBS" + target, libname); - - STDOUT.WriteLine(location); - - return location; - } - - // Check in their standard lib path - location = find_pattern_in_path(libname, WshShell.Environment("Process").Item("LIB")); - - if (location) { - location = condense_path(location); - libname = FSO.GetFileName(location); - ADD_FLAG("LIBS" + target, libname); - - STDOUT.WriteLine(" " + libname); - return location; - } - - // Check in their general extra libs path - location = find_pattern_in_path(libname, PHP_EXTRA_LIBS); - if (location) { - location = condense_path(location); - libname = FSO.GetFileName(location); - ADD_FLAG("LIBS" + target, libname); - STDOUT.WriteLine(""); - return location; - } - } - - STDOUT.WriteLine(""); - - return false; -} - -function OLD_CHECK_LIB(libnames, target, path_to_check) -{ - if (target == null) { - target = ""; - } else { - target = "_" + target.toUpperCase(); - } - - if (path_to_check == null) { - path_to_check = php_usual_lib_suspects; - } else { - path_to_check += ";" + php_usual_lib_suspects; - } - var have = 0; - var p; - var i; - var libname; - - var subdir = PHP_DEBUG == "yes" ? "Debug" : (PHP_DEBUG_PACK == "yes"?"Release_Dbg":"Release"); - - libnames = libnames.split(';'); - for (i = 0; i < libnames.length; i++) { - libname = libnames[i]; - p = search_paths(libname, path_to_check, "LIB"); - - if (!p) { - p = search_paths(subdir + "\\" + libname, path_to_check, "LIB"); - if (p) { - p += "\\" + subdir; - } - } - - if (typeof(p) == "string") { - ADD_FLAG("LDFLAGS" + target, '/libpath:"' + p + '" '); - ADD_FLAG("LIBS" + target, libname); - have = 1; - } else if (p == true) { - ADD_FLAG("LIBS" + target, libname); - have = 1; - } else { - /* not found in the defaults or the explicit paths, - * so check the general extra libs; if we find - * it here, no need to add another /libpath: for it as we - * already have it covered, but we need to add the lib - * to LIBS_XXX */ - if (false != search_paths(libname, PHP_EXTRA_LIBS, null)) { - ADD_FLAG("LIBS" + target, libname); - have = 1; - } - } - - if (have) { - break; - } - } - -// AC_DEFINE("HAVE_" + header_name.toUpperCase().replace(new RegExp("/\\\\-\.", "g"), "_"), have); - - return have; - -} - -function CHECK_FUNC_IN_HEADER(header_name, func_name, path_to_check, add_to_flag) -{ - var c = false; - var sym; - - STDOUT.Write("Checking for " + func_name + " in " + header_name + " ... "); - - c = GREP_HEADER(header_name, func_name, path_to_check); - - sym = func_name.toUpperCase(); - sym = sym.replace(new RegExp("[\\\\/\.-]", "g"), "_"); - - if (typeof(add_to_flag) == "undefined") { - AC_DEFINE("HAVE_" + sym, c ? 1 : 0); - } else { - ADD_FLAG(add_to_flag, "/DHAVE_" + sym + "=" + (c ? "1" : "0")); - } - - if (c) { - STDOUT.WriteLine("OK"); - return c; - } - STDOUT.WriteLine("No"); - return false; -} - -function GREP_HEADER(header_name, regex, path_to_check) -{ - var c = false; - - if (FSO.FileExists(path_to_check + "\\" + header_name)) { - c = file_get_contents(path_to_check + "\\" + header_name); - } - - if (!c) { - /* look in the include path */ - - var p = search_paths(header_name, path_to_check, "INCLUDE"); - if (typeof(p) == "string") { - c = file_get_contents(p); - } else if (p == false) { - p = search_paths(header_name, PHP_EXTRA_INCLUDES, null); - if (typeof(p) == "string") { - c = file_get_contents(p); - } - } - if (!c) { - return false; - } - } - - if (typeof(regex) == "string") { - regex = new RegExp(regex); - } - - if (c.match(regex)) { - /* caller can now use RegExp.$1 etc. to get at patterns */ - return true; - } - return false; -} - -function CHECK_HEADER_ADD_INCLUDE(header_name, flag_name, path_to_check, use_env, add_dir_part, add_to_flag_only) -{ - var dir_part_to_add = ""; - - if (use_env == null) { - use_env = true; - } - - // if true, add the dir part of the header_name to the include path - if (add_dir_part == null) { - add_dir_part = false; - } else if (add_dir_part) { - var basename = FSO.GetFileName(header_name); - dir_part_to_add = "\\" + header_name.substr(0, header_name.length - basename.length - 1); - } - - if (path_to_check == null) { - path_to_check = php_usual_include_suspects; - } else { - path_to_check += ";" + php_usual_include_suspects; - } - - var p = search_paths(header_name, path_to_check, use_env ? "INCLUDE" : null); - var have = 0; - var sym; - - if (typeof(p) == "string") { - ADD_FLAG(flag_name, '/I "' + p + dir_part_to_add + '" '); - } else if (p == false) { - /* not found in the defaults or the explicit paths, - * so check the general extra includes; if we find - * it here, no need to add another /I for it as we - * already have it covered, unless we are adding - * the dir part.... */ - p = search_paths(header_name, PHP_EXTRA_INCLUDES, null); - if (typeof(p) == "string" && add_dir_part) { - ADD_FLAG(flag_name, '/I "' + p + dir_part_to_add + '" '); - } - } - have = p ? 1 : 0 - - sym = header_name.toUpperCase(); - sym = sym.replace(new RegExp("[\\\\/\.-]", "g"), "_"); - - if (typeof(add_to_flag_only) == "undefined" && - flag_name.match(new RegExp("^CFLAGS_(.*)$"))) { - add_to_flag_only = true; - } - - if (typeof(add_to_flag_only) != "undefined") { - ADD_FLAG(flag_name, "/DHAVE_" + sym + "=" + have); - } else { - AC_DEFINE("HAVE_" + sym, have, "have the " + header_name + " header file"); - } - - return p; -} - -/* emits rule to generate version info for a SAPI - * or extension. Returns the name of the .res file - * that will be generated */ -function generate_version_info_resource(makefiletarget, basename, creditspath, sapi) -{ - var resname = makefiletarget + ".res"; - var res_desc = makefiletarget; - var res_prod_name = "PHP " + makefiletarget; - var credits; - var thanks = ""; - var logo = ""; - var debug = ""; - var project_url = "http://www.php.net"; - var project_header = creditspath + "/php_" + basename + ".h"; - var versioning = ""; - - if (sapi) { - var internal_name = basename.toUpperCase() + " SAPI"; - } else { - var internal_name = basename.toUpperCase() + " extension"; - } - - if (FSO.FileExists(creditspath + '/CREDITS')) { - credits = FSO.OpenTextFile(creditspath + '/CREDITS', 1); - res_desc = credits.ReadLine(); - try { - thanks = credits.ReadLine(); - } catch (e) { - thanks = null; - } - if (thanks == null) { - thanks = ""; - } else { - thanks = "Thanks to " + thanks; - } - credits.Close(); - } - - if (creditspath.match(new RegExp("pecl"))) { - /* PECL project url - this will eventually work correctly for all */ - project_url = "http://pecl.php.net/" + basename; - - /* keep independent versioning PECL-specific for now */ - if (FSO.FileExists(project_header)) { - if (header = FSO.OpenTextFile(project_header, 1)) { - contents = header.ReadAll(); - /* allowed: x.x.x[a|b|-alpha|-beta][RCx][-dev] */ - if (contents.match(new RegExp('PHP_' + basename.toUpperCase() + '_VERSION(\\s+)"((\\d+\.\\d+(\.\\d+)?)((a|b)(\\d)?|\-[a-z]{3,5})?(RC\\d+)?(\-dev)?)'))) { - project_version = RegExp.$2; - file_version = RegExp.$3.split('.'); - if (!file_version[2]) { - file_version[2] = 0; - } - versioning = '\\"" /d EXT_FILE_VERSION=' + file_version[0] + ',' + file_version[1] + ',' + file_version[2] + ' /d EXT_VERSION="\\"' + project_version; - } - header.Close(); - } - } - } - - if (makefiletarget.match(new RegExp("\\.exe$"))) { - logo = " /d WANT_LOGO "; - } - - if (PHP_DEBUG != "no") { - debug = " /d _DEBUG"; - } - - /** - * Use user supplied template.rc if it exists - */ - if (FSO.FileExists(creditspath + '\\template.rc')) { - MFO.WriteLine("$(BUILD_DIR)\\" + resname + ": " + creditspath + "\\template.rc"); - MFO.WriteLine("\t$(RC) /fo $(BUILD_DIR)\\" + resname + logo + debug + - ' /d FILE_DESCRIPTION="\\"' + res_desc + '\\"" /d FILE_NAME="\\"' + - makefiletarget + '\\"" /d PRODUCT_NAME="\\"' + res_prod_name + - versioning + '\\"" /d THANKS_GUYS="\\"' + thanks + '\\"" ' + - creditspath + '\\template.rc'); - return resname; - } - if (MODE_PHPIZE) { - MFO.WriteLine("$(BUILD_DIR)\\" + resname + ": $(PHP_DIR)\\build\\template.rc"); - MFO.WriteLine("\t$(RC) /I $(PHP_DIR)/include /n /fo $(BUILD_DIR)\\" + resname + logo + debug + - ' /d FILE_DESCRIPTION="\\"' + res_desc + '\\"" /d FILE_NAME="\\"' - + makefiletarget + '\\"" /d URL="\\"' + project_url + - '\\"" /d INTERNAL_NAME="\\"' + internal_name + versioning + - '\\"" /d THANKS_GUYS="\\"' + thanks + '\\"" $(PHP_DIR)\\build\\template.rc'); - } else { - MFO.WriteLine("$(BUILD_DIR)\\" + resname + ": win32\\build\\template.rc"); - MFO.WriteLine("\t$(RC) /n /fo $(BUILD_DIR)\\" + resname + logo + debug + - ' /d FILE_DESCRIPTION="\\"' + res_desc + '\\"" /d FILE_NAME="\\"' - + makefiletarget + '\\"" /d URL="\\"' + project_url + - '\\"" /d INTERNAL_NAME="\\"' + internal_name + versioning + - '\\"" /d THANKS_GUYS="\\"' + thanks + '\\"" win32\\build\\template.rc'); - } - MFO.WriteBlankLines(1); - return resname; -} - -/* Check if PGO is enabled for given module. To disable PGO for a particular module, -define a global variable by the following name scheme before SAPI() or EXTENSION() call - var PHP_MYMODULE_PGO = false; */ -function is_pgo_desired(mod) -{ - var varname = "PHP_" + mod.toUpperCase() + "_PGO"; - - /* XXX enable PGO in phpize mode */ - if (MODE_PHPIZE) { - return false; - } - - /* don't disable if there's no mention of the varname */ - if (eval("typeof " + varname + " == 'undefined'")) { - return true; - } - - return eval("!!" + varname); -} - -function SAPI(sapiname, file_list, makefiletarget, cflags, obj_dir) -{ - var SAPI = sapiname.toUpperCase(); - var ldflags; - var resname; - var ld; - var manifest; - - if (typeof(obj_dir) == "undefined") { - sapiname_for_printing = configure_module_dirname; - } else { - sapiname_for_printing = configure_module_dirname + " (via " + obj_dir + ")"; - } - - STDOUT.WriteLine("Enabling SAPI " + sapiname_for_printing); - - MFO.WriteBlankLines(1); - MFO.WriteLine("# objects for SAPI " + sapiname); - MFO.WriteBlankLines(1); - - if (cflags) { - ADD_FLAG('CFLAGS_' + SAPI, cflags); - } - - ADD_SOURCES(configure_module_dirname, file_list, sapiname, obj_dir); - MFO.WriteBlankLines(1); - MFO.WriteLine("# SAPI " + sapiname); - MFO.WriteBlankLines(1); - - /* generate a .res file containing version information */ - resname = generate_version_info_resource(makefiletarget, sapiname, configure_module_dirname, true); - - MFO.WriteLine(makefiletarget + ": $(BUILD_DIR)\\" + makefiletarget); - MFO.WriteLine("\t@echo SAPI " + sapiname_for_printing + " build complete"); - if (MODE_PHPIZE) { - MFO.WriteLine("$(BUILD_DIR)\\" + makefiletarget + ": $(DEPS_" + SAPI + ") $(" + SAPI + "_GLOBAL_OBJS) $(PHPLIB) $(BUILD_DIR)\\" + resname); - } else { - MFO.WriteLine("$(BUILD_DIR)\\" + makefiletarget + ": $(DEPS_" + SAPI + ") $(" + SAPI + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(BUILD_DIR)\\" + resname); - } - - if (makefiletarget.match(new RegExp("\\.dll$"))) { - ldflags = "/dll $(LDFLAGS)"; - manifest = "-@$(_VC_MANIFEST_EMBED_DLL)"; - } else if (makefiletarget.match(new RegExp("\\.lib$"))) { - ldflags = "$(LDFLAGS)"; - ld = "$(MAKE_LIB)"; - } else { - ldflags = "$(LDFLAGS)"; - manifest = "-@$(_VC_MANIFEST_EMBED_EXE)"; - } - - if(is_pgo_desired(sapiname) && (PHP_PGI == "yes" || PHP_PGO != "no")) { - // Add compiler and link flags if PGO options are selected - if (PHP_DEBUG != "yes" && PHP_PGI == "yes") { - ADD_FLAG('CFLAGS_' + SAPI, "/GL /O2"); - ADD_FLAG('LDFLAGS_' + SAPI, "/LTCG:PGINSTRUMENT"); - } - else if (PHP_DEBUG != "yes" && PHP_PGO != "no") { - ADD_FLAG('CFLAGS_' + SAPI, "/GL /O2"); - ADD_FLAG('LDFLAGS_' + SAPI, "/LTCG:PGUPDATE"); - } - - ldflags += " /PGD:$(PGOPGD_DIR)\\" + makefiletarget.substring(0, makefiletarget.indexOf(".")) + ".pgd"; - } - - if (MODE_PHPIZE) { - if (ld) { - MFO.WriteLine("\t" + ld + " /nologo /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(" + SAPI + "_GLOBAL_OBJS) $(PHPLIB) $(LDFLAGS_" + SAPI + ") $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname); - } else { - ld = "@$(CC)"; - MFO.WriteLine("\t" + ld + " /nologo " + " $(" + SAPI + "_GLOBAL_OBJS) $(PHPLIB) $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname + " /link /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(LDFLAGS_" + SAPI + ")"); - } - } else { - if (ld) { - MFO.WriteLine("\t" + ld + " /nologo /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(" + SAPI + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LDFLAGS_" + SAPI + ") $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname); - } else { - ld = "@$(CC)"; - MFO.WriteLine("\t" + ld + " /nologo " + " $(" + SAPI + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname + " /link /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(LDFLAGS_" + SAPI + ")"); - } - } - - if (manifest) { - MFO.WriteLine("\t" + manifest); - } - - DEFINE('CFLAGS_' + SAPI + '_OBJ', '$(CFLAGS_' + SAPI + ')'); - - if (configure_module_dirname.match("pecl")) { - ADD_FLAG("PECL_TARGETS", makefiletarget); - } else { - ADD_FLAG("SAPI_TARGETS", makefiletarget); - } - - MFO.WriteBlankLines(1); - sapi_enabled[sapi_enabled.length] = [sapiname]; -} - -function ADD_DIST_FILE(filename) -{ - if (configure_module_dirname.match("pecl")) { - ADD_FLAG("PECL_EXTRA_DIST_FILES", filename); - } else { - ADD_FLAG("PHP_EXTRA_DIST_FILES", filename); - } -} - -function file_get_contents(filename) -{ - var f, c; - try { - f = FSO.OpenTextFile(filename, 1); - c = f.ReadAll(); - f.Close(); - return c; - } catch (e) { - STDOUT.WriteLine("Problem reading " + filename); - return false; - } -} - -// Add a dependency on another extension, so that -// the dependencies are built before extname -function ADD_EXTENSION_DEP(extname, dependson, optional) -{ - var EXT = extname.toUpperCase(); - var DEP = dependson.toUpperCase(); - var dep_present = false; - var dep_shared = false; - - try { - dep_present = eval("PHP_" + DEP); - - if (dep_present != "no") { - try { - dep_shared = eval("PHP_" + DEP + "_SHARED"); - } catch (e) { - dep_shared = false; - } - } - - } catch (e) { - dep_present = "no"; - } - - if (optional) { - if (dep_present == "no") { - MESSAGE("\t" + dependson + " not found: " + dependson + " support in " + extname + " disabled"); - return false; - } - } - - var ext_shared = eval("PHP_" + EXT + "_SHARED"); - - if (dep_shared) { - if (!ext_shared) { - if (optional) { - MESSAGE("\tstatic " + extname + " cannot depend on shared " + dependson + ": " + dependson + "support disabled"); - return false; - } - ERROR("static " + extname + " cannot depend on shared " + dependson); - } - - ADD_FLAG("LIBS_" + EXT, "php_" + dependson + ".lib"); - if (MODE_PHPIZE) { - ADD_FLAG("LDFLAGS_" + EXT, "/libpath:$(BUILD_DIR_DEV)\\lib"); - ADD_FLAG("DEPS_" + EXT, "$(BUILD_DIR_DEV)\\lib\\php_" + dependson + ".lib"); - } else { - ADD_FLAG("LDFLAGS_" + EXT, "/libpath:$(BUILD_DIR)"); - ADD_FLAG("DEPS_" + EXT, "$(BUILD_DIR)\\php_" + dependson + ".lib"); - } - - } else { - - if (dep_present == "no") { - if (ext_shared) { - WARNING(extname + " cannot be built: missing dependency, " + dependson + " not found"); - - var dllname = ' php_' + extname + '.dll'; - - if (!REMOVE_TARGET(dllname, 'EXT_TARGETS')) { - REMOVE_TARGET(dllname, 'PECL_TARGETS'); - } - - return false; - - } - - ERROR("Cannot build " + extname + "; " + dependson + " not enabled"); - return false; - } - } // dependency is statically built-in to PHP - return true; -} - -var static_pgo_enabled = false; - -function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir) -{ - var objs = null; - var EXT = extname.toUpperCase(); - var extname_for_printing; - var ldflags; - - if (shared == null) { - eval("shared = PHP_" + EXT + "_SHARED;"); - } else { - eval("PHP_" + EXT + "_SHARED = shared;"); - } - - if (cflags == null) { - cflags = ""; - } - - if (typeof(obj_dir) == "undefined") { - extname_for_printing = configure_module_dirname; - } else { - extname_for_printing = configure_module_dirname + " (via " + obj_dir + ")"; - } - - if (shared) { - STDOUT.WriteLine("Enabling extension " + extname_for_printing + " [shared]"); - cflags = "/D COMPILE_DL_" + EXT + " /D " + EXT + "_EXPORTS=1 " + cflags; - ADD_FLAG("CFLAGS_PHP", "/D COMPILE_DL_" + EXT); - } else { - STDOUT.WriteLine("Enabling extension " + extname_for_printing); - } - - MFO.WriteBlankLines(1); - MFO.WriteLine("# objects for EXT " + extname); - MFO.WriteBlankLines(1); - - ADD_SOURCES(configure_module_dirname, file_list, extname, obj_dir); - - MFO.WriteBlankLines(1); - - if (shared) { - if (dllname == null) { - dllname = "php_" + extname + ".dll"; - } - var libname = dllname.substring(0, dllname.length-4) + ".lib"; - - var resname = generate_version_info_resource(dllname, extname, configure_module_dirname, false); - var ld = "@$(CC)"; - - ldflags = ""; - if (is_pgo_desired(extname) && (PHP_PGI == "yes" || PHP_PGO != "no")) { - // Add compiler and link flags if PGO options are selected - if (PHP_DEBUG != "yes" && PHP_PGI == "yes") { - ADD_FLAG('LDFLAGS_' + EXT, "/LTCG:PGINSTRUMENT"); - } - else if (PHP_DEBUG != "yes" && PHP_PGO != "no") { - ADD_FLAG('LDFLAGS_' + EXT, "/LTCG:PGUPDATE"); - } - - ADD_FLAG('CFLAGS_' + EXT, "/GL /O2"); - - ldflags = " /PGD:$(PGOPGD_DIR)\\" + dllname.substring(0, dllname.indexOf(".")) + ".pgd"; - } - - MFO.WriteLine("$(BUILD_DIR)\\" + libname + ": $(BUILD_DIR)\\" + dllname); - MFO.WriteBlankLines(1); - if (MODE_PHPIZE) { - MFO.WriteLine("$(BUILD_DIR)\\" + dllname + ": $(DEPS_" + EXT + ") $(" + EXT + "_GLOBAL_OBJS) $(PHPLIB) $(BUILD_DIR)\\" + resname); - MFO.WriteLine("\t" + ld + " $(" + EXT + "_GLOBAL_OBJS) $(PHPLIB) $(LIBS_" + EXT + ") $(LIBS) $(BUILD_DIR)\\" + resname + " /link /out:$(BUILD_DIR)\\" + dllname + " $(DLL_LDFLAGS) $(LDFLAGS) $(LDFLAGS_" + EXT + ")"); - } else { - MFO.WriteLine("$(BUILD_DIR)\\" + dllname + ": $(DEPS_" + EXT + ") $(" + EXT + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(BUILD_DIR)\\" + resname); - MFO.WriteLine("\t" + ld + " $(" + EXT + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LIBS_" + EXT + ") $(LIBS) $(BUILD_DIR)\\" + resname + " /link /out:$(BUILD_DIR)\\" + dllname + ldflags + " $(DLL_LDFLAGS) $(LDFLAGS) $(LDFLAGS_" + EXT + ")"); - } - MFO.WriteLine("\t-@$(_VC_MANIFEST_EMBED_DLL)"); - MFO.WriteBlankLines(1); - - if (configure_module_dirname.match("pecl")) { - ADD_FLAG("PECL_TARGETS", dllname); - } else { - ADD_FLAG("EXT_TARGETS", dllname); - } - MFO.WriteLine(dllname + ": $(BUILD_DIR)\\" + dllname); - MFO.WriteLine("\t@echo EXT " + extname + " build complete"); - MFO.WriteBlankLines(1); - - DEFINE('CFLAGS_' + EXT + '_OBJ', '$(CFLAGS_' + EXT + ')'); - } else { - ADD_FLAG("STATIC_EXT_OBJS", "$(" + EXT + "_GLOBAL_OBJS)"); - ADD_FLAG("STATIC_EXT_LIBS", "$(LIBS_" + EXT + ")"); - ADD_FLAG("STATIC_EXT_LDFLAGS", "$(LDFLAGS_" + EXT + ")"); - ADD_FLAG("STATIC_EXT_CFLAGS", "$(CFLAGS_" + EXT + ")"); - if (is_pgo_desired(extname) && (PHP_PGI == "yes" || PHP_PGO != "no")) { - if (!static_pgo_enabled) { - if (PHP_DEBUG != "yes" && PHP_PGI == "yes") { - ADD_FLAG('STATIC_EXT_LDFLAGS', "/LTCG:PGINSTRUMENT"); - } - else if (PHP_DEBUG != "yes" && PHP_PGO != "no") { - ADD_FLAG('STATIC_EXT_LDFLAGS', "/LTCG:PGUPDATE"); - } - - ADD_FLAG("STATIC_EXT_CFLAGS", "/GL /O2"); - static_pgo_enabled = true; - } - } - - /* find the header that declares the module pointer, - * so we can include it in internal_functions.c */ - var ext_dir = FSO.GetFolder(configure_module_dirname); - var fc = new Enumerator(ext_dir.Files); - var re = /\.h$/; - var s, c; - for (; !fc.atEnd(); fc.moveNext()) { - s = fc.item() + ""; - if (s.match(re)) { - c = file_get_contents(s); - if (c.match("phpext_")) { - extension_include_code += '#include "' + configure_module_dirname + '/' + FSO.GetFileName(s) + '"\r\n'; - } - } - } - - extension_module_ptrs += '\tphpext_' + extname + '_ptr,\r\n'; - - DEFINE('CFLAGS_' + EXT + '_OBJ', '$(CFLAGS_PHP) $(CFLAGS_' + EXT + ')'); - } - if (MODE_PHPIZE && FSO.FileExists(PHP_DIR + "/include/main/config.pickle.h")) { - cflags = "/FI main/config.pickle.h " + cflags; - } - ADD_FLAG("CFLAGS_" + EXT, cflags); - - extensions_enabled[extensions_enabled.length] = [extname, shared ? 'shared' : 'static']; -} - -function ADD_SOURCES(dir, file_list, target, obj_dir) -{ - var i; - var tv; - var src, obj, sym, flags; - - if (target == null) { - target = "php"; - } - - sym = target.toUpperCase() + "_GLOBAL_OBJS"; - flags = "CFLAGS_" + target.toUpperCase() + '_OBJ'; - - if (configure_subst.Exists(sym)) { - tv = configure_subst.Item(sym); - } else { - tv = ""; - } - - file_list = file_list.split(new RegExp("\\s+")); - file_list.sort(); - - var re = new RegExp("\.[a-z0-9A-Z]+$"); - - dir = dir.replace(new RegExp("/", "g"), "\\"); - var objs_line = ""; - var srcs_line = ""; - - var sub_build = "$(BUILD_DIR)\\"; - - /* if module dir is not a child of the main source dir, - * we need to tweak it; we should have detected such a - * case in condense_path and rewritten the path to - * be relative. - * This probably breaks for non-sibling dirs, but that - * is not a problem as buildconf only checks for pecl - * as either a child or a sibling */ - if (obj_dir == null) { - var build_dir = dir.replace(new RegExp("^..\\\\"), ""); - var mangle_dir = build_dir.replace(new RegExp("[\\\\/.-]", "g"), "_"); - var bd_flags_name = "CFLAGS_BD_" + mangle_dir.toUpperCase(); - } - else { - var build_dir = obj_dir.replace(new RegExp("^..\\\\"), ""); - var mangle_dir = build_dir.replace(new RegExp("[\\\\/.-]", "g"), "_"); - var bd_flags_name = "CFLAGS_BD_" + mangle_dir.toUpperCase(); - } - - var dirs = build_dir.split("\\"); - var i, d = ""; - for (i = 0; i < dirs.length; i++) { - d += dirs[i]; - build_dirs[build_dirs.length] = d; - d += "\\"; - } - sub_build += d; - - - DEFINE(bd_flags_name, " /Fd" + sub_build + " /Fp" + sub_build + " /FR" + sub_build + " "); - - for (i in file_list) { - src = file_list[i]; - obj = src.replace(re, ".obj"); - tv += " " + sub_build + obj; - - if (!PHP_MP_DISABLED) { - if (i > 0) { - objs_line += " " + sub_build + obj; - srcs_line += " " + dir + "\\" + src; - } else { - objs_line = sub_build + obj; - srcs_line = dir + "\\" + src; - } - } else { - MFO.WriteLine(sub_build + obj + ": " + dir + "\\" + src); - - if (PHP_ANALYZER == "pvs") { - MFO.WriteLine("\t@\"$(PVS_STUDIO)\" --cl-params $(" + flags + ") $(CFLAGS) $(" + bd_flags_name + ") /c " + dir + "\\" + src + " --source-file " + dir + "\\" + src - + " --cfg PVS-Studio.conf --errors-off \"V122 V117 V111\" "); - } - MFO.WriteLine("\t@$(CC) $(" + flags + ") $(CFLAGS) $(" + bd_flags_name + ") /c " + dir + "\\" + src + " /Fo" + sub_build + obj); - } - } - - if (!PHP_MP_DISABLED) { - MFO.WriteLine(objs_line + ": " + srcs_line); - MFO.WriteLine("\t$(CC) $(" + flags + ") $(CFLAGS) /Fo" + sub_build + " $(" + bd_flags_name + ") /c " + srcs_line); - } - - DEFINE(sym, tv); -} - -function REMOVE_TARGET(dllname, flag) -{ - var dllname = dllname.replace(/\s/g, ""); - var EXT = dllname.replace(/php_(\S+)\.dll/, "$1").toUpperCase(); - var php_flags = configure_subst.Item("CFLAGS_PHP"); - - if (configure_subst.Exists(flag)) { - var targets = configure_subst.Item(flag); - - if (targets.match(dllname)) { - configure_subst.Remove(flag); - targets = targets.replace(dllname, ""); - targets = targets.replace(/\s+/, " "); - targets = targets.replace(/\s$/, ""); - configure_subst.Add(flag, targets); - configure_hdr.Add("HAVE_" + EXT, new Array(0, "")); - configure_subst.Item("CFLAGS_PHP") = php_flags.replace(" /D COMPILE_DL_" + EXT, ""); - extensions_enabled.pop(); - return true; - } - } - return false; -} - -function generate_internal_functions() -{ - var infile, outfile; - var indata; - - STDOUT.WriteLine("Generating main/internal_functions.c"); - - infile = FSO.OpenTextFile("main/internal_functions.c.in", 1); - indata = infile.ReadAll(); - infile.Close(); - - indata = indata.replace("@EXT_INCLUDE_CODE@", extension_include_code); - indata = indata.replace("@EXT_MODULE_PTRS@", extension_module_ptrs); - - if (FSO.FileExists("main/internal_functions.c")) { - var origdata = file_get_contents("main/internal_functions.c"); - - if (origdata == indata) { - STDOUT.WriteLine("\t[content unchanged; skipping]"); - return; - } - } - - outfile = FSO.CreateTextFile("main/internal_functions.c", true); - outfile.Write(indata); - outfile.Close(); -} - -function output_as_table(header, ar_out) -{ - var l = header.length; - var cols = 80; - var fixedlength = ""; - var t = 0; - var i,j,k,m; - var out = "| "; - var min = new Array(l); - var max = new Array(l); - - if (!!ar_out[0] && l != ar_out[0].length) { - STDOUT.WriteLine("Invalid header argument, can't output the table " + l + " " + ar_out[0].length ); - return; - } - - for (j=0; j < l; j++) { - var tmax, tmin; - - /*Figure out the max length per column */ - tmin = 0; - tmax = 0; - for (k = 0; k < ar_out.length; k++) { - if(typeof ar_out[k][j] != 'undefined') { - var t = ar_out[k][j].length; - if (t > tmax) tmax = t; - else if (t < tmin) tmin = t; - } - } - if (tmax > header[j].length) { - max[j] = tmax; - } else { - max[j] = header[j].length; - } - if (tmin < header[j].length) { - min[j] = header[j].length; - } - } - - sep = ""; - k = 0; - for (i = 0; i < l; i++) { - k += max[i] + 3; - } - k++; - - for (j=0; j < k; j++) { - sep += "-"; - } - - STDOUT.WriteLine(sep); - out = "|"; - for (j=0; j < l; j++) { - out += " " + header[j]; - for (var i = 0; i < (max[j] - header[j].length); i++){ - out += " "; - } - out += " |"; - } - STDOUT.WriteLine(out); - - STDOUT.WriteLine(sep); - - out = "|"; - for (i=0; i < ar_out.length; i++) { - line = ar_out[i]; - for (j=0; j < l; j++) { - out += " " + line[j]; - if(typeof line[j] != 'undefined') { - for (var k = 0; k < (max[j] - line[j].length); k++){ - out += " "; - } - } - out += " |"; - } - STDOUT.WriteLine(out); - out = "|"; - } - - STDOUT.WriteLine(sep); -} - -function write_summary() -{ - var ar = new Array(); - - STDOUT.WriteBlankLines(2); - - STDOUT.WriteLine("Enabled extensions:"); - output_as_table(["Extension", "Mode"], extensions_enabled.sort()); - STDOUT.WriteBlankLines(2); - if (!MODE_PHPIZE) { - STDOUT.WriteLine("Enabled SAPI:"); - output_as_table(["Sapi Name"], sapi_enabled); - STDOUT.WriteBlankLines(2); - } - ar[0] = ['Build type', PHP_DEBUG == "yes" ? "Debug" : "Release"]; - ar[1] = ['Thread Safety', PHP_ZTS == "yes" ? "Yes" : "No"]; - ar[2] = ['Compiler', VC_VERSIONS[VCVERS]]; - ar[3] = ['Architecture', X64 ? 'x64' : 'x86']; - if (PHP_PGO == "yes") { - ar[4] = ['Optimization', "PGO"]; - } else if (PHP_PGI == "yes") { - ar[4] = ['Optimization', "PGI"]; - } else { - ar[4] = ['Optimization', PHP_DEBUG == "yes" ? "disabled" : "PGO disabled"]; - } - if (PHP_ANALYZER == "vs") { - ar[5] = ['Static analyzer', 'Visual Studio']; - } else if (PHP_ANALYZER == "pvs") { - ar[5] = ['Static analyzer', 'PVS-Studio']; - } else { - ar[5] = ['Static analyzer', 'disabled']; - } - - output_as_table(["",""], ar); - STDOUT.WriteBlankLines(2); -} - -function generate_files() -{ - var i, dir, bd, last; - - STDOUT.WriteBlankLines(1); - STDOUT.WriteLine("Creating build dirs..."); - dir = get_define("BUILD_DIR"); - build_dirs.sort(); - last = null; - - if (!FSO.FolderExists(dir)) { - FSO.CreateFolder(dir); - } - - for (i = 0; i < build_dirs.length; i++) { - bd = FSO.BuildPath(dir, build_dirs[i]); - if (bd == last) { - continue; - } - last = bd; - - build_dir = get_define('BUILD_DIR'); - build_dir = build_dir.replace(new RegExp("\\\\", "g"), "\\\\"); - if (build_dir.substr(build_dir.Length - 2, 2) != '\\\\') { - build_dir += '\\\\'; - } - ADD_FLAG("BUILD_DIRS_SUB", bd.replace(new RegExp(build_dir), '')); - - if (!FSO.FolderExists(bd)) { - FSO.CreateFolder(bd); - } - } - - STDOUT.WriteLine("Generating files..."); - generate_makefile(); - if (!MODE_PHPIZE) { - generate_internal_functions(); - generate_config_h(); - generate_phpize(); - } else { - generate_config_pickle_h(); - generate_ext_pickle(); - } - STDOUT.WriteLine("Done."); - STDOUT.WriteBlankLines(1); - write_summary(); - - if (PHP_SNAPSHOT_BUILD != "no") { - STDOUT.WriteLine("Type 'nmake snap' to build a PHP snapshot"); - } else { - STDOUT.WriteLine("Type 'nmake' to build PHP"); - } -} - -function generate_ext_pickle() -{ - var content; - var DEPS = null; - var dest; - var deps_lines = new Array(); - - var build_var_name = function(name) { - return "PHP_" + name.toUpperCase(); - } - - STDOUT.WriteLine("Generating pickle deps"); - dest = PHP_DIR + "/script/"; - - if (!FSO.FolderExists(dest)) { - FSO.CreateFolder(dest); - } - - if (FSO.FileExists(dest + "/ext_pickle.js")) { - DEPS = FSO.OpenTextFile(dest + "/ext_pickle.js", 1); - - while (!DEPS.AtEndOfStream) { - var ln = DEPS.ReadLine(); - var found = false; - - for (var i in extensions_enabled) { - var reg0 = new RegExp(build_var_name(extensions_enabled[i][0]) + "\s*=.+", "g"); - var reg1 = new RegExp(build_var_name(extensions_enabled[i][0]) + "_SHARED" + "\s*=.+", "g"); - - if (ln.match(reg1) || ln.match(reg0)) { - found = true; - break; - } - } - - if (!found) { - deps_lines.push(ln); - } - } - } - - for (var i in extensions_enabled) { - deps_lines.push(build_var_name(extensions_enabled[i][0]) + "=true;"); - deps_lines.push(build_var_name(extensions_enabled[i][0]) + "_SHARED=" + (extensions_enabled[i][1] == 'shared' ? 'true' : 'false') + ";"); - } - - if (!!DEPS) { - DEPS.Close(); - DEPS = null; - } - - /* Replace the ext_pickle.js with the new content */ - DEPS = FSO.CreateTextFile(dest + "/ext_pickle.js", true); - - for (var j in deps_lines) { - DEPS.WriteLine(deps_lines[j]); - } - - DEPS.Close(); -} - -function generate_config_pickle_h() -{ - var outfile = null; - var lines = new Array(); - var keys = (new VBArray(configure_hdr.Keys())).toArray(); - dest = PHP_DIR + "/include/main"; - - var ignore_key = function(key) { - var ignores = [ "CONFIGURE_COMMAND", "PHP_COMPILER_ID", "COMPILER", "ARCHITECTURE", "HAVE_STRNLEN", "PHP_DIR" ]; - - for (var k in ignores) { - if (ignores[k] == key) { - return true; - } - } - - return false; - } - - - STDOUT.WriteLine("Generating main/config.pickle.h"); - - if (FSO.FileExists(dest + "/config.pickle.h")) { - outfile = FSO.OpenTextFile(dest + "/config.pickle.h", 1); - - while (!outfile.AtEndOfStream) { - var found = false; - var ln = outfile.ReadLine(); - - for (var i in keys) { - var reg = new RegExp("#define[\s ]+" + keys[i] + "[\s ]*.*", "g"); - - if (ln.match(reg)) { - found = true; - break; - } - } - - if (!found) { - lines.push(ln); - } - } - } - - for (var i in keys) { - var item = configure_hdr.Item(keys[i]); - - if (ignore_key(keys[i])) { - continue; - } - - /* XXX fix comment handling */ - /*if (!lines[j].match(/^#define.+/g)) { - continue; - }*/ - - lines.push("#define " + keys[i] + " " + item[0]); - } - - if (outfile) { - outfile.Close(); - outfile = null; - } - - outfile = FSO.CreateTextFile(dest + "/config.pickle.h", true); - - for (var k in lines) { - outfile.WriteLine(lines[k]); - } - - outfile.Close(); -} - -function generate_config_h() -{ - var infile, outfile; - var indata; - var prefix; - - prefix = PHP_PREFIX.replace(new RegExp("\\\\", "g"), "\\\\"); - - STDOUT.WriteLine("Generating main/config.w32.h"); - - infile = FSO.OpenTextFile("win32/build/config.w32.h.in", 1); - indata = infile.ReadAll(); - infile.Close(); - - outfile = FSO.CreateTextFile("main/config.w32.h", true); - - indata = indata.replace(new RegExp("@PREFIX@", "g"), prefix); - outfile.Write(indata); - - var keys = (new VBArray(configure_hdr.Keys())).toArray(); - var i, j; - var item; - var pieces, stuff_to_crack, chunk; - - outfile.WriteBlankLines(1); - outfile.WriteLine("/* values determined by configure.js */"); - - for (i in keys) { - item = configure_hdr.Item(keys[i]); - outfile.WriteBlankLines(1); - pieces = item[0]; - - if (item[1] != undefined) { - outfile.WriteLine("/* " + item[1] + " */"); - } - - if (typeof(pieces) == "string" && pieces.charCodeAt(0) == 34) { - /* quoted string have a maximal length of 2k under vc. - * solution is to crack them and let the compiler concat - * them implicitly */ - stuff_to_crack = pieces; - pieces = ""; - - while (stuff_to_crack.length) { - j = 65; - while (stuff_to_crack.charCodeAt(j) != 32 && j < stuff_to_crack.length) - j++; - - chunk = stuff_to_crack.substr(0, j); - pieces += chunk; - stuff_to_crack = stuff_to_crack.substr(chunk.length); - if (stuff_to_crack.length) - pieces += '" "'; - } - } - - outfile.WriteLine("#define " + keys[i] + " " + pieces); - } - - if (VCVERS >= 1800) { - outfile.WriteLine(""); - outfile.WriteLine("#define HAVE_ACOSH 1"); - outfile.WriteLine("#define HAVE_ASINH 1"); - outfile.WriteLine("#define HAVE_ATANH 1"); - } - - - outfile.Close(); -} - -function generate_phpize() -{ - STDOUT.WriteLine("Generating phpize"); - dest = get_define("BUILD_DIR") + '/devel'; - - if (!FSO.FolderExists(dest)) { - FSO.CreateFolder(dest); - } - - var MF = FSO.CreateTextFile(dest + "/phpize.js", true); - var DEPS = FSO.CreateTextFile(dest + "/ext_deps.js", true); - - prefix = get_define("PHP_PREFIX"); - prefix = prefix.replace(new RegExp("/", "g"), "\\"); - prefix = prefix.replace(new RegExp("\\\\", "g"), "\\\\"); - MF.WriteLine("var PHP_PREFIX=" + '"' + prefix + '"'); - MF.WriteLine("var PHP_ZTS=" + '"' + (PHP_ZTS.toLowerCase() == "yes" ? "Yes" : "No") + '"'); - MF.WriteLine("var VC_VERSION=" + VCVERS); - MF.WriteLine("var PHP_VERSION=" + PHP_VERSION); - MF.WriteLine("var PHP_MINOR_VERSION=" + PHP_MINOR_VERSION); - MF.WriteLine("var PHP_RELEASE_VERSION=" + PHP_RELEASE_VERSION); - MF.WriteBlankLines(1); - MF.WriteLine("/* Genereted extensions list with mode (static/shared) */"); - - var count = extensions_enabled.length; - for (i in extensions_enabled) { - out = "PHP_" + extensions_enabled[i][0].toUpperCase() + "_SHARED=" + (extensions_enabled[i][1] == 'shared' ? 'true' : 'false') + ";"; - DEPS.WriteLine("PHP_" + extensions_enabled[i][0].toUpperCase() + "=true;"); - DEPS.WriteLine(out); - MF.WriteLine(out); - } - - MF.WriteBlankLines(2); - MF.WriteLine("/* Genereted win32/build/phpize.js.in */"); - MF.WriteBlankLines(1); - MF.Write(file_get_contents("win32/build/phpize.js.in")); - MF.Close(); - DEPS.Close(); - - /* Generate flags file */ - /* spit out variable definitions */ - CJ = FSO.CreateTextFile(dest + "/config.phpize.js"); - - CJ.WriteLine("var PHP_ZTS =" + '"' + PHP_ZTS + '"'); - CJ.WriteLine("var PHP_DLL_LIB =" + '"' + get_define('PHPLIB') + '"'); - CJ.WriteLine("var PHP_DLL =" + '"' + get_define('PHPDLL') + '"'); - CJ.WriteBlankLines(1); - CJ.Close(); -} - -function generate_makefile() -{ - STDOUT.WriteLine("Generating Makefile"); - var MF = FSO.CreateTextFile("Makefile", true); - - MF.WriteLine("# Generated by configure.js"); - /* spit out variable definitions */ - var keys = (new VBArray(configure_subst.Keys())).toArray(); - var i; - MF.WriteLine("PHP_SRC_DIR =" + PHP_SRC_DIR); - for (i in keys) { - // The trailing space is needed to prevent the trailing backslash - // that is part of the build dir flags (CFLAGS_BD_XXX) from being - // seen as a line continuation character - MF.WriteLine(keys[i] + "=" + - //word_wrap_and_indent(1, configure_subst.Item(keys[i]), ' \\', '\t') + " " - configure_subst.Item(keys[i]) + " " - ); - MF.WriteBlankLines(1); - } - - MF.WriteBlankLines(1); - if (MODE_PHPIZE) { - var TF = FSO.OpenTextFile(PHP_DIR + "/script/Makefile.phpize", 1); - } else { - var TF = FSO.OpenTextFile("win32/build/Makefile", 1); - } - - MF.Write(TF.ReadAll()); - - MF.WriteLine("build-headers:"); - MF.WriteLine(" @if not exist $(BUILD_DIR_DEV)\\include mkdir $(BUILD_DIR_DEV)\\include >nul"); - MF.WriteLine(" @for %D in ($(INSTALL_HEADERS_DIR)) do @if not exist $(BUILD_DIR_DEV)\\include\\%D mkdir $(BUILD_DIR_DEV)\\include\\%D >nul"); - for (i in headers_install) { - if (headers_install[i][2] != "") { - MF.WriteLine(" @if not exist $(BUILD_DIR_DEV)\\include\\" + headers_install[i][2] + " mkdir $(BUILD_DIR_DEV)\\include\\" + - headers_install[i][2] + ">nul"); - MF.WriteLine(" @copy " + headers_install[i][0] + " " + "$(BUILD_DIR_DEV)\\include\\" + headers_install[i][2] + " /y >nul"); - } - } - MF.WriteLine(" @for %D in ($(INSTALL_HEADERS_DIR)) do @copy %D*.h $(BUILD_DIR_DEV)\\include\\%D /y >nul"); - if (MODE_PHPIZE) { - MF.WriteBlankLines(1); - MF.WriteLine("build-bins:"); - for (var i in extensions_enabled) { - var lib = "php_" + extensions_enabled[i][0] + ".lib"; - var dll = "php_" + extensions_enabled[i][0] + ".dll"; - MF.WriteLine(" @copy $(BUILD_DIR)\\" + lib + " $(BUILD_DIR_DEV)\\lib"); - MF.WriteLine(" @copy $(BUILD_DIR)\\" + dll + " $(PHP_PREFIX)"); - } - } else { - MF.WriteBlankLines(1); - MF.WriteLine("build-ext-libs:"); - MF.WriteLine(" @if not exist $(BUILD_DIR_DEV)\\lib mkdir $(BUILD_DIR_DEV)\\lib >nul"); - for (var i in extensions_enabled) { - var lib; - - lib = "php_" + extensions_enabled[i][0] + "*.lib"; - - if ('shared' == extensions_enabled[i][1]) { - MF.WriteLine(" @if exist $(BUILD_DIR)\\" + lib + " copy $(BUILD_DIR)\\" + lib + " $(BUILD_DIR_DEV)\\lib"); - } - } - } - TF.Close(); - - MF.WriteBlankLines(2); - - MFO.Close(); - TF = FSO.OpenTextFile("Makefile.objects", 1); - if (!TF.AtEndOfStream) { - MF.Write(TF.ReadAll()); - } - TF.Close(); - - MF.Close(); -} - -function ADD_FLAG(name, flags, target) -{ - if (target != null) { - name = target.toUpperCase() + "_" + name; - } - if (configure_subst.Exists(name)) { - var curr_flags = configure_subst.Item(name); - - if (curr_flags.indexOf(flags) >= 0) { - return; - } - - flags = curr_flags + " " + flags; - configure_subst.Remove(name); - } - configure_subst.Add(name, flags); -} - -function get_define(name) -{ - if (configure_subst.Exists(name)) { - return configure_subst.Item(name); - } - return ""; -} - -// Add a .def to the core to export symbols -function ADD_DEF_FILE(name) -{ - if (!configure_subst.Exists("PHPDEF")) { - DEFINE("PHPDEF", "$(BUILD_DIR)\\$(PHPDLL).def"); - ADD_FLAG("PHP_LDFLAGS", "/def:$(PHPDEF)"); - } - ADD_FLAG("PHP_DLL_DEF_SOURCES", name); -} - -function AC_DEFINE(name, value, comment, quote) -{ - if (quote == null) { - quote = true; - } - if (quote && typeof(value) == "string") { - value = '"' + value.replace(new RegExp('(["\\\\])', "g"), '\\$1') + '"'; - } else if (typeof(value) != "undefined" && value.length == 0) { - value = '""'; - } - var item = new Array(value, comment); - if (configure_hdr.Exists(name)) { - var orig_item = configure_hdr.Item(name); - STDOUT.WriteLine("AC_DEFINE[" + name + "]=" + value + ": is already defined to " + orig_item[0]); - } else { - configure_hdr.Add(name, item); - } -} - -function MESSAGE(msg) -{ - STDOUT.WriteLine("" + msg); -} - -function ERROR(msg) -{ - STDERR.WriteLine("ERROR: " + msg); - WScript.Quit(3); -} - -function WARNING(msg) -{ - STDERR.WriteLine("WARNING: " + msg); - STDERR.WriteBlankLines(1); -} - -function copy_and_subst(srcname, destname, subst_array) -{ - if (!FSO.FileExists(srcname)) { - srcname = configure_module_dirname + "\\" + srcname; - destname = configure_module_dirname + "\\" + destname; - } - - var content = file_get_contents(srcname); - var i; - - for (i = 0; i < subst_array.length; i+=2) { - var re = subst_array[i]; - var rep = subst_array[i+1]; - - content = content.replace(re, rep); - } - - var f = FSO.CreateTextFile(destname, true); - f.Write(content); - f.Close(); -} - -// glob using simple filename wildcards -// returns an array of matches that are found -// in the filesystem -function glob(path_pattern) -{ - var path_parts = path_pattern.replace(new RegExp("/", "g"), "\\").split("\\"); - var p; - var base = ""; - var is_pat_re = /\*/; - -//STDOUT.WriteLine("glob: " + path_pattern); - - if (FSO.FileExists(path_pattern)) { - return new Array(path_pattern); - } - - // first, build as much as possible that doesn't have a pattern - for (p = 0; p < path_parts.length; p++) { - if (path_parts[p].match(is_pat_re)) - break; - if (p) - base += "\\"; - base += path_parts[p]; - } - - return _inner_glob(base, p, path_parts); -} - -function _inner_glob(base, p, parts) -{ - var pat = parts[p]; - var full_name = base + "\\" + pat; - var re = null; - var items = null; - - if (p == parts.length) { - return false; - } - -//STDOUT.WriteLine("inner: base=" + base + " p=" + p + " pat=" + pat); - - if (FSO.FileExists(full_name)) { - if (p < parts.length - 1) { - // we didn't reach the full extent of the pattern - return false; - } - return new Array(full_name); - } - - if (FSO.FolderExists(full_name) && p == parts.length - 1) { - // we have reached the end of the pattern; no need to recurse - return new Array(full_name); - } - - // Convert the pattern into a regexp - re = new RegExp("^" + pat.replace(/\./g, '\\.').replace(/\*/g, '.*').replace(/\?/g, '.') + "$", "i"); - - items = new Array(); - - if (!FSO.FolderExists(base)) { - return false; - } - - var folder = FSO.GetFolder(base); - var fc = null; - var subitems = null; - var item_name = null; - var j; - - fc = new Enumerator(folder.SubFolders); - for (; !fc.atEnd(); fc.moveNext()) { - item_name = FSO.GetFileName(fc.item()); - - if (item_name.match(re)) { - // got a match; if we are at the end of the pattern, just add these - // things to the items array - if (p == parts.length - 1) { - items[items.length] = fc.item(); - } else { - // we should recurse and do more matches - subitems = _inner_glob(base + "\\" + item_name, p + 1, parts); - if (subitems) { - for (j = 0; j < subitems.length; j++) { - items[items.length] = subitems[j]; - } - } - } - } - } - - // if we are at the end of the pattern, we should match - // files too - if (p == parts.length - 1) { - fc = new Enumerator(folder.Files); - for (; !fc.atEnd(); fc.moveNext()) { - item_name = FSO.GetFileName(fc.item()); - if (item_name.match(re)) { - items[items.length] = fc.item(); - } - } - } - - if (items.length == 0) - return false; - - return items; -} - -function PHP_INSTALL_HEADERS(dir, headers_list) -{ - headers_list = headers_list.split(new RegExp("\\s+")); - headers_list.sort(); - if (dir.length > 0 && dir.substr(dir.length - 1) != '/' && dir.substr(dir.length - 1) != '\\') { - dir += '/'; - } - dir = dir.replace(new RegExp("/", "g"), "\\"); - - for (i in headers_list) { - found = false; - src = headers_list[i]; - src = src.replace(new RegExp("/", "g"), "\\"); - isdir = FSO.FolderExists(dir + src); - isfile = FSO.FileExists(dir + src); - if (isdir) { - if (src.length > 0 && src.substr(src.length - 1) != '/' && src.substr(src.length - 1) != '\\') { - src += '\\'; - } - headers_install[headers_install.length] = [dir + src, 'dir','']; - ADD_FLAG("INSTALL_HEADERS_DIR", dir + src); - found = true; - } else if (isfile) { - dirname = FSO.GetParentFolderName(dir + src); - headers_install[headers_install.length] = [dir + src, 'file', dirname]; - ADD_FLAG("INSTALL_HEADERS", dir + src); - found = true; - } else { - path = configure_module_dirname + "\\"+ src; - isdir = FSO.FolderExists(path); - isfile = FSO.FileExists(path); - if (isdir) { - if (src.length > 0 && src.substr(src.length - 1) != '/' && src.substr(src.length - 1) != '\\') { - src += '\\'; - } - headers_install[headers_install.length] = [path, 'dir','']; - ADD_FLAG("INSTALL_HEADERS_DIR", path); - } else if (isfile) { - dirname = FSO.GetParentFolderName(path); - headers_install[headers_install.length] = [path, 'file', dir]; - ADD_FLAG("INSTALL_HEADERS", dir + src); - found = true; - } - } - - if (found == false) { - STDOUT.WriteLine(headers_list); - ERROR("Cannot find header " + dir + src); - } - } -} - -// for snapshot builders, this option will attempt to enable everything -// and you can then build everything, ignoring fatal errors within a module -// by running "nmake snap" -PHP_SNAPSHOT_BUILD = "no"; -if (!MODE_PHPIZE) { - ARG_ENABLE('snapshot-build', 'Build a snapshot; turns on everything it can and ignores build errors', 'no'); - - // one-shot build optimizes build by asking compiler to build - // several objects at once, reducing overhead of starting new - // compiler processes. - ARG_ENABLE('one-shot', 'Optimize for fast build - best for release and snapshot builders, not so hot for edit-and-rebuild hacking', 'no'); -} - +// Utils for configure script +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2008 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Wez Furlong | + +----------------------------------------------------------------------+ +*/ + +// $Id: confutils.js,v 1.60.2.1.2.8.2.33 2009-05-29 07:43:07 kalle Exp $ + +var STDOUT = WScript.StdOut; +var STDERR = WScript.StdErr; +var WshShell = WScript.CreateObject("WScript.Shell"); +var FSO = WScript.CreateObject("Scripting.FileSystemObject"); +var MFO = null; +var SYSTEM_DRIVE = WshShell.Environment("Process").Item("SystemDrive"); +var PROGRAM_FILES = WshShell.Environment("Process").Item("ProgramFiles"); +var PROGRAM_FILESx86 = WshShell.Environment("Process").Item("ProgramFiles(x86)"); +var VCINSTALLDIR = WshShell.Environment("Process").Item("VCINSTALLDIR"); +var PHP_SRC_DIR=FSO.GetParentFolderName(WScript.ScriptFullName); + +var VS_TOOLSET = true; +var CLANG_TOOLSET = false; +var INTEL_TOOLSET = false; +var VCVERS = -1; +var CLANGVERS = -1; +var INTELVERS = -1; +var COMPILER_NUMERIC_VERSION = -1; +var COMPILER_NAME = "unknown"; + +/* Store the enabled extensions (summary + QA check) */ +var extensions_enabled = new Array(); + +/* Store the SAPI enabled (summary + QA check) */ +var sapi_enabled = new Array(); + +/* Store the headers to install */ +var headers_install = new Array(); + +/* Mapping CL version > human readable name */ +var VC_VERSIONS = new Array(); +VC_VERSIONS[1200] = 'MSVC6 (Visual C++ 6.0)'; +VC_VERSIONS[1300] = 'MSVC7 (Visual C++ 2002)'; +VC_VERSIONS[1310] = 'MSVC7.1 (Visual C++ 2003)'; +VC_VERSIONS[1400] = 'MSVC8 (Visual C++ 2005)'; +VC_VERSIONS[1500] = 'MSVC9 (Visual C++ 2008)'; +VC_VERSIONS[1600] = 'MSVC10 (Visual C++ 2010)'; +VC_VERSIONS[1700] = 'MSVC11 (Visual C++ 2012)'; +VC_VERSIONS[1800] = 'MSVC12 (Visual C++ 2013)'; +/* XXX update after the final rename */ +VC_VERSIONS[1900] = 'MSVC14 (Visual C++ CTP14)'; + +var VC_VERSIONS_SHORT = new Array(); +VC_VERSIONS_SHORT[1200] = 'VC6'; +VC_VERSIONS_SHORT[1300] = 'VC7'; +VC_VERSIONS_SHORT[1310] = 'VC7.1'; +VC_VERSIONS_SHORT[1400] = 'VC8'; +VC_VERSIONS_SHORT[1500] = 'VC9'; +VC_VERSIONS_SHORT[1600] = 'VC10'; +VC_VERSIONS_SHORT[1700] = 'VC11'; +VC_VERSIONS_SHORT[1800] = 'VC12'; +VC_VERSIONS_SHORT[1900] = 'VC14'; + +if (PROGRAM_FILES == null) { + PROGRAM_FILES = "C:\\Program Files"; +} + +if (MODE_PHPIZE) { + if (!FSO.FileExists("config.w32")) { + STDERR.WriteLine("Must be run from the root of the extension source"); + WScript.Quit(10); + } +} else { + if (!FSO.FileExists("README.GIT-RULES")) { + STDERR.WriteLine("Must be run from the root of the php source"); + WScript.Quit(10); + } +} + +var CWD = WshShell.CurrentDirectory; + +if (typeof(CWD) == "undefined") { + CWD = FSO.GetParentFolderName(FSO.GetAbsolutePathName("README.GIT-RULES")); +} + +/* defaults; we pick up the precise versions from configure.in */ +var PHP_VERSION = 5; +var PHP_MINOR_VERSION = 0; +var PHP_RELEASE_VERSION = 0; +var PHP_EXTRA_VERSION = ""; +var PHP_VERSION_STRING = "5.0.0"; + +function get_version_numbers() +{ + var cin = file_get_contents("configure.in"); + + if (cin.match(new RegExp("PHP_MAJOR_VERSION=(\\d+)"))) { + PHP_VERSION = RegExp.$1; + } + if (cin.match(new RegExp("PHP_MINOR_VERSION=(\\d+)"))) { + PHP_MINOR_VERSION = RegExp.$1; + } + if (cin.match(new RegExp("PHP_RELEASE_VERSION=(\\d+)"))) { + PHP_RELEASE_VERSION = RegExp.$1; + } + PHP_VERSION_STRING = PHP_VERSION + "." + PHP_MINOR_VERSION + "." + PHP_RELEASE_VERSION; + + if (cin.match(new RegExp("PHP_EXTRA_VERSION=\"([^\"]+)\""))) { + PHP_EXTRA_VERSION = RegExp.$1; + if (PHP_EXTRA_VERSION.length) { + PHP_VERSION_STRING += PHP_EXTRA_VERSION; + } + } + DEFINE('PHP_VERSION_STRING', PHP_VERSION_STRING); +} + +configure_args = new Array(); +configure_subst = WScript.CreateObject("Scripting.Dictionary"); + +configure_hdr = WScript.CreateObject("Scripting.Dictionary"); +build_dirs = new Array(); + +extension_include_code = ""; +extension_module_ptrs = ""; + +if (!MODE_PHPIZE) { + get_version_numbers(); +} + +/* execute a command and return the output as a string */ +function execute(command_line) +{ + var e = WshShell.Exec(command_line); + var ret = ""; + + ret = e.StdOut.ReadAll(); + +//STDOUT.WriteLine("command " + command_line); +//STDOUT.WriteLine(ret); + + return ret; +} + +function probe_binary(EXE, what) +{ + // tricky escapes to get stderr redirection to work + var command = 'cmd /c ""' + EXE; + if (what == "version") { + command = command + '" -v"'; + } + var version = execute(command + '" 2>&1"'); + + if (what == "64") { + if (version.match(/x64/)) { + return 1; + } + } else { + if (version.match(/(\d+\.\d+(\.\d+)?(\.\d+)?)/)) { + return RegExp.$1; + } + } + return 0; +} + +function condense_path(path) +{ + path = FSO.GetAbsolutePathName(path); + + if (path.substr(0, CWD.length).toLowerCase() + == CWD.toLowerCase() && + (path.charCodeAt(CWD.length) == 92 || path.charCodeAt(CWD.length) == 47)) { + return path.substr(CWD.length + 1); + } + + var a = CWD.split("\\"); + var b = path.split("\\"); + var i, j; + + for (i = 0; i < b.length; i++) { + if (a[i].toLowerCase() == b[i].toLowerCase()) + continue; + if (i > 0) { + /* first difference found */ + path = ""; + for (j = 0; j < a.length - i; j++) { + path += "..\\"; + } + for (j = i; j < b.length; j++) { + path += b[j]; + if (j < b.length - 1) + path += "\\"; + } + return path; + } + /* on a different drive */ + break; + } + + return path; +} + +function ConfigureArg(type, optname, helptext, defval) +{ + var opptype = type == "enable" ? "disable" : "without"; + + if (defval == "yes" || defval == "yes,shared") { + this.arg = "--" + opptype + "-" + optname; + this.imparg = "--" + type + "-" + optname; + } else { + this.arg = "--" + type + "-" + optname; + this.imparg = "--" + opptype + "-" + optname; + } + + this.optname = optname; + this.helptext = helptext; + this.defval = defval; + this.symval = optname.toUpperCase().replace(new RegExp("-", "g"), "_"); + this.seen = false; + this.argval = defval; +} + +function ARG_WITH(optname, helptext, defval) +{ + configure_args[configure_args.length] = new ConfigureArg("with", optname, helptext, defval); +} + +function ARG_ENABLE(optname, helptext, defval) +{ + configure_args[configure_args.length] = new ConfigureArg("enable", optname, helptext, defval); +} + +function analyze_arg(argval) +{ + var ret = new Array(); + var shared = false; + + if (argval == "shared") { + shared = true; + argval = "yes"; + } else if (argval == null) { + /* nothing */ + } else if (arg_match = argval.match(new RegExp("^shared,(.*)"))) { + shared = true; + argval = arg_match[1]; + } else if (arg_match = argval.match(new RegExp("^(.*),shared$"))) { + shared = true; + argval = arg_match[1]; + } + + ret[0] = shared; + ret[1] = argval; + return ret; +} + +function word_wrap_and_indent(indent, text, line_suffix, indent_char) +{ + if (text == null) { + return ""; + } + + var words = text.split(new RegExp("\\s+", "g")); + var i = 0; + var ret_text = ""; + var this_line = ""; + var t; + var space = ""; + var lines = 0; + + if (line_suffix == null) { + line_suffix = ""; + } + + if (indent_char == null) { + indent_char = " "; + } + + for (i = 0; i < indent; i++) { + space += indent_char; + } + + for (i = 0; i < words.length; i++) { + if (this_line.length) { + t = this_line + " " + words[i]; + } else { + t = words[i]; + } + + if (t.length + indent > 78) { + if (lines++) { + ret_text += space; + } + ret_text += this_line + line_suffix + "\r\n"; + this_line = ""; + } + + if (this_line.length) { + this_line += " " + words[i]; + } else { + this_line = words[i]; + } + } + + if (this_line.length) { + if (lines) + ret_text += space; + ret_text += this_line; + } + + return ret_text; +} + +function conf_process_args() +{ + var i, j; + var configure_help_mode = false; + var analyzed = false; + var nice = "cscript /nologo configure.js "; + var disable_all = false; + + args = WScript.Arguments; + for (i = 0; i < args.length; i++) { + arg = args(i); + nice += ' "' + arg + '"'; + if (arg == "--help") { + configure_help_mode = true; + break; + } + if (arg == "--disable-all") { + disable_all = true; + continue; + } + + // If it is --foo=bar, split on the equals sign + arg = arg.split("=", 2); + argname = arg[0]; + if (arg.length > 1) { + argval = arg[1]; + } else { + argval = null; + } + + // Find the arg + found = false; + for (j = 0; j < configure_args.length; j++) { + if (argname == configure_args[j].imparg || argname == configure_args[j].arg) { + found = true; + + arg = configure_args[j]; + arg.seen = true; + + analyzed = analyze_arg(argval); + + /* Force shared when called after phpize */ + if (MODE_PHPIZE) { + shared = "shared"; + } else { + shared = analyzed[0]; + } + argval = analyzed[1]; + + if (argname == arg.imparg) { + /* we matched the implicit, or default arg */ + if (argval == null) { + argval = arg.defval; + } + } else { + /* we matched the non-default arg */ + if (argval == null) { + argval = arg.defval == "no" ? "yes" : "no"; + } + } + + arg.argval = argval; + eval("PHP_" + arg.symval + " = argval;"); + eval("PHP_" + arg.symval + "_SHARED = shared;"); + break; + } + } + if (!found) { + STDERR.WriteLine("Unknown option " + argname + "; please try configure.js --help for a list of valid options"); + WScript.Quit(2); + } + } + + if (configure_help_mode) { + STDOUT.WriteLine(word_wrap_and_indent(0, +"Options that enable extensions and SAPI will accept \ +'yes' or 'no' as a parameter. They also accept 'shared' \ +as a synonym for 'yes' and request a shared build of that \ +module. Not all modules can be built as shared modules; \ +configure will display [shared] after the module name if \ +can be built that way. \ +" + )); + STDOUT.WriteBlankLines(1); + + // Measure width to pretty-print the output + max_width = 0; + for (i = 0; i < configure_args.length; i++) { + arg = configure_args[i]; + if (arg.arg.length > max_width) + max_width = arg.arg.length; + } + + for (i = 0; i < configure_args.length; i++) { + arg = configure_args[i]; + + n = max_width - arg.arg.length; + pad = " "; + for (j = 0; j < n; j++) { + pad += " "; + } + STDOUT.WriteLine(" " + arg.arg + pad + word_wrap_and_indent(max_width + 5, arg.helptext)); + } + WScript.Quit(1); + } + + var snapshot_build_exclusions = new Array( + 'debug', 'crt-debug', 'lzf-better-compression', + 'php-build', 'snapshot-template', 'ereg', + 'pcre-regex', 'fastcgi', 'force-cgi-redirect', + 'path-info-check', 'zts', 'ipv6', 'memory-limit', + 'zend-multibyte', 'fd-setsize', 'memory-manager', + 't1lib', 'pgi', 'pgo' + ); + var force; + + // Now set any defaults we might have missed out earlier + for (i = 0; i < configure_args.length; i++) { + arg = configure_args[i]; + if (arg.seen) + continue; + analyzed = analyze_arg(arg.defval); + shared = analyzed[0]; + argval = analyzed[1]; + + // Don't trust a default "yes" answer for a non-core module + // in a snapshot build + if (PHP_SNAPSHOT_BUILD != "no" && argval == "yes" && !shared) { + + force = true; + for (j = 0; j < snapshot_build_exclusions.length; j++) { + if (snapshot_build_exclusions[j] == arg.optname) { + force = false; + break; + } + } + + if (force) { + /* now check if it is a core module */ + force = false; + for (j = 0; j < core_module_list.length; j++) { + if (core_module_list[j] == arg.optname) { + force = true; + break; + } + } + + if (!force) { + STDOUT.WriteLine("snapshot: forcing " + arg.arg + " shared"); + shared = true; + } + } + } + + if (PHP_SNAPSHOT_BUILD != "no" && argval == "no") { + force = true; + for (j = 0; j < snapshot_build_exclusions.length; j++) { + if (snapshot_build_exclusions[j] == arg.optname) { + force = false; + break; + } + } + if (force) { + STDOUT.WriteLine("snapshot: forcing " + arg.optname + " on"); + argval = "yes"; + shared = true; + } + } + + if (disable_all) { + force = true; + for (j = 0; j < snapshot_build_exclusions.length; j++) { + if (snapshot_build_exclusions[j] == arg.optname) { + force = false; + break; + } + } + if (force) { + if (arg.defval == '') { + argval = ''; + } else { + argval = "no"; + } + shared = false; + } + } + + eval("PHP_" + arg.symval + " = argval;"); + eval("PHP_" + arg.symval + "_SHARED = shared;"); + } + + MFO = FSO.CreateTextFile("Makefile.objects", true); + + STDOUT.WriteLine("Saving configure options to config.nice.bat"); + var nicefile = FSO.CreateTextFile("config.nice.bat", true); + nicefile.WriteLine(nice + " %*"); + nicefile.Close(); + + AC_DEFINE('CONFIGURE_COMMAND', nice, "Configure line"); +} + +function DEFINE(name, value) +{ + if (configure_subst.Exists(name)) { + configure_subst.Remove(name); + } + configure_subst.Add(name, value); +} + +// Searches a set of paths for a file; +// returns the dir in which the file was found, +// true if it was found in the default env path, +// or false if it was not found at all. +// env_name is the optional name of an env var +// specifying the default path to search +function search_paths(thing_to_find, explicit_path, env_name) +{ + var i, found = false, place = false, file, env; + + STDOUT.Write("Checking for " + thing_to_find + " ... "); + + thing_to_find = thing_to_find.replace(new RegExp("/", "g"), "\\"); + + if (explicit_path != null) { + if (typeof(explicit_path) == "string") { + explicit_path = explicit_path.split(";"); + } + + for (i = 0; i < explicit_path.length; i++) { + file = glob(explicit_path[i] + "\\" + thing_to_find); + if (file) { + found = true; + place = file[0]; + place = place.substr(0, place.length - thing_to_find.length - 1); + break; + } + } + } + + if (!found && env_name != null) { + env = WshShell.Environment("Process").Item(env_name); + env = env.split(";"); + for (i = 0; i < env.length; i++) { + file = glob(env[i] + "\\" + thing_to_find); + if (file) { + found = true; + place = true; + break; + } + } + } + + if (found && place == true) { + STDOUT.WriteLine(" "); + } else if (found) { + STDOUT.WriteLine(" " + place); + } else { + STDOUT.WriteLine(" "); + } + return place; +} + +function PATH_PROG(progname, additional_paths, symbol) +{ + var exe; + var place; + var cyg_path = PHP_CYGWIN + "\\bin;" + PHP_CYGWIN + "\\usr\\local\\bin"; + var php_build_bin_path = PHP_PHP_BUILD + "\\bin" + + exe = progname + ".exe"; + + if (additional_paths == null) { + additional_paths = cyg_path; + } else { + additional_paths += ";" + cyg_path; + } + + additional_paths = additional_paths + ";" + php_build_bin_path; + + place = search_paths(exe, additional_paths, "PATH"); + + if (place == true) { + place = exe; + } else if (place != false) { + place = place + "\\" + exe; + } + + if (place) { + if (symbol == null) { + symbol = progname.toUpperCase(); + } + DEFINE(symbol, place); + } + return place; +} + +function find_pattern_in_path(pattern, path) +{ + if (path == null) { + return false; + } + + var dirs = path.split(';'); + var i; + var items; + + for (i = 0; i < dirs.length; i++) { + items = glob(dirs[i] + "\\" + pattern); + if (items) { + return condense_path(items[0]); + } + } + return false; +} + +function CHECK_LIB(libnames, target, path_to_check, common_name) +{ + STDOUT.Write("Checking for library " + libnames + " ... "); + + if (common_name == null && target != null) { + common_name = target; + } + + if (path_to_check == null) { + path_to_check = ""; + } + + // if they specified a common name for the package that contains + // the library, tag some useful defaults on to the end of the + // path to be searched + if (common_name != null) { + path_to_check += ";" + PHP_PHP_BUILD + "\\" + common_name + "*"; + path_to_check += ";" + PHP_PHP_BUILD + "\\lib\\" + common_name + "*"; + path_to_check += ";..\\" + common_name + "*"; + } + + // Determine target for build flags + if (target == null) { + target = ""; + } else { + target = "_" + target.toUpperCase(); + } + + // Expand path to include general dirs + path_to_check += ";" + php_usual_lib_suspects; + + // It is common practice to put libs under one of these dir names + var subdirs = new Array(PHP_DEBUG == "yes" ? "Debug" : (PHP_DEBUG_PACK == "yes"?"Release_Dbg":"Release"), "lib", "libs", "libexec"); + + // libnames can be ; separated list of accepted library names + libnames = libnames.split(';'); + + // for debug builds, lib may have _debug appended, we want that first + if (PHP_DEBUG == "yes") { + var length = libnames.length; + for (var i = 0; i < length; i++) { + var name = new String(libnames[i]); + rExp = /.lib$/i; + name = name.replace(rExp,"_debug.lib"); + libnames.unshift(name); + } + } + + var i, j, k, libname; + var location = false; + var path = path_to_check.split(';'); + + for (i = 0; i < libnames.length; i++) { + libname = libnames[i]; + + for (k = 0; k < path.length; k++) { + location = glob(path[k] + "\\" + libname); + if (location) { + location = location[0]; + break; + } + for (j = 0; j < subdirs.length; j++) { + location = glob(path[k] + "\\" + subdirs[j] + "\\" + libname); + if (location) { + location = location[0]; + break; + } + } + if (location) + break; + } + + if (location) { + location = condense_path(location); + var libdir = FSO.GetParentFolderName(location); + libname = FSO.GetFileName(location); + ADD_FLAG("LDFLAGS" + target, '/libpath:"' + libdir + '" '); + ADD_FLAG("LIBS" + target, libname); + + STDOUT.WriteLine(location); + + return location; + } + + // Check in their standard lib path + location = find_pattern_in_path(libname, WshShell.Environment("Process").Item("LIB")); + + if (location) { + location = condense_path(location); + libname = FSO.GetFileName(location); + ADD_FLAG("LIBS" + target, libname); + + STDOUT.WriteLine(" " + libname); + return location; + } + + // Check in their general extra libs path + location = find_pattern_in_path(libname, PHP_EXTRA_LIBS); + if (location) { + location = condense_path(location); + libname = FSO.GetFileName(location); + ADD_FLAG("LIBS" + target, libname); + STDOUT.WriteLine(""); + return location; + } + } + + STDOUT.WriteLine(""); + + return false; +} + +function OLD_CHECK_LIB(libnames, target, path_to_check) +{ + if (target == null) { + target = ""; + } else { + target = "_" + target.toUpperCase(); + } + + if (path_to_check == null) { + path_to_check = php_usual_lib_suspects; + } else { + path_to_check += ";" + php_usual_lib_suspects; + } + var have = 0; + var p; + var i; + var libname; + + var subdir = PHP_DEBUG == "yes" ? "Debug" : (PHP_DEBUG_PACK == "yes"?"Release_Dbg":"Release"); + + libnames = libnames.split(';'); + for (i = 0; i < libnames.length; i++) { + libname = libnames[i]; + p = search_paths(libname, path_to_check, "LIB"); + + if (!p) { + p = search_paths(subdir + "\\" + libname, path_to_check, "LIB"); + if (p) { + p += "\\" + subdir; + } + } + + if (typeof(p) == "string") { + ADD_FLAG("LDFLAGS" + target, '/libpath:"' + p + '" '); + ADD_FLAG("LIBS" + target, libname); + have = 1; + } else if (p == true) { + ADD_FLAG("LIBS" + target, libname); + have = 1; + } else { + /* not found in the defaults or the explicit paths, + * so check the general extra libs; if we find + * it here, no need to add another /libpath: for it as we + * already have it covered, but we need to add the lib + * to LIBS_XXX */ + if (false != search_paths(libname, PHP_EXTRA_LIBS, null)) { + ADD_FLAG("LIBS" + target, libname); + have = 1; + } + } + + if (have) { + break; + } + } + +// AC_DEFINE("HAVE_" + header_name.toUpperCase().replace(new RegExp("/\\\\-\.", "g"), "_"), have); + + return have; + +} + +function CHECK_FUNC_IN_HEADER(header_name, func_name, path_to_check, add_to_flag) +{ + var c = false; + var sym; + + STDOUT.Write("Checking for " + func_name + " in " + header_name + " ... "); + + c = GREP_HEADER(header_name, func_name, path_to_check); + + sym = func_name.toUpperCase(); + sym = sym.replace(new RegExp("[\\\\/\.-]", "g"), "_"); + + if (typeof(add_to_flag) == "undefined") { + AC_DEFINE("HAVE_" + sym, c ? 1 : 0); + } else { + ADD_FLAG(add_to_flag, "/DHAVE_" + sym + "=" + (c ? "1" : "0")); + } + + if (c) { + STDOUT.WriteLine("OK"); + return c; + } + STDOUT.WriteLine("No"); + return false; +} + +function GREP_HEADER(header_name, regex, path_to_check) +{ + var c = false; + + if (FSO.FileExists(path_to_check + "\\" + header_name)) { + c = file_get_contents(path_to_check + "\\" + header_name); + } + + if (!c) { + /* look in the include path */ + + var p = search_paths(header_name, path_to_check, "INCLUDE"); + if (typeof(p) == "string") { + c = file_get_contents(p); + } else if (p == false) { + p = search_paths(header_name, PHP_EXTRA_INCLUDES, null); + if (typeof(p) == "string") { + c = file_get_contents(p); + } + } + if (!c) { + return false; + } + } + + if (typeof(regex) == "string") { + regex = new RegExp(regex); + } + + if (c.match(regex)) { + /* caller can now use RegExp.$1 etc. to get at patterns */ + return true; + } + return false; +} + +function CHECK_HEADER_ADD_INCLUDE(header_name, flag_name, path_to_check, use_env, add_dir_part, add_to_flag_only) +{ + var dir_part_to_add = ""; + + if (use_env == null) { + use_env = true; + } + + // if true, add the dir part of the header_name to the include path + if (add_dir_part == null) { + add_dir_part = false; + } else if (add_dir_part) { + var basename = FSO.GetFileName(header_name); + dir_part_to_add = "\\" + header_name.substr(0, header_name.length - basename.length - 1); + } + + if (path_to_check == null) { + path_to_check = php_usual_include_suspects; + } else { + path_to_check += ";" + php_usual_include_suspects; + } + + var p = search_paths(header_name, path_to_check, use_env ? "INCLUDE" : null); + var have = 0; + var sym; + + if (typeof(p) == "string") { + ADD_FLAG(flag_name, '/I "' + p + dir_part_to_add + '" '); + } else if (p == false) { + /* not found in the defaults or the explicit paths, + * so check the general extra includes; if we find + * it here, no need to add another /I for it as we + * already have it covered, unless we are adding + * the dir part.... */ + p = search_paths(header_name, PHP_EXTRA_INCLUDES, null); + if (typeof(p) == "string" && add_dir_part) { + ADD_FLAG(flag_name, '/I "' + p + dir_part_to_add + '" '); + } + } + have = p ? 1 : 0 + + sym = header_name.toUpperCase(); + sym = sym.replace(new RegExp("[\\\\/\.-]", "g"), "_"); + + if (typeof(add_to_flag_only) == "undefined" && + flag_name.match(new RegExp("^CFLAGS_(.*)$"))) { + add_to_flag_only = true; + } + + if (typeof(add_to_flag_only) != "undefined") { + ADD_FLAG(flag_name, "/DHAVE_" + sym + "=" + have); + } else { + AC_DEFINE("HAVE_" + sym, have, "have the " + header_name + " header file"); + } + + return p; +} + +/* emits rule to generate version info for a SAPI + * or extension. Returns the name of the .res file + * that will be generated */ +function generate_version_info_resource(makefiletarget, basename, creditspath, sapi) +{ + var resname = makefiletarget + ".res"; + var res_desc = makefiletarget; + var res_prod_name = "PHP " + makefiletarget; + var credits; + var thanks = ""; + var logo = ""; + var debug = ""; + var project_url = "http://www.php.net"; + var project_header = creditspath + "/php_" + basename + ".h"; + var versioning = ""; + + if (sapi) { + var internal_name = basename.toUpperCase() + " SAPI"; + } else { + var internal_name = basename.toUpperCase() + " extension"; + } + + if (FSO.FileExists(creditspath + '/CREDITS')) { + credits = FSO.OpenTextFile(creditspath + '/CREDITS', 1); + res_desc = credits.ReadLine(); + try { + thanks = credits.ReadLine(); + } catch (e) { + thanks = null; + } + if (thanks == null) { + thanks = ""; + } else { + thanks = "Thanks to " + thanks; + } + credits.Close(); + } + + if (creditspath.match(new RegExp("pecl"))) { + /* PECL project url - this will eventually work correctly for all */ + project_url = "http://pecl.php.net/" + basename; + + /* keep independent versioning PECL-specific for now */ + if (FSO.FileExists(project_header)) { + if (header = FSO.OpenTextFile(project_header, 1)) { + contents = header.ReadAll(); + /* allowed: x.x.x[a|b|-alpha|-beta][RCx][-dev] */ + if (contents.match(new RegExp('PHP_' + basename.toUpperCase() + '_VERSION(\\s+)"((\\d+\.\\d+(\.\\d+)?)((a|b)(\\d)?|\-[a-z]{3,5})?(RC\\d+)?(\-dev)?)'))) { + project_version = RegExp.$2; + file_version = RegExp.$3.split('.'); + if (!file_version[2]) { + file_version[2] = 0; + } + versioning = '\\"" /d EXT_FILE_VERSION=' + file_version[0] + ',' + file_version[1] + ',' + file_version[2] + ' /d EXT_VERSION="\\"' + project_version; + } + header.Close(); + } + } + } + + if (makefiletarget.match(new RegExp("\\.exe$"))) { + logo = " /d WANT_LOGO "; + } + + if (PHP_DEBUG != "no") { + debug = " /d _DEBUG"; + } + + /** + * Use user supplied template.rc if it exists + */ + if (FSO.FileExists(creditspath + '\\template.rc')) { + MFO.WriteLine("$(BUILD_DIR)\\" + resname + ": " + creditspath + "\\template.rc"); + MFO.WriteLine("\t$(RC) /fo $(BUILD_DIR)\\" + resname + logo + debug + + ' /d FILE_DESCRIPTION="\\"' + res_desc + '\\"" /d FILE_NAME="\\"' + + makefiletarget + '\\"" /d PRODUCT_NAME="\\"' + res_prod_name + + versioning + '\\"" /d THANKS_GUYS="\\"' + thanks + '\\"" ' + + creditspath + '\\template.rc'); + return resname; + } + if (MODE_PHPIZE) { + MFO.WriteLine("$(BUILD_DIR)\\" + resname + ": $(PHP_DIR)\\build\\template.rc"); + MFO.WriteLine("\t$(RC) /I $(PHP_DIR)/include /n /fo $(BUILD_DIR)\\" + resname + logo + debug + + ' /d FILE_DESCRIPTION="\\"' + res_desc + '\\"" /d FILE_NAME="\\"' + + makefiletarget + '\\"" /d URL="\\"' + project_url + + '\\"" /d INTERNAL_NAME="\\"' + internal_name + versioning + + '\\"" /d THANKS_GUYS="\\"' + thanks + '\\"" $(PHP_DIR)\\build\\template.rc'); + } else { + MFO.WriteLine("$(BUILD_DIR)\\" + resname + ": win32\\build\\template.rc"); + MFO.WriteLine("\t$(RC) /n /fo $(BUILD_DIR)\\" + resname + logo + debug + + ' /d FILE_DESCRIPTION="\\"' + res_desc + '\\"" /d FILE_NAME="\\"' + + makefiletarget + '\\"" /d URL="\\"' + project_url + + '\\"" /d INTERNAL_NAME="\\"' + internal_name + versioning + + '\\"" /d THANKS_GUYS="\\"' + thanks + '\\"" win32\\build\\template.rc'); + } + MFO.WriteBlankLines(1); + return resname; +} + +/* Check if PGO is enabled for given module. To disable PGO for a particular module, +define a global variable by the following name scheme before SAPI() or EXTENSION() call + var PHP_MYMODULE_PGO = false; */ +function is_pgo_desired(mod) +{ + var varname = "PHP_" + mod.toUpperCase() + "_PGO"; + + /* XXX enable PGO in phpize mode */ + if (MODE_PHPIZE) { + return false; + } + + /* don't disable if there's no mention of the varname */ + if (eval("typeof " + varname + " == 'undefined'")) { + return true; + } + + return eval("!!" + varname); +} + +function SAPI(sapiname, file_list, makefiletarget, cflags, obj_dir) +{ + var SAPI = sapiname.toUpperCase(); + var ldflags; + var resname; + var ld; + var manifest; + + if (typeof(obj_dir) == "undefined") { + sapiname_for_printing = configure_module_dirname; + } else { + sapiname_for_printing = configure_module_dirname + " (via " + obj_dir + ")"; + } + + STDOUT.WriteLine("Enabling SAPI " + sapiname_for_printing); + + MFO.WriteBlankLines(1); + MFO.WriteLine("# objects for SAPI " + sapiname); + MFO.WriteBlankLines(1); + + if (cflags) { + ADD_FLAG('CFLAGS_' + SAPI, cflags); + } + + ADD_SOURCES(configure_module_dirname, file_list, sapiname, obj_dir); + MFO.WriteBlankLines(1); + MFO.WriteLine("# SAPI " + sapiname); + MFO.WriteBlankLines(1); + + /* generate a .res file containing version information */ + resname = generate_version_info_resource(makefiletarget, sapiname, configure_module_dirname, true); + + MFO.WriteLine(makefiletarget + ": $(BUILD_DIR)\\" + makefiletarget); + MFO.WriteLine("\t@echo SAPI " + sapiname_for_printing + " build complete"); + if (MODE_PHPIZE) { + MFO.WriteLine("$(BUILD_DIR)\\" + makefiletarget + ": $(DEPS_" + SAPI + ") $(" + SAPI + "_GLOBAL_OBJS) $(PHPLIB) $(BUILD_DIR)\\" + resname); + } else { + MFO.WriteLine("$(BUILD_DIR)\\" + makefiletarget + ": $(DEPS_" + SAPI + ") $(" + SAPI + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(BUILD_DIR)\\" + resname); + } + + if (makefiletarget.match(new RegExp("\\.dll$"))) { + ldflags = "/dll $(LDFLAGS)"; + manifest = "-@$(_VC_MANIFEST_EMBED_DLL)"; + } else if (makefiletarget.match(new RegExp("\\.lib$"))) { + ldflags = "$(LDFLAGS)"; + ld = "$(MAKE_LIB)"; + } else { + ldflags = "$(LDFLAGS)"; + manifest = "-@$(_VC_MANIFEST_EMBED_EXE)"; + } + + if(is_pgo_desired(sapiname) && (PHP_PGI == "yes" || PHP_PGO != "no")) { + // Add compiler and link flags if PGO options are selected + if (PHP_DEBUG != "yes" && PHP_PGI == "yes") { + ADD_FLAG('CFLAGS_' + SAPI, "/GL /O2"); + ADD_FLAG('LDFLAGS_' + SAPI, "/LTCG:PGINSTRUMENT"); + } + else if (PHP_DEBUG != "yes" && PHP_PGO != "no") { + ADD_FLAG('CFLAGS_' + SAPI, "/GL /O2"); + ADD_FLAG('LDFLAGS_' + SAPI, "/LTCG:PGUPDATE"); + } + + ldflags += " /PGD:$(PGOPGD_DIR)\\" + makefiletarget.substring(0, makefiletarget.indexOf(".")) + ".pgd"; + } + + if (MODE_PHPIZE) { + if (ld) { + MFO.WriteLine("\t" + ld + " /nologo /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(" + SAPI + "_GLOBAL_OBJS) $(PHPLIB) $(LDFLAGS_" + SAPI + ") $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname); + } else { + ld = "@$(CC)"; + MFO.WriteLine("\t" + ld + " /nologo " + " $(" + SAPI + "_GLOBAL_OBJS) $(PHPLIB) $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname + " /link /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(LDFLAGS_" + SAPI + ")"); + } + } else { + if (ld) { + MFO.WriteLine("\t" + ld + " /nologo /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(" + SAPI + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LDFLAGS_" + SAPI + ") $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname); + } else { + ld = "@$(CC)"; + MFO.WriteLine("\t" + ld + " /nologo " + " $(" + SAPI + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname + " /link /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(LDFLAGS_" + SAPI + ")"); + } + } + + if (manifest) { + MFO.WriteLine("\t" + manifest); + } + + DEFINE('CFLAGS_' + SAPI + '_OBJ', '$(CFLAGS_' + SAPI + ')'); + + if (configure_module_dirname.match("pecl")) { + ADD_FLAG("PECL_TARGETS", makefiletarget); + } else { + ADD_FLAG("SAPI_TARGETS", makefiletarget); + } + + MFO.WriteBlankLines(1); + sapi_enabled[sapi_enabled.length] = [sapiname]; +} + +function ADD_DIST_FILE(filename) +{ + if (configure_module_dirname.match("pecl")) { + ADD_FLAG("PECL_EXTRA_DIST_FILES", filename); + } else { + ADD_FLAG("PHP_EXTRA_DIST_FILES", filename); + } +} + +function file_get_contents(filename) +{ + var f, c; + try { + f = FSO.OpenTextFile(filename, 1); + c = f.ReadAll(); + f.Close(); + return c; + } catch (e) { + STDOUT.WriteLine("Problem reading " + filename); + return false; + } +} + +// Add a dependency on another extension, so that +// the dependencies are built before extname +function ADD_EXTENSION_DEP(extname, dependson, optional) +{ + var EXT = extname.toUpperCase(); + var DEP = dependson.toUpperCase(); + var dep_present = false; + var dep_shared = false; + + try { + dep_present = eval("PHP_" + DEP); + + if (dep_present != "no") { + try { + dep_shared = eval("PHP_" + DEP + "_SHARED"); + } catch (e) { + dep_shared = false; + } + } + + } catch (e) { + dep_present = "no"; + } + + if (optional) { + if (dep_present == "no") { + MESSAGE("\t" + dependson + " not found: " + dependson + " support in " + extname + " disabled"); + return false; + } + } + + var ext_shared = eval("PHP_" + EXT + "_SHARED"); + + if (dep_shared) { + if (!ext_shared) { + if (optional) { + MESSAGE("\tstatic " + extname + " cannot depend on shared " + dependson + ": " + dependson + "support disabled"); + return false; + } + ERROR("static " + extname + " cannot depend on shared " + dependson); + } + + ADD_FLAG("LIBS_" + EXT, "php_" + dependson + ".lib"); + if (MODE_PHPIZE) { + ADD_FLAG("LDFLAGS_" + EXT, "/libpath:$(BUILD_DIR_DEV)\\lib"); + ADD_FLAG("DEPS_" + EXT, "$(BUILD_DIR_DEV)\\lib\\php_" + dependson + ".lib"); + } else { + ADD_FLAG("LDFLAGS_" + EXT, "/libpath:$(BUILD_DIR)"); + ADD_FLAG("DEPS_" + EXT, "$(BUILD_DIR)\\php_" + dependson + ".lib"); + } + + } else { + + if (dep_present == "no") { + if (ext_shared) { + WARNING(extname + " cannot be built: missing dependency, " + dependson + " not found"); + + var dllname = ' php_' + extname + '.dll'; + + if (!REMOVE_TARGET(dllname, 'EXT_TARGETS')) { + REMOVE_TARGET(dllname, 'PECL_TARGETS'); + } + + return false; + + } + + ERROR("Cannot build " + extname + "; " + dependson + " not enabled"); + return false; + } + } // dependency is statically built-in to PHP + return true; +} + +var static_pgo_enabled = false; + +function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir) +{ + var objs = null; + var EXT = extname.toUpperCase(); + var extname_for_printing; + var ldflags; + + if (shared == null) { + eval("shared = PHP_" + EXT + "_SHARED;"); + } else { + eval("PHP_" + EXT + "_SHARED = shared;"); + } + + if (cflags == null) { + cflags = ""; + } + + if (typeof(obj_dir) == "undefined") { + extname_for_printing = configure_module_dirname; + } else { + extname_for_printing = configure_module_dirname + " (via " + obj_dir + ")"; + } + + if (shared) { + STDOUT.WriteLine("Enabling extension " + extname_for_printing + " [shared]"); + cflags = "/D COMPILE_DL_" + EXT + " /D " + EXT + "_EXPORTS=1 " + cflags; + ADD_FLAG("CFLAGS_PHP", "/D COMPILE_DL_" + EXT); + } else { + STDOUT.WriteLine("Enabling extension " + extname_for_printing); + } + + MFO.WriteBlankLines(1); + MFO.WriteLine("# objects for EXT " + extname); + MFO.WriteBlankLines(1); + + ADD_SOURCES(configure_module_dirname, file_list, extname, obj_dir); + + MFO.WriteBlankLines(1); + + if (shared) { + if (dllname == null) { + dllname = "php_" + extname + ".dll"; + } + var libname = dllname.substring(0, dllname.length-4) + ".lib"; + + var resname = generate_version_info_resource(dllname, extname, configure_module_dirname, false); + var ld = "@$(CC)"; + + ldflags = ""; + if (is_pgo_desired(extname) && (PHP_PGI == "yes" || PHP_PGO != "no")) { + // Add compiler and link flags if PGO options are selected + if (PHP_DEBUG != "yes" && PHP_PGI == "yes") { + ADD_FLAG('LDFLAGS_' + EXT, "/LTCG:PGINSTRUMENT"); + } + else if (PHP_DEBUG != "yes" && PHP_PGO != "no") { + ADD_FLAG('LDFLAGS_' + EXT, "/LTCG:PGUPDATE"); + } + + ADD_FLAG('CFLAGS_' + EXT, "/GL /O2"); + + ldflags = " /PGD:$(PGOPGD_DIR)\\" + dllname.substring(0, dllname.indexOf(".")) + ".pgd"; + } + + MFO.WriteLine("$(BUILD_DIR)\\" + libname + ": $(BUILD_DIR)\\" + dllname); + MFO.WriteBlankLines(1); + if (MODE_PHPIZE) { + MFO.WriteLine("$(BUILD_DIR)\\" + dllname + ": $(DEPS_" + EXT + ") $(" + EXT + "_GLOBAL_OBJS) $(PHPLIB) $(BUILD_DIR)\\" + resname); + MFO.WriteLine("\t" + ld + " $(" + EXT + "_GLOBAL_OBJS) $(PHPLIB) $(LIBS_" + EXT + ") $(LIBS) $(BUILD_DIR)\\" + resname + " /link /out:$(BUILD_DIR)\\" + dllname + " $(DLL_LDFLAGS) $(LDFLAGS) $(LDFLAGS_" + EXT + ")"); + } else { + MFO.WriteLine("$(BUILD_DIR)\\" + dllname + ": $(DEPS_" + EXT + ") $(" + EXT + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(BUILD_DIR)\\" + resname); + MFO.WriteLine("\t" + ld + " $(" + EXT + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LIBS_" + EXT + ") $(LIBS) $(BUILD_DIR)\\" + resname + " /link /out:$(BUILD_DIR)\\" + dllname + ldflags + " $(DLL_LDFLAGS) $(LDFLAGS) $(LDFLAGS_" + EXT + ")"); + } + MFO.WriteLine("\t-@$(_VC_MANIFEST_EMBED_DLL)"); + MFO.WriteBlankLines(1); + + if (configure_module_dirname.match("pecl")) { + ADD_FLAG("PECL_TARGETS", dllname); + } else { + ADD_FLAG("EXT_TARGETS", dllname); + } + MFO.WriteLine(dllname + ": $(BUILD_DIR)\\" + dllname); + MFO.WriteLine("\t@echo EXT " + extname + " build complete"); + MFO.WriteBlankLines(1); + + DEFINE('CFLAGS_' + EXT + '_OBJ', '$(CFLAGS_' + EXT + ')'); + } else { + ADD_FLAG("STATIC_EXT_OBJS", "$(" + EXT + "_GLOBAL_OBJS)"); + ADD_FLAG("STATIC_EXT_LIBS", "$(LIBS_" + EXT + ")"); + ADD_FLAG("STATIC_EXT_LDFLAGS", "$(LDFLAGS_" + EXT + ")"); + ADD_FLAG("STATIC_EXT_CFLAGS", "$(CFLAGS_" + EXT + ")"); + if (is_pgo_desired(extname) && (PHP_PGI == "yes" || PHP_PGO != "no")) { + if (!static_pgo_enabled) { + if (PHP_DEBUG != "yes" && PHP_PGI == "yes") { + ADD_FLAG('STATIC_EXT_LDFLAGS', "/LTCG:PGINSTRUMENT"); + } + else if (PHP_DEBUG != "yes" && PHP_PGO != "no") { + ADD_FLAG('STATIC_EXT_LDFLAGS', "/LTCG:PGUPDATE"); + } + + ADD_FLAG("STATIC_EXT_CFLAGS", "/GL /O2"); + static_pgo_enabled = true; + } + } + + /* find the header that declares the module pointer, + * so we can include it in internal_functions.c */ + var ext_dir = FSO.GetFolder(configure_module_dirname); + var fc = new Enumerator(ext_dir.Files); + var re = /\.h$/; + var s, c; + for (; !fc.atEnd(); fc.moveNext()) { + s = fc.item() + ""; + if (s.match(re)) { + c = file_get_contents(s); + if (c.match("phpext_")) { + extension_include_code += '#include "' + configure_module_dirname + '/' + FSO.GetFileName(s) + '"\r\n'; + } + } + } + + extension_module_ptrs += '\tphpext_' + extname + '_ptr,\r\n'; + + DEFINE('CFLAGS_' + EXT + '_OBJ', '$(CFLAGS_PHP) $(CFLAGS_' + EXT + ')'); + } + if (MODE_PHPIZE && FSO.FileExists(PHP_DIR + "/include/main/config.pickle.h")) { + cflags = "/FI main/config.pickle.h " + cflags; + } + ADD_FLAG("CFLAGS_" + EXT, cflags); + + extensions_enabled[extensions_enabled.length] = [extname, shared ? 'shared' : 'static']; +} + +function ADD_SOURCES(dir, file_list, target, obj_dir) +{ + var i; + var tv; + var src, obj, sym, flags; + + if (target == null) { + target = "php"; + } + + sym = target.toUpperCase() + "_GLOBAL_OBJS"; + flags = "CFLAGS_" + target.toUpperCase() + '_OBJ'; + + if (configure_subst.Exists(sym)) { + tv = configure_subst.Item(sym); + } else { + tv = ""; + } + + file_list = file_list.split(new RegExp("\\s+")); + file_list.sort(); + + var re = new RegExp("\.[a-z0-9A-Z]+$"); + + dir = dir.replace(new RegExp("/", "g"), "\\"); + var objs_line = ""; + var srcs_line = ""; + + var sub_build = "$(BUILD_DIR)\\"; + + /* if module dir is not a child of the main source dir, + * we need to tweak it; we should have detected such a + * case in condense_path and rewritten the path to + * be relative. + * This probably breaks for non-sibling dirs, but that + * is not a problem as buildconf only checks for pecl + * as either a child or a sibling */ + if (obj_dir == null) { + var build_dir = dir.replace(new RegExp("^..\\\\"), ""); + var mangle_dir = build_dir.replace(new RegExp("[\\\\/.-]", "g"), "_"); + var bd_flags_name = "CFLAGS_BD_" + mangle_dir.toUpperCase(); + } + else { + var build_dir = obj_dir.replace(new RegExp("^..\\\\"), ""); + var mangle_dir = build_dir.replace(new RegExp("[\\\\/.-]", "g"), "_"); + var bd_flags_name = "CFLAGS_BD_" + mangle_dir.toUpperCase(); + } + + var dirs = build_dir.split("\\"); + var i, d = ""; + for (i = 0; i < dirs.length; i++) { + d += dirs[i]; + build_dirs[build_dirs.length] = d; + d += "\\"; + } + sub_build += d; + + + DEFINE(bd_flags_name, " /Fp" + sub_build + " /FR" + sub_build + " "); + + for (i in file_list) { + src = file_list[i]; + obj = src.replace(re, ".obj"); + tv += " " + sub_build + obj; + + if (!PHP_MP_DISABLED) { + if (i > 0) { + objs_line += " " + sub_build + obj; + srcs_line += " " + dir + "\\" + src; + } else { + objs_line = sub_build + obj; + srcs_line = dir + "\\" + src; + } + } else { + MFO.WriteLine(sub_build + obj + ": " + dir + "\\" + src); + + if (PHP_ANALYZER == "pvs") { + MFO.WriteLine("\t@\"$(PVS_STUDIO)\" --cl-params $(" + flags + ") $(CFLAGS) $(" + bd_flags_name + ") /c " + dir + "\\" + src + " --source-file " + dir + "\\" + src + + " --cfg PVS-Studio.conf --errors-off \"V122 V117 V111\" "); + } + MFO.WriteLine("\t@$(CC) $(" + flags + ") $(CFLAGS) $(" + bd_flags_name + ") /c " + dir + "\\" + src + " /Fo" + sub_build + obj); + } + } + + if (!PHP_MP_DISABLED) { + MFO.WriteLine(objs_line + ": " + srcs_line); + MFO.WriteLine("\t$(CC) $(" + flags + ") $(CFLAGS) /Fo" + sub_build + " $(" + bd_flags_name + ") /c " + srcs_line); + } + + DEFINE(sym, tv); +} + +function REMOVE_TARGET(dllname, flag) +{ + var dllname = dllname.replace(/\s/g, ""); + var EXT = dllname.replace(/php_(\S+)\.dll/, "$1").toUpperCase(); + var php_flags = configure_subst.Item("CFLAGS_PHP"); + + if (configure_subst.Exists(flag)) { + var targets = configure_subst.Item(flag); + + if (targets.match(dllname)) { + configure_subst.Remove(flag); + targets = targets.replace(dllname, ""); + targets = targets.replace(/\s+/, " "); + targets = targets.replace(/\s$/, ""); + configure_subst.Add(flag, targets); + configure_hdr.Add("HAVE_" + EXT, new Array(0, "")); + configure_subst.Item("CFLAGS_PHP") = php_flags.replace(" /D COMPILE_DL_" + EXT, ""); + extensions_enabled.pop(); + return true; + } + } + return false; +} + +function generate_internal_functions() +{ + var infile, outfile; + var indata; + + STDOUT.WriteLine("Generating main/internal_functions.c"); + + infile = FSO.OpenTextFile("main/internal_functions.c.in", 1); + indata = infile.ReadAll(); + infile.Close(); + + indata = indata.replace("@EXT_INCLUDE_CODE@", extension_include_code); + indata = indata.replace("@EXT_MODULE_PTRS@", extension_module_ptrs); + + if (FSO.FileExists("main/internal_functions.c")) { + var origdata = file_get_contents("main/internal_functions.c"); + + if (origdata == indata) { + STDOUT.WriteLine("\t[content unchanged; skipping]"); + return; + } + } + + outfile = FSO.CreateTextFile("main/internal_functions.c", true); + outfile.Write(indata); + outfile.Close(); +} + +function output_as_table(header, ar_out) +{ + var l = header.length; + var cols = 80; + var fixedlength = ""; + var t = 0; + var i,j,k,m; + var out = "| "; + var min = new Array(l); + var max = new Array(l); + + if (!!ar_out[0] && l != ar_out[0].length) { + STDOUT.WriteLine("Invalid header argument, can't output the table " + l + " " + ar_out[0].length ); + return; + } + + for (j=0; j < l; j++) { + var tmax, tmin; + + /*Figure out the max length per column */ + tmin = 0; + tmax = 0; + for (k = 0; k < ar_out.length; k++) { + if(typeof ar_out[k][j] != 'undefined') { + var t = ar_out[k][j].length; + if (t > tmax) tmax = t; + else if (t < tmin) tmin = t; + } + } + if (tmax > header[j].length) { + max[j] = tmax; + } else { + max[j] = header[j].length; + } + if (tmin < header[j].length) { + min[j] = header[j].length; + } + } + + sep = ""; + k = 0; + for (i = 0; i < l; i++) { + k += max[i] + 3; + } + k++; + + for (j=0; j < k; j++) { + sep += "-"; + } + + STDOUT.WriteLine(sep); + out = "|"; + for (j=0; j < l; j++) { + out += " " + header[j]; + for (var i = 0; i < (max[j] - header[j].length); i++){ + out += " "; + } + out += " |"; + } + STDOUT.WriteLine(out); + + STDOUT.WriteLine(sep); + + out = "|"; + for (i=0; i < ar_out.length; i++) { + line = ar_out[i]; + for (j=0; j < l; j++) { + out += " " + line[j]; + if(typeof line[j] != 'undefined') { + for (var k = 0; k < (max[j] - line[j].length); k++){ + out += " "; + } + } + out += " |"; + } + STDOUT.WriteLine(out); + out = "|"; + } + + STDOUT.WriteLine(sep); +} + +function write_summary() +{ + var ar = new Array(); + + STDOUT.WriteBlankLines(2); + + STDOUT.WriteLine("Enabled extensions:"); + output_as_table(["Extension", "Mode"], extensions_enabled.sort()); + STDOUT.WriteBlankLines(2); + if (!MODE_PHPIZE) { + STDOUT.WriteLine("Enabled SAPI:"); + output_as_table(["Sapi Name"], sapi_enabled); + STDOUT.WriteBlankLines(2); + } + ar[0] = ['Build type', PHP_DEBUG == "yes" ? "Debug" : "Release"]; + ar[1] = ['Thread Safety', PHP_ZTS == "yes" ? "Yes" : "No"]; + ar[2] = ['Compiler', COMPILER_NAME]; + ar[3] = ['Architecture', X64 ? 'x64' : 'x86']; + if (PHP_PGO == "yes") { + ar[4] = ['Optimization', "PGO"]; + } else if (PHP_PGI == "yes") { + ar[4] = ['Optimization', "PGI"]; + } else { + ar[4] = ['Optimization', PHP_DEBUG == "yes" ? "disabled" : "PGO disabled"]; + } + if (PHP_ANALYZER == "vs") { + ar[5] = ['Static analyzer', 'Visual Studio']; + } else if (PHP_ANALYZER == "pvs") { + ar[5] = ['Static analyzer', 'PVS-Studio']; + } else { + ar[5] = ['Static analyzer', 'disabled']; + } + + output_as_table(["",""], ar); + STDOUT.WriteBlankLines(2); +} + +function generate_files() +{ + var i, dir, bd, last; + + STDOUT.WriteBlankLines(1); + STDOUT.WriteLine("Creating build dirs..."); + dir = get_define("BUILD_DIR"); + build_dirs.sort(); + last = null; + + if (!FSO.FolderExists(dir)) { + FSO.CreateFolder(dir); + } + + for (i = 0; i < build_dirs.length; i++) { + bd = FSO.BuildPath(dir, build_dirs[i]); + if (bd == last) { + continue; + } + last = bd; + + build_dir = get_define('BUILD_DIR'); + build_dir = build_dir.replace(new RegExp("\\\\", "g"), "\\\\"); + if (build_dir.substr(build_dir.Length - 2, 2) != '\\\\') { + build_dir += '\\\\'; + } + ADD_FLAG("BUILD_DIRS_SUB", bd.replace(new RegExp(build_dir), '')); + + if (!FSO.FolderExists(bd)) { + FSO.CreateFolder(bd); + } + } + + STDOUT.WriteLine("Generating files..."); + generate_makefile(); + if (!MODE_PHPIZE) { + generate_internal_functions(); + generate_config_h(); + generate_phpize(); + } else { + generate_config_pickle_h(); + generate_ext_pickle(); + } + STDOUT.WriteLine("Done."); + STDOUT.WriteBlankLines(1); + write_summary(); + + if (PHP_SNAPSHOT_BUILD != "no") { + STDOUT.WriteLine("Type 'nmake snap' to build a PHP snapshot"); + } else { + STDOUT.WriteLine("Type 'nmake' to build PHP"); + } +} + +function generate_ext_pickle() +{ + var content; + var DEPS = null; + var dest; + var deps_lines = new Array(); + + var build_var_name = function(name) { + return "PHP_" + name.toUpperCase(); + } + + STDOUT.WriteLine("Generating pickle deps"); + dest = PHP_DIR + "/script/"; + + if (!FSO.FolderExists(dest)) { + FSO.CreateFolder(dest); + } + + if (FSO.FileExists(dest + "/ext_pickle.js")) { + DEPS = FSO.OpenTextFile(dest + "/ext_pickle.js", 1); + + while (!DEPS.AtEndOfStream) { + var ln = DEPS.ReadLine(); + var found = false; + + for (var i in extensions_enabled) { + var reg0 = new RegExp(build_var_name(extensions_enabled[i][0]) + "\s*=.+", "g"); + var reg1 = new RegExp(build_var_name(extensions_enabled[i][0]) + "_SHARED" + "\s*=.+", "g"); + + if (ln.match(reg1) || ln.match(reg0)) { + found = true; + break; + } + } + + if (!found) { + deps_lines.push(ln); + } + } + } + + for (var i in extensions_enabled) { + deps_lines.push(build_var_name(extensions_enabled[i][0]) + "=true;"); + deps_lines.push(build_var_name(extensions_enabled[i][0]) + "_SHARED=" + (extensions_enabled[i][1] == 'shared' ? 'true' : 'false') + ";"); + } + + if (!!DEPS) { + DEPS.Close(); + DEPS = null; + } + + /* Replace the ext_pickle.js with the new content */ + DEPS = FSO.CreateTextFile(dest + "/ext_pickle.js", true); + + for (var j in deps_lines) { + DEPS.WriteLine(deps_lines[j]); + } + + DEPS.Close(); +} + +function generate_config_pickle_h() +{ + var outfile = null; + var lines = new Array(); + var keys = (new VBArray(configure_hdr.Keys())).toArray(); + dest = PHP_DIR + "/include/main"; + + var ignore_key = function(key) { + var ignores = [ "CONFIGURE_COMMAND", "PHP_COMPILER_ID", "COMPILER", "ARCHITECTURE", "HAVE_STRNLEN", "PHP_DIR" ]; + + for (var k in ignores) { + if (ignores[k] == key) { + return true; + } + } + + return false; + } + + + STDOUT.WriteLine("Generating main/config.pickle.h"); + + if (FSO.FileExists(dest + "/config.pickle.h")) { + outfile = FSO.OpenTextFile(dest + "/config.pickle.h", 1); + + while (!outfile.AtEndOfStream) { + var found = false; + var ln = outfile.ReadLine(); + + for (var i in keys) { + var reg = new RegExp("#define[\s ]+" + keys[i] + "[\s ]*.*", "g"); + + if (ln.match(reg)) { + found = true; + break; + } + } + + if (!found) { + lines.push(ln); + } + } + } + + for (var i in keys) { + var item = configure_hdr.Item(keys[i]); + + if (ignore_key(keys[i])) { + continue; + } + + /* XXX fix comment handling */ + /*if (!lines[j].match(/^#define.+/g)) { + continue; + }*/ + + lines.push("#define " + keys[i] + " " + item[0]); + } + + if (outfile) { + outfile.Close(); + outfile = null; + } + + outfile = FSO.CreateTextFile(dest + "/config.pickle.h", true); + + for (var k in lines) { + outfile.WriteLine(lines[k]); + } + + outfile.Close(); +} + +function generate_config_h() +{ + var infile, outfile; + var indata; + var prefix; + + prefix = PHP_PREFIX.replace(new RegExp("\\\\", "g"), "\\\\"); + + STDOUT.WriteLine("Generating main/config.w32.h"); + + infile = FSO.OpenTextFile("win32/build/config.w32.h.in", 1); + indata = infile.ReadAll(); + infile.Close(); + + outfile = FSO.CreateTextFile("main/config.w32.h", true); + + indata = indata.replace(new RegExp("@PREFIX@", "g"), prefix); + outfile.Write(indata); + + var keys = (new VBArray(configure_hdr.Keys())).toArray(); + var i, j; + var item; + var pieces, stuff_to_crack, chunk; + + outfile.WriteBlankLines(1); + outfile.WriteLine("/* values determined by configure.js */"); + + for (i in keys) { + item = configure_hdr.Item(keys[i]); + outfile.WriteBlankLines(1); + pieces = item[0]; + + if (item[1] != undefined) { + outfile.WriteLine("/* " + item[1] + " */"); + } + + if (typeof(pieces) == "string" && pieces.charCodeAt(0) == 34) { + /* quoted string have a maximal length of 2k under vc. + * solution is to crack them and let the compiler concat + * them implicitly */ + stuff_to_crack = pieces; + pieces = ""; + + while (stuff_to_crack.length) { + j = 65; + while (stuff_to_crack.charCodeAt(j) != 32 && j < stuff_to_crack.length) + j++; + + chunk = stuff_to_crack.substr(0, j); + pieces += chunk; + stuff_to_crack = stuff_to_crack.substr(chunk.length); + if (stuff_to_crack.length) + pieces += '" "'; + } + } + + outfile.WriteLine("#define " + keys[i] + " " + pieces); + } + + if (VS_TOOLSET && VCVERS >= 1800) { + outfile.WriteLine(""); + outfile.WriteLine("#define HAVE_ACOSH 1"); + outfile.WriteLine("#define HAVE_ASINH 1"); + outfile.WriteLine("#define HAVE_ATANH 1"); + } + + + outfile.Close(); +} + +function generate_phpize() +{ + STDOUT.WriteLine("Generating phpize"); + dest = get_define("BUILD_DIR") + '/devel'; + + if (!FSO.FolderExists(dest)) { + FSO.CreateFolder(dest); + } + + var MF = FSO.CreateTextFile(dest + "/phpize.js", true); + var DEPS = FSO.CreateTextFile(dest + "/ext_deps.js", true); + + prefix = get_define("PHP_PREFIX"); + prefix = prefix.replace(new RegExp("/", "g"), "\\"); + prefix = prefix.replace(new RegExp("\\\\", "g"), "\\\\"); + MF.WriteLine("var PHP_PREFIX=" + '"' + prefix + '"'); + MF.WriteLine("var PHP_ZTS=" + '"' + (PHP_ZTS.toLowerCase() == "yes" ? "Yes" : "No") + '"'); + MF.WriteLine("var VC_VERSION=" + VCVERS); + MF.WriteLine("var PHP_VERSION=" + PHP_VERSION); + MF.WriteLine("var PHP_MINOR_VERSION=" + PHP_MINOR_VERSION); + MF.WriteLine("var PHP_RELEASE_VERSION=" + PHP_RELEASE_VERSION); + MF.WriteBlankLines(1); + MF.WriteLine("/* Genereted extensions list with mode (static/shared) */"); + + var count = extensions_enabled.length; + for (i in extensions_enabled) { + out = "PHP_" + extensions_enabled[i][0].toUpperCase() + "_SHARED=" + (extensions_enabled[i][1] == 'shared' ? 'true' : 'false') + ";"; + DEPS.WriteLine("PHP_" + extensions_enabled[i][0].toUpperCase() + "=true;"); + DEPS.WriteLine(out); + MF.WriteLine(out); + } + + MF.WriteBlankLines(2); + MF.WriteLine("/* Genereted win32/build/phpize.js.in */"); + MF.WriteBlankLines(1); + MF.Write(file_get_contents("win32/build/phpize.js.in")); + MF.Close(); + DEPS.Close(); + + /* Generate flags file */ + /* spit out variable definitions */ + CJ = FSO.CreateTextFile(dest + "/config.phpize.js"); + + CJ.WriteLine("var PHP_ZTS =" + '"' + PHP_ZTS + '"'); + CJ.WriteLine("var PHP_DLL_LIB =" + '"' + get_define('PHPLIB') + '"'); + CJ.WriteLine("var PHP_DLL =" + '"' + get_define('PHPDLL') + '"'); + CJ.WriteBlankLines(1); + CJ.Close(); +} + +function generate_makefile() +{ + STDOUT.WriteLine("Generating Makefile"); + var MF = FSO.CreateTextFile("Makefile", true); + + MF.WriteLine("# Generated by configure.js"); + /* spit out variable definitions */ + var keys = (new VBArray(configure_subst.Keys())).toArray(); + var i; + MF.WriteLine("PHP_SRC_DIR =" + PHP_SRC_DIR); + for (i in keys) { + // The trailing space is needed to prevent the trailing backslash + // that is part of the build dir flags (CFLAGS_BD_XXX) from being + // seen as a line continuation character + MF.WriteLine(keys[i] + "=" + + //word_wrap_and_indent(1, configure_subst.Item(keys[i]), ' \\', '\t') + " " + configure_subst.Item(keys[i]) + " " + ); + MF.WriteBlankLines(1); + } + + MF.WriteBlankLines(1); + if (MODE_PHPIZE) { + var TF = FSO.OpenTextFile(PHP_DIR + "/script/Makefile.phpize", 1); + } else { + var TF = FSO.OpenTextFile("win32/build/Makefile", 1); + } + + MF.Write(TF.ReadAll()); + + MF.WriteLine("build-headers:"); + MF.WriteLine(" @if not exist $(BUILD_DIR_DEV)\\include mkdir $(BUILD_DIR_DEV)\\include >nul"); + MF.WriteLine(" @for %D in ($(INSTALL_HEADERS_DIR)) do @if not exist $(BUILD_DIR_DEV)\\include\\%D mkdir $(BUILD_DIR_DEV)\\include\\%D >nul"); + for (i in headers_install) { + if (headers_install[i][2] != "") { + MF.WriteLine(" @if not exist $(BUILD_DIR_DEV)\\include\\" + headers_install[i][2] + " mkdir $(BUILD_DIR_DEV)\\include\\" + + headers_install[i][2] + ">nul"); + MF.WriteLine(" @copy " + headers_install[i][0] + " " + "$(BUILD_DIR_DEV)\\include\\" + headers_install[i][2] + " /y >nul"); + } + } + MF.WriteLine(" @for %D in ($(INSTALL_HEADERS_DIR)) do @copy %D*.h $(BUILD_DIR_DEV)\\include\\%D /y >nul"); + if (MODE_PHPIZE) { + MF.WriteBlankLines(1); + MF.WriteLine("build-bins:"); + for (var i in extensions_enabled) { + var lib = "php_" + extensions_enabled[i][0] + ".lib"; + var dll = "php_" + extensions_enabled[i][0] + ".dll"; + MF.WriteLine(" @copy $(BUILD_DIR)\\" + lib + " $(BUILD_DIR_DEV)\\lib"); + MF.WriteLine(" @copy $(BUILD_DIR)\\" + dll + " $(PHP_PREFIX)"); + } + } else { + MF.WriteBlankLines(1); + MF.WriteLine("build-ext-libs:"); + MF.WriteLine(" @if not exist $(BUILD_DIR_DEV)\\lib mkdir $(BUILD_DIR_DEV)\\lib >nul"); + for (var i in extensions_enabled) { + var lib; + + lib = "php_" + extensions_enabled[i][0] + "*.lib"; + + if ('shared' == extensions_enabled[i][1]) { + MF.WriteLine(" @if exist $(BUILD_DIR)\\" + lib + " copy $(BUILD_DIR)\\" + lib + " $(BUILD_DIR_DEV)\\lib"); + } + } + } + TF.Close(); + + MF.WriteBlankLines(2); + + MFO.Close(); + TF = FSO.OpenTextFile("Makefile.objects", 1); + if (!TF.AtEndOfStream) { + MF.Write(TF.ReadAll()); + } + TF.Close(); + + MF.Close(); +} + +function ADD_FLAG(name, flags, target) +{ + if (target != null) { + name = target.toUpperCase() + "_" + name; + } + if (configure_subst.Exists(name)) { + var curr_flags = configure_subst.Item(name); + + if (curr_flags.indexOf(flags) >= 0) { + return; + } + + flags = curr_flags + " " + flags; + configure_subst.Remove(name); + } + configure_subst.Add(name, flags); +} + +function get_define(name) +{ + if (configure_subst.Exists(name)) { + return configure_subst.Item(name); + } + return ""; +} + +// Add a .def to the core to export symbols +function ADD_DEF_FILE(name) +{ + if (!configure_subst.Exists("PHPDEF")) { + DEFINE("PHPDEF", "$(BUILD_DIR)\\$(PHPDLL).def"); + ADD_FLAG("PHP_LDFLAGS", "/def:$(PHPDEF)"); + } + ADD_FLAG("PHP_DLL_DEF_SOURCES", name); +} + +function AC_DEFINE(name, value, comment, quote) +{ + if (quote == null) { + quote = true; + } + if (quote && typeof(value) == "string") { + value = '"' + value.replace(new RegExp('(["\\\\])', "g"), '\\$1') + '"'; + } else if (typeof(value) != "undefined" && value.length == 0) { + value = '""'; + } + var item = new Array(value, comment); + if (configure_hdr.Exists(name)) { + var orig_item = configure_hdr.Item(name); + STDOUT.WriteLine("AC_DEFINE[" + name + "]=" + value + ": is already defined to " + orig_item[0]); + } else { + configure_hdr.Add(name, item); + } +} + +function MESSAGE(msg) +{ + STDOUT.WriteLine("" + msg); +} + +function ERROR(msg) +{ + STDERR.WriteLine("ERROR: " + msg); + WScript.Quit(3); +} + +function WARNING(msg) +{ + STDERR.WriteLine("WARNING: " + msg); + STDERR.WriteBlankLines(1); +} + +function copy_and_subst(srcname, destname, subst_array) +{ + if (!FSO.FileExists(srcname)) { + srcname = configure_module_dirname + "\\" + srcname; + destname = configure_module_dirname + "\\" + destname; + } + + var content = file_get_contents(srcname); + var i; + + for (i = 0; i < subst_array.length; i+=2) { + var re = subst_array[i]; + var rep = subst_array[i+1]; + + content = content.replace(re, rep); + } + + var f = FSO.CreateTextFile(destname, true); + f.Write(content); + f.Close(); +} + +// glob using simple filename wildcards +// returns an array of matches that are found +// in the filesystem +function glob(path_pattern) +{ + var path_parts = path_pattern.replace(new RegExp("/", "g"), "\\").split("\\"); + var p; + var base = ""; + var is_pat_re = /\*/; + +//STDOUT.WriteLine("glob: " + path_pattern); + + if (FSO.FileExists(path_pattern)) { + return new Array(path_pattern); + } + + // first, build as much as possible that doesn't have a pattern + for (p = 0; p < path_parts.length; p++) { + if (path_parts[p].match(is_pat_re)) + break; + if (p) + base += "\\"; + base += path_parts[p]; + } + + return _inner_glob(base, p, path_parts); +} + +function _inner_glob(base, p, parts) +{ + var pat = parts[p]; + var full_name = base + "\\" + pat; + var re = null; + var items = null; + + if (p == parts.length) { + return false; + } + +//STDOUT.WriteLine("inner: base=" + base + " p=" + p + " pat=" + pat); + + if (FSO.FileExists(full_name)) { + if (p < parts.length - 1) { + // we didn't reach the full extent of the pattern + return false; + } + return new Array(full_name); + } + + if (FSO.FolderExists(full_name) && p == parts.length - 1) { + // we have reached the end of the pattern; no need to recurse + return new Array(full_name); + } + + // Convert the pattern into a regexp + re = new RegExp("^" + pat.replace(/\./g, '\\.').replace(/\*/g, '.*').replace(/\?/g, '.') + "$", "i"); + + items = new Array(); + + if (!FSO.FolderExists(base)) { + return false; + } + + var folder = FSO.GetFolder(base); + var fc = null; + var subitems = null; + var item_name = null; + var j; + + fc = new Enumerator(folder.SubFolders); + for (; !fc.atEnd(); fc.moveNext()) { + item_name = FSO.GetFileName(fc.item()); + + if (item_name.match(re)) { + // got a match; if we are at the end of the pattern, just add these + // things to the items array + if (p == parts.length - 1) { + items[items.length] = fc.item(); + } else { + // we should recurse and do more matches + subitems = _inner_glob(base + "\\" + item_name, p + 1, parts); + if (subitems) { + for (j = 0; j < subitems.length; j++) { + items[items.length] = subitems[j]; + } + } + } + } + } + + // if we are at the end of the pattern, we should match + // files too + if (p == parts.length - 1) { + fc = new Enumerator(folder.Files); + for (; !fc.atEnd(); fc.moveNext()) { + item_name = FSO.GetFileName(fc.item()); + if (item_name.match(re)) { + items[items.length] = fc.item(); + } + } + } + + if (items.length == 0) + return false; + + return items; +} + +function PHP_INSTALL_HEADERS(dir, headers_list) +{ + headers_list = headers_list.split(new RegExp("\\s+")); + headers_list.sort(); + if (dir.length > 0 && dir.substr(dir.length - 1) != '/' && dir.substr(dir.length - 1) != '\\') { + dir += '/'; + } + dir = dir.replace(new RegExp("/", "g"), "\\"); + + for (i in headers_list) { + found = false; + src = headers_list[i]; + src = src.replace(new RegExp("/", "g"), "\\"); + isdir = FSO.FolderExists(dir + src); + isfile = FSO.FileExists(dir + src); + if (isdir) { + if (src.length > 0 && src.substr(src.length - 1) != '/' && src.substr(src.length - 1) != '\\') { + src += '\\'; + } + headers_install[headers_install.length] = [dir + src, 'dir','']; + ADD_FLAG("INSTALL_HEADERS_DIR", dir + src); + found = true; + } else if (isfile) { + dirname = FSO.GetParentFolderName(dir + src); + headers_install[headers_install.length] = [dir + src, 'file', dirname]; + ADD_FLAG("INSTALL_HEADERS", dir + src); + found = true; + } else { + path = configure_module_dirname + "\\"+ src; + isdir = FSO.FolderExists(path); + isfile = FSO.FileExists(path); + if (isdir) { + if (src.length > 0 && src.substr(src.length - 1) != '/' && src.substr(src.length - 1) != '\\') { + src += '\\'; + } + headers_install[headers_install.length] = [path, 'dir','']; + ADD_FLAG("INSTALL_HEADERS_DIR", path); + } else if (isfile) { + dirname = FSO.GetParentFolderName(path); + headers_install[headers_install.length] = [path, 'file', dir]; + ADD_FLAG("INSTALL_HEADERS", dir + src); + found = true; + } + } + + if (found == false) { + STDOUT.WriteLine(headers_list); + ERROR("Cannot find header " + dir + src); + } + } +} + +// for snapshot builders, this option will attempt to enable everything +// and you can then build everything, ignoring fatal errors within a module +// by running "nmake snap" +PHP_SNAPSHOT_BUILD = "no"; +if (!MODE_PHPIZE) { + ARG_ENABLE('snapshot-build', 'Build a snapshot; turns on everything it can and ignores build errors', 'no'); + + // one-shot build optimizes build by asking compiler to build + // several objects at once, reducing overhead of starting new + // compiler processes. + ARG_ENABLE('one-shot', 'Optimize for fast build - best for release and snapshot builders, not so hot for edit-and-rebuild hacking', 'no'); +} + +function toolset_get_compiler() +{ + if (VS_TOOLSET) { + return PATH_PROG('cl', null, 'PHP_CL') + } else if (CLANG_TOOLSET) { + return PATH_PROG('clang-cl', null, 'PHP_CL') + } else if (INTEL_TOOLSET) { + return PATH_PROG('icl', null, 'PHP_CL') + } + + ERROR("Wrong toolset"); +} + +function toolset_get_compiler_version() +{ + var version; + + if (VS_TOOLSET) { + version = probe_binary(PHP_CL).substr(0, 5).replace('.', ''); + + return version; + } else if (CLANG_TOOLSET) { + var command = 'cmd /c ""' + PHP_CL + '" -v"'; + var full = execute(command + '" 2>&1"'); + + if (full.match(/clang version ([\d\.]+) \((.*)\)/)) { + version = RegExp.$1; + version = version.replace(/\./g, ''); + version = version/100 < 1 ? version*10 : version; + + return version; + } + } else if (INTEL_TOOLSET) { + var command = 'cmd /c ""' + PHP_CL + '" -v"'; + var full = execute(command + '" 2>&1"'); + + if (full.match(/Version (\d\.\d\.\d)/)) { + version = RegExp.$1; + version = version.replace(/\./g, ''); + version = version/100 < 1 ? version*10 : version; + + return version; + } + } + + ERROR("Wrong toolset"); +} + +function toolset_get_compiler_name() +{ + var version; + + if (VS_TOOLSET) { + version = probe_binary(PHP_CL).substr(0, 5).replace('.', ''); + return VC_VERSIONS[version]; + } else if (CLANG_TOOLSET || INTEL_TOOLSET) { + var command = 'cmd /c ""' + PHP_CL + '" -v"'; + var full = execute(command + '" 2>&1"'); + + return full.split(/\n/)[0].replace(/\s/g, ' '); + } + + ERROR("Wrong toolset"); +} + + +function toolset_is_64() +{ + if (VS_TOOLSET) { + return probe_binary(PHP_CL, 64, null, 'PHP_CL'); + } else if (CLANG_TOOLSET) { + /* Seems to be impossible to get it from the clang binary, so lets use the normal cl.exe, + as clang should be running in VS environment. */ + var vs_cl = PATH_PROG('cl', null, 'PHP_CL') + return probe_binary(vs_cl, 64); + } else if (INTEL_TOOLSET) { + + } + + ERROR("Wrong toolset"); +} + + +function toolset_get_linker() +{ + if (VS_TOOLSET) { + return PATH_PROG('link', WshShell.Environment("Process").Item("PATH")); + } else if (CLANG_TOOLSET) { + //return PATH_PROG('lld', WshShell.Environment("Process").Item("PATH"), "LINK"); + return PATH_PROG('link', WshShell.Environment("Process").Item("PATH")); + } else if (INTEL_TOOLSET) { + return PATH_PROG('xilink', WshShell.Environment("Process").Item("PATH"), "LINK"); + } + + ERROR("Wrong toolset"); +} + + From cd2aa28a7d1d7049f48b66084f629d6b1552128e Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 6 Nov 2014 23:04:53 +0100 Subject: [PATCH 261/398] basic support for Intel Composer --- win32/build/config.w32 | 15 +++++++++++---- win32/build/confutils.js | 8 +++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/win32/build/config.w32 b/win32/build/config.w32 index c06ae509b7a..7305b480dca 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -3,11 +3,15 @@ // "Master" config file; think of it as a configure.in // equivalent. -ARG_WITH("toolset", "Toolset to use for the compilation, supported: vs, clang", "vs"); +ARG_WITH("toolset", "Toolset to use for the compilation, supported: vs, clang, intel", "vs"); if ("clang" == PHP_TOOLSET) { VS_TOOLSET = false; CLANG_TOOLSET = true; INTEL_TOOLSET = false; +} else if ("intel" == PHP_TOOLSET) { + VS_TOOLSET = false; + CLANG_TOOLSET = false; + INTEL_TOOLSET = true; } else { /* Visual Studio is the default toolset. */ PHP_TOOLSET = "no" == PHP_TOOLSET ? "vs" : PHP_TOOLSET; @@ -56,8 +60,11 @@ if (VS_TOOLSET) { AC_DEFINE('PHP_COMPILER_ID', "clang"); /* XXX something better were to write here */ } else if (INTEL_TOOLSET) { - //INTELVERS = compiler_ver; - // .... + INTELVERS = COMPILER_NUMERIC_VERSION; + + AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version"); + DEFINE("PHP_COMPILER_SHORT", "icc"); + AC_DEFINE('PHP_COMPILER_ID', "icc"); /* XXX something better were to write here */ } STDOUT.WriteLine(" Detected compiler " + COMPILER_NAME); @@ -427,7 +434,7 @@ ADD_SOURCES("win32", "inet.c fnmatch.c sockets.c"); if (VS_TOOLSET && VCVERS <= 1300) { ADD_SOURCES("win32", "strtoi64.c"); } -if (VS_TOOLSET && VCVERS >= 1400) { +if (VS_TOOLSET && VCVERS >= 1400 || INTEL_TOOLSET) { AC_DEFINE('HAVE_STRNLEN', 1); } diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 33fcf7ce738..da548225de3 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -2328,7 +2328,7 @@ function toolset_get_compiler_version() var command = 'cmd /c ""' + PHP_CL + '" -v"'; var full = execute(command + '" 2>&1"'); - if (full.match(/Version (\d\.\d\.\d)/)) { + if (full.match(/Version (\d+\.\d+\.\d+)/)) { version = RegExp.$1; version = version.replace(/\./g, ''); version = version/100 < 1 ? version*10 : version; @@ -2337,7 +2337,7 @@ function toolset_get_compiler_version() } } - ERROR("Wrong toolset"); + ERROR("Failed to parse compiler out for compiler version"); } function toolset_get_compiler_name() @@ -2368,7 +2368,9 @@ function toolset_is_64() var vs_cl = PATH_PROG('cl', null, 'PHP_CL') return probe_binary(vs_cl, 64); } else if (INTEL_TOOLSET) { - + /*seems the easiest way as well for now */ + var vs_cl = PATH_PROG('cl', null, 'PHP_CL') + return probe_binary(vs_cl, 64); } ERROR("Wrong toolset"); From ac71c5812b9246edbae7c9fe8281c1186c1b9a4a Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 6 Nov 2014 23:15:56 +0100 Subject: [PATCH 262/398] fix x64 recognition for clang and icc --- win32/build/confutils.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/win32/build/confutils.js b/win32/build/confutils.js index da548225de3..c2bb4b0fbd7 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -2361,16 +2361,17 @@ function toolset_get_compiler_name() function toolset_is_64() { if (VS_TOOLSET) { - return probe_binary(PHP_CL, 64, null, 'PHP_CL'); + return probe_binary(PHP_CL, 64); } else if (CLANG_TOOLSET) { - /* Seems to be impossible to get it from the clang binary, so lets use the normal cl.exe, - as clang should be running in VS environment. */ - var vs_cl = PATH_PROG('cl', null, 'PHP_CL') - return probe_binary(vs_cl, 64); + var command = 'cmd /c ""' + PHP_CL + '" -v"'; + var full = execute(command + '" 2>&1"'); + + return null != full.match(/x86_64/); } else if (INTEL_TOOLSET) { - /*seems the easiest way as well for now */ - var vs_cl = PATH_PROG('cl', null, 'PHP_CL') - return probe_binary(vs_cl, 64); + var command = 'cmd /c ""' + PHP_CL + '" -v"'; + var full = execute(command + '" 2>&1"'); + + return null != full.match(/Intel\(R\) 64/); } ERROR("Wrong toolset"); From 1310bb5e2ec3ab428b26396237dce82a506ba2b5 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 6 Nov 2014 23:43:36 +0100 Subject: [PATCH 263/398] using the determined linker instead of compiler this is a clang issue, longer parameter strings would be issue for both compiler and linker --- win32/build/Makefile | 3 ++- win32/build/config.w32 | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/win32/build/Makefile b/win32/build/Makefile index b2918b7117c..90f02d24943 100644 --- a/win32/build/Makefile +++ b/win32/build/Makefile @@ -89,7 +89,8 @@ $(PHPDLL_RES): win32\build\template.rc win32\build\template.rc $(BUILD_DIR)\$(PHPDLL): generated_files $(PHPDEF) $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(PHPDLL_RES) $(MCFILE) - @$(CC) $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(STATIC_EXT_LIBS) $(LIBS) $(PHPDLL_RES) /link /out:$(BUILD_DIR)\$(PHPDLL) $(PHP7_PGD_OPTION) $(PHP_LDFLAGS) $(LDFLAGS) $(STATIC_EXT_LDFLAGS) +# @$(CC) $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(STATIC_EXT_LIBS) $(LIBS) $(PHPDLL_RES) /link /out:$(BUILD_DIR)\$(PHPDLL) $(PHP7_PGD_OPTION) $(PHP_LDFLAGS) $(LDFLAGS) $(STATIC_EXT_LDFLAGS) + @"$(LINK)" $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(STATIC_EXT_LIBS) $(LIBS) $(PHPDLL_RES) /out:$(BUILD_DIR)\$(PHPDLL) $(PHP7_PGD_OPTION) $(PHP_LDFLAGS) $(LDFLAGS) $(STATIC_EXT_LDFLAGS) -@$(_VC_MANIFEST_EMBED_DLL) $(BUILD_DIR)\$(PHPLIB): $(BUILD_DIR)\$(PHPDLL) diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 7305b480dca..5af43734f0c 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -233,7 +233,7 @@ if (VS_TOOLSET && VCVERS >= 1500 && PHP_MP != 'disable') { // General link flags -if (VS_TOOLSET || CLANG_TOOLSET) { +if (VS_TOOLSET) { if (VCVERS >= 1700) { DEFINE("LDFLAGS", "/nologo "); } else { From 936575c2e20230800ca1a50110100034da42f599 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 7 Nov 2014 00:57:15 +0100 Subject: [PATCH 264/398] adjust pid_t declaration so it doesn't conflict with apache one --- main/win95nt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/win95nt.h b/main/win95nt.h index 76bec05ea52..febffecadf7 100644 --- a/main/win95nt.h +++ b/main/win95nt.h @@ -55,7 +55,7 @@ typedef char * caddr_t; typedef unsigned int uint; typedef unsigned long ulong; #if !NSAPI -typedef long pid_t; +typedef int pid_t; #endif /* missing in vc5 math.h */ From 46d6baf6a0113245e7442450a2592a81feb55a8a Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 7 Nov 2014 00:58:02 +0100 Subject: [PATCH 265/398] fix linking for clang, using linker directly --- win32/build/config.w32 | 4 ++-- win32/build/confutils.js | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 5af43734f0c..a64cdd66c33 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -233,8 +233,8 @@ if (VS_TOOLSET && VCVERS >= 1500 && PHP_MP != 'disable') { // General link flags -if (VS_TOOLSET) { - if (VCVERS >= 1700) { +if (VS_TOOLSET || CLANG_TOOLSET) { + if (VCVERS >= 1700 || CLANG_TOOLSET) { DEFINE("LDFLAGS", "/nologo "); } else { DEFINE("LDFLAGS", "/nologo /version:" + diff --git a/win32/build/confutils.js b/win32/build/confutils.js index c2bb4b0fbd7..55d1e8ccc29 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -1117,15 +1117,15 @@ function SAPI(sapiname, file_list, makefiletarget, cflags, obj_dir) if (ld) { MFO.WriteLine("\t" + ld + " /nologo /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(" + SAPI + "_GLOBAL_OBJS) $(PHPLIB) $(LDFLAGS_" + SAPI + ") $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname); } else { - ld = "@$(CC)"; - MFO.WriteLine("\t" + ld + " /nologo " + " $(" + SAPI + "_GLOBAL_OBJS) $(PHPLIB) $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname + " /link /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(LDFLAGS_" + SAPI + ")"); + ld = '@"$(LINK)"'; + MFO.WriteLine("\t" + ld + " /nologo " + " $(" + SAPI + "_GLOBAL_OBJS) $(PHPLIB) $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname + " /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(LDFLAGS_" + SAPI + ")"); } } else { if (ld) { MFO.WriteLine("\t" + ld + " /nologo /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(" + SAPI + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LDFLAGS_" + SAPI + ") $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname); } else { - ld = "@$(CC)"; - MFO.WriteLine("\t" + ld + " /nologo " + " $(" + SAPI + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname + " /link /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(LDFLAGS_" + SAPI + ")"); + ld = '@"$(LINK)"'; + MFO.WriteLine("\t" + ld + " /nologo " + " $(" + SAPI + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname + " /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(LDFLAGS_" + SAPI + ")"); } } @@ -1290,7 +1290,7 @@ function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir) var libname = dllname.substring(0, dllname.length-4) + ".lib"; var resname = generate_version_info_resource(dllname, extname, configure_module_dirname, false); - var ld = "@$(CC)"; + var ld = '@"$(LINK)"'; ldflags = ""; if (is_pgo_desired(extname) && (PHP_PGI == "yes" || PHP_PGO != "no")) { @@ -1311,10 +1311,10 @@ function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir) MFO.WriteBlankLines(1); if (MODE_PHPIZE) { MFO.WriteLine("$(BUILD_DIR)\\" + dllname + ": $(DEPS_" + EXT + ") $(" + EXT + "_GLOBAL_OBJS) $(PHPLIB) $(BUILD_DIR)\\" + resname); - MFO.WriteLine("\t" + ld + " $(" + EXT + "_GLOBAL_OBJS) $(PHPLIB) $(LIBS_" + EXT + ") $(LIBS) $(BUILD_DIR)\\" + resname + " /link /out:$(BUILD_DIR)\\" + dllname + " $(DLL_LDFLAGS) $(LDFLAGS) $(LDFLAGS_" + EXT + ")"); + MFO.WriteLine("\t" + ld + " $(" + EXT + "_GLOBAL_OBJS) $(PHPLIB) $(LIBS_" + EXT + ") $(LIBS) $(BUILD_DIR)\\" + resname + " /out:$(BUILD_DIR)\\" + dllname + " $(DLL_LDFLAGS) $(LDFLAGS) $(LDFLAGS_" + EXT + ")"); } else { MFO.WriteLine("$(BUILD_DIR)\\" + dllname + ": $(DEPS_" + EXT + ") $(" + EXT + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(BUILD_DIR)\\" + resname); - MFO.WriteLine("\t" + ld + " $(" + EXT + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LIBS_" + EXT + ") $(LIBS) $(BUILD_DIR)\\" + resname + " /link /out:$(BUILD_DIR)\\" + dllname + ldflags + " $(DLL_LDFLAGS) $(LDFLAGS) $(LDFLAGS_" + EXT + ")"); + MFO.WriteLine("\t" + ld + " $(" + EXT + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LIBS_" + EXT + ") $(LIBS) $(BUILD_DIR)\\" + resname + " /out:$(BUILD_DIR)\\" + dllname + ldflags + " $(DLL_LDFLAGS) $(LDFLAGS) $(LDFLAGS_" + EXT + ")"); } MFO.WriteLine("\t-@$(_VC_MANIFEST_EMBED_DLL)"); MFO.WriteBlankLines(1); From 4d8c28af60c9876749cf6aa83b56f4903df1d063 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 7 Nov 2014 11:48:03 +0100 Subject: [PATCH 266/398] catch up the toolset changes with phpize also packed common parts into functions so there's less code duplication --- win32/build/config.w32 | 116 +++------------------------- win32/build/config.w32.phpize.in | 91 ++++------------------ win32/build/confutils.js | 128 +++++++++++++++++++++++++++++-- 3 files changed, 147 insertions(+), 188 deletions(-) diff --git a/win32/build/config.w32 b/win32/build/config.w32 index a64cdd66c33..85cec0ce87d 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -4,69 +4,11 @@ // equivalent. ARG_WITH("toolset", "Toolset to use for the compilation, supported: vs, clang, intel", "vs"); -if ("clang" == PHP_TOOLSET) { - VS_TOOLSET = false; - CLANG_TOOLSET = true; - INTEL_TOOLSET = false; -} else if ("intel" == PHP_TOOLSET) { - VS_TOOLSET = false; - CLANG_TOOLSET = false; - INTEL_TOOLSET = true; -} else { - /* Visual Studio is the default toolset. */ - PHP_TOOLSET = "no" == PHP_TOOLSET ? "vs" : PHP_TOOLSET; - if (!!PHP_TOOLSET && "vs" != PHP_TOOLSET) { - ERROR("Unsupported toolset name '" + PHP_TOOLSET + "'"); - } - VS_TOOLSET = true; - CLANG_TOOLSET = false; - INTEL_TOOLSET = false; -} - +toolset_option_handle(); ARG_WITH('cygwin', 'Path to cygwin utilities on your system', '\\cygwin'); -PHP_CL = toolset_get_compiler(); -if (!PHP_CL) { - ERROR("MS C++ compiler is required"); -} - -COMPILER_NUMERIC_VERSION = toolset_get_compiler_version(); -COMPILER_NAME = toolset_get_compiler_name(); - -if (VS_TOOLSET) { - /* For the record here: */ - // 1200 is VC6 - // 1300 is vs.net 2002 - // 1310 is vs.net 2003 - // 1400 is vs.net 2005 - // 1500 is vs.net 2008 - // 1600 is vs.net 2010 - // Which version of the compiler do we have? - VCVERS = COMPILER_NUMERIC_VERSION; - - if (VCVERS < 1500) { - ERROR("Unsupported MS C++ Compiler, VC9 (2008) minimum is required"); - } - - AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version"); - DEFINE("PHP_COMPILER_SHORT", VC_VERSIONS_SHORT[VCVERS]); - AC_DEFINE('PHP_COMPILER_ID', VC_VERSIONS_SHORT[VCVERS], "Compiler compatibility ID"); -} else if (CLANG_TOOLSET) { - CLANGVERS = COMPILER_NUMERIC_VERSION; - - AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version"); - DEFINE("PHP_COMPILER_SHORT", "clang"); - AC_DEFINE('PHP_COMPILER_ID', "clang"); /* XXX something better were to write here */ - -} else if (INTEL_TOOLSET) { - INTELVERS = COMPILER_NUMERIC_VERSION; - - AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version"); - DEFINE("PHP_COMPILER_SHORT", "icc"); - AC_DEFINE('PHP_COMPILER_ID', "icc"); /* XXX something better were to write here */ -} -STDOUT.WriteLine(" Detected compiler " + COMPILER_NAME); +toolset_setup_compiler(); // do we use x64 or 80x86 version of compiler? X64 = toolset_is_64(); @@ -78,53 +20,8 @@ if (X64) { AC_DEFINE('ARCHITECTURE', X64 ? 'x64' : 'x86', "Detected compiler architecture"); DEFINE("PHP_ARCHITECTURE", X64 ? 'x64' : 'x86'); -// cygwin now ships with link.exe. Avoid searching the cygwin path -// for this, as we want the MS linker, not the fileutil -toolset_get_linker(); - -PATH_PROG('nmake'); - -// we don't want to define LIB, as that will override the default library path -// that is set in that env var -PATH_PROG('lib', null, 'MAKE_LIB'); -if (!PATH_PROG('bison')) { - ERROR('bison is required') -} - -// There's a minimum requirement for re2c.. -MINRE2C = "0.13.4"; - -RE2C = PATH_PROG('re2c'); -if (RE2C) { - var intvers, intmin; - var pattern = /\./g; - - RE2CVERS = probe_binary(RE2C, "version"); - STDOUT.WriteLine(' Detected re2c version ' + RE2CVERS); - - intvers = RE2CVERS.replace(pattern, '') - 0; - intmin = MINRE2C.replace(pattern, '') - 0; - - if (intvers < intmin) { - STDOUT.WriteLine('WARNING: The minimum RE2C version requirement is ' + MINRE2C); - STDOUT.WriteLine('Parsers will not be generated. Upgrade your copy at http://sf.net/projects/re2c'); - DEFINE('RE2C', ''); - } else { - DEFINE('RE2C_FLAGS', ''); - } -} else { - STDOUT.WriteLine('Parsers will not be regenerated'); -} -PATH_PROG('zip'); -PATH_PROG('lemon'); - -// avoid picking up midnight commander from cygwin -PATH_PROG('mc', WshShell.Environment("Process").Item("PATH")); - -// Try locating manifest tool -if (VS_TOOLSET && VCVERS > 1200) { - PATH_PROG('mt', WshShell.Environment("Process").Item("PATH")); -} +toolset_setup_linker(); +toolset_setup_project_tools(); // stick objects somewhere outside of the source tree ARG_ENABLE('object-out-dir', 'Alternate location for binary objects during build', ''); @@ -180,6 +77,10 @@ DEFINE('CFLAGS_PHP_OBJ', '$(CFLAGS_PHP) $(STATIC_EXT_CFLAGS)'); // General CFLAGS for building objects DEFINE("CFLAGS", "/nologo $(BASE_INCLUDES) /D _WINDOWS \ /D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /W3 "); +if (VS_TOOLSET) { + ADD_FLAG("CFLAGS", " /FD "); +} + if (CLANG_TOOLSET) { if (X64) { ADD_FLAG('CFLAGS', ' -m64 '); @@ -420,6 +321,7 @@ ADD_SOURCES("Zend", "zend_language_parser.c zend_language_scanner.c \ zend_float.c zend_string.c zend_generators.c zend_virtual_cwd.c zend_ast.c \ zend_inheritance.c"); +/* XXX inspect this for other toolsets */ if (VS_TOOLSET && VCVERS == 1200) { AC_DEFINE('ZEND_DVAL_TO_LVAL_CAST_OK', 1); } diff --git a/win32/build/config.w32.phpize.in b/win32/build/config.w32.phpize.in index 9b28352c8fe..91ebc241845 100644 --- a/win32/build/config.w32.phpize.in +++ b/win32/build/config.w32.phpize.in @@ -3,32 +3,15 @@ // "Master" config file; think of it as a configure.in // equivalent. +ARG_WITH("toolset", "Toolset to use for the compilation, supported: vs, clang, intel", "vs"); +toolset_option_handle() + var PHP_CYGWIN="notset"; -PHP_CL = PATH_PROG('cl', null, 'PHP_CL'); -if (!PHP_CL) { - ERROR("MS C++ compiler is required"); -} -/* For the record here: */ -// 1200 is VC6 -// 1300 is vs.net 2002 -// 1310 is vs.net 2003 -// 1400 is vs.net 2005 -// 1500 is vs.net 2008 -// 1600 is vs.net 2010 -// Which version of the compiler do we have? -VCVERS = probe_binary(PHP_CL).substr(0, 5).replace('.', ''); -STDOUT.WriteLine(" Detected compiler " + VC_VERSIONS[VCVERS]); -if (VCVERS < 1500) { - ERROR("Unsupported MS C++ Compiler, VC9 (2008) minimum is required"); -} - -AC_DEFINE('COMPILER', VC_VERSIONS[VCVERS], "Detected compiler version"); -DEFINE("PHP_COMPILER_SHORT", VC_VERSIONS_SHORT[VCVERS]); -AC_DEFINE('PHP_COMPILER_ID', VC_VERSIONS_SHORT[VCVERS], "Compiler compatibility ID"); +toolset_setup_compiler(); // do we use x64 or 80x86 version of compiler? -X64 = probe_binary(PHP_CL, 64, null, 'PHP_CL'); +X64 = toolset_is_64(); if (X64) { STDOUT.WriteLine(" Detected 64-bit compiler"); } else { @@ -37,52 +20,8 @@ if (X64) { AC_DEFINE('ARCHITECTURE', X64 ? 'x64' : 'x86', "Detected compiler architecture"); DEFINE("PHP_ARCHITECTURE", X64 ? 'x64' : 'x86'); -// cygwin now ships with link.exe. Avoid searching the cygwin path -// for this, as we want the MS linker, not the fileutil -PATH_PROG('link', WshShell.Environment("Process").Item("PATH")); -PATH_PROG('nmake'); - -// we don't want to define LIB, as that will override the default library path -// that is set in that env var -PATH_PROG('lib', null, 'MAKE_LIB'); -if (!PATH_PROG('bison')) { - ERROR('bison is required') -} - -// There's a minimum requirement for re2c.. -MINRE2C = "0.13.4"; - -RE2C = PATH_PROG('re2c'); -if (RE2C) { - var intvers, intmin; - var pattern = /\./g; - - RE2CVERS = probe_binary(RE2C, "version"); - STDOUT.WriteLine(' Detected re2c version ' + RE2CVERS); - - intvers = RE2CVERS.replace(pattern, '') - 0; - intmin = MINRE2C.replace(pattern, '') - 0; - - if (intvers < intmin) { - STDOUT.WriteLine('WARNING: The minimum RE2C version requirement is ' + MINRE2C); - STDOUT.WriteLine('Parsers will not be generated. Upgrade your copy at http://sf.net/projects/re2c'); - DEFINE('RE2C', ''); - } else { - DEFINE('RE2C_FLAGS', ''); - } -} else { - STDOUT.WriteLine('Parsers will not be regenerated'); -} -PATH_PROG('zip'); -PATH_PROG('lemon'); - -// avoid picking up midnight commander from cygwin -PATH_PROG('mc', WshShell.Environment("Process").Item("PATH")); - -// Try locating manifest tool -if (VCVERS > 1200) { - PATH_PROG('mt', WshShell.Environment("Process").Item("PATH")); -} +toolset_setup_linker(); +toolset_setup_project_tools(); // stick objects somewhere outside of the source tree ARG_ENABLE('object-out-dir', 'Alternate location for binary objects during build', ''); @@ -121,10 +60,13 @@ DEFINE("CFLAGS_PHP", "/D _USRDLL /D PHP7DLLTS_EXPORTS /D PHP_EXPORTS \ DEFINE('CFLAGS_PHP_OBJ', '$(CFLAGS_PHP) $(STATIC_EXT_CFLAGS)'); // General CFLAGS for building objects -DEFINE("CFLAGS", "/nologo /FD $(BASE_INCLUDES) /D _WINDOWS \ +DEFINE("CFLAGS", "/nologo $(BASE_INCLUDES) /D _WINDOWS \ /D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /W3 "); +if (VS_TOOLSET) { + ADD_FLAG("CFLAGS", " /FD "); +} -if (VCVERS < 1400) { +if (VS_TOOLSET && VCVERS < 1400) { // Enable automatic precompiled headers ADD_FLAG('CFLAGS', ' /YX '); @@ -134,7 +76,7 @@ if (VCVERS < 1400) { } } -if (VCVERS >= 1400) { +if (VS_TOOLSET && VCVERS >= 1400) { // fun stuff: MS deprecated ANSI stdio and similar functions // disable annoying warnings. In addition, time_t defaults // to 64-bit. Ask for 32-bit. @@ -153,7 +95,7 @@ if (VCVERS >= 1400) { ARG_WITH('prefix', 'PHP installation prefix', ''); ARG_WITH('mp', 'Tell Visual Studio use up to [n,auto,disable] processes for compilation', 'auto'); var PHP_MP_DISABLED = true; -if (VCVERS >= 1500 && PHP_MP != 'disable') { +if (VS_TOOLSET && VCVERS >= 1500 && PHP_MP != 'disable') { // no from disable-all if(PHP_MP == 'auto' || PHP_MP == 'no') { ADD_FLAG('CFLAGS', ' /MP '); @@ -334,11 +276,12 @@ STDOUT.WriteLine("Build dir: " + get_define('BUILD_DIR')); STDOUT.WriteLine("PHP Core: " + get_define('PHPDLL') + " and " + get_define('PHPLIB')); -if (VCVERS == 1200) { +/* XXX inspect this for other toolsets */ +if (VS_TOOLSET && VCVERS == 1200) { AC_DEFINE('ZEND_DVAL_TO_LVAL_CAST_OK', 1); } -if (VCVERS >= 1400) { +if (INTEL_TOOLSET || VS_TOOLSET && VCVERS >= 1400) { AC_DEFINE('HAVE_STRNLEN', 1); } diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 55d1e8ccc29..cafb267b1ea 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -39,6 +39,9 @@ var INTELVERS = -1; var COMPILER_NUMERIC_VERSION = -1; var COMPILER_NAME = "unknown"; +// There's a minimum requirement for re2c.. +var MINRE2C = "0.13.4"; + /* Store the enabled extensions (summary + QA check) */ var extensions_enabled = new Array(); @@ -2292,6 +2295,118 @@ if (!MODE_PHPIZE) { ARG_ENABLE('one-shot', 'Optimize for fast build - best for release and snapshot builders, not so hot for edit-and-rebuild hacking', 'no'); } + +function toolset_option_handle() +{ + if ("clang" == PHP_TOOLSET) { + VS_TOOLSET = false; + CLANG_TOOLSET = true; + INTEL_TOOLSET = false; + } else if ("intel" == PHP_TOOLSET) { + VS_TOOLSET = false; + CLANG_TOOLSET = false; + INTEL_TOOLSET = true; + } else { + /* Visual Studio is the default toolset. */ + PHP_TOOLSET = "no" == PHP_TOOLSET ? "vs" : PHP_TOOLSET; + if (!!PHP_TOOLSET && "vs" != PHP_TOOLSET) { + ERROR("Unsupported toolset name '" + PHP_TOOLSET + "'"); + } + VS_TOOLSET = true; + CLANG_TOOLSET = false; + INTEL_TOOLSET = false; + } +} + +function toolset_setup_compiler() +{ + PHP_CL = toolset_get_compiler(); + if (!PHP_CL) { + ERROR("Compiler not found"); + } + + COMPILER_NUMERIC_VERSION = toolset_get_compiler_version(); + COMPILER_NAME = toolset_get_compiler_name(); + + if (VS_TOOLSET) { + /* For the record here: */ + // 1200 is VC6 + // 1300 is vs.net 2002 + // 1310 is vs.net 2003 + // 1400 is vs.net 2005 + // 1500 is vs.net 2008 + // 1600 is vs.net 2010 + // Which version of the compiler do we have? + VCVERS = COMPILER_NUMERIC_VERSION; + + if (VCVERS < 1500) { + ERROR("Unsupported MS C++ Compiler, VC9 (2008) minimum is required"); + } + + AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version"); + DEFINE("PHP_COMPILER_SHORT", VC_VERSIONS_SHORT[VCVERS]); + AC_DEFINE('PHP_COMPILER_ID', VC_VERSIONS_SHORT[VCVERS], "Compiler compatibility ID"); + } else if (CLANG_TOOLSET) { + CLANGVERS = COMPILER_NUMERIC_VERSION; + + AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version"); + DEFINE("PHP_COMPILER_SHORT", "clang"); + AC_DEFINE('PHP_COMPILER_ID', "clang"); /* XXX something better were to write here */ + + } else if (INTEL_TOOLSET) { + INTELVERS = COMPILER_NUMERIC_VERSION; + + AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version"); + DEFINE("PHP_COMPILER_SHORT", "icc"); + AC_DEFINE('PHP_COMPILER_ID', "icc"); /* XXX something better were to write here */ + } + STDOUT.WriteLine(" Detected compiler " + COMPILER_NAME); +} + +function toolset_setup_project_tools() +{ + PATH_PROG('nmake'); + + // we don't want to define LIB, as that will override the default library path + // that is set in that env var + PATH_PROG('lib', null, 'MAKE_LIB'); + if (!PATH_PROG('bison')) { + ERROR('bison is required') + } + + RE2C = PATH_PROG('re2c'); + if (RE2C) { + var intvers, intmin; + var pattern = /\./g; + + RE2CVERS = probe_binary(RE2C, "version"); + STDOUT.WriteLine(' Detected re2c version ' + RE2CVERS); + + intvers = RE2CVERS.replace(pattern, '') - 0; + intmin = MINRE2C.replace(pattern, '') - 0; + + if (intvers < intmin) { + STDOUT.WriteLine('WARNING: The minimum RE2C version requirement is ' + MINRE2C); + STDOUT.WriteLine('Parsers will not be generated. Upgrade your copy at http://sf.net/projects/re2c'); + DEFINE('RE2C', ''); + } else { + DEFINE('RE2C_FLAGS', ''); + } + } else { + STDOUT.WriteLine('Parsers will not be regenerated'); + } + PATH_PROG('zip'); + PATH_PROG('lemon'); + + // avoid picking up midnight commander from cygwin + PATH_PROG('mc', WshShell.Environment("Process").Item("PATH")); + + // Try locating manifest tool + if (VS_TOOLSET && VCVERS > 1200) { + PATH_PROG('mt', WshShell.Environment("Process").Item("PATH")); + } +} + function toolset_get_compiler() { if (VS_TOOLSET) { @@ -2302,7 +2417,7 @@ function toolset_get_compiler() return PATH_PROG('icl', null, 'PHP_CL') } - ERROR("Wrong toolset"); + ERROR("Unsupported toolset"); } function toolset_get_compiler_version() @@ -2337,7 +2452,7 @@ function toolset_get_compiler_version() } } - ERROR("Failed to parse compiler out for compiler version"); + ERROR("Failed to parse compiler version or unsupported toolset"); } function toolset_get_compiler_name() @@ -2354,7 +2469,7 @@ function toolset_get_compiler_name() return full.split(/\n/)[0].replace(/\s/g, ' '); } - ERROR("Wrong toolset"); + WARNING("Unsupported toolset"); } @@ -2374,11 +2489,11 @@ function toolset_is_64() return null != full.match(/Intel\(R\) 64/); } - ERROR("Wrong toolset"); + ERROR("Unsupported toolset"); } -function toolset_get_linker() +function toolset_setup_linker() { if (VS_TOOLSET) { return PATH_PROG('link', WshShell.Environment("Process").Item("PATH")); @@ -2389,7 +2504,6 @@ function toolset_get_linker() return PATH_PROG('xilink', WshShell.Environment("Process").Item("PATH"), "LINK"); } - ERROR("Wrong toolset"); + ERROR("Unsupported toolset"); } - From 722dd4637b20cbf40b22ac77b054abb47a1d1e9a Mon Sep 17 00:00:00 2001 From: Julien Pauli Date: Fri, 7 Nov 2014 12:59:48 +0100 Subject: [PATCH 267/398] Fixed NEWS for 5.5 --- NEWS | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/NEWS b/NEWS index 2340bea13d4..a646aee6229 100644 --- a/NEWS +++ b/NEWS @@ -2,8 +2,14 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2014, PHP 5.5.20 +- PDO_pgsql: + . Fixed bug #66584 (Segmentation fault on statement deallocation) (Matteo) + . Fixed bug #67462 (PDO_PGSQL::beginTransaction() wrongly throws exception + when not in transaction) (Matteo) + . Fixed bug #68351 (PDO::PARAM_BOOL and ATTR_EMULATE_PREPARES misbehaving) + (Matteo) -?? ??? 2014, PHP 5.5.19 +13 Nov 2014, PHP 5.5.19 - Core: . Fixed bug #68095 (AddressSanitizer reports a heap buffer overflow in @@ -17,6 +23,10 @@ PHP NEWS . Fixed bug #68283 (fileinfo: out-of-bounds read in elf note headers). (CVE-2014-3710) (Remi) +- FPM: + . Implemented FR #55508 (listen and listen.allowed_clients should take IPv6 + addresses). (Robin Gloster) + - GD: . Fixed bug #65171 (imagescale() fails without height param). (Remi) @@ -32,13 +42,6 @@ PHP NEWS . Fixed bug #68087 (ODBC not correctly reading DATE column when preceded by a VARCHAR column) (Keyur Govande) -- PDO_pgsql: - . Fixed bug #66584 (Segmentation fault on statement deallocation) (Matteo) - . Fixed bug #67462 (PDO_PGSQL::beginTransaction() wrongly throws exception - when not in transaction) (Matteo) - . Fixed bug #68351 (PDO::PARAM_BOOL and ATTR_EMULATE_PREPARES misbehaving) - (Matteo) - - SPL: . Fixed bug #68128 (Regression in RecursiveRegexIterator) (Tjerk) @@ -60,8 +63,6 @@ PHP NEWS - FPM: . Fixed bug #65641 (PHP-FPM incorrectly defines the SCRIPT_NAME variable when using Apache, mod_proxy-fcgi and ProxyPass). (Remi) - . Implemented FR #55508 (listen and listen.allowed_clients should take IPv6 - addresses). (Robin Gloster) - Reflection: . Fixed bug #68103 (Duplicate entry in Reflection for class alias). (Remi) From b155ba21bd509dff28dd8084d71c8a476027a0cd Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 7 Nov 2014 13:48:29 +0100 Subject: [PATCH 268/398] further refactoring of toolset+phpize stuff --- win32/build/config.w32 | 50 ++-------------------------- win32/build/config.w32.phpize.in | 32 +----------------- win32/build/confutils.js | 57 ++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 79 deletions(-) diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 85cec0ce87d..0a801af6fd0 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -75,45 +75,7 @@ DEFINE("CFLAGS_PHP", "/D _USRDLL /D PHP7DLLTS_EXPORTS /D PHP_EXPORTS \ DEFINE('CFLAGS_PHP_OBJ', '$(CFLAGS_PHP) $(STATIC_EXT_CFLAGS)'); // General CFLAGS for building objects -DEFINE("CFLAGS", "/nologo $(BASE_INCLUDES) /D _WINDOWS \ -/D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /W3 "); -if (VS_TOOLSET) { - ADD_FLAG("CFLAGS", " /FD "); -} - -if (CLANG_TOOLSET) { - if (X64) { - ADD_FLAG('CFLAGS', ' -m64 '); - } else { - ADD_FLAG('CFLAGS', ' -m32 '); - } -} - -if (VS_TOOLSET && VCVERS < 1400) { - // Enable automatic precompiled headers - ADD_FLAG('CFLAGS', ' /YX '); - - if (PHP_DEBUG == "yes") { - // Set some debug/release specific options - ADD_FLAG('CFLAGS', ' /GZ '); - } -} - -if (VS_TOOLSET && VCVERS >= 1400) { - // fun stuff: MS deprecated ANSI stdio and similar functions - // disable annoying warnings. In addition, time_t defaults - // to 64-bit. Ask for 32-bit. - if (X64) { - ADD_FLAG('CFLAGS', ' /wd4996 '); - } else { - ADD_FLAG('CFLAGS', ' /wd4996 /D_USE_32BIT_TIME_T=1 '); - } - - if (PHP_DEBUG == "yes") { - // Set some debug/release specific options - ADD_FLAG('CFLAGS', ' /RTC1 '); - } -} +toolset_setup_common_cflags(); ARG_WITH('mp', 'Tell Visual Studio use up to [n,auto,disable] processes for compilation', 'auto'); var PHP_MP_DISABLED = true; @@ -133,15 +95,7 @@ if (VS_TOOLSET && VCVERS >= 1500 && PHP_MP != 'disable') { } // General link flags - -if (VS_TOOLSET || CLANG_TOOLSET) { - if (VCVERS >= 1700 || CLANG_TOOLSET) { - DEFINE("LDFLAGS", "/nologo "); - } else { - DEFINE("LDFLAGS", "/nologo /version:" + - PHP_VERSION + "." + PHP_MINOR_VERSION + "." + PHP_RELEASE_VERSION); - } -} +toolset_setup_common_ldlags(); // General DLL link flags DEFINE("DLL_LDFLAGS", "/dll "); diff --git a/win32/build/config.w32.phpize.in b/win32/build/config.w32.phpize.in index 91ebc241845..0b7443e5629 100644 --- a/win32/build/config.w32.phpize.in +++ b/win32/build/config.w32.phpize.in @@ -60,37 +60,7 @@ DEFINE("CFLAGS_PHP", "/D _USRDLL /D PHP7DLLTS_EXPORTS /D PHP_EXPORTS \ DEFINE('CFLAGS_PHP_OBJ', '$(CFLAGS_PHP) $(STATIC_EXT_CFLAGS)'); // General CFLAGS for building objects -DEFINE("CFLAGS", "/nologo $(BASE_INCLUDES) /D _WINDOWS \ -/D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /W3 "); -if (VS_TOOLSET) { - ADD_FLAG("CFLAGS", " /FD "); -} - -if (VS_TOOLSET && VCVERS < 1400) { - // Enable automatic precompiled headers - ADD_FLAG('CFLAGS', ' /YX '); - - if (PHP_DEBUG == "yes") { - // Set some debug/release specific options - ADD_FLAG('CFLAGS', ' /GZ '); - } -} - -if (VS_TOOLSET && VCVERS >= 1400) { - // fun stuff: MS deprecated ANSI stdio and similar functions - // disable annoying warnings. In addition, time_t defaults - // to 64-bit. Ask for 32-bit. - if (X64) { - ADD_FLAG('CFLAGS', ' /wd4996 '); - } else { - ADD_FLAG('CFLAGS', ' /wd4996 /D_USE_32BIT_TIME_T=1 '); - } - - if (PHP_DEBUG == "yes") { - // Set some debug/release specific options - ADD_FLAG('CFLAGS', ' /RTC1 '); - } -} +toolset_setup_common_cflags(); ARG_WITH('prefix', 'PHP installation prefix', ''); ARG_WITH('mp', 'Tell Visual Studio use up to [n,auto,disable] processes for compilation', 'auto'); diff --git a/win32/build/confutils.js b/win32/build/confutils.js index cafb267b1ea..9da415c47ef 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -2507,3 +2507,60 @@ function toolset_setup_linker() ERROR("Unsupported toolset"); } +function toolset_setup_common_cflags() +{ + DEFINE("CFLAGS", "/nologo $(BASE_INCLUDES) /D _WINDOWS \ + /D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /W3 "); + + if (VS_TOOLSET) { + ADD_FLAG("CFLAGS", " /FD "); + + if (VCVERS < 1400) { + // Enable automatic precompiled headers + ADD_FLAG('CFLAGS', ' /YX '); + + if (PHP_DEBUG == "yes") { + // Set some debug/release specific options + ADD_FLAG('CFLAGS', ' /GZ '); + } + } + + if (VCVERS >= 1400) { + // fun stuff: MS deprecated ANSI stdio and similar functions + // disable annoying warnings. In addition, time_t defaults + // to 64-bit. Ask for 32-bit. + if (X64) { + ADD_FLAG('CFLAGS', ' /wd4996 '); + } else { + ADD_FLAG('CFLAGS', ' /wd4996 /D_USE_32BIT_TIME_T=1 '); + } + + if (PHP_DEBUG == "yes") { + // Set some debug/release specific options + ADD_FLAG('CFLAGS', ' /RTC1 '); + } + } + + } else if (CLANG_TOOLSET) { + if (X64) { + ADD_FLAG('CFLAGS', ' -m64 '); + } else { + ADD_FLAG('CFLAGS', ' -m32 '); + } + } +} + +function toolset_setup_common_ldlags() +{ + if (VS_TOOLSET) { + if (VCVERS >= 1700) { + DEFINE("LDFLAGS", "/nologo "); + } else { + DEFINE("LDFLAGS", "/nologo /version:" + + PHP_VERSION + "." + PHP_MINOR_VERSION + "." + PHP_RELEASE_VERSION); + } + } else { + DEFINE("LDFLAGS", "/nologo "); + } +} + From c78c6adbd5aa2199472facc6b8d3cbca18fbc382 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 7 Nov 2014 14:07:33 +0100 Subject: [PATCH 269/398] parametrize WINVER and update its value --- win32/build/config.w32 | 2 +- win32/build/config.w32.phpize.in | 2 +- win32/build/confutils.js | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 0a801af6fd0..b3cad0b8d42 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -70,7 +70,7 @@ DEFINE("BASE_INCLUDES", "/I . /I main /I Zend /I TSRM /I ext "); // CFLAGS for building the PHP dll DEFINE("CFLAGS_PHP", "/D _USRDLL /D PHP7DLLTS_EXPORTS /D PHP_EXPORTS \ -/D LIBZEND_EXPORTS /D TSRM_EXPORTS /D SAPI_EXPORTS /D WINVER=0x500"); +/D LIBZEND_EXPORTS /D TSRM_EXPORTS /D SAPI_EXPORTS /D WINVER=" + WINVER); DEFINE('CFLAGS_PHP_OBJ', '$(CFLAGS_PHP) $(STATIC_EXT_CFLAGS)'); diff --git a/win32/build/config.w32.phpize.in b/win32/build/config.w32.phpize.in index 0b7443e5629..b765b650af7 100644 --- a/win32/build/config.w32.phpize.in +++ b/win32/build/config.w32.phpize.in @@ -55,7 +55,7 @@ DEFINE("BASE_INCLUDES", "/I " + PHP_DIR + "/include /I " + PHP_DIR + "/include/m // CFLAGS for building the PHP dll DEFINE("CFLAGS_PHP", "/D _USRDLL /D PHP7DLLTS_EXPORTS /D PHP_EXPORTS \ -/D LIBZEND_EXPORTS /D TSRM_EXPORTS /D SAPI_EXPORTS /D WINVER=0x500"); +/D LIBZEND_EXPORTS /D TSRM_EXPORTS /D SAPI_EXPORTS /D WINVER=" + WINVER); DEFINE('CFLAGS_PHP_OBJ', '$(CFLAGS_PHP) $(STATIC_EXT_CFLAGS)'); diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 9da415c47ef..bc6de3f331d 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -39,6 +39,8 @@ var INTELVERS = -1; var COMPILER_NUMERIC_VERSION = -1; var COMPILER_NAME = "unknown"; +var WINVER = "0x0600"; /* Vista */ + // There's a minimum requirement for re2c.. var MINRE2C = "0.13.4"; From cfd2b39c187fa82a79556a4f2fa4bebac77eb412 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 7 Nov 2014 14:36:13 +0100 Subject: [PATCH 270/398] add /fallback for clang-cl --- win32/build/confutils.js | 1 + 1 file changed, 1 insertion(+) diff --git a/win32/build/confutils.js b/win32/build/confutils.js index bc6de3f331d..35694cb426e 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -2549,6 +2549,7 @@ function toolset_setup_common_cflags() } else { ADD_FLAG('CFLAGS', ' -m32 '); } + ADD_FLAG("CFLAGS", " /fallback "); } } From fc734cf95da914aa0f6eac0b8ceeb1c1d9fcdf69 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 7 Nov 2014 18:33:37 +0100 Subject: [PATCH 271/398] further catch up with phpize and improved clang arch setup --- win32/build/config.w32 | 7 ------- win32/build/config.w32.phpize.in | 7 ------- win32/build/confutils.js | 20 ++++++++++++++++---- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/win32/build/config.w32 b/win32/build/config.w32 index b3cad0b8d42..81a7bd901ab 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -68,13 +68,6 @@ DEFINE('PHP_PREFIX', PHP_PREFIX); DEFINE("BASE_INCLUDES", "/I . /I main /I Zend /I TSRM /I ext "); -// CFLAGS for building the PHP dll -DEFINE("CFLAGS_PHP", "/D _USRDLL /D PHP7DLLTS_EXPORTS /D PHP_EXPORTS \ -/D LIBZEND_EXPORTS /D TSRM_EXPORTS /D SAPI_EXPORTS /D WINVER=" + WINVER); - -DEFINE('CFLAGS_PHP_OBJ', '$(CFLAGS_PHP) $(STATIC_EXT_CFLAGS)'); - -// General CFLAGS for building objects toolset_setup_common_cflags(); ARG_WITH('mp', 'Tell Visual Studio use up to [n,auto,disable] processes for compilation', 'auto'); diff --git a/win32/build/config.w32.phpize.in b/win32/build/config.w32.phpize.in index b765b650af7..c3263ba5e90 100644 --- a/win32/build/config.w32.phpize.in +++ b/win32/build/config.w32.phpize.in @@ -53,13 +53,6 @@ DEFINE('PHP_PREFIX', PHP_PREFIX); DEFINE("BASE_INCLUDES", "/I " + PHP_DIR + "/include /I " + PHP_DIR + "/include/main /I " + PHP_DIR + "/include/Zend /I " + PHP_DIR + "/include/TSRM /I " + PHP_DIR + "/include/ext "); -// CFLAGS for building the PHP dll -DEFINE("CFLAGS_PHP", "/D _USRDLL /D PHP7DLLTS_EXPORTS /D PHP_EXPORTS \ -/D LIBZEND_EXPORTS /D TSRM_EXPORTS /D SAPI_EXPORTS /D WINVER=" + WINVER); - -DEFINE('CFLAGS_PHP_OBJ', '$(CFLAGS_PHP) $(STATIC_EXT_CFLAGS)'); - -// General CFLAGS for building objects toolset_setup_common_cflags(); ARG_WITH('prefix', 'PHP installation prefix', ''); diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 35694cb426e..0892c0068e6 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -2480,10 +2480,15 @@ function toolset_is_64() if (VS_TOOLSET) { return probe_binary(PHP_CL, 64); } else if (CLANG_TOOLSET) { - var command = 'cmd /c ""' + PHP_CL + '" -v"'; + /*var command = 'cmd /c ""' + PHP_CL + '" -v"'; var full = execute(command + '" 2>&1"'); - return null != full.match(/x86_64/); + return null != full.match(/x86_64/);*/ + + /* Even executed within an environment setup with vcvars32.bat, + clang-cl doesn't recognize the arch toolset. But as it needs + the VS environment, checking the arch of cl.exe is correct. */ + return probe_binary(PATH_PROG('cl', null), 64); } else if (INTEL_TOOLSET) { var command = 'cmd /c ""' + PHP_CL + '" -v"'; var full = execute(command + '" 2>&1"'); @@ -2511,6 +2516,13 @@ function toolset_setup_linker() function toolset_setup_common_cflags() { + // CFLAGS for building the PHP dll + DEFINE("CFLAGS_PHP", "/D _USRDLL /D PHP7DLLTS_EXPORTS /D PHP_EXPORTS \ + /D LIBZEND_EXPORTS /D TSRM_EXPORTS /D SAPI_EXPORTS /D WINVER=" + WINVER); + + DEFINE('CFLAGS_PHP_OBJ', '$(CFLAGS_PHP) $(STATIC_EXT_CFLAGS)'); + + // General CFLAGS for building objects DEFINE("CFLAGS", "/nologo $(BASE_INCLUDES) /D _WINDOWS \ /D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /W3 "); @@ -2545,9 +2557,9 @@ function toolset_setup_common_cflags() } else if (CLANG_TOOLSET) { if (X64) { - ADD_FLAG('CFLAGS', ' -m64 '); + ADD_FLAG('CFLAGS', '-m64'); } else { - ADD_FLAG('CFLAGS', ' -m32 '); + ADD_FLAG('CFLAGS', '-m32'); } ADD_FLAG("CFLAGS", " /fallback "); } From 2e5cba25e8fa7e980746d0111c0740fdd4002b74 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 7 Nov 2014 18:39:03 +0100 Subject: [PATCH 272/398] either ms or intel linker is used, /libpath is supported --- win32/build/config.w32 | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 81a7bd901ab..ebe80111488 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -232,12 +232,10 @@ function add_extra_dirs() for (i = 0; i < path.length; i++) { f = FSO.GetAbsolutePathName(path[i]); if (FSO.FolderExists(f)) { - if (VS_TOOLSET) { - if (VCVERS <= 1200 && f.indexOf(" ") >= 0) { - ADD_FLAG("LDFLAGS", '/libpath:"\\"' + f + '\\"" '); - } else { - ADD_FLAG("LDFLAGS", '/libpath:"' + f + '" '); - } + if (VS_TOOLSET && VCVERS <= 1200 && f.indexOf(" ") >= 0) { + ADD_FLAG("LDFLAGS", '/libpath:"\\"' + f + '\\"" '); + } else { + ADD_FLAG("LDFLAGS", '/libpath:"' + f + '" '); } } } From 7d7182e1b04544beb5de764e7a91be41848b2e15 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 7 Nov 2014 19:13:41 +0100 Subject: [PATCH 273/398] fix gd compilation with icc toolset --- ext/gd/config.w32 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ext/gd/config.w32 b/ext/gd/config.w32 index 2127fc5dcee..b6f45a9c647 100644 --- a/ext/gd/config.w32 +++ b/ext/gd/config.w32 @@ -83,6 +83,9 @@ if (PHP_GD != "no") { /D USE_GD_IOCTX \ /D MSWIN32 \ "); + if (INTEL_TOOLSET) { + ADD_FLAG("LDFLAGS_GD", "/nodefaultlib:libcmt"); + } PHP_INSTALL_HEADERS("", "ext/gd ext/gd/libgd" ); } else { From af7e3064f35708fa9540ee1c18217811980f0865 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 7 Nov 2014 19:24:17 +0100 Subject: [PATCH 274/398] rename intel toolset to icc - shorter --- ext/gd/config.w32 | 2 +- win32/build/config.w32 | 4 ++-- win32/build/config.w32.phpize.in | 4 ++-- win32/build/confutils.js | 24 ++++++++++++------------ 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ext/gd/config.w32 b/ext/gd/config.w32 index b6f45a9c647..da6d0d2ff51 100644 --- a/ext/gd/config.w32 +++ b/ext/gd/config.w32 @@ -83,7 +83,7 @@ if (PHP_GD != "no") { /D USE_GD_IOCTX \ /D MSWIN32 \ "); - if (INTEL_TOOLSET) { + if (ICC_TOOLSET) { ADD_FLAG("LDFLAGS_GD", "/nodefaultlib:libcmt"); } diff --git a/win32/build/config.w32 b/win32/build/config.w32 index ebe80111488..2a1dd0a7c17 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -3,7 +3,7 @@ // "Master" config file; think of it as a configure.in // equivalent. -ARG_WITH("toolset", "Toolset to use for the compilation, supported: vs, clang, intel", "vs"); +ARG_WITH("toolset", "Toolset to use for the compilation, supported: vs, clang, icc", "vs"); toolset_option_handle(); ARG_WITH('cygwin', 'Path to cygwin utilities on your system', '\\cygwin'); @@ -281,7 +281,7 @@ ADD_SOURCES("win32", "inet.c fnmatch.c sockets.c"); if (VS_TOOLSET && VCVERS <= 1300) { ADD_SOURCES("win32", "strtoi64.c"); } -if (VS_TOOLSET && VCVERS >= 1400 || INTEL_TOOLSET) { +if (VS_TOOLSET && VCVERS >= 1400 || ICC_TOOLSET) { AC_DEFINE('HAVE_STRNLEN', 1); } diff --git a/win32/build/config.w32.phpize.in b/win32/build/config.w32.phpize.in index c3263ba5e90..0ced9b30a0b 100644 --- a/win32/build/config.w32.phpize.in +++ b/win32/build/config.w32.phpize.in @@ -3,7 +3,7 @@ // "Master" config file; think of it as a configure.in // equivalent. -ARG_WITH("toolset", "Toolset to use for the compilation, supported: vs, clang, intel", "vs"); +ARG_WITH("toolset", "Toolset to use for the compilation, supported: vs, clang, icc", "vs"); toolset_option_handle() var PHP_CYGWIN="notset"; @@ -244,7 +244,7 @@ if (VS_TOOLSET && VCVERS == 1200) { AC_DEFINE('ZEND_DVAL_TO_LVAL_CAST_OK', 1); } -if (INTEL_TOOLSET || VS_TOOLSET && VCVERS >= 1400) { +if (ICC_TOOLSET || VS_TOOLSET && VCVERS >= 1400) { AC_DEFINE('HAVE_STRNLEN', 1); } diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 0892c0068e6..9d23c83a24c 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -32,7 +32,7 @@ var PHP_SRC_DIR=FSO.GetParentFolderName(WScript.ScriptFullName); var VS_TOOLSET = true; var CLANG_TOOLSET = false; -var INTEL_TOOLSET = false; +var ICC_TOOLSET = false; var VCVERS = -1; var CLANGVERS = -1; var INTELVERS = -1; @@ -2303,20 +2303,20 @@ function toolset_option_handle() if ("clang" == PHP_TOOLSET) { VS_TOOLSET = false; CLANG_TOOLSET = true; - INTEL_TOOLSET = false; - } else if ("intel" == PHP_TOOLSET) { + ICC_TOOLSET = false; + } else if ("icc" == PHP_TOOLSET) { VS_TOOLSET = false; CLANG_TOOLSET = false; - INTEL_TOOLSET = true; + ICC_TOOLSET = true; } else { /* Visual Studio is the default toolset. */ PHP_TOOLSET = "no" == PHP_TOOLSET ? "vs" : PHP_TOOLSET; if (!!PHP_TOOLSET && "vs" != PHP_TOOLSET) { - ERROR("Unsupported toolset name '" + PHP_TOOLSET + "'"); + ERROR("Unsupported toolset '" + PHP_TOOLSET + "'"); } VS_TOOLSET = true; CLANG_TOOLSET = false; - INTEL_TOOLSET = false; + ICC_TOOLSET = false; } } @@ -2355,7 +2355,7 @@ function toolset_setup_compiler() DEFINE("PHP_COMPILER_SHORT", "clang"); AC_DEFINE('PHP_COMPILER_ID', "clang"); /* XXX something better were to write here */ - } else if (INTEL_TOOLSET) { + } else if (ICC_TOOLSET) { INTELVERS = COMPILER_NUMERIC_VERSION; AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version"); @@ -2415,7 +2415,7 @@ function toolset_get_compiler() return PATH_PROG('cl', null, 'PHP_CL') } else if (CLANG_TOOLSET) { return PATH_PROG('clang-cl', null, 'PHP_CL') - } else if (INTEL_TOOLSET) { + } else if (ICC_TOOLSET) { return PATH_PROG('icl', null, 'PHP_CL') } @@ -2441,7 +2441,7 @@ function toolset_get_compiler_version() return version; } - } else if (INTEL_TOOLSET) { + } else if (ICC_TOOLSET) { var command = 'cmd /c ""' + PHP_CL + '" -v"'; var full = execute(command + '" 2>&1"'); @@ -2464,7 +2464,7 @@ function toolset_get_compiler_name() if (VS_TOOLSET) { version = probe_binary(PHP_CL).substr(0, 5).replace('.', ''); return VC_VERSIONS[version]; - } else if (CLANG_TOOLSET || INTEL_TOOLSET) { + } else if (CLANG_TOOLSET || ICC_TOOLSET) { var command = 'cmd /c ""' + PHP_CL + '" -v"'; var full = execute(command + '" 2>&1"'); @@ -2489,7 +2489,7 @@ function toolset_is_64() clang-cl doesn't recognize the arch toolset. But as it needs the VS environment, checking the arch of cl.exe is correct. */ return probe_binary(PATH_PROG('cl', null), 64); - } else if (INTEL_TOOLSET) { + } else if (ICC_TOOLSET) { var command = 'cmd /c ""' + PHP_CL + '" -v"'; var full = execute(command + '" 2>&1"'); @@ -2507,7 +2507,7 @@ function toolset_setup_linker() } else if (CLANG_TOOLSET) { //return PATH_PROG('lld', WshShell.Environment("Process").Item("PATH"), "LINK"); return PATH_PROG('link', WshShell.Environment("Process").Item("PATH")); - } else if (INTEL_TOOLSET) { + } else if (ICC_TOOLSET) { return PATH_PROG('xilink', WshShell.Environment("Process").Item("PATH"), "LINK"); } From 12cf41ca356800d5ff77b08d7b2410ea6b07a71c Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 7 Nov 2014 19:58:30 +0100 Subject: [PATCH 275/398] move more common ldflags into function --- win32/build/config.w32 | 6 ------ win32/build/config.w32.phpize.in | 7 ++----- win32/build/confutils.js | 6 ++++++ 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 2a1dd0a7c17..7187eacca14 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -90,12 +90,6 @@ if (VS_TOOLSET && VCVERS >= 1500 && PHP_MP != 'disable') { // General link flags toolset_setup_common_ldlags(); -// General DLL link flags -DEFINE("DLL_LDFLAGS", "/dll "); - -// PHP DLL link flags -DEFINE("PHP_LDFLAGS", "$(DLL_LDFLAGS)"); - // General libs // urlmon.lib ole32.lib oleaut32.lib uuid.lib gdi32.lib winspool.lib comdlg32.lib DEFINE("LIBS", "kernel32.lib ole32.lib user32.lib advapi32.lib shell32.lib ws2_32.lib Dnsapi.lib"); diff --git a/win32/build/config.w32.phpize.in b/win32/build/config.w32.phpize.in index 0ced9b30a0b..5a7f31d5d44 100644 --- a/win32/build/config.w32.phpize.in +++ b/win32/build/config.w32.phpize.in @@ -77,11 +77,8 @@ if (VS_TOOLSET && VCVERS >= 1500 && PHP_MP != 'disable') { * files that make up the snapshot template? */ ARG_WITH("snapshot-template", "Path to snapshot builder template dir", "no"); -// General DLL link flags -DEFINE("DLL_LDFLAGS", "/dll "); - -// PHP DLL link flags -DEFINE("PHP_LDFLAGS", "$(DLL_LDFLAGS)"); +// General link flags +toolset_setup_common_ldlags(); // General libs // urlmon.lib ole32.lib oleaut32.lib uuid.lib gdi32.lib winspool.lib comdlg32.lib diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 9d23c83a24c..0f07e18120b 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -2567,6 +2567,12 @@ function toolset_setup_common_cflags() function toolset_setup_common_ldlags() { + // General DLL link flags + DEFINE("DLL_LDFLAGS", "/dll "); + + // PHP DLL link flags + DEFINE("PHP_LDFLAGS", "$(DLL_LDFLAGS)"); + if (VS_TOOLSET) { if (VCVERS >= 1700) { DEFINE("LDFLAGS", "/nologo "); From ab849392549c41fd3fc3d6ed2a324688f2afe47d Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Mon, 10 Nov 2014 13:46:47 +0800 Subject: [PATCH 276/398] Fixed bug #68370 ("unset($this)" can make the program crash) --- NEWS | 1 + Zend/tests/bug68370.phpt | 18 ++++++++++++++++++ Zend/zend_execute_API.c | 7 ------- 3 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 Zend/tests/bug68370.phpt diff --git a/NEWS b/NEWS index 9e5e1388c81..79a2b8893f5 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,7 @@ PHP NEWS ?? ??? 2014, PHP 5.5.19 - Core: + . Fixed bug #68370 ("unset($this)" can make the program crash). (Laruence) . Fixed bug #68095 (AddressSanitizer reports a heap buffer overflow in php_getopt()). (Stas) . Fixed bug #68118 ($a->foo .= 'test'; can leave $a->foo undefined). (Nikita) diff --git a/Zend/tests/bug68370.phpt b/Zend/tests/bug68370.phpt new file mode 100644 index 00000000000..25589bf455d --- /dev/null +++ b/Zend/tests/bug68370.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #68370 "unset($this)" can make the program crash +--FILE-- +test(); +print_r($x); +unset($c, $x); +--EXPECTF-- +Array +( +) diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 7e2a3378dac..9d4eebf0100 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -1761,13 +1761,6 @@ ZEND_API void zend_rebuild_symbol_table(TSRMLS_D) /* {{{ */ /*printf("Cache miss! Initialized %x\n", EG(active_symbol_table));*/ } ex->symbol_table = EG(active_symbol_table); - - if (ex->op_array->this_var != -1 && - !*EX_CV_NUM(ex, ex->op_array->this_var) && - EG(This)) { - *EX_CV_NUM(ex, ex->op_array->this_var) = (zval**)EX_CV_NUM(ex, ex->op_array->last_var + ex->op_array->this_var); - **EX_CV_NUM(ex, ex->op_array->this_var) = EG(This); - } for (i = 0; i < ex->op_array->last_var; i++) { if (*EX_CV_NUM(ex, i)) { zend_hash_quick_update(EG(active_symbol_table), From eacf998af2bccc1020fb0ef2a2d1af4a0df41294 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Mon, 10 Nov 2014 13:47:50 +0800 Subject: [PATCH 277/398] Update NEWS --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index b02976cb0f1..81840b0b0fc 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,7 @@ PHP NEWS ?? ??? 2014, PHP 5.6.3 - Core: + . Fixed bug #68370 ("unset($this)" can make the program crash). (Laruence) . Fixed bug #68104 (Segfault while pre-evaluating a disabled function). (Laruence) . Implemented 64-bit format codes for pack() and unpack(). (Leigh) From 249e3de5da9cc7b5dc5bde81ad8ac9e8034349d4 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Mon, 10 Nov 2014 17:54:18 +0800 Subject: [PATCH 278/398] Fixed segfault in bug62500.phpt --- Zend/zend_vm_def.h | 8 +-- Zend/zend_vm_execute.h | 160 ++++++++++++++++++++--------------------- 2 files changed, 84 insertions(+), 84 deletions(-) diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index b6d2b82cdea..81d5cfc1e65 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -1326,7 +1326,8 @@ ZEND_VM_HANDLER(82, ZEND_FETCH_OBJ_R, CONST|TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV) /* here we are sure we are dealing with an object */ do { if (OP2_TYPE == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -1415,8 +1416,6 @@ ZEND_VM_HANDLER(91, ZEND_FETCH_OBJ_IS, CONST|TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV zval *container; zend_free_op free_op2; zval *offset; - zval *retval; - zend_property_info *prop_info; SAVE_OPLINE(); container = GET_OP1_OBJ_ZVAL_PTR_DEREF(BP_VAR_IS); @@ -1431,7 +1430,8 @@ ZEND_VM_HANDLER(91, ZEND_FETCH_OBJ_IS, CONST|TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV /* here we are sure we are dealing with an object */ do { if (OP2_TYPE == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 8257789cd20..07507f3b810 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -3986,7 +3986,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_ /* here we are sure we are dealing with an object */ do { if (IS_CONST == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -4025,8 +4026,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE zval *container; zval *offset; - zval *retval; - zend_property_info *prop_info; SAVE_OPLINE(); container = opline->op1.zv; @@ -4041,7 +4040,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE /* here we are sure we are dealing with an object */ do { if (IS_CONST == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -5380,7 +5380,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HA /* here we are sure we are dealing with an object */ do { if (IS_TMP_VAR == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -5420,8 +5421,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_H zval *container; zend_free_op free_op2; zval *offset; - zval *retval; - zend_property_info *prop_info; SAVE_OPLINE(); container = opline->op1.zv; @@ -5436,7 +5435,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_H /* here we are sure we are dealing with an object */ do { if (IS_TMP_VAR == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -6619,7 +6619,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HA /* here we are sure we are dealing with an object */ do { if (IS_VAR == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -6659,8 +6660,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_H zval *container; zend_free_op free_op2; zval *offset; - zval *retval; - zend_property_info *prop_info; SAVE_OPLINE(); container = opline->op1.zv; @@ -6675,7 +6674,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_H /* here we are sure we are dealing with an object */ do { if (IS_VAR == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -8583,7 +8583,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HAN /* here we are sure we are dealing with an object */ do { if (IS_CV == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -8622,8 +8623,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HA zval *container; zval *offset; - zval *retval; - zend_property_info *prop_info; SAVE_OPLINE(); container = opline->op1.zv; @@ -8638,7 +8637,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HA /* here we are sure we are dealing with an object */ do { if (IS_CV == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -10956,7 +10956,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HA /* here we are sure we are dealing with an object */ do { if (IS_CONST == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -10995,8 +10996,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_H zval *container; zval *offset; - zval *retval; - zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -11011,7 +11010,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_H /* here we are sure we are dealing with an object */ do { if (IS_CONST == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -12226,7 +12226,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HAND /* here we are sure we are dealing with an object */ do { if (IS_TMP_VAR == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -12266,8 +12267,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HAN zval *container; zend_free_op free_op2; zval *offset; - zval *retval; - zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -12282,7 +12281,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HAN /* here we are sure we are dealing with an object */ do { if (IS_TMP_VAR == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -13438,7 +13438,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HAND /* here we are sure we are dealing with an object */ do { if (IS_VAR == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -13478,8 +13479,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HAN zval *container; zend_free_op free_op2; zval *offset; - zval *retval; - zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -13494,7 +13493,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HAN /* here we are sure we are dealing with an object */ do { if (IS_VAR == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -15267,7 +15267,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDL /* here we are sure we are dealing with an object */ do { if (IS_CV == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -15306,8 +15307,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HAND zval *container; zval *offset; - zval *retval; - zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -15322,7 +15321,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HAND /* here we are sure we are dealing with an object */ do { if (IS_CV == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -18762,7 +18762,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HA /* here we are sure we are dealing with an object */ do { if (IS_CONST == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -18850,8 +18851,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_H zval *container; zval *offset; - zval *retval; - zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -18866,7 +18865,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_H /* here we are sure we are dealing with an object */ do { if (IS_CONST == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -21100,7 +21100,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAND /* here we are sure we are dealing with an object */ do { if (IS_TMP_VAR == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -21189,8 +21190,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAN zval *container; zend_free_op free_op2; zval *offset; - zval *retval; - zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -21205,7 +21204,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAN /* here we are sure we are dealing with an object */ do { if (IS_TMP_VAR == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -23276,7 +23276,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAND /* here we are sure we are dealing with an object */ do { if (IS_VAR == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -23365,8 +23366,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAN zval *container; zend_free_op free_op2; zval *offset; - zval *retval; - zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -23381,7 +23380,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAN /* here we are sure we are dealing with an object */ do { if (IS_VAR == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -26712,7 +26712,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDL /* here we are sure we are dealing with an object */ do { if (IS_CV == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -26800,8 +26801,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HAND zval *container; zval *offset; - zval *retval; - zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -26816,7 +26815,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HAND /* here we are sure we are dealing with an object */ do { if (IS_CV == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -28462,7 +28462,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE /* here we are sure we are dealing with an object */ do { if (IS_CONST == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -28550,8 +28551,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCOD zval *container; zval *offset; - zval *retval; - zend_property_info *prop_info; SAVE_OPLINE(); container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); @@ -28566,7 +28565,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCOD /* here we are sure we are dealing with an object */ do { if (IS_CONST == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -29870,7 +29870,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_H /* here we are sure we are dealing with an object */ do { if (IS_TMP_VAR == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -29959,8 +29960,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_ zval *container; zend_free_op free_op2; zval *offset; - zval *retval; - zend_property_info *prop_info; SAVE_OPLINE(); container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); @@ -29975,7 +29974,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_ /* here we are sure we are dealing with an object */ do { if (IS_TMP_VAR == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -31191,7 +31191,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_H /* here we are sure we are dealing with an object */ do { if (IS_VAR == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -31280,8 +31281,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_ zval *container; zend_free_op free_op2; zval *offset; - zval *retval; - zend_property_info *prop_info; SAVE_OPLINE(); container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); @@ -31296,7 +31295,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_ /* here we are sure we are dealing with an object */ do { if (IS_VAR == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -32999,7 +32999,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HA /* here we are sure we are dealing with an object */ do { if (IS_CV == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -33087,8 +33088,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_H zval *container; zval *offset; - zval *retval; - zend_property_info *prop_info; SAVE_OPLINE(); container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); @@ -33103,7 +33102,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_H /* here we are sure we are dealing with an object */ do { if (IS_CV == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -36248,7 +36248,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HAN /* here we are sure we are dealing with an object */ do { if (IS_CONST == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -36336,8 +36337,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HA zval *container; zval *offset; - zval *retval; - zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_cv_deref_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); @@ -36352,7 +36351,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HA /* here we are sure we are dealing with an object */ do { if (IS_CONST == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -38416,7 +38416,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDL /* here we are sure we are dealing with an object */ do { if (IS_TMP_VAR == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -38505,8 +38506,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HAND zval *container; zend_free_op free_op2; zval *offset; - zval *retval; - zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_cv_deref_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); @@ -38521,7 +38520,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HAND /* here we are sure we are dealing with an object */ do { if (IS_TMP_VAR == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -40464,7 +40464,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDL /* here we are sure we are dealing with an object */ do { if (IS_VAR == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -40553,8 +40554,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HAND zval *container; zend_free_op free_op2; zval *offset; - zval *retval; - zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_cv_deref_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); @@ -40569,7 +40568,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HAND /* here we are sure we are dealing with an object */ do { if (IS_VAR == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -43625,7 +43625,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLE /* here we are sure we are dealing with an object */ do { if (IS_CV == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -43713,8 +43714,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDL zval *container; zval *offset; - zval *retval; - zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_cv_deref_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); @@ -43729,7 +43728,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDL /* here we are sure we are dealing with an object */ do { if (IS_CV == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + EXPECTED(Z_TYPE_P(offset) == IS_STRING) && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); From 999d387bf8183e6ddb755dd3e6e4454044c28641 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 10 Nov 2014 09:14:15 +0100 Subject: [PATCH 279/398] move these functions to the appropriate place and include the necessary header --- TSRM/tsrm_win32.c | 48 ++++++++++++++++++++++++++++++++++++++++ TSRM/tsrm_win32.h | 3 +++ Zend/zend_virtual_cwd.c | 49 ----------------------------------------- 3 files changed, 51 insertions(+), 49 deletions(-) diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c index 9936320a951..7194dffd610 100644 --- a/TSRM/tsrm_win32.c +++ b/TSRM/tsrm_win32.c @@ -722,4 +722,52 @@ TSRM_API char *realpath(char *orig_path, char *buffer) return buffer; } +#if HAVE_UTIME +static zend_always_inline void UnixTimeToFileTime(time_t t, LPFILETIME pft) /* {{{ */ +{ + // Note that LONGLONG is a 64-bit value + LONGLONG ll; + + ll = Int32x32To64(t, 10000000) + 116444736000000000; + pft->dwLowDateTime = (DWORD)ll; + pft->dwHighDateTime = ll >> 32; +} +/* }}} */ + +TSRM_API int win32_utime(const char *filename, struct utimbuf *buf) /* {{{ */ +{ + FILETIME mtime, atime; + HANDLE hFile; + + hFile = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ, NULL, + OPEN_ALWAYS, FILE_FLAG_BACKUP_SEMANTICS, NULL); + + /* OPEN_ALWAYS mode sets the last error to ERROR_ALREADY_EXISTS but + the CreateFile operation succeeds */ + if (GetLastError() == ERROR_ALREADY_EXISTS) { + SetLastError(0); + } + + if ( hFile == INVALID_HANDLE_VALUE ) { + return -1; + } + + if (!buf) { + SYSTEMTIME st; + GetSystemTime(&st); + SystemTimeToFileTime(&st, &mtime); + atime = mtime; + } else { + UnixTimeToFileTime(buf->modtime, &mtime); + UnixTimeToFileTime(buf->actime, &atime); + } + if (!SetFileTime(hFile, NULL, &atime, &mtime)) { + CloseHandle(hFile); + return -1; + } + CloseHandle(hFile); + return 1; +} +/* }}} */ +#endif #endif diff --git a/TSRM/tsrm_win32.h b/TSRM/tsrm_win32.h index 5933b54ddf3..beff1e88cfd 100644 --- a/TSRM/tsrm_win32.h +++ b/TSRM/tsrm_win32.h @@ -23,6 +23,9 @@ #include "TSRM.h" #include +#if HAVE_UTIME +# include +#endif struct ipc_perm { int key; diff --git a/Zend/zend_virtual_cwd.c b/Zend/zend_virtual_cwd.c index 385df393bf5..f8b42b1596e 100644 --- a/Zend/zend_virtual_cwd.c +++ b/Zend/zend_virtual_cwd.c @@ -1540,55 +1540,6 @@ CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC) /* {{{ */ /* }}} */ #if HAVE_UTIME -#ifdef TSRM_WIN32 -static void UnixTimeToFileTime(time_t t, LPFILETIME pft) /* {{{ */ -{ - // Note that LONGLONG is a 64-bit value - LONGLONG ll; - - ll = Int32x32To64(t, 10000000) + 116444736000000000; - pft->dwLowDateTime = (DWORD)ll; - pft->dwHighDateTime = ll >> 32; -} -/* }}} */ - -TSRM_API int win32_utime(const char *filename, struct utimbuf *buf) /* {{{ */ -{ - FILETIME mtime, atime; - HANDLE hFile; - - hFile = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ, NULL, - OPEN_ALWAYS, FILE_FLAG_BACKUP_SEMANTICS, NULL); - - /* OPEN_ALWAYS mode sets the last error to ERROR_ALREADY_EXISTS but - the CreateFile operation succeeds */ - if (GetLastError() == ERROR_ALREADY_EXISTS) { - SetLastError(0); - } - - if ( hFile == INVALID_HANDLE_VALUE ) { - return -1; - } - - if (!buf) { - SYSTEMTIME st; - GetSystemTime(&st); - SystemTimeToFileTime(&st, &mtime); - atime = mtime; - } else { - UnixTimeToFileTime(buf->modtime, &mtime); - UnixTimeToFileTime(buf->actime, &atime); - } - if (!SetFileTime(hFile, NULL, &atime, &mtime)) { - CloseHandle(hFile); - return -1; - } - CloseHandle(hFile); - return 1; -} -/* }}} */ -#endif - CWD_API int virtual_utime(const char *filename, struct utimbuf *buf TSRMLS_DC) /* {{{ */ { cwd_state new_state; From 25e75cd091e607c531260dc1cc2937b7461d894f Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 10 Nov 2014 09:30:29 +0100 Subject: [PATCH 280/398] use proper declarations for zend_stat_t --- win32/glob.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/win32/glob.h b/win32/glob.h index 63b8fc2f677..24ae69467cf 100644 --- a/win32/glob.h +++ b/win32/glob.h @@ -47,7 +47,8 @@ # include #endif -zend_stat_t; +#include "Zend/zend_stream.h" + typedef struct { int gl_pathc; /* Count of total paths so far. */ int gl_matchc; /* Count of paths matching pattern. */ From 744fb45217b9175b086350f503812f8946da2217 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 10 Nov 2014 10:57:27 +0100 Subject: [PATCH 281/398] better description for the toolset config option --- win32/build/config.w32 | 4 +++- win32/build/config.w32.phpize.in | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 7187eacca14..e89b805973f 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -3,7 +3,9 @@ // "Master" config file; think of it as a configure.in // equivalent. -ARG_WITH("toolset", "Toolset to use for the compilation, supported: vs, clang, icc", "vs"); +ARG_WITH("toolset", "Toolset to use for the compilation, give: vs, clang, icc. " + + "The only recommended and supported toolset for production use " + + "is Visual Studio. Use others at your own risk.", "vs"); toolset_option_handle(); ARG_WITH('cygwin', 'Path to cygwin utilities on your system', '\\cygwin'); diff --git a/win32/build/config.w32.phpize.in b/win32/build/config.w32.phpize.in index 5a7f31d5d44..da6f6ebae88 100644 --- a/win32/build/config.w32.phpize.in +++ b/win32/build/config.w32.phpize.in @@ -3,7 +3,9 @@ // "Master" config file; think of it as a configure.in // equivalent. -ARG_WITH("toolset", "Toolset to use for the compilation, supported: vs, clang, icc", "vs"); +ARG_WITH("toolset", "Toolset to use for the compilation, give: vs, clang, icc. " + + "The only recommended and supported toolset for production use " + + "is Visual Studio. Use others at your own risk.", "vs"); toolset_option_handle() var PHP_CYGWIN="notset"; From 5eb65a71a741a23a0aa133eb1b128ca19f678b41 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 10 Nov 2014 14:25:14 +0100 Subject: [PATCH 282/398] update UPGRADING.INTERNALS --- UPGRADING.INTERNALS | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 92cebc8db32..0c9080cc42e 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -114,4 +114,17 @@ PHP 7.0 INTERNALS UPGRADE NOTES 2. Build system changes ======================== - + a. Unix build system changes + + b. Windows build system changes + + - Besides Visual Studio, building with Clang or Intel Composer is now + possible. To enable an alternative toolset, add the option + --with-toolset=[vs,clang,icc] to the configure line. The default + toolset is vs. Still clang or icc need the correct environment + which involves many tools from the vs toolset. + + AWARENESS The only recommended and supported toolset to produce production + ready binaries is Visual Studio. Still other compilers can be used now for + testing and analyzing purposes. + From 84cd04fca0398cfd77ecb0ef7f2e816d4496192b Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Mon, 10 Nov 2014 23:35:45 +0800 Subject: [PATCH 283/398] A better fix(do the convertion in compile time) --- Zend/tests/class_properties_const.phpt | 25 ++++++++++++++++ Zend/zend_compile.c | 3 +- Zend/zend_vm_def.h | 2 -- Zend/zend_vm_execute.h | 40 -------------------------- 4 files changed, 27 insertions(+), 43 deletions(-) create mode 100644 Zend/tests/class_properties_const.phpt diff --git a/Zend/tests/class_properties_const.phpt b/Zend/tests/class_properties_const.phpt new file mode 100644 index 00000000000..ac871b5c2bf --- /dev/null +++ b/Zend/tests/class_properties_const.phpt @@ -0,0 +1,25 @@ +--TEST-- +Const class properties(runtime cache) +--FILE-- +{array()}); +var_dump($a->{1}); +var_dump($a->{function(){}}); +?> +--EXPECTF-- +Notice: Array to string conversion in %sclass_properties_const.php on line %d +runtime + +Notice: Undefined property: A::$Array in %sclass_properties_const.php on line %d +NULL + +Notice: Undefined property: A::$1 in %sclass_properties_const.php on line %d +NULL + +Catchable fatal error: Object of class Closure could not be converted to string in %sclass_properties_const.php on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index babf39ff403..d66ed5db357 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -2109,7 +2109,8 @@ static zend_op *zend_delayed_compile_prop(znode *result, zend_ast *ast, uint32_t zend_compile_expr(&prop_node, prop_ast TSRMLS_CC); opline = zend_delayed_emit_op(result, ZEND_FETCH_OBJ_R, &obj_node, &prop_node TSRMLS_CC); - if (opline->op2_type == IS_CONST && Z_TYPE(CONSTANT(opline->op2.constant)) == IS_STRING) { + if (opline->op2_type == IS_CONST) { + convert_to_string(&CONSTANT(opline->op2.constant)); zend_alloc_polymorphic_cache_slot(opline->op2.constant TSRMLS_CC); } diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 81d5cfc1e65..9e8e628362b 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -1326,7 +1326,6 @@ ZEND_VM_HANDLER(82, ZEND_FETCH_OBJ_R, CONST|TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV) /* here we are sure we are dealing with an object */ do { if (OP2_TYPE == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -1430,7 +1429,6 @@ ZEND_VM_HANDLER(91, ZEND_FETCH_OBJ_IS, CONST|TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV /* here we are sure we are dealing with an object */ do { if (OP2_TYPE == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 07507f3b810..8f4de2f8f6f 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -3986,7 +3986,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_ /* here we are sure we are dealing with an object */ do { if (IS_CONST == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -4040,7 +4039,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE /* here we are sure we are dealing with an object */ do { if (IS_CONST == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -5380,7 +5378,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HA /* here we are sure we are dealing with an object */ do { if (IS_TMP_VAR == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -5435,7 +5432,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_H /* here we are sure we are dealing with an object */ do { if (IS_TMP_VAR == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -6619,7 +6615,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HA /* here we are sure we are dealing with an object */ do { if (IS_VAR == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -6674,7 +6669,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_H /* here we are sure we are dealing with an object */ do { if (IS_VAR == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -8583,7 +8577,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HAN /* here we are sure we are dealing with an object */ do { if (IS_CV == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -8637,7 +8630,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HA /* here we are sure we are dealing with an object */ do { if (IS_CV == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -10956,7 +10948,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HA /* here we are sure we are dealing with an object */ do { if (IS_CONST == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -11010,7 +11001,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_H /* here we are sure we are dealing with an object */ do { if (IS_CONST == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -12226,7 +12216,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HAND /* here we are sure we are dealing with an object */ do { if (IS_TMP_VAR == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -12281,7 +12270,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HAN /* here we are sure we are dealing with an object */ do { if (IS_TMP_VAR == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -13438,7 +13426,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HAND /* here we are sure we are dealing with an object */ do { if (IS_VAR == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -13493,7 +13480,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HAN /* here we are sure we are dealing with an object */ do { if (IS_VAR == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -15267,7 +15253,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDL /* here we are sure we are dealing with an object */ do { if (IS_CV == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -15321,7 +15306,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HAND /* here we are sure we are dealing with an object */ do { if (IS_CV == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -18762,7 +18746,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HA /* here we are sure we are dealing with an object */ do { if (IS_CONST == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -18865,7 +18848,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_H /* here we are sure we are dealing with an object */ do { if (IS_CONST == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -21100,7 +21082,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAND /* here we are sure we are dealing with an object */ do { if (IS_TMP_VAR == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -21204,7 +21185,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAN /* here we are sure we are dealing with an object */ do { if (IS_TMP_VAR == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -23276,7 +23256,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAND /* here we are sure we are dealing with an object */ do { if (IS_VAR == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -23380,7 +23359,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAN /* here we are sure we are dealing with an object */ do { if (IS_VAR == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -26712,7 +26690,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDL /* here we are sure we are dealing with an object */ do { if (IS_CV == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -26815,7 +26792,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HAND /* here we are sure we are dealing with an object */ do { if (IS_CV == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -28462,7 +28438,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE /* here we are sure we are dealing with an object */ do { if (IS_CONST == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -28565,7 +28540,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCOD /* here we are sure we are dealing with an object */ do { if (IS_CONST == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -29870,7 +29844,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_H /* here we are sure we are dealing with an object */ do { if (IS_TMP_VAR == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -29974,7 +29947,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_ /* here we are sure we are dealing with an object */ do { if (IS_TMP_VAR == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -31191,7 +31163,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_H /* here we are sure we are dealing with an object */ do { if (IS_VAR == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -31295,7 +31266,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_ /* here we are sure we are dealing with an object */ do { if (IS_VAR == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -32999,7 +32969,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HA /* here we are sure we are dealing with an object */ do { if (IS_CV == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -33102,7 +33071,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_H /* here we are sure we are dealing with an object */ do { if (IS_CV == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -36248,7 +36216,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HAN /* here we are sure we are dealing with an object */ do { if (IS_CONST == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -36351,7 +36318,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HA /* here we are sure we are dealing with an object */ do { if (IS_CONST == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -38416,7 +38382,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDL /* here we are sure we are dealing with an object */ do { if (IS_TMP_VAR == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -38520,7 +38485,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HAND /* here we are sure we are dealing with an object */ do { if (IS_TMP_VAR == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -40464,7 +40428,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDL /* here we are sure we are dealing with an object */ do { if (IS_VAR == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -40568,7 +40531,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HAND /* here we are sure we are dealing with an object */ do { if (IS_VAR == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -43625,7 +43587,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLE /* here we are sure we are dealing with an object */ do { if (IS_CV == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); @@ -43728,7 +43689,6 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDL /* here we are sure we are dealing with an object */ do { if (IS_CV == IS_CONST && - EXPECTED(Z_TYPE_P(offset) == IS_STRING) && EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); zend_object *zobj = Z_OBJ_P(container); From 44bc735a62dcbfbd628d8721c2ee83491dcb073c Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Mon, 10 Nov 2014 23:41:55 +0800 Subject: [PATCH 284/398] convert_to_string also does the check --- Zend/zend_compile.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index d66ed5db357..ebbb0050883 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -2985,9 +2985,7 @@ void zend_compile_global_var(zend_ast *ast TSRMLS_DC) /* {{{ */ zend_compile_expr(&name_node, name_ast TSRMLS_CC); if (name_node.op_type == IS_CONST) { - if (Z_TYPE(name_node.u.constant) != IS_STRING) { - convert_to_string(&name_node.u.constant); - } + convert_to_string(&name_node.u.constant); } if (zend_try_compile_cv(&result, var_ast TSRMLS_CC) == SUCCESS) { From 1e5077d1e85cf150b0aedb72da68c8e335f39841 Mon Sep 17 00:00:00 2001 From: Rasmus Lerdorf Date: Mon, 10 Nov 2014 10:41:18 -0800 Subject: [PATCH 285/398] Fix skipif test here --- ext/sockets/tests/mcast_ipv4_send.phpt | 131 +++++++++++++------------ 1 file changed, 66 insertions(+), 65 deletions(-) diff --git a/ext/sockets/tests/mcast_ipv4_send.phpt b/ext/sockets/tests/mcast_ipv4_send.phpt index ac5bce91623..0dd858f297c 100644 --- a/ext/sockets/tests/mcast_ipv4_send.phpt +++ b/ext/sockets/tests/mcast_ipv4_send.phpt @@ -1,65 +1,66 @@ ---TEST-- -Multicast support: IPv4 send options ---SKIPIF-- - Date: Mon, 10 Nov 2014 10:41:18 -0800 Subject: [PATCH 286/398] Fix skipif test here --- ext/sockets/tests/mcast_ipv4_send.phpt | 131 +++++++++++++------------ 1 file changed, 66 insertions(+), 65 deletions(-) diff --git a/ext/sockets/tests/mcast_ipv4_send.phpt b/ext/sockets/tests/mcast_ipv4_send.phpt index ac5bce91623..0dd858f297c 100644 --- a/ext/sockets/tests/mcast_ipv4_send.phpt +++ b/ext/sockets/tests/mcast_ipv4_send.phpt @@ -1,65 +1,66 @@ ---TEST-- -Multicast support: IPv4 send options ---SKIPIF-- - Date: Mon, 10 Nov 2014 10:41:18 -0800 Subject: [PATCH 287/398] Fix skipif test here --- ext/sockets/tests/mcast_ipv4_send.phpt | 131 +++++++++++++------------ 1 file changed, 66 insertions(+), 65 deletions(-) diff --git a/ext/sockets/tests/mcast_ipv4_send.phpt b/ext/sockets/tests/mcast_ipv4_send.phpt index ac5bce91623..0dd858f297c 100644 --- a/ext/sockets/tests/mcast_ipv4_send.phpt +++ b/ext/sockets/tests/mcast_ipv4_send.phpt @@ -1,65 +1,66 @@ ---TEST-- -Multicast support: IPv4 send options ---SKIPIF-- - Date: Mon, 10 Nov 2014 17:31:31 +0100 Subject: [PATCH 288/398] initialiize opline for the case it lands in default case --- Zend/zend_compile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index ebbb0050883..c3a572a04d5 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -5468,7 +5468,7 @@ void zend_compile_isset_or_empty(znode *result, zend_ast *ast TSRMLS_DC) /* {{{ zend_ast *var_ast = ast->child[0]; znode var_node; - zend_op *opline; + zend_op *opline = NULL; ZEND_ASSERT(ast->kind == ZEND_AST_ISSET || ast->kind == ZEND_AST_EMPTY); From 88ba5a625c7efb1001ce90c8f4649cff830d82a4 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 10 Nov 2014 18:16:31 +0100 Subject: [PATCH 289/398] do portable socket checks also introduced a portable macro for that --- Zend/zend_portability.h | 6 ++++++ sapi/cli/php_cli_server.c | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index a6dac42b5a2..f056b163388 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -394,6 +394,12 @@ char *alloca(); #define ZEND_SECURE_ZERO(var, size) memset((var), 0, (size)) #endif +#ifdef ZEND_WIN32 +#define ZEND_VALID_SOCKET(sock) (INVALID_SOCKET != (sock)) +#else +#define ZEND_VALID_SOCKET(sock) ((sock) >= 0) +#endif + #endif /* ZEND_PORTABILITY_H */ /* diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index 19a94218ff8..20e27f0bb76 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -556,7 +556,7 @@ static void sapi_cli_server_flush(void *server_context TSRMLS_DC) /* {{{ */ return; } - if (client->sock < 0) { + if (!ZEND_VALID_SOCKET(client->sock)) { php_handle_aborted_connection(); return; } @@ -1338,7 +1338,7 @@ out: php_network_freeaddresses(sal); } if (err) { - if (retval >= 0) { + if (ZEND_VALID_SOCKET(retval)) { closesocket(retval); } if (errstr) { @@ -2186,7 +2186,7 @@ static void php_cli_server_dtor(php_cli_server *server TSRMLS_DC) /* {{{ */ { zend_hash_destroy(&server->clients); zend_hash_destroy(&server->extension_mime_types); - if (server->server_sock >= 0) { + if (ZEND_VALID_SOCKET(server->server_sock)) { closesocket(server->server_sock); } if (server->host) { @@ -2407,7 +2407,7 @@ static int php_cli_server_do_event_for_each_fd_callback(void *_params, php_socke return FAILURE; } client_sock = accept(server->server_sock, sa, &socklen); - if (client_sock < 0) { + if (!ZEND_VALID_SOCKET(client_sock)) { char *errstr; errstr = php_socket_strerror(php_socket_errno(), NULL, 0); php_cli_server_logf("Failed to accept a client (reason: %s)" TSRMLS_CC, errstr); From c3471cc1c9ce58a9c1dd4abbbf2dd72a760ea46b Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 10 Nov 2014 18:20:11 +0100 Subject: [PATCH 290/398] cleanup unused variable --- sapi/cli/php_cli_server.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index 20e27f0bb76..9612352b00e 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -838,7 +838,6 @@ static int php_cli_server_poller_iter_on_active(php_cli_server_poller *poller, v SOCKET fd; int events; } entries[FD_SETSIZE * 2]; - php_socket_t fd = 0; size_t i; struct socket_entry *n = entries, *m; From 940e69147ec127e44e8eb66d9bab6d3de136e4c9 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 10 Nov 2014 18:21:55 +0100 Subject: [PATCH 291/398] fix var usage only when unistd.h available --- sapi/cli/php_cli_server.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index 9612352b00e..49680cede42 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -259,7 +259,9 @@ static php_cli_server_http_response_status_code_pair template_map[] = { { 501, "

%s

Request method not supported.

" } }; +#if HAVE_UNISTD_H static int php_cli_output_is_tty = OUTPUT_NOT_CHECKED; +#endif static size_t php_cli_server_client_send_through(php_cli_server_client *client, const char *str, size_t str_len); static php_cli_server_chunk *php_cli_server_chunk_heap_new_self_contained(size_t len); From 5ad7cad103df571c6a73c39aad969208a3c04748 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 10 Nov 2014 18:24:59 +0100 Subject: [PATCH 292/398] fix sprintf spec --- sapi/cli/ps_title.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sapi/cli/ps_title.c b/sapi/cli/ps_title.c index 97eec86e5b8..4885d9ea6e0 100644 --- a/sapi/cli/ps_title.c +++ b/sapi/cli/ps_title.c @@ -311,7 +311,7 @@ const char* ps_title_errno(int rc) #ifdef PS_USE_WIN32 case PS_TITLE_WINDOWS_ERROR: - sprintf(windows_error_details, "Windows error code: %u", GetLastError()); + sprintf(windows_error_details, "Windows error code: %lu", GetLastError()); return windows_error_details; #endif } From 96805364fa89f98e5dff24e2eab9bb780c87e5de Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 10 Nov 2014 18:26:20 +0100 Subject: [PATCH 293/398] fix var declaration used by macro conditions --- sapi/cli/ps_title.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sapi/cli/ps_title.c b/sapi/cli/ps_title.c index 4885d9ea6e0..6cef483983d 100644 --- a/sapi/cli/ps_title.c +++ b/sapi/cli/ps_title.c @@ -129,7 +129,9 @@ static char** save_argv; * This holds the 'locally' allocated environ from the save_ps_args method. * This is subsequently free'd at exit. */ +#if defined(PS_USE_CLOBBER_ARGV) static char** frozen_environ, **new_environ; +#endif /* * Call this method early, before any code has used the original argv passed in From 64c081f347b177d11b1083a6f13efa744884ff98 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 10 Nov 2014 23:28:03 +0100 Subject: [PATCH 294/398] moved libs and debug/release mode setup into functions --- win32/build/config.w32 | 27 ++------------------------- win32/build/config.w32.phpize.in | 27 ++------------------------- win32/build/confutils.js | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 50 deletions(-) diff --git a/win32/build/config.w32 b/win32/build/config.w32 index e89b805973f..43ff038062e 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -93,29 +93,10 @@ if (VS_TOOLSET && VCVERS >= 1500 && PHP_MP != 'disable') { toolset_setup_common_ldlags(); // General libs -// urlmon.lib ole32.lib oleaut32.lib uuid.lib gdi32.lib winspool.lib comdlg32.lib -DEFINE("LIBS", "kernel32.lib ole32.lib user32.lib advapi32.lib shell32.lib ws2_32.lib Dnsapi.lib"); +toolset_setup_common_libs(); // Set some debug/release specific options -if (PHP_DEBUG == "yes") { - ADD_FLAG("CFLAGS", "/LDd /MDd /W3 /Gm /Od /D _DEBUG /D ZEND_DEBUG=1 " + - (X64?"/Zi":"/ZI")); - ADD_FLAG("LDFLAGS", "/debug"); - // Avoid problems when linking to release libraries that use the release - // version of the libc - ADD_FLAG("PHP_LDFLAGS", "/nodefaultlib:msvcrt"); -} else { - // Generate external debug files when --enable-debug-pack is specified - if (PHP_DEBUG_PACK == "yes") { - ADD_FLAG("CFLAGS", "/Zi"); - ADD_FLAG("LDFLAGS", "/incremental:no /debug /opt:ref,icf"); - } - // Equivalent to Release_TSInline build -> best optimization - ADD_FLAG("CFLAGS", "/LD /MD /W3 /Ox /D NDebug /D NDEBUG /D ZEND_WIN32_FORCE_INLINE /GF /D ZEND_DEBUG=0"); - - // if you have VS.Net /GS hardens the binary against buffer overruns - // ADD_FLAG("CFLAGS", "/GS"); -} +toolset_setup_build_mode(); if (PHP_ZTS == "yes") { ADD_FLAG("CFLAGS", "/D ZTS=1"); @@ -126,10 +107,6 @@ if (PHP_ZTS == "yes") { DEFINE("PHP_ZTS_ARCHIVE_POSTFIX", PHP_ZTS == "yes" ? '' : "-nts"); - -// we want msvcrt in the PHP DLL -ADD_FLAG("PHP_LDFLAGS", "/nodefaultlib:libcmt"); - // set up the build dir and DLL name if (PHP_DEBUG == "yes" && PHP_ZTS == "yes") { DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Debug_TS"); diff --git a/win32/build/config.w32.phpize.in b/win32/build/config.w32.phpize.in index da6f6ebae88..e2860e3a963 100644 --- a/win32/build/config.w32.phpize.in +++ b/win32/build/config.w32.phpize.in @@ -83,29 +83,10 @@ ARG_WITH("snapshot-template", "Path to snapshot builder template dir", "no"); toolset_setup_common_ldlags(); // General libs -// urlmon.lib ole32.lib oleaut32.lib uuid.lib gdi32.lib winspool.lib comdlg32.lib -DEFINE("LIBS", "kernel32.lib ole32.lib user32.lib advapi32.lib shell32.lib ws2_32.lib Dnsapi.lib"); +toolset_setup_common_libs(); // Set some debug/release specific options -if (PHP_DEBUG == "yes") { - ADD_FLAG("CFLAGS", "/LDd /MDd /W3 /Gm /Od /D _DEBUG /D ZEND_DEBUG=1 " + - (X64?"/Zi":"/ZI")); - ADD_FLAG("LDFLAGS", "/debug"); - // Avoid problems when linking to release libraries that use the release - // version of the libc - ADD_FLAG("PHP_LDFLAGS", "/nodefaultlib:msvcrt"); -} else { - // Generate external debug files when --enable-debug-pack is specified - if (PHP_DEBUG_PACK == "yes") { - ADD_FLAG("CFLAGS", "/Zi"); - ADD_FLAG("LDFLAGS", "/incremental:no /debug /opt:ref,icf"); - } - // Equivalent to Release_TSInline build -> best optimization - ADD_FLAG("CFLAGS", "/LD /MD /W3 /Ox /D NDebug /D NDEBUG /D ZEND_WIN32_FORCE_INLINE /GF /D ZEND_DEBUG=0"); - - // if you have VS.Net /GS hardens the binary against buffer overruns - // ADD_FLAG("CFLAGS", "/GS"); -} +toolset_setup_build_mode(); if (PHP_ZTS == "yes") { ADD_FLAG("CFLAGS", "/D ZTS=1"); @@ -113,10 +94,6 @@ if (PHP_ZTS == "yes") { DEFINE("PHP_ZTS_ARCHIVE_POSTFIX", PHP_ZTS == "yes" ? '' : "-nts"); - -// we want msvcrt in the PHP DLL -ADD_FLAG("PHP_LDFLAGS", "/nodefaultlib:libcmt"); - // set up the build dir and DLL name if (PHP_DEBUG == "yes" && PHP_ZTS == "yes") { DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Debug_TS"); diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 0f07e18120b..bad5f1322ea 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -2583,5 +2583,37 @@ function toolset_setup_common_ldlags() } else { DEFINE("LDFLAGS", "/nologo "); } + + // we want msvcrt in the PHP DLL + ADD_FLAG("PHP_LDFLAGS", "/nodefaultlib:libcmt"); +} + +function toolset_setup_common_libs() +{ + // urlmon.lib ole32.lib oleaut32.lib uuid.lib gdi32.lib winspool.lib comdlg32.lib + DEFINE("LIBS", "kernel32.lib ole32.lib user32.lib advapi32.lib shell32.lib ws2_32.lib Dnsapi.lib"); +} + +function toolset_setup_build_mode() +{ + if (PHP_DEBUG == "yes") { + ADD_FLAG("CFLAGS", "/LDd /MDd /W3 /Gm /Od /D _DEBUG /D ZEND_DEBUG=1 " + + (X64?"/Zi":"/ZI")); + ADD_FLAG("LDFLAGS", "/debug"); + // Avoid problems when linking to release libraries that use the release + // version of the libc + ADD_FLAG("PHP_LDFLAGS", "/nodefaultlib:msvcrt"); + } else { + // Generate external debug files when --enable-debug-pack is specified + if (PHP_DEBUG_PACK == "yes") { + ADD_FLAG("CFLAGS", "/Zi"); + ADD_FLAG("LDFLAGS", "/incremental:no /debug /opt:ref,icf"); + } + // Equivalent to Release_TSInline build -> best optimization + ADD_FLAG("CFLAGS", "/LD /MD /W3 /Ox /D NDebug /D NDEBUG /D ZEND_WIN32_FORCE_INLINE /GF /D ZEND_DEBUG=0"); + + // if you have VS.Net /GS hardens the binary against buffer overruns + // ADD_FLAG("CFLAGS", "/GS"); + } } From d509e79d70bfe43c782437b0dbd7dee1501acb6a Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 11 Nov 2014 00:38:37 +0100 Subject: [PATCH 295/398] further fixes to win build - fixed pdb generation with vs - made object-out-dir to use an absolute path, that fixes path issues with x86/x64 and nmake snap --- win32/build/Makefile | 7 +------ win32/build/config.w32 | 13 +------------ win32/build/config.w32.phpize.in | 13 +------------ win32/build/confutils.js | 25 ++++++++++++++++++++++++- 4 files changed, 27 insertions(+), 31 deletions(-) diff --git a/win32/build/Makefile b/win32/build/Makefile index 90f02d24943..d6a22c162c6 100644 --- a/win32/build/Makefile +++ b/win32/build/Makefile @@ -158,19 +158,14 @@ build-dist: $(BUILD_DIR)\deplister.exe $(BUILD_DIR)\php.exe -d date.timezone=UTC -n -dphar.readonly=0 win32/build/mkdist.php "$(BUILD_DIR)" "$(PHP_BUILD)" "$(PHPDLL)" "$(SAPI_TARGETS)" "$(EXT_TARGETS) $(PHP_EXTRA_DIST_FILES)" "$(PECL_TARGETS) $(PECL_EXTRA_DIST_FILES)" "$(SNAPSHOT_TEMPLATE)" cd $(BUILD_DIR)\php-$(PHP_VERSION_STRING) -$(ZIP) -9 -q -r ..\php-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip . - cd ..\.. cd $(BUILD_DIR)\pecl-$(PHP_VERSION_STRING) -$(ZIP) -9 -q -r ..\pecl-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip . - cd ..\.. cd $(BUILD_DIR)\php-test-pack-$(PHP_VERSION_STRING) -$(ZIP) -9 -q -r ..\php-test-pack-$(PHP_VERSION_STRING).zip . - cd ..\.. cd $(BUILD_DIR) -$(ZIP) -9 -q php-debug-pack-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip *.pdb - cd - cd -$(ZIP) -9 -q -r php-devel-pack-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip $(BUILD_DIR_DEV_NAME) - cd ..\.. + cd $(BUILD_DIR) dist: all build-dist snap: build-snap build-devel build-dist diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 43ff038062e..85a96f1694f 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -27,18 +27,7 @@ toolset_setup_project_tools(); // stick objects somewhere outside of the source tree ARG_ENABLE('object-out-dir', 'Alternate location for binary objects during build', ''); -if (PHP_OBJECT_OUT_DIR.length) { - PHP_OBJECT_OUT_DIR = FSO.GetAbsolutePathName(PHP_OBJECT_OUT_DIR); - if (!FSO.FolderExists(PHP_OBJECT_OUT_DIR)) { - ERROR('you chosen output directory ' + PHP_OBJECT_OUT_DIR + ' does not exist'); - } - PHP_OBJECT_OUT_DIR += '\\'; -} else if (X64) { - if (!FSO.FolderExists("x64")) { - FSO.CreateFolder("x64"); - } - PHP_OBJECT_OUT_DIR = 'x64\\'; -} +object_out_dir_option_handle(); ARG_ENABLE('debug', 'Compile with debugging symbols', "no"); ARG_ENABLE('debug-pack', 'Release binaries with external debug symbols (--enable-debug must not be specified)', 'no'); diff --git a/win32/build/config.w32.phpize.in b/win32/build/config.w32.phpize.in index e2860e3a963..52947c1ace8 100644 --- a/win32/build/config.w32.phpize.in +++ b/win32/build/config.w32.phpize.in @@ -27,18 +27,7 @@ toolset_setup_project_tools(); // stick objects somewhere outside of the source tree ARG_ENABLE('object-out-dir', 'Alternate location for binary objects during build', ''); -if (PHP_OBJECT_OUT_DIR.length) { - PHP_OBJECT_OUT_DIR = FSO.GetAbsolutePathName(PHP_OBJECT_OUT_DIR); - if (!FSO.FolderExists(PHP_OBJECT_OUT_DIR)) { - ERROR('you chosen output directory ' + PHP_OBJECT_OUT_DIR + ' does not exist'); - } - PHP_OBJECT_OUT_DIR += '\\'; -} else if (X64) { - if (!FSO.FolderExists("x64")) { - FSO.CreateFolder("x64"); - } - PHP_OBJECT_OUT_DIR = 'x64\\'; -} +object_out_dir_option_handle(); ARG_ENABLE('debug', 'Compile with debugging symbols', "no"); ARG_ENABLE('debug-pack', 'Release binaries with external debug symbols (--enable-debug must not be specified)', 'no'); diff --git a/win32/build/confutils.js b/win32/build/confutils.js index bad5f1322ea..c73ae6b2fdb 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -1439,7 +1439,10 @@ function ADD_SOURCES(dir, file_list, target, obj_dir) sub_build += d; - DEFINE(bd_flags_name, " /Fp" + sub_build + " /FR" + sub_build + " "); + DEFINE(bd_flags_name, "/Fp" + sub_build + " /FR" + sub_build + " "); + if (VS_TOOLSET) { + ADD_FLAG(bd_flags_name, "/Fd" + sub_build); + } for (i in file_list) { src = file_list[i]; @@ -2617,3 +2620,23 @@ function toolset_setup_build_mode() } } +function object_out_dir_option_handle() +{ + if (PHP_OBJECT_OUT_DIR.length) { + PHP_OBJECT_OUT_DIR = FSO.GetAbsolutePathName(PHP_OBJECT_OUT_DIR); + if (!FSO.FolderExists(PHP_OBJECT_OUT_DIR)) { + ERROR('you chosen output directory ' + PHP_OBJECT_OUT_DIR + ' does not exist'); + } + PHP_OBJECT_OUT_DIR += '\\'; + } else { + PHP_OBJECT_OUT_DIR = FSO.GetAbsolutePathName("."); + + if (X64) { + PHP_OBJECT_OUT_DIR += '\\x64\\'; + if (!FSO.FolderExists(PHP_OBJECT_OUT_DIR)) { + FSO.CreateFolder(PHP_OBJECT_OUT_DIR); + } + } + } +} + From 6d215f8ceed95c5404dbdeb71b82f84cc83f33d3 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 11 Nov 2014 00:51:21 +0100 Subject: [PATCH 296/398] fix trailing slash --- win32/build/confutils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/win32/build/confutils.js b/win32/build/confutils.js index c73ae6b2fdb..c7e8c119c02 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -2629,10 +2629,10 @@ function object_out_dir_option_handle() } PHP_OBJECT_OUT_DIR += '\\'; } else { - PHP_OBJECT_OUT_DIR = FSO.GetAbsolutePathName("."); + PHP_OBJECT_OUT_DIR = FSO.GetAbsolutePathName(".") + '\\'; if (X64) { - PHP_OBJECT_OUT_DIR += '\\x64\\'; + PHP_OBJECT_OUT_DIR += 'x64\\'; if (!FSO.FolderExists(PHP_OBJECT_OUT_DIR)) { FSO.CreateFolder(PHP_OBJECT_OUT_DIR); } From 327d4f9afbb81ea7bf4fd2c6c69019e886047e60 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Tue, 11 Nov 2014 16:22:49 +0800 Subject: [PATCH 297/398] Fixed bug #68361 (Segmentation fault on SoapClient::__getTypes) --- NEWS | 12 ++-- ext/soap/soap.c | 3 + ext/soap/tests/bug68361.phpt | 114 +++++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+), 4 deletions(-) create mode 100644 ext/soap/tests/bug68361.phpt diff --git a/NEWS b/NEWS index 79a2b8893f5..99a58662e7f 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,10 @@ PHP NEWS . Fixed bug #68129 (parse_url() - incomplete support for empty usernames and passwords) (Tjerk) +- CURL: + . Add CURL_SSLVERSION_TLSv1_0, CURL_SSLVERSION_TLSv1_1, and + CURL_SSLVERSION_TLSv1_2 constants if supported by libcurl (Rasmus) + - Fileinfo: . Fixed bug #66242 (libmagic: don't assume char is signed). (ArdB) . Fixed bug #68283 (fileinfo: out-of-bounds read in elf note headers). @@ -33,13 +37,13 @@ PHP NEWS . Fixed bug #68087 (ODBC not correctly reading DATE column when preceded by a VARCHAR column) (Keyur Govande) +- SOAP: + . Fixed bug #68361 (Segmentation fault on SoapClient::__getTypes). + (Laruence) + - SPL: . Fixed bug #68128 (Regression in RecursiveRegexIterator) (Tjerk) -- CURL: - . Add CURL_SSLVERSION_TLSv1_0, CURL_SSLVERSION_TLSv1_1, and - CURL_SSLVERSION_TLSv1_2 constants if supported by libcurl (Rasmus) - 16 Oct 2014, PHP 5.5.18 - Core: diff --git a/ext/soap/soap.c b/ext/soap/soap.c index cca8c912e96..80a3a93cec0 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -4746,6 +4746,7 @@ static void type_to_string(sdlTypePtr type, smart_str *buf, int level) zend_hash_find(type->attributes, SOAP_1_1_ENC_NAMESPACE":arrayType", sizeof(SOAP_1_1_ENC_NAMESPACE":arrayType"), (void **)&attr) == SUCCESS && + (*attr)->extraAttributes && zend_hash_find((*attr)->extraAttributes, WSDL_NAMESPACE":arrayType", sizeof(WSDL_NAMESPACE":arrayType"), (void **)&ext) == SUCCESS) { char *end = strchr((*ext)->val, '['); int len; @@ -4770,6 +4771,7 @@ static void type_to_string(sdlTypePtr type, smart_str *buf, int level) zend_hash_find(type->attributes, SOAP_1_2_ENC_NAMESPACE":itemType", sizeof(SOAP_1_2_ENC_NAMESPACE":itemType"), (void **)&attr) == SUCCESS && + (*attr)->extraAttributes && zend_hash_find((*attr)->extraAttributes, WSDL_NAMESPACE":itemType", sizeof(WSDL_NAMESPACE":arrayType"), (void **)&ext) == SUCCESS) { smart_str_appends(buf, (*ext)->val); smart_str_appendc(buf, ' '); @@ -4789,6 +4791,7 @@ static void type_to_string(sdlTypePtr type, smart_str *buf, int level) zend_hash_find(type->attributes, SOAP_1_2_ENC_NAMESPACE":arraySize", sizeof(SOAP_1_2_ENC_NAMESPACE":arraySize"), (void **)&attr) == SUCCESS && + (*attr)->extraAttributes && zend_hash_find((*attr)->extraAttributes, WSDL_NAMESPACE":itemType", sizeof(WSDL_NAMESPACE":arraySize"), (void **)&ext) == SUCCESS) { smart_str_appendc(buf, '['); smart_str_appends(buf, (*ext)->val); diff --git a/ext/soap/tests/bug68361.phpt b/ext/soap/tests/bug68361.phpt new file mode 100644 index 00000000000..6dbba8a4259 --- /dev/null +++ b/ext/soap/tests/bug68361.phpt @@ -0,0 +1,114 @@ +--TEST-- +Bug #68361 Segmentation fault on SoapClient::__getTypes +--SKIPIF-- + +--FILE-- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +XML; + +file_put_contents(__DIR__ . "/bug68361.xml", $xml); +$client = new SoapClient(__DIR__ . "/bug68361.xml"); + +$res = $client->__getTypes(); // Segmentation fault here + +print_r($res); +?> +--CLEAN-- + +--EXPECT-- +Array +( + [0] => anyType ArrayOfEmployeeReturn[] + [1] => struct Employee { + int id; + string department; + string name; + int age; +} + [2] => struct User { + string name; + int age; +} +) From 399ec40a7613ef4092668c211d04e1d59c167a14 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Tue, 11 Nov 2014 16:24:59 +0800 Subject: [PATCH 298/398] Update NEWS --- NEWS | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/NEWS b/NEWS index 81840b0b0fc..376d7f350b9 100644 --- a/NEWS +++ b/NEWS @@ -24,9 +24,9 @@ PHP NEWS . Fixed bug #68129 (parse_url() - incomplete support for empty usernames and passwords) (Tjerk) -- phpdbg: - . Added XML protocol (-x command line flag). (Bob) - . Added hard interruptions (twice SIGINT). (Bob) +- CURL: + . Add CURL_SSLVERSION_TLSv1_0, CURL_SSLVERSION_TLSv1_1, and + CURL_SSLVERSION_TLSv1_2 constants if supported by libcurl (Rasmus) - Fileinfo: . Fixed bug #66242 (libmagic: don't assume char is signed). (ArdB) @@ -49,36 +49,40 @@ PHP NEWS . Fixed bug #63595 (GMP memory management conflicts with other libraries using GMP). (Remi) -- Reflection: - . Fixed bug #68103 (Duplicate entry in Reflection for class alias). (Remi) +- Mysqli: + . Fixed bug #68114 (linker error on some OS X machines with fixed width + decimal support) (Keyur Govande) - OpenSSL: . Fixed bug #68074 (Allow to use system cipher list instead of hardcoded value). (Remi) -- Mysqli: - . Fixed bug #68114 (linker error on some OS X machines with fixed width - decimal support) (Keyur Govande) - - ODBC: . Fixed bug #68087 (ODBC not correctly reading DATE column when preceded by a VARCHAR column) (Keyur Govande) +- phpdbg: + . Added XML protocol (-x command line flag). (Bob) + . Added hard interruptions (twice SIGINT). (Bob) + +- PDO_pgsql: + . Fixed bug #68199 (PDO::pgsqlGetNotify doesn't support NOTIFY payloads) + (Matteo, Alain Laporte) + +- Reflection: + . Fixed bug #68103 (Duplicate entry in Reflection for class alias). (Remi) + - Session: . Fixed bug #68331 (Session custom storage callable functions not being called) (Yasuo Ohgaki) +- SOAP: + . Fixed bug #68361 (Segmentation fault on SoapClient::__getTypes). + (Laruence) + - SPL: . Fixed bug #68128 (Regression in RecursiveRegexIterator) (Tjerk) -- CURL: - . Add CURL_SSLVERSION_TLSv1_0, CURL_SSLVERSION_TLSv1_1, and - CURL_SSLVERSION_TLSv1_2 constants if supported by libcurl (Rasmus) - -- PDO_pgsql: - . Fixed bug #68199 (PDO::pgsqlGetNotify doesn't support NOTIFY payloads) - (Matteo, Alain Laporte) - 16 Oct 2014, PHP 5.6.2 - Core: From 8511b33bd08bb17ba55510c0607670f6f6bfc3c0 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Tue, 11 Nov 2014 16:33:36 +0800 Subject: [PATCH 299/398] Update NEWs --- NEWS | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/NEWS b/NEWS index fba96937fb1..319623c922e 100644 --- a/NEWS +++ b/NEWS @@ -2,9 +2,6 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 20??, PHP 7.0.0 --Fileinfo: - . Fixed bug #66242 (libmagic: don't assume char is signed). (ArdB) - - CLI server: . Refactor MIME type handling to use a hash table instead of linear search. (Adam) @@ -22,15 +19,35 @@ PHP NEWS . Implemented the RFC `Catchable "Call to a member function bar() on a non-object"` (Timm) -- Reflection - . Fixed inheritance chain of Reflector interface (Tjerk) - - DBA: . Fixed bug #62490 (dba_delete returns true on missing item (inifile)). (Mike) +- DOM: + . Made DOMNode::textContent writeable. (Tjerk) + +- GD: + . Made fontFetch's path parser thread-safe. (Sara) + +- Fileinfo: + . Fixed bug #66242 (libmagic: don't assume char is signed). (ArdB) + - FPM: . Fixed bug #65933 (Cannot specify config lines longer than 1024 bytes). (Chris Wright) +- Reflection + . Fixed inheritance chain of Reflector interface (Tjerk) + +- Session: + . Fixed bug #67694 (Regression in session_regenerate_id()). (Tjerk) + +- SOAP: + . Fixed bug #68361 (Segmentation fault on SoapClient::__getTypes). + (Laruence) + +- SPL: + . Implemented #67886 (SplPriorityQueue/SplHeap doesn't expose extractFlags + nor curruption state). (Julien) + - Standard: . Removed call_user_method() and call_user_method_array() functions. (Kalle) . Fix user session handlers (See rfc:session.user.return-value). (Sara) @@ -40,17 +57,4 @@ PHP NEWS - XSL: . Fixed bug #64776 (The XSLT extension is not thread safe). (Mike) -- GD: - . Made fontFetch's path parser thread-safe. (Sara) - -- Session: - . Fixed bug #67694 (Regression in session_regenerate_id()). (Tjerk) - -- SPL: - . Implemented #67886 (SplPriorityQueue/SplHeap doesn't expose extractFlags - nor curruption state). (Julien) - -- DOM: - . Made DOMNode::textContent writeable. (Tjerk) - <<< NOTE: Insert NEWS from last stable release here prior to actual release! >>> From 695a102ede7301389c5224114407e91c93c46f90 Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Tue, 11 Nov 2014 14:01:24 -0300 Subject: [PATCH 300/398] - Updated to version 2014.10 (2014j) --- ext/date/lib/timezonedb.h | 1356 +++++++++++++++++++------------------ 1 file changed, 688 insertions(+), 668 deletions(-) diff --git a/ext/date/lib/timezonedb.h b/ext/date/lib/timezonedb.h index 0fd9bfbe10c..157f0f4941c 100644 --- a/ext/date/lib/timezonedb.h +++ b/ext/date/lib/timezonedb.h @@ -2,589 +2,589 @@ const timelib_tzdb_index_entry timezonedb_idx_builtin[583] = { { "Africa/Abidjan" , 0x000000 }, { "Africa/Accra" , 0x000055 }, { "Africa/Addis_Ababa" , 0x00019D }, - { "Africa/Algiers" , 0x0001F3 }, - { "Africa/Asmara" , 0x00031E }, - { "Africa/Asmera" , 0x000374 }, - { "Africa/Bamako" , 0x0003CA }, - { "Africa/Bangui" , 0x00041F }, - { "Africa/Banjul" , 0x000474 }, - { "Africa/Bissau" , 0x0004C9 }, - { "Africa/Blantyre" , 0x00052F }, - { "Africa/Brazzaville" , 0x000584 }, - { "Africa/Bujumbura" , 0x0005D9 }, - { "Africa/Cairo" , 0x00062E }, - { "Africa/Casablanca" , 0x000A15 }, - { "Africa/Ceuta" , 0x000C77 }, - { "Africa/Conakry" , 0x000F7E }, - { "Africa/Dakar" , 0x000FD3 }, - { "Africa/Dar_es_Salaam" , 0x001028 }, - { "Africa/Djibouti" , 0x001095 }, - { "Africa/Douala" , 0x0010EA }, - { "Africa/El_Aaiun" , 0x00113F }, - { "Africa/Freetown" , 0x00136A }, - { "Africa/Gaborone" , 0x0013BF }, - { "Africa/Harare" , 0x001414 }, - { "Africa/Johannesburg" , 0x001469 }, - { "Africa/Juba" , 0x0014D7 }, - { "Africa/Kampala" , 0x0015EA }, - { "Africa/Khartoum" , 0x001669 }, - { "Africa/Kigali" , 0x00177C }, - { "Africa/Kinshasa" , 0x0017D1 }, - { "Africa/Lagos" , 0x00183D }, - { "Africa/Libreville" , 0x001892 }, - { "Africa/Lome" , 0x0018E7 }, - { "Africa/Luanda" , 0x00193C }, - { "Africa/Lubumbashi" , 0x001991 }, - { "Africa/Lusaka" , 0x0019FD }, - { "Africa/Malabo" , 0x001A52 }, - { "Africa/Maputo" , 0x001AA7 }, - { "Africa/Maseru" , 0x001AFC }, - { "Africa/Mbabane" , 0x001B6A }, - { "Africa/Mogadishu" , 0x001BD8 }, - { "Africa/Monrovia" , 0x001C33 }, - { "Africa/Nairobi" , 0x001C99 }, - { "Africa/Ndjamena" , 0x001D18 }, - { "Africa/Niamey" , 0x001D84 }, - { "Africa/Nouakchott" , 0x001DD9 }, - { "Africa/Ouagadougou" , 0x001E2E }, - { "Africa/Porto-Novo" , 0x001E83 }, - { "Africa/Sao_Tome" , 0x001ED8 }, - { "Africa/Timbuktu" , 0x001F2D }, - { "Africa/Tripoli" , 0x001F82 }, - { "Africa/Tunis" , 0x00208B }, - { "Africa/Windhoek" , 0x00219D }, - { "America/Adak" , 0x0023E4 }, - { "America/Anchorage" , 0x00275A }, - { "America/Anguilla" , 0x002ACE }, - { "America/Antigua" , 0x002B23 }, - { "America/Araguaina" , 0x002B89 }, - { "America/Argentina/Buenos_Aires" , 0x002CEE }, - { "America/Argentina/Catamarca" , 0x002E9C }, - { "America/Argentina/ComodRivadavia" , 0x00305D }, - { "America/Argentina/Cordoba" , 0x003203 }, - { "America/Argentina/Jujuy" , 0x0033D8 }, - { "America/Argentina/La_Rioja" , 0x00358C }, - { "America/Argentina/Mendoza" , 0x003744 }, - { "America/Argentina/Rio_Gallegos" , 0x003904 }, - { "America/Argentina/Salta" , 0x003AB9 }, - { "America/Argentina/San_Juan" , 0x003C65 }, - { "America/Argentina/San_Luis" , 0x003E1D }, - { "America/Argentina/Tucuman" , 0x003FE3 }, - { "America/Argentina/Ushuaia" , 0x00419F }, - { "America/Aruba" , 0x00435A }, - { "America/Asuncion" , 0x0043C0 }, - { "America/Atikokan" , 0x0046A5 }, - { "America/Atka" , 0x00477B }, - { "America/Bahia" , 0x004AE1 }, - { "America/Bahia_Banderas" , 0x004C74 }, - { "America/Barbados" , 0x004EED }, - { "America/Belem" , 0x004F87 }, - { "America/Belize" , 0x005082 }, - { "America/Blanc-Sablon" , 0x0051FE }, - { "America/Boa_Vista" , 0x0052B2 }, - { "America/Bogota" , 0x0053BB }, - { "America/Boise" , 0x005427 }, - { "America/Buenos_Aires" , 0x0057BE }, - { "America/Cambridge_Bay" , 0x005957 }, - { "America/Campo_Grande" , 0x005C7F }, - { "America/Cancun" , 0x005F6E }, - { "America/Caracas" , 0x0061B0 }, - { "America/Catamarca" , 0x006217 }, - { "America/Cayenne" , 0x0063BD }, - { "America/Cayman" , 0x00641F }, - { "America/Chicago" , 0x006474 }, - { "America/Chihuahua" , 0x00698B }, - { "America/Coral_Harbour" , 0x006BF6 }, - { "America/Cordoba" , 0x006C88 }, - { "America/Costa_Rica" , 0x006E2E }, - { "America/Creston" , 0x006EB8 }, - { "America/Cuiaba" , 0x006F44 }, - { "America/Curacao" , 0x007222 }, - { "America/Danmarkshavn" , 0x007288 }, - { "America/Dawson" , 0x0073CC }, - { "America/Dawson_Creek" , 0x0076E9 }, - { "America/Denver" , 0x0078C3 }, - { "America/Detroit" , 0x007C49 }, - { "America/Dominica" , 0x007FA8 }, - { "America/Edmonton" , 0x007FFD }, - { "America/Eirunepe" , 0x0083B5 }, - { "America/El_Salvador" , 0x0084CD }, - { "America/Ensenada" , 0x008542 }, - { "America/Fort_Wayne" , 0x0089E9 }, - { "America/Fortaleza" , 0x0088AB }, - { "America/Glace_Bay" , 0x008C53 }, - { "America/Godthab" , 0x008FCA }, - { "America/Goose_Bay" , 0x00928E }, - { "America/Grand_Turk" , 0x00974B }, - { "America/Grenada" , 0x009920 }, - { "America/Guadeloupe" , 0x009975 }, - { "America/Guatemala" , 0x0099CA }, - { "America/Guayaquil" , 0x009A53 }, - { "America/Guyana" , 0x009AB0 }, - { "America/Halifax" , 0x009B31 }, - { "America/Havana" , 0x00A047 }, - { "America/Hermosillo" , 0x00A3BA }, - { "America/Indiana/Indianapolis" , 0x00A498 }, - { "America/Indiana/Knox" , 0x00A729 }, - { "America/Indiana/Marengo" , 0x00AAC0 }, - { "America/Indiana/Petersburg" , 0x00AD66 }, - { "America/Indiana/Tell_City" , 0x00B2B3 }, - { "America/Indiana/Vevay" , 0x00B54C }, - { "America/Indiana/Vincennes" , 0x00B787 }, - { "America/Indiana/Winamac" , 0x00BA3B }, - { "America/Indianapolis" , 0x00B049 }, - { "America/Inuvik" , 0x00BCF4 }, - { "America/Iqaluit" , 0x00BFEB }, - { "America/Jamaica" , 0x00C30D }, - { "America/Jujuy" , 0x00C3D2 }, - { "America/Juneau" , 0x00C57C }, - { "America/Kentucky/Louisville" , 0x00C8FA }, - { "America/Kentucky/Monticello" , 0x00CD18 }, - { "America/Knox_IN" , 0x00D09D }, - { "America/Kralendijk" , 0x00D40E }, - { "America/La_Paz" , 0x00D474 }, - { "America/Lima" , 0x00D4DB }, - { "America/Los_Angeles" , 0x00D583 }, - { "America/Louisville" , 0x00D994 }, - { "America/Lower_Princes" , 0x00DD89 }, - { "America/Maceio" , 0x00DDEF }, - { "America/Managua" , 0x00DF29 }, - { "America/Manaus" , 0x00DFDC }, - { "America/Marigot" , 0x00E0DE }, - { "America/Martinique" , 0x00E133 }, - { "America/Matamoros" , 0x00E19F }, - { "America/Mazatlan" , 0x00E3F8 }, - { "America/Mendoza" , 0x00E665 }, - { "America/Menominee" , 0x00E819 }, - { "America/Merida" , 0x00EB9A }, - { "America/Metlakatla" , 0x00EDD5 }, - { "America/Mexico_City" , 0x00EF10 }, - { "America/Miquelon" , 0x00F18B }, - { "America/Moncton" , 0x00F3FD }, - { "America/Monterrey" , 0x00F894 }, - { "America/Montevideo" , 0x00FAF7 }, - { "America/Montreal" , 0x00FE09 }, - { "America/Montserrat" , 0x0102F9 }, - { "America/Nassau" , 0x01034E }, - { "America/New_York" , 0x010693 }, - { "America/Nipigon" , 0x010B9E }, - { "America/Nome" , 0x010EEF }, - { "America/Noronha" , 0x01126D }, - { "America/North_Dakota/Beulah" , 0x01139D }, - { "America/North_Dakota/Center" , 0x011731 }, - { "America/North_Dakota/New_Salem" , 0x011AC5 }, - { "America/Ojinaga" , 0x011E6E }, - { "America/Panama" , 0x0120CF }, - { "America/Pangnirtung" , 0x012124 }, - { "America/Paramaribo" , 0x01245A }, - { "America/Phoenix" , 0x0124EC }, - { "America/Port-au-Prince" , 0x0125AA }, - { "America/Port_of_Spain" , 0x0128CE }, - { "America/Porto_Acre" , 0x0127CA }, - { "America/Porto_Velho" , 0x012923 }, - { "America/Puerto_Rico" , 0x012A19 }, - { "America/Rainy_River" , 0x012A84 }, - { "America/Rankin_Inlet" , 0x012DBC }, - { "America/Recife" , 0x0130A2 }, - { "America/Regina" , 0x0131CC }, - { "America/Resolute" , 0x01338A }, - { "America/Rio_Branco" , 0x013672 }, - { "America/Rosario" , 0x01377A }, - { "America/Santa_Isabel" , 0x013920 }, - { "America/Santarem" , 0x013CC3 }, - { "America/Santiago" , 0x013DC8 }, - { "America/Santo_Domingo" , 0x014171 }, - { "America/Sao_Paulo" , 0x014237 }, - { "America/Scoresbysund" , 0x014546 }, - { "America/Shiprock" , 0x014834 }, - { "America/Sitka" , 0x014BAD }, - { "America/St_Barthelemy" , 0x014F35 }, - { "America/St_Johns" , 0x014F8A }, - { "America/St_Kitts" , 0x0154DD }, - { "America/St_Lucia" , 0x015532 }, - { "America/St_Thomas" , 0x015587 }, - { "America/St_Vincent" , 0x0155DC }, - { "America/Swift_Current" , 0x015631 }, - { "America/Tegucigalpa" , 0x015752 }, - { "America/Thule" , 0x0157D1 }, - { "America/Thunder_Bay" , 0x015A18 }, - { "America/Tijuana" , 0x015D61 }, - { "America/Toronto" , 0x0160FA }, - { "America/Tortola" , 0x01661A }, - { "America/Vancouver" , 0x01666F }, - { "America/Virgin" , 0x016AAC }, - { "America/Whitehorse" , 0x016B01 }, - { "America/Winnipeg" , 0x016E1E }, - { "America/Yakutat" , 0x01725E }, - { "America/Yellowknife" , 0x0175C9 }, - { "Antarctica/Casey" , 0x0178D9 }, - { "Antarctica/Davis" , 0x017977 }, - { "Antarctica/DumontDUrville" , 0x017A18 }, - { "Antarctica/Macquarie" , 0x017AA9 }, - { "Antarctica/Mawson" , 0x017CF6 }, - { "Antarctica/McMurdo" , 0x017D72 }, - { "Antarctica/Palmer" , 0x01811D }, - { "Antarctica/Rothera" , 0x018439 }, - { "Antarctica/South_Pole" , 0x0184AF }, - { "Antarctica/Syowa" , 0x01882D }, - { "Antarctica/Troll" , 0x01889B }, - { "Antarctica/Vostok" , 0x018A6D }, - { "Arctic/Longyearbyen" , 0x018ADE }, - { "Asia/Aden" , 0x018E10 }, - { "Asia/Almaty" , 0x018E65 }, - { "Asia/Amman" , 0x018FE4 }, - { "Asia/Anadyr" , 0x01929A }, - { "Asia/Aqtau" , 0x01949C }, - { "Asia/Aqtobe" , 0x01969B }, - { "Asia/Ashgabat" , 0x019853 }, - { "Asia/Ashkhabad" , 0x019970 }, - { "Asia/Baghdad" , 0x019A8D }, - { "Asia/Bahrain" , 0x019C02 }, - { "Asia/Baku" , 0x019C68 }, - { "Asia/Bangkok" , 0x019F50 }, - { "Asia/Beirut" , 0x019FA5 }, - { "Asia/Bishkek" , 0x01A2B2 }, - { "Asia/Brunei" , 0x01A45E }, - { "Asia/Calcutta" , 0x01A4C0 }, - { "Asia/Chita" , 0x01A539 }, - { "Asia/Choibalsan" , 0x01A74E }, - { "Asia/Chongqing" , 0x01A8C7 }, - { "Asia/Chungking" , 0x01A967 }, - { "Asia/Colombo" , 0x01AA07 }, - { "Asia/Dacca" , 0x01AAA3 }, - { "Asia/Damascus" , 0x01AB49 }, - { "Asia/Dhaka" , 0x01AE99 }, - { "Asia/Dili" , 0x01AF3F }, - { "Asia/Dubai" , 0x01AFC9 }, - { "Asia/Dushanbe" , 0x01B01E }, - { "Asia/Gaza" , 0x01B121 }, - { "Asia/Harbin" , 0x01B474 }, - { "Asia/Hebron" , 0x01B514 }, - { "Asia/Ho_Chi_Minh" , 0x01B870 }, - { "Asia/Hong_Kong" , 0x01B912 }, - { "Asia/Hovd" , 0x01BAD4 }, - { "Asia/Irkutsk" , 0x01BC4C }, - { "Asia/Istanbul" , 0x01BE37 }, - { "Asia/Jakarta" , 0x01C224 }, - { "Asia/Jayapura" , 0x01C2CE }, - { "Asia/Jerusalem" , 0x01C36B }, - { "Asia/Kabul" , 0x01C69A }, - { "Asia/Kamchatka" , 0x01C6EB }, - { "Asia/Karachi" , 0x01C8E4 }, - { "Asia/Kashgar" , 0x01C999 }, - { "Asia/Kathmandu" , 0x01C9EE }, - { "Asia/Katmandu" , 0x01CA54 }, - { "Asia/Khandyga" , 0x01CABA }, - { "Asia/Kolkata" , 0x01CCE4 }, - { "Asia/Krasnoyarsk" , 0x01CD5D }, - { "Asia/Kuala_Lumpur" , 0x01CF4A }, - { "Asia/Kuching" , 0x01D007 }, - { "Asia/Kuwait" , 0x01D0F5 }, - { "Asia/Macao" , 0x01D14A }, - { "Asia/Macau" , 0x01D285 }, - { "Asia/Magadan" , 0x01D3C0 }, - { "Asia/Makassar" , 0x01D5C4 }, - { "Asia/Manila" , 0x01D689 }, - { "Asia/Muscat" , 0x01D70E }, - { "Asia/Nicosia" , 0x01D763 }, - { "Asia/Novokuznetsk" , 0x01DA4B }, - { "Asia/Novosibirsk" , 0x01DC6B }, - { "Asia/Omsk" , 0x01DE5B }, - { "Asia/Oral" , 0x01E047 }, - { "Asia/Phnom_Penh" , 0x01E217 }, - { "Asia/Pontianak" , 0x01E26C }, - { "Asia/Pyongyang" , 0x01E32E }, - { "Asia/Qatar" , 0x01E3BE }, - { "Asia/Qyzylorda" , 0x01E424 }, - { "Asia/Rangoon" , 0x01E5FA }, - { "Asia/Riyadh" , 0x01E672 }, - { "Asia/Saigon" , 0x01E6C7 }, - { "Asia/Sakhalin" , 0x01E769 }, - { "Asia/Samarkand" , 0x01E966 }, - { "Asia/Seoul" , 0x01EA9C }, - { "Asia/Shanghai" , 0x01EB63 }, - { "Asia/Singapore" , 0x01EC0F }, - { "Asia/Srednekolymsk" , 0x01ECC6 }, - { "Asia/Taipei" , 0x01EEC6 }, - { "Asia/Tashkent" , 0x01EFF7 }, - { "Asia/Tbilisi" , 0x01F128 }, - { "Asia/Tehran" , 0x01F2E2 }, - { "Asia/Tel_Aviv" , 0x01F550 }, - { "Asia/Thimbu" , 0x01F87F }, - { "Asia/Thimphu" , 0x01F8E5 }, - { "Asia/Tokyo" , 0x01F94B }, - { "Asia/Ujung_Pandang" , 0x01F9D5 }, - { "Asia/Ulaanbaatar" , 0x01FA52 }, - { "Asia/Ulan_Bator" , 0x01FBAD }, - { "Asia/Urumqi" , 0x01FCFA }, - { "Asia/Ust-Nera" , 0x01FD5C }, - { "Asia/Vientiane" , 0x01FF6E }, - { "Asia/Vladivostok" , 0x01FFC3 }, - { "Asia/Yakutsk" , 0x0201AD }, - { "Asia/Yekaterinburg" , 0x020397 }, - { "Asia/Yerevan" , 0x0205B8 }, - { "Atlantic/Azores" , 0x0207B8 }, - { "Atlantic/Bermuda" , 0x020CBB }, - { "Atlantic/Canary" , 0x020F9C }, - { "Atlantic/Cape_Verde" , 0x021272 }, - { "Atlantic/Faeroe" , 0x0212EB }, - { "Atlantic/Faroe" , 0x02158F }, - { "Atlantic/Jan_Mayen" , 0x021833 }, - { "Atlantic/Madeira" , 0x021B65 }, - { "Atlantic/Reykjavik" , 0x02206E }, - { "Atlantic/South_Georgia" , 0x022227 }, - { "Atlantic/St_Helena" , 0x022439 }, - { "Atlantic/Stanley" , 0x02226B }, - { "Australia/ACT" , 0x02248E }, - { "Australia/Adelaide" , 0x0227B1 }, - { "Australia/Brisbane" , 0x022AE3 }, - { "Australia/Broken_Hill" , 0x022BB0 }, - { "Australia/Canberra" , 0x022EF4 }, - { "Australia/Currie" , 0x023217 }, - { "Australia/Darwin" , 0x023550 }, - { "Australia/Eucla" , 0x0235DC }, - { "Australia/Hobart" , 0x0236B8 }, - { "Australia/LHI" , 0x023A1C }, - { "Australia/Lindeman" , 0x023CBD }, - { "Australia/Lord_Howe" , 0x023DA4 }, - { "Australia/Melbourne" , 0x024055 }, - { "Australia/North" , 0x024380 }, - { "Australia/NSW" , 0x0243FA }, - { "Australia/Perth" , 0x02471D }, - { "Australia/Queensland" , 0x0247FB }, - { "Australia/South" , 0x0248AD }, - { "Australia/Sydney" , 0x024BD0 }, - { "Australia/Tasmania" , 0x024F13 }, - { "Australia/Victoria" , 0x02525E }, - { "Australia/West" , 0x025581 }, - { "Australia/Yancowinna" , 0x02563D }, - { "Brazil/Acre" , 0x025965 }, - { "Brazil/DeNoronha" , 0x025A69 }, - { "Brazil/East" , 0x025B89 }, - { "Brazil/West" , 0x025E66 }, - { "Canada/Atlantic" , 0x025F5E }, - { "Canada/Central" , 0x026446 }, - { "Canada/East-Saskatchewan" , 0x026D50 }, - { "Canada/Eastern" , 0x026860 }, - { "Canada/Mountain" , 0x026ED9 }, - { "Canada/Newfoundland" , 0x02724F }, - { "Canada/Pacific" , 0x02777A }, - { "Canada/Saskatchewan" , 0x027B93 }, - { "Canada/Yukon" , 0x027D1C }, - { "CET" , 0x02801F }, - { "Chile/Continental" , 0x028328 }, - { "Chile/EasterIsland" , 0x0286C3 }, - { "CST6CDT" , 0x028A05 }, - { "Cuba" , 0x028D56 }, - { "EET" , 0x0290C9 }, - { "Egypt" , 0x02937C }, - { "Eire" , 0x029763 }, - { "EST" , 0x029C74 }, - { "EST5EDT" , 0x029CB8 }, - { "Etc/GMT" , 0x02A009 }, - { "Etc/GMT+0" , 0x02A0D5 }, - { "Etc/GMT+1" , 0x02A15F }, - { "Etc/GMT+10" , 0x02A1EC }, - { "Etc/GMT+11" , 0x02A27A }, - { "Etc/GMT+12" , 0x02A308 }, - { "Etc/GMT+2" , 0x02A423 }, - { "Etc/GMT+3" , 0x02A4AF }, - { "Etc/GMT+4" , 0x02A53B }, - { "Etc/GMT+5" , 0x02A5C7 }, - { "Etc/GMT+6" , 0x02A653 }, - { "Etc/GMT+7" , 0x02A6DF }, - { "Etc/GMT+8" , 0x02A76B }, - { "Etc/GMT+9" , 0x02A7F7 }, - { "Etc/GMT-0" , 0x02A091 }, - { "Etc/GMT-1" , 0x02A119 }, - { "Etc/GMT-10" , 0x02A1A5 }, - { "Etc/GMT-11" , 0x02A233 }, - { "Etc/GMT-12" , 0x02A2C1 }, - { "Etc/GMT-13" , 0x02A34F }, - { "Etc/GMT-14" , 0x02A396 }, - { "Etc/GMT-2" , 0x02A3DD }, - { "Etc/GMT-3" , 0x02A469 }, - { "Etc/GMT-4" , 0x02A4F5 }, - { "Etc/GMT-5" , 0x02A581 }, - { "Etc/GMT-6" , 0x02A60D }, - { "Etc/GMT-7" , 0x02A699 }, - { "Etc/GMT-8" , 0x02A725 }, - { "Etc/GMT-9" , 0x02A7B1 }, - { "Etc/GMT0" , 0x02A04D }, - { "Etc/Greenwich" , 0x02A83D }, - { "Etc/UCT" , 0x02A881 }, - { "Etc/Universal" , 0x02A8C5 }, - { "Etc/UTC" , 0x02A909 }, - { "Etc/Zulu" , 0x02A94D }, - { "Europe/Amsterdam" , 0x02A991 }, - { "Europe/Andorra" , 0x02ADCF }, - { "Europe/Athens" , 0x02B04B }, - { "Europe/Belfast" , 0x02B38E }, - { "Europe/Belgrade" , 0x02B8C5 }, - { "Europe/Berlin" , 0x02BB8E }, - { "Europe/Bratislava" , 0x02BEF2 }, - { "Europe/Brussels" , 0x02C224 }, - { "Europe/Bucharest" , 0x02C65B }, - { "Europe/Budapest" , 0x02C985 }, - { "Europe/Busingen" , 0x02CCEE }, - { "Europe/Chisinau" , 0x02CFA5 }, - { "Europe/Copenhagen" , 0x02D333 }, - { "Europe/Dublin" , 0x02D63D }, - { "Europe/Gibraltar" , 0x02DB4E }, - { "Europe/Guernsey" , 0x02DFA5 }, - { "Europe/Helsinki" , 0x02E4DC }, - { "Europe/Isle_of_Man" , 0x02E792 }, - { "Europe/Istanbul" , 0x02ECC9 }, - { "Europe/Jersey" , 0x02F0B6 }, - { "Europe/Kaliningrad" , 0x02F5ED }, - { "Europe/Kiev" , 0x02F858 }, - { "Europe/Lisbon" , 0x02FB74 }, - { "Europe/Ljubljana" , 0x030078 }, - { "Europe/London" , 0x030341 }, - { "Europe/Luxembourg" , 0x030878 }, - { "Europe/Madrid" , 0x030CCE }, - { "Europe/Malta" , 0x031094 }, - { "Europe/Mariehamn" , 0x03144D }, - { "Europe/Minsk" , 0x031703 }, - { "Europe/Monaco" , 0x031916 }, - { "Europe/Moscow" , 0x031D51 }, - { "Europe/Nicosia" , 0x031FAB }, - { "Europe/Oslo" , 0x032293 }, - { "Europe/Paris" , 0x0325C5 }, - { "Europe/Podgorica" , 0x032A0B }, - { "Europe/Prague" , 0x032CD4 }, - { "Europe/Riga" , 0x033006 }, - { "Europe/Rome" , 0x03334B }, - { "Europe/Samara" , 0x03370E }, - { "Europe/San_Marino" , 0x033977 }, - { "Europe/Sarajevo" , 0x033D3A }, - { "Europe/Simferopol" , 0x034003 }, - { "Europe/Skopje" , 0x034254 }, - { "Europe/Sofia" , 0x03451D }, - { "Europe/Stockholm" , 0x034825 }, - { "Europe/Tallinn" , 0x034AD4 }, - { "Europe/Tirane" , 0x034E0E }, - { "Europe/Tiraspol" , 0x035114 }, - { "Europe/Uzhgorod" , 0x0354A2 }, - { "Europe/Vaduz" , 0x0357B9 }, - { "Europe/Vatican" , 0x035A68 }, - { "Europe/Vienna" , 0x035E2B }, - { "Europe/Vilnius" , 0x036158 }, - { "Europe/Volgograd" , 0x036497 }, - { "Europe/Warsaw" , 0x0366B8 }, - { "Europe/Zagreb" , 0x036A99 }, - { "Europe/Zaporozhye" , 0x036D62 }, - { "Europe/Zurich" , 0x0370A3 }, - { "Factory" , 0x037352 }, - { "GB" , 0x0373C3 }, - { "GB-Eire" , 0x0378FA }, - { "GMT" , 0x037E31 }, - { "GMT+0" , 0x037EFD }, - { "GMT-0" , 0x037EB9 }, - { "GMT0" , 0x037E75 }, - { "Greenwich" , 0x037F41 }, - { "Hongkong" , 0x037F85 }, - { "HST" , 0x038147 }, - { "Iceland" , 0x03818B }, - { "Indian/Antananarivo" , 0x038344 }, - { "Indian/Chagos" , 0x0383B8 }, - { "Indian/Christmas" , 0x03841A }, - { "Indian/Cocos" , 0x03845E }, - { "Indian/Comoro" , 0x0384A2 }, - { "Indian/Kerguelen" , 0x0384F7 }, - { "Indian/Mahe" , 0x03854C }, - { "Indian/Maldives" , 0x0385A1 }, - { "Indian/Mauritius" , 0x0385F6 }, - { "Indian/Mayotte" , 0x03866C }, - { "Indian/Reunion" , 0x0386C1 }, - { "Iran" , 0x038716 }, - { "Israel" , 0x038984 }, - { "Jamaica" , 0x038CB3 }, - { "Japan" , 0x038D78 }, - { "Kwajalein" , 0x038E02 }, - { "Libya" , 0x038E65 }, - { "MET" , 0x038F6E }, - { "Mexico/BajaNorte" , 0x039277 }, - { "Mexico/BajaSur" , 0x0395E0 }, - { "Mexico/General" , 0x039825 }, - { "MST" , 0x039A83 }, - { "MST7MDT" , 0x039AC7 }, - { "Navajo" , 0x039E18 }, - { "NZ" , 0x03A191 }, - { "NZ-CHAT" , 0x03A50F }, - { "Pacific/Apia" , 0x03A7F3 }, - { "Pacific/Auckland" , 0x03A98F }, - { "Pacific/Bougainville" , 0x03AD1B }, - { "Pacific/Chatham" , 0x03AD92 }, - { "Pacific/Chuuk" , 0x03B085 }, - { "Pacific/Easter" , 0x03B0DE }, - { "Pacific/Efate" , 0x03B42D }, - { "Pacific/Enderbury" , 0x03B4F3 }, - { "Pacific/Fakaofo" , 0x03B561 }, - { "Pacific/Fiji" , 0x03B5B2 }, - { "Pacific/Funafuti" , 0x03B745 }, - { "Pacific/Galapagos" , 0x03B789 }, - { "Pacific/Gambier" , 0x03B801 }, - { "Pacific/Guadalcanal" , 0x03B866 }, - { "Pacific/Guam" , 0x03B8BB }, - { "Pacific/Honolulu" , 0x03B911 }, - { "Pacific/Johnston" , 0x03B988 }, - { "Pacific/Kiritimati" , 0x03BA07 }, - { "Pacific/Kosrae" , 0x03BA72 }, - { "Pacific/Kwajalein" , 0x03BACF }, - { "Pacific/Majuro" , 0x03BB3B }, - { "Pacific/Marquesas" , 0x03BB9A }, - { "Pacific/Midway" , 0x03BC01 }, - { "Pacific/Nauru" , 0x03BC8B }, - { "Pacific/Niue" , 0x03BD03 }, - { "Pacific/Norfolk" , 0x03BD61 }, - { "Pacific/Noumea" , 0x03BDB6 }, - { "Pacific/Pago_Pago" , 0x03BE46 }, - { "Pacific/Palau" , 0x03BEBD }, - { "Pacific/Pitcairn" , 0x03BF01 }, - { "Pacific/Pohnpei" , 0x03BF56 }, - { "Pacific/Ponape" , 0x03BFAB }, - { "Pacific/Port_Moresby" , 0x03BFF0 }, - { "Pacific/Rarotonga" , 0x03C042 }, - { "Pacific/Saipan" , 0x03C11E }, - { "Pacific/Samoa" , 0x03C181 }, - { "Pacific/Tahiti" , 0x03C1F8 }, - { "Pacific/Tarawa" , 0x03C25D }, - { "Pacific/Tongatapu" , 0x03C2B1 }, - { "Pacific/Truk" , 0x03C33D }, - { "Pacific/Wake" , 0x03C382 }, - { "Pacific/Wallis" , 0x03C3D2 }, - { "Pacific/Yap" , 0x03C416 }, - { "Poland" , 0x03C45B }, - { "Portugal" , 0x03C83C }, - { "PRC" , 0x03CD38 }, - { "PST8PDT" , 0x03CDD8 }, - { "ROC" , 0x03D129 }, - { "ROK" , 0x03D25A }, - { "Singapore" , 0x03D321 }, - { "Turkey" , 0x03D3D8 }, - { "UCT" , 0x03D7C5 }, - { "Universal" , 0x03D809 }, - { "US/Alaska" , 0x03D84D }, - { "US/Aleutian" , 0x03DBB6 }, - { "US/Arizona" , 0x03DF1C }, - { "US/Central" , 0x03DFAA }, - { "US/East-Indiana" , 0x03E9B4 }, - { "US/Eastern" , 0x03E4B5 }, - { "US/Hawaii" , 0x03EC1E }, - { "US/Indiana-Starke" , 0x03EC8F }, - { "US/Michigan" , 0x03F000 }, - { "US/Mountain" , 0x03F337 }, - { "US/Pacific" , 0x03F6B0 }, - { "US/Pacific-New" , 0x03FAB5 }, - { "US/Samoa" , 0x03FEBA }, - { "UTC" , 0x03FF31 }, - { "W-SU" , 0x040228 }, - { "WET" , 0x03FF75 }, - { "Zulu" , 0x04046B }, + { "Africa/Algiers" , 0x00021C }, + { "Africa/Asmara" , 0x000347 }, + { "Africa/Asmera" , 0x0003C6 }, + { "Africa/Bamako" , 0x000445 }, + { "Africa/Bangui" , 0x00049A }, + { "Africa/Banjul" , 0x0004EF }, + { "Africa/Bissau" , 0x000544 }, + { "Africa/Blantyre" , 0x0005AA }, + { "Africa/Brazzaville" , 0x0005FF }, + { "Africa/Bujumbura" , 0x000654 }, + { "Africa/Cairo" , 0x0006A9 }, + { "Africa/Casablanca" , 0x000A90 }, + { "Africa/Ceuta" , 0x000CF2 }, + { "Africa/Conakry" , 0x000FF9 }, + { "Africa/Dakar" , 0x00104E }, + { "Africa/Dar_es_Salaam" , 0x0010A3 }, + { "Africa/Djibouti" , 0x001122 }, + { "Africa/Douala" , 0x0011A1 }, + { "Africa/El_Aaiun" , 0x0011F6 }, + { "Africa/Freetown" , 0x001421 }, + { "Africa/Gaborone" , 0x001476 }, + { "Africa/Harare" , 0x0014CB }, + { "Africa/Johannesburg" , 0x001520 }, + { "Africa/Juba" , 0x00158E }, + { "Africa/Kampala" , 0x0016A1 }, + { "Africa/Khartoum" , 0x001720 }, + { "Africa/Kigali" , 0x001833 }, + { "Africa/Kinshasa" , 0x001888 }, + { "Africa/Lagos" , 0x0018F4 }, + { "Africa/Libreville" , 0x001949 }, + { "Africa/Lome" , 0x00199E }, + { "Africa/Luanda" , 0x0019F3 }, + { "Africa/Lubumbashi" , 0x001A48 }, + { "Africa/Lusaka" , 0x001AB4 }, + { "Africa/Malabo" , 0x001B09 }, + { "Africa/Maputo" , 0x001B5E }, + { "Africa/Maseru" , 0x001BB3 }, + { "Africa/Mbabane" , 0x001C21 }, + { "Africa/Mogadishu" , 0x001C8F }, + { "Africa/Monrovia" , 0x001D0E }, + { "Africa/Nairobi" , 0x001D74 }, + { "Africa/Ndjamena" , 0x001DF3 }, + { "Africa/Niamey" , 0x001E5F }, + { "Africa/Nouakchott" , 0x001EB4 }, + { "Africa/Ouagadougou" , 0x001F09 }, + { "Africa/Porto-Novo" , 0x001F5E }, + { "Africa/Sao_Tome" , 0x001FB3 }, + { "Africa/Timbuktu" , 0x002008 }, + { "Africa/Tripoli" , 0x00205D }, + { "Africa/Tunis" , 0x002166 }, + { "Africa/Windhoek" , 0x002278 }, + { "America/Adak" , 0x0024BF }, + { "America/Anchorage" , 0x002835 }, + { "America/Anguilla" , 0x002BA9 }, + { "America/Antigua" , 0x002BFE }, + { "America/Araguaina" , 0x002C64 }, + { "America/Argentina/Buenos_Aires" , 0x002DC9 }, + { "America/Argentina/Catamarca" , 0x002F77 }, + { "America/Argentina/ComodRivadavia" , 0x003138 }, + { "America/Argentina/Cordoba" , 0x0032DE }, + { "America/Argentina/Jujuy" , 0x0034B3 }, + { "America/Argentina/La_Rioja" , 0x003667 }, + { "America/Argentina/Mendoza" , 0x00381F }, + { "America/Argentina/Rio_Gallegos" , 0x0039DF }, + { "America/Argentina/Salta" , 0x003B94 }, + { "America/Argentina/San_Juan" , 0x003D40 }, + { "America/Argentina/San_Luis" , 0x003EF8 }, + { "America/Argentina/Tucuman" , 0x0040BE }, + { "America/Argentina/Ushuaia" , 0x00427A }, + { "America/Aruba" , 0x004435 }, + { "America/Asuncion" , 0x00449B }, + { "America/Atikokan" , 0x004780 }, + { "America/Atka" , 0x004856 }, + { "America/Bahia" , 0x004BBC }, + { "America/Bahia_Banderas" , 0x004D4F }, + { "America/Barbados" , 0x004FC8 }, + { "America/Belem" , 0x005062 }, + { "America/Belize" , 0x00515D }, + { "America/Blanc-Sablon" , 0x0052D9 }, + { "America/Boa_Vista" , 0x00538D }, + { "America/Bogota" , 0x005496 }, + { "America/Boise" , 0x005502 }, + { "America/Buenos_Aires" , 0x005899 }, + { "America/Cambridge_Bay" , 0x005A32 }, + { "America/Campo_Grande" , 0x005D5A }, + { "America/Cancun" , 0x006049 }, + { "America/Caracas" , 0x00628B }, + { "America/Catamarca" , 0x0062F2 }, + { "America/Cayenne" , 0x006498 }, + { "America/Cayman" , 0x0064FA }, + { "America/Chicago" , 0x00654F }, + { "America/Chihuahua" , 0x006A66 }, + { "America/Coral_Harbour" , 0x006CD1 }, + { "America/Cordoba" , 0x006D63 }, + { "America/Costa_Rica" , 0x006F09 }, + { "America/Creston" , 0x006F93 }, + { "America/Cuiaba" , 0x00701F }, + { "America/Curacao" , 0x0072FD }, + { "America/Danmarkshavn" , 0x007363 }, + { "America/Dawson" , 0x0074A7 }, + { "America/Dawson_Creek" , 0x0077C4 }, + { "America/Denver" , 0x00799E }, + { "America/Detroit" , 0x007D24 }, + { "America/Dominica" , 0x008083 }, + { "America/Edmonton" , 0x0080D8 }, + { "America/Eirunepe" , 0x008490 }, + { "America/El_Salvador" , 0x0085A8 }, + { "America/Ensenada" , 0x00861D }, + { "America/Fort_Wayne" , 0x008AC4 }, + { "America/Fortaleza" , 0x008986 }, + { "America/Glace_Bay" , 0x008D2E }, + { "America/Godthab" , 0x0090A5 }, + { "America/Goose_Bay" , 0x009369 }, + { "America/Grand_Turk" , 0x009826 }, + { "America/Grenada" , 0x009A05 }, + { "America/Guadeloupe" , 0x009A5A }, + { "America/Guatemala" , 0x009AAF }, + { "America/Guayaquil" , 0x009B38 }, + { "America/Guyana" , 0x009B95 }, + { "America/Halifax" , 0x009C16 }, + { "America/Havana" , 0x00A12C }, + { "America/Hermosillo" , 0x00A49F }, + { "America/Indiana/Indianapolis" , 0x00A57D }, + { "America/Indiana/Knox" , 0x00A80E }, + { "America/Indiana/Marengo" , 0x00ABA5 }, + { "America/Indiana/Petersburg" , 0x00AE4B }, + { "America/Indiana/Tell_City" , 0x00B398 }, + { "America/Indiana/Vevay" , 0x00B631 }, + { "America/Indiana/Vincennes" , 0x00B86C }, + { "America/Indiana/Winamac" , 0x00BB20 }, + { "America/Indianapolis" , 0x00B12E }, + { "America/Inuvik" , 0x00BDD9 }, + { "America/Iqaluit" , 0x00C0D0 }, + { "America/Jamaica" , 0x00C3F2 }, + { "America/Jujuy" , 0x00C4B7 }, + { "America/Juneau" , 0x00C661 }, + { "America/Kentucky/Louisville" , 0x00C9DF }, + { "America/Kentucky/Monticello" , 0x00CDFD }, + { "America/Knox_IN" , 0x00D182 }, + { "America/Kralendijk" , 0x00D4F3 }, + { "America/La_Paz" , 0x00D559 }, + { "America/Lima" , 0x00D5C0 }, + { "America/Los_Angeles" , 0x00D668 }, + { "America/Louisville" , 0x00DA79 }, + { "America/Lower_Princes" , 0x00DE6E }, + { "America/Maceio" , 0x00DED4 }, + { "America/Managua" , 0x00E00E }, + { "America/Manaus" , 0x00E0C1 }, + { "America/Marigot" , 0x00E1C3 }, + { "America/Martinique" , 0x00E218 }, + { "America/Matamoros" , 0x00E284 }, + { "America/Mazatlan" , 0x00E4DD }, + { "America/Mendoza" , 0x00E74A }, + { "America/Menominee" , 0x00E8FE }, + { "America/Merida" , 0x00EC7F }, + { "America/Metlakatla" , 0x00EEBA }, + { "America/Mexico_City" , 0x00EFF5 }, + { "America/Miquelon" , 0x00F270 }, + { "America/Moncton" , 0x00F4E2 }, + { "America/Monterrey" , 0x00F979 }, + { "America/Montevideo" , 0x00FBDC }, + { "America/Montreal" , 0x00FEEE }, + { "America/Montserrat" , 0x0103DE }, + { "America/Nassau" , 0x010433 }, + { "America/New_York" , 0x010778 }, + { "America/Nipigon" , 0x010C83 }, + { "America/Nome" , 0x010FD4 }, + { "America/Noronha" , 0x011352 }, + { "America/North_Dakota/Beulah" , 0x011482 }, + { "America/North_Dakota/Center" , 0x011816 }, + { "America/North_Dakota/New_Salem" , 0x011BAA }, + { "America/Ojinaga" , 0x011F53 }, + { "America/Panama" , 0x0121B4 }, + { "America/Pangnirtung" , 0x012209 }, + { "America/Paramaribo" , 0x01253F }, + { "America/Phoenix" , 0x0125D1 }, + { "America/Port-au-Prince" , 0x01268F }, + { "America/Port_of_Spain" , 0x0129B3 }, + { "America/Porto_Acre" , 0x0128AF }, + { "America/Porto_Velho" , 0x012A08 }, + { "America/Puerto_Rico" , 0x012AFE }, + { "America/Rainy_River" , 0x012B69 }, + { "America/Rankin_Inlet" , 0x012EA1 }, + { "America/Recife" , 0x013187 }, + { "America/Regina" , 0x0132B1 }, + { "America/Resolute" , 0x01346F }, + { "America/Rio_Branco" , 0x013757 }, + { "America/Rosario" , 0x01385F }, + { "America/Santa_Isabel" , 0x013A05 }, + { "America/Santarem" , 0x013DA8 }, + { "America/Santiago" , 0x013EAD }, + { "America/Santo_Domingo" , 0x014256 }, + { "America/Sao_Paulo" , 0x01431C }, + { "America/Scoresbysund" , 0x01462B }, + { "America/Shiprock" , 0x014919 }, + { "America/Sitka" , 0x014C92 }, + { "America/St_Barthelemy" , 0x01501A }, + { "America/St_Johns" , 0x01506F }, + { "America/St_Kitts" , 0x0155C2 }, + { "America/St_Lucia" , 0x015617 }, + { "America/St_Thomas" , 0x01566C }, + { "America/St_Vincent" , 0x0156C1 }, + { "America/Swift_Current" , 0x015716 }, + { "America/Tegucigalpa" , 0x015837 }, + { "America/Thule" , 0x0158B6 }, + { "America/Thunder_Bay" , 0x015AFD }, + { "America/Tijuana" , 0x015E46 }, + { "America/Toronto" , 0x0161DF }, + { "America/Tortola" , 0x0166FF }, + { "America/Vancouver" , 0x016754 }, + { "America/Virgin" , 0x016B91 }, + { "America/Whitehorse" , 0x016BE6 }, + { "America/Winnipeg" , 0x016F03 }, + { "America/Yakutat" , 0x017343 }, + { "America/Yellowknife" , 0x0176AE }, + { "Antarctica/Casey" , 0x0179BE }, + { "Antarctica/Davis" , 0x017A5C }, + { "Antarctica/DumontDUrville" , 0x017AFD }, + { "Antarctica/Macquarie" , 0x017B8E }, + { "Antarctica/Mawson" , 0x017DDB }, + { "Antarctica/McMurdo" , 0x017E57 }, + { "Antarctica/Palmer" , 0x018202 }, + { "Antarctica/Rothera" , 0x01851E }, + { "Antarctica/South_Pole" , 0x018594 }, + { "Antarctica/Syowa" , 0x018912 }, + { "Antarctica/Troll" , 0x018980 }, + { "Antarctica/Vostok" , 0x018B52 }, + { "Arctic/Longyearbyen" , 0x018BC3 }, + { "Asia/Aden" , 0x018EF5 }, + { "Asia/Almaty" , 0x018F4A }, + { "Asia/Amman" , 0x0190C9 }, + { "Asia/Anadyr" , 0x01937F }, + { "Asia/Aqtau" , 0x019581 }, + { "Asia/Aqtobe" , 0x019780 }, + { "Asia/Ashgabat" , 0x019938 }, + { "Asia/Ashkhabad" , 0x019A55 }, + { "Asia/Baghdad" , 0x019B72 }, + { "Asia/Bahrain" , 0x019CE7 }, + { "Asia/Baku" , 0x019D4D }, + { "Asia/Bangkok" , 0x01A035 }, + { "Asia/Beirut" , 0x01A08A }, + { "Asia/Bishkek" , 0x01A397 }, + { "Asia/Brunei" , 0x01A543 }, + { "Asia/Calcutta" , 0x01A5A5 }, + { "Asia/Chita" , 0x01A61E }, + { "Asia/Choibalsan" , 0x01A833 }, + { "Asia/Chongqing" , 0x01A9AC }, + { "Asia/Chungking" , 0x01AA4C }, + { "Asia/Colombo" , 0x01AAEC }, + { "Asia/Dacca" , 0x01AB88 }, + { "Asia/Damascus" , 0x01AC2E }, + { "Asia/Dhaka" , 0x01AF7E }, + { "Asia/Dili" , 0x01B024 }, + { "Asia/Dubai" , 0x01B0AE }, + { "Asia/Dushanbe" , 0x01B103 }, + { "Asia/Gaza" , 0x01B206 }, + { "Asia/Harbin" , 0x01B559 }, + { "Asia/Hebron" , 0x01B5F9 }, + { "Asia/Ho_Chi_Minh" , 0x01B955 }, + { "Asia/Hong_Kong" , 0x01B9F7 }, + { "Asia/Hovd" , 0x01BBB9 }, + { "Asia/Irkutsk" , 0x01BD31 }, + { "Asia/Istanbul" , 0x01BF1C }, + { "Asia/Jakarta" , 0x01C309 }, + { "Asia/Jayapura" , 0x01C3B3 }, + { "Asia/Jerusalem" , 0x01C450 }, + { "Asia/Kabul" , 0x01C77F }, + { "Asia/Kamchatka" , 0x01C7D0 }, + { "Asia/Karachi" , 0x01C9C9 }, + { "Asia/Kashgar" , 0x01CA7E }, + { "Asia/Kathmandu" , 0x01CAD3 }, + { "Asia/Katmandu" , 0x01CB39 }, + { "Asia/Khandyga" , 0x01CB9F }, + { "Asia/Kolkata" , 0x01CDC9 }, + { "Asia/Krasnoyarsk" , 0x01CE42 }, + { "Asia/Kuala_Lumpur" , 0x01D02F }, + { "Asia/Kuching" , 0x01D0EC }, + { "Asia/Kuwait" , 0x01D1DA }, + { "Asia/Macao" , 0x01D22F }, + { "Asia/Macau" , 0x01D36A }, + { "Asia/Magadan" , 0x01D4A5 }, + { "Asia/Makassar" , 0x01D6A9 }, + { "Asia/Manila" , 0x01D76E }, + { "Asia/Muscat" , 0x01D7F3 }, + { "Asia/Nicosia" , 0x01D848 }, + { "Asia/Novokuznetsk" , 0x01DB30 }, + { "Asia/Novosibirsk" , 0x01DD50 }, + { "Asia/Omsk" , 0x01DF40 }, + { "Asia/Oral" , 0x01E12C }, + { "Asia/Phnom_Penh" , 0x01E2FC }, + { "Asia/Pontianak" , 0x01E351 }, + { "Asia/Pyongyang" , 0x01E413 }, + { "Asia/Qatar" , 0x01E498 }, + { "Asia/Qyzylorda" , 0x01E4FE }, + { "Asia/Rangoon" , 0x01E6D4 }, + { "Asia/Riyadh" , 0x01E74C }, + { "Asia/Saigon" , 0x01E7A1 }, + { "Asia/Sakhalin" , 0x01E843 }, + { "Asia/Samarkand" , 0x01EA40 }, + { "Asia/Seoul" , 0x01EB76 }, + { "Asia/Shanghai" , 0x01EC69 }, + { "Asia/Singapore" , 0x01ED15 }, + { "Asia/Srednekolymsk" , 0x01EDCC }, + { "Asia/Taipei" , 0x01EFCC }, + { "Asia/Tashkent" , 0x01F0FD }, + { "Asia/Tbilisi" , 0x01F22E }, + { "Asia/Tehran" , 0x01F3E8 }, + { "Asia/Tel_Aviv" , 0x01F656 }, + { "Asia/Thimbu" , 0x01F985 }, + { "Asia/Thimphu" , 0x01F9EB }, + { "Asia/Tokyo" , 0x01FA51 }, + { "Asia/Ujung_Pandang" , 0x01FADB }, + { "Asia/Ulaanbaatar" , 0x01FB58 }, + { "Asia/Ulan_Bator" , 0x01FCB3 }, + { "Asia/Urumqi" , 0x01FE00 }, + { "Asia/Ust-Nera" , 0x01FE62 }, + { "Asia/Vientiane" , 0x020074 }, + { "Asia/Vladivostok" , 0x0200C9 }, + { "Asia/Yakutsk" , 0x0202B3 }, + { "Asia/Yekaterinburg" , 0x02049D }, + { "Asia/Yerevan" , 0x0206BE }, + { "Atlantic/Azores" , 0x0208BE }, + { "Atlantic/Bermuda" , 0x020DC1 }, + { "Atlantic/Canary" , 0x0210A2 }, + { "Atlantic/Cape_Verde" , 0x021378 }, + { "Atlantic/Faeroe" , 0x0213F1 }, + { "Atlantic/Faroe" , 0x021695 }, + { "Atlantic/Jan_Mayen" , 0x021939 }, + { "Atlantic/Madeira" , 0x021C6B }, + { "Atlantic/Reykjavik" , 0x022174 }, + { "Atlantic/South_Georgia" , 0x02232D }, + { "Atlantic/St_Helena" , 0x02253F }, + { "Atlantic/Stanley" , 0x022371 }, + { "Australia/ACT" , 0x022594 }, + { "Australia/Adelaide" , 0x0228B7 }, + { "Australia/Brisbane" , 0x022BE9 }, + { "Australia/Broken_Hill" , 0x022CB6 }, + { "Australia/Canberra" , 0x022FFA }, + { "Australia/Currie" , 0x02331D }, + { "Australia/Darwin" , 0x023656 }, + { "Australia/Eucla" , 0x0236E2 }, + { "Australia/Hobart" , 0x0237BE }, + { "Australia/LHI" , 0x023B22 }, + { "Australia/Lindeman" , 0x023DC3 }, + { "Australia/Lord_Howe" , 0x023EAA }, + { "Australia/Melbourne" , 0x02415B }, + { "Australia/North" , 0x024486 }, + { "Australia/NSW" , 0x024500 }, + { "Australia/Perth" , 0x024823 }, + { "Australia/Queensland" , 0x024901 }, + { "Australia/South" , 0x0249B3 }, + { "Australia/Sydney" , 0x024CD6 }, + { "Australia/Tasmania" , 0x025019 }, + { "Australia/Victoria" , 0x025364 }, + { "Australia/West" , 0x025687 }, + { "Australia/Yancowinna" , 0x025743 }, + { "Brazil/Acre" , 0x025A6B }, + { "Brazil/DeNoronha" , 0x025B6F }, + { "Brazil/East" , 0x025C8F }, + { "Brazil/West" , 0x025F6C }, + { "Canada/Atlantic" , 0x026064 }, + { "Canada/Central" , 0x02654C }, + { "Canada/East-Saskatchewan" , 0x026E56 }, + { "Canada/Eastern" , 0x026966 }, + { "Canada/Mountain" , 0x026FDF }, + { "Canada/Newfoundland" , 0x027355 }, + { "Canada/Pacific" , 0x027880 }, + { "Canada/Saskatchewan" , 0x027C99 }, + { "Canada/Yukon" , 0x027E22 }, + { "CET" , 0x028125 }, + { "Chile/Continental" , 0x02842E }, + { "Chile/EasterIsland" , 0x0287C9 }, + { "CST6CDT" , 0x028B0B }, + { "Cuba" , 0x028E5C }, + { "EET" , 0x0291CF }, + { "Egypt" , 0x029482 }, + { "Eire" , 0x029869 }, + { "EST" , 0x029D7A }, + { "EST5EDT" , 0x029DBE }, + { "Etc/GMT" , 0x02A10F }, + { "Etc/GMT+0" , 0x02A1DB }, + { "Etc/GMT+1" , 0x02A265 }, + { "Etc/GMT+10" , 0x02A2F2 }, + { "Etc/GMT+11" , 0x02A380 }, + { "Etc/GMT+12" , 0x02A40E }, + { "Etc/GMT+2" , 0x02A529 }, + { "Etc/GMT+3" , 0x02A5B5 }, + { "Etc/GMT+4" , 0x02A641 }, + { "Etc/GMT+5" , 0x02A6CD }, + { "Etc/GMT+6" , 0x02A759 }, + { "Etc/GMT+7" , 0x02A7E5 }, + { "Etc/GMT+8" , 0x02A871 }, + { "Etc/GMT+9" , 0x02A8FD }, + { "Etc/GMT-0" , 0x02A197 }, + { "Etc/GMT-1" , 0x02A21F }, + { "Etc/GMT-10" , 0x02A2AB }, + { "Etc/GMT-11" , 0x02A339 }, + { "Etc/GMT-12" , 0x02A3C7 }, + { "Etc/GMT-13" , 0x02A455 }, + { "Etc/GMT-14" , 0x02A49C }, + { "Etc/GMT-2" , 0x02A4E3 }, + { "Etc/GMT-3" , 0x02A56F }, + { "Etc/GMT-4" , 0x02A5FB }, + { "Etc/GMT-5" , 0x02A687 }, + { "Etc/GMT-6" , 0x02A713 }, + { "Etc/GMT-7" , 0x02A79F }, + { "Etc/GMT-8" , 0x02A82B }, + { "Etc/GMT-9" , 0x02A8B7 }, + { "Etc/GMT0" , 0x02A153 }, + { "Etc/Greenwich" , 0x02A943 }, + { "Etc/UCT" , 0x02A987 }, + { "Etc/Universal" , 0x02A9CB }, + { "Etc/UTC" , 0x02AA0F }, + { "Etc/Zulu" , 0x02AA53 }, + { "Europe/Amsterdam" , 0x02AA97 }, + { "Europe/Andorra" , 0x02AED5 }, + { "Europe/Athens" , 0x02B151 }, + { "Europe/Belfast" , 0x02B494 }, + { "Europe/Belgrade" , 0x02B9CB }, + { "Europe/Berlin" , 0x02BC94 }, + { "Europe/Bratislava" , 0x02BFF8 }, + { "Europe/Brussels" , 0x02C32A }, + { "Europe/Bucharest" , 0x02C761 }, + { "Europe/Budapest" , 0x02CA8B }, + { "Europe/Busingen" , 0x02CDF4 }, + { "Europe/Chisinau" , 0x02D0AB }, + { "Europe/Copenhagen" , 0x02D439 }, + { "Europe/Dublin" , 0x02D743 }, + { "Europe/Gibraltar" , 0x02DC54 }, + { "Europe/Guernsey" , 0x02E0AB }, + { "Europe/Helsinki" , 0x02E5E2 }, + { "Europe/Isle_of_Man" , 0x02E898 }, + { "Europe/Istanbul" , 0x02EDCF }, + { "Europe/Jersey" , 0x02F1BC }, + { "Europe/Kaliningrad" , 0x02F6F3 }, + { "Europe/Kiev" , 0x02F95E }, + { "Europe/Lisbon" , 0x02FC7A }, + { "Europe/Ljubljana" , 0x03017E }, + { "Europe/London" , 0x030447 }, + { "Europe/Luxembourg" , 0x03097E }, + { "Europe/Madrid" , 0x030DD4 }, + { "Europe/Malta" , 0x03119A }, + { "Europe/Mariehamn" , 0x031553 }, + { "Europe/Minsk" , 0x031809 }, + { "Europe/Monaco" , 0x031A1C }, + { "Europe/Moscow" , 0x031E57 }, + { "Europe/Nicosia" , 0x0320B1 }, + { "Europe/Oslo" , 0x032399 }, + { "Europe/Paris" , 0x0326CB }, + { "Europe/Podgorica" , 0x032B11 }, + { "Europe/Prague" , 0x032DDA }, + { "Europe/Riga" , 0x03310C }, + { "Europe/Rome" , 0x033451 }, + { "Europe/Samara" , 0x033814 }, + { "Europe/San_Marino" , 0x033A7D }, + { "Europe/Sarajevo" , 0x033E40 }, + { "Europe/Simferopol" , 0x034109 }, + { "Europe/Skopje" , 0x03435A }, + { "Europe/Sofia" , 0x034623 }, + { "Europe/Stockholm" , 0x03492B }, + { "Europe/Tallinn" , 0x034BDA }, + { "Europe/Tirane" , 0x034F14 }, + { "Europe/Tiraspol" , 0x03521A }, + { "Europe/Uzhgorod" , 0x0355A8 }, + { "Europe/Vaduz" , 0x0358BF }, + { "Europe/Vatican" , 0x035B6E }, + { "Europe/Vienna" , 0x035F31 }, + { "Europe/Vilnius" , 0x03625E }, + { "Europe/Volgograd" , 0x03659D }, + { "Europe/Warsaw" , 0x0367BE }, + { "Europe/Zagreb" , 0x036B9F }, + { "Europe/Zaporozhye" , 0x036E68 }, + { "Europe/Zurich" , 0x0371A9 }, + { "Factory" , 0x037458 }, + { "GB" , 0x0374C9 }, + { "GB-Eire" , 0x037A00 }, + { "GMT" , 0x037F37 }, + { "GMT+0" , 0x038003 }, + { "GMT-0" , 0x037FBF }, + { "GMT0" , 0x037F7B }, + { "Greenwich" , 0x038047 }, + { "Hongkong" , 0x03808B }, + { "HST" , 0x03824D }, + { "Iceland" , 0x038291 }, + { "Indian/Antananarivo" , 0x03844A }, + { "Indian/Chagos" , 0x0384C9 }, + { "Indian/Christmas" , 0x03852B }, + { "Indian/Cocos" , 0x03856F }, + { "Indian/Comoro" , 0x0385B3 }, + { "Indian/Kerguelen" , 0x038632 }, + { "Indian/Mahe" , 0x038687 }, + { "Indian/Maldives" , 0x0386DC }, + { "Indian/Mauritius" , 0x038731 }, + { "Indian/Mayotte" , 0x0387A7 }, + { "Indian/Reunion" , 0x038826 }, + { "Iran" , 0x03887B }, + { "Israel" , 0x038AE9 }, + { "Jamaica" , 0x038E18 }, + { "Japan" , 0x038EDD }, + { "Kwajalein" , 0x038F67 }, + { "Libya" , 0x038FCA }, + { "MET" , 0x0390D3 }, + { "Mexico/BajaNorte" , 0x0393DC }, + { "Mexico/BajaSur" , 0x039745 }, + { "Mexico/General" , 0x03998A }, + { "MST" , 0x039BE8 }, + { "MST7MDT" , 0x039C2C }, + { "Navajo" , 0x039F7D }, + { "NZ" , 0x03A2F6 }, + { "NZ-CHAT" , 0x03A674 }, + { "Pacific/Apia" , 0x03A958 }, + { "Pacific/Auckland" , 0x03AAF4 }, + { "Pacific/Bougainville" , 0x03AE80 }, + { "Pacific/Chatham" , 0x03AEF7 }, + { "Pacific/Chuuk" , 0x03B1EA }, + { "Pacific/Easter" , 0x03B243 }, + { "Pacific/Efate" , 0x03B592 }, + { "Pacific/Enderbury" , 0x03B658 }, + { "Pacific/Fakaofo" , 0x03B6C6 }, + { "Pacific/Fiji" , 0x03B717 }, + { "Pacific/Funafuti" , 0x03B8AA }, + { "Pacific/Galapagos" , 0x03B8EE }, + { "Pacific/Gambier" , 0x03B966 }, + { "Pacific/Guadalcanal" , 0x03B9CB }, + { "Pacific/Guam" , 0x03BA20 }, + { "Pacific/Honolulu" , 0x03BA76 }, + { "Pacific/Johnston" , 0x03BAED }, + { "Pacific/Kiritimati" , 0x03BB6C }, + { "Pacific/Kosrae" , 0x03BBD7 }, + { "Pacific/Kwajalein" , 0x03BC34 }, + { "Pacific/Majuro" , 0x03BCA0 }, + { "Pacific/Marquesas" , 0x03BCFF }, + { "Pacific/Midway" , 0x03BD66 }, + { "Pacific/Nauru" , 0x03BDF0 }, + { "Pacific/Niue" , 0x03BE68 }, + { "Pacific/Norfolk" , 0x03BEC6 }, + { "Pacific/Noumea" , 0x03BF1B }, + { "Pacific/Pago_Pago" , 0x03BFAB }, + { "Pacific/Palau" , 0x03C022 }, + { "Pacific/Pitcairn" , 0x03C066 }, + { "Pacific/Pohnpei" , 0x03C0BB }, + { "Pacific/Ponape" , 0x03C110 }, + { "Pacific/Port_Moresby" , 0x03C155 }, + { "Pacific/Rarotonga" , 0x03C1A7 }, + { "Pacific/Saipan" , 0x03C283 }, + { "Pacific/Samoa" , 0x03C2E6 }, + { "Pacific/Tahiti" , 0x03C35D }, + { "Pacific/Tarawa" , 0x03C3C2 }, + { "Pacific/Tongatapu" , 0x03C416 }, + { "Pacific/Truk" , 0x03C4A2 }, + { "Pacific/Wake" , 0x03C4E7 }, + { "Pacific/Wallis" , 0x03C537 }, + { "Pacific/Yap" , 0x03C57B }, + { "Poland" , 0x03C5C0 }, + { "Portugal" , 0x03C9A1 }, + { "PRC" , 0x03CE9D }, + { "PST8PDT" , 0x03CF3D }, + { "ROC" , 0x03D28E }, + { "ROK" , 0x03D3BF }, + { "Singapore" , 0x03D4B2 }, + { "Turkey" , 0x03D569 }, + { "UCT" , 0x03D956 }, + { "Universal" , 0x03D99A }, + { "US/Alaska" , 0x03D9DE }, + { "US/Aleutian" , 0x03DD47 }, + { "US/Arizona" , 0x03E0AD }, + { "US/Central" , 0x03E13B }, + { "US/East-Indiana" , 0x03EB45 }, + { "US/Eastern" , 0x03E646 }, + { "US/Hawaii" , 0x03EDAF }, + { "US/Indiana-Starke" , 0x03EE20 }, + { "US/Michigan" , 0x03F191 }, + { "US/Mountain" , 0x03F4C8 }, + { "US/Pacific" , 0x03F841 }, + { "US/Pacific-New" , 0x03FC46 }, + { "US/Samoa" , 0x04004B }, + { "UTC" , 0x0400C2 }, + { "W-SU" , 0x0403B9 }, + { "WET" , 0x040106 }, + { "Zulu" , 0x0405FC }, }; /* This is a generated file, do not modify */ -const unsigned char timelib_timezone_db_data_builtin[263343] = { +const unsigned char timelib_timezone_db_data_builtin[263744] = { /* Africa/Abidjan */ @@ -620,11 +620,13 @@ const unsigned char timelib_timezone_db_data_builtin[263343] = { /* Africa/Addis_Ababa */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x45, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x09, 0xC0, 0xAF, 0xF2, 0x98, -0x01, 0x00, 0x00, 0x24, 0x68, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x05, 0x41, 0x44, 0x4D, -0x54, 0x00, 0x45, 0x41, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x97, 0x1C, 0xE5, 0x01, 0x4D, -0xB5, 0xB0, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x13, 0xB1, 0xEE, 0xDA, 0xFC, +0xB4, 0xC2, 0x9A, 0xD0, 0xC7, 0x91, 0x47, 0xD8, 0xED, 0x2F, 0xE1, 0xD4, 0x01, 0x02, 0x03, 0x01, +0x00, 0x00, 0x22, 0x84, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x04, 0x00, 0x00, 0x23, 0x28, +0x00, 0x08, 0x00, 0x00, 0x26, 0xAC, 0x00, 0x0D, 0x4C, 0x4D, 0x54, 0x00, 0x45, 0x41, 0x54, 0x00, +0x42, 0x45, 0x41, 0x54, 0x00, 0x42, 0x45, 0x41, 0x55, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x97, 0x1C, 0xE5, 0x01, 0x4D, 0xB5, 0xB0, 0x00, 0x00, 0x00, 0x00, /* Africa/Algiers */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x44, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -649,19 +651,23 @@ const unsigned char timelib_timezone_db_data_builtin[263343] = { /* Africa/Asmara */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x45, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x09, 0xC0, 0xAF, 0xF2, 0x98, -0x01, 0x00, 0x00, 0x24, 0x68, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x05, 0x41, 0x44, 0x4D, -0x54, 0x00, 0x45, 0x41, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA0, 0xB9, 0xD5, 0x01, 0x4D, -0xFD, 0x4D, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x13, 0xB1, 0xEE, 0xDA, 0xFC, +0xB4, 0xC2, 0x9A, 0xD0, 0xC7, 0x91, 0x47, 0xD8, 0xED, 0x2F, 0xE1, 0xD4, 0x01, 0x02, 0x03, 0x01, +0x00, 0x00, 0x22, 0x84, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x04, 0x00, 0x00, 0x23, 0x28, +0x00, 0x08, 0x00, 0x00, 0x26, 0xAC, 0x00, 0x0D, 0x4C, 0x4D, 0x54, 0x00, 0x45, 0x41, 0x54, 0x00, +0x42, 0x45, 0x41, 0x54, 0x00, 0x42, 0x45, 0x41, 0x55, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0xA0, 0xB9, 0xD5, 0x01, 0x4D, 0xFD, 0x4D, 0x00, 0x00, 0x00, 0x00, /* Africa/Asmera */ 0x50, 0x48, 0x50, 0x31, 0x00, 0x3F, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x09, 0xC0, 0xAF, 0xF2, 0x98, -0x01, 0x00, 0x00, 0x24, 0x68, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x05, 0x41, 0x44, 0x4D, -0x54, 0x00, 0x45, 0x41, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x89, 0x54, 0x40, 0x01, 0x12, -0xA8, 0x80, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x13, 0xB1, 0xEE, 0xDA, 0xFC, +0xB4, 0xC2, 0x9A, 0xD0, 0xC7, 0x91, 0x47, 0xD8, 0xED, 0x2F, 0xE1, 0xD4, 0x01, 0x02, 0x03, 0x01, +0x00, 0x00, 0x22, 0x84, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x04, 0x00, 0x00, 0x23, 0x28, +0x00, 0x08, 0x00, 0x00, 0x26, 0xAC, 0x00, 0x0D, 0x4C, 0x4D, 0x54, 0x00, 0x45, 0x41, 0x54, 0x00, +0x42, 0x45, 0x41, 0x54, 0x00, 0x42, 0x45, 0x41, 0x55, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x89, 0x54, 0x40, 0x01, 0x12, 0xA8, 0x80, 0x00, 0x00, 0x00, 0x00, /* Africa/Bamako */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x4D, 0x4C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -895,20 +901,23 @@ const unsigned char timelib_timezone_db_data_builtin[263343] = { /* Africa/Dar_es_Salaam */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x54, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0E, 0xB6, 0xA3, 0xD3, 0xAC, -0xD6, 0x9D, 0x7F, 0xD0, 0xEF, 0x12, 0x66, 0xD4, 0x01, 0x02, 0x01, 0x00, 0x00, 0x24, 0xD4, 0x00, -0x00, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x04, 0x00, 0x00, 0x26, 0xAC, 0x00, 0x08, 0x4C, 0x4D, 0x54, -0x00, 0x45, 0x41, 0x54, 0x00, 0x42, 0x45, 0x41, 0x55, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7E, 0xF4, 0x00, 0x01, 0x4E, 0x99, 0x8D, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x13, 0xB1, 0xEE, 0xDA, 0xFC, +0xB4, 0xC2, 0x9A, 0xD0, 0xC7, 0x91, 0x47, 0xD8, 0xED, 0x2F, 0xE1, 0xD4, 0x01, 0x02, 0x03, 0x01, +0x00, 0x00, 0x22, 0x84, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x04, 0x00, 0x00, 0x23, 0x28, +0x00, 0x08, 0x00, 0x00, 0x26, 0xAC, 0x00, 0x0D, 0x4C, 0x4D, 0x54, 0x00, 0x45, 0x41, 0x54, 0x00, +0x42, 0x45, 0x41, 0x54, 0x00, 0x42, 0x45, 0x41, 0x55, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x7E, 0xF4, 0x00, 0x01, 0x4E, 0x99, 0x8D, 0x00, 0x00, 0x00, 0x00, /* Africa/Djibouti */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x44, 0x4A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x91, 0xF3, 0xD2, 0x0C, -0x01, 0x00, 0x00, 0x28, 0x74, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x04, 0x4C, 0x4D, 0x54, -0x00, 0x45, 0x41, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9B, 0x07, 0x80, 0x01, 0x54, 0x7F, -0xF8, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x13, 0xB1, 0xEE, 0xDA, 0xFC, +0xB4, 0xC2, 0x9A, 0xD0, 0xC7, 0x91, 0x47, 0xD8, 0xED, 0x2F, 0xE1, 0xD4, 0x01, 0x02, 0x03, 0x01, +0x00, 0x00, 0x22, 0x84, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x04, 0x00, 0x00, 0x23, 0x28, +0x00, 0x08, 0x00, 0x00, 0x26, 0xAC, 0x00, 0x0D, 0x4C, 0x4D, 0x54, 0x00, 0x45, 0x41, 0x54, 0x00, +0x42, 0x45, 0x41, 0x54, 0x00, 0x42, 0x45, 0x41, 0x55, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x9B, 0x07, 0x80, 0x01, 0x54, 0x7F, 0xF8, 0x00, 0x00, 0x00, 0x00, /* Africa/Douala */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x43, 0x4D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1011,9 +1020,9 @@ const unsigned char timelib_timezone_db_data_builtin[263343] = { /* Africa/Kampala */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x55, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x13, 0xB1, 0xEE, 0xDF, 0x1C, -0xB4, 0xC2, 0x9A, 0xD0, 0xD6, 0x9D, 0x86, 0xD8, 0xE7, 0x8C, 0x47, 0x54, 0x01, 0x02, 0x03, 0x01, -0x00, 0x00, 0x1E, 0x64, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x04, 0x00, 0x00, 0x23, 0x28, +0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x13, 0xB1, 0xEE, 0xDA, 0xFC, +0xB4, 0xC2, 0x9A, 0xD0, 0xC7, 0x91, 0x47, 0xD8, 0xED, 0x2F, 0xE1, 0xD4, 0x01, 0x02, 0x03, 0x01, +0x00, 0x00, 0x22, 0x84, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x04, 0x00, 0x00, 0x23, 0x28, 0x00, 0x08, 0x00, 0x00, 0x26, 0xAC, 0x00, 0x0D, 0x4C, 0x4D, 0x54, 0x00, 0x45, 0x41, 0x54, 0x00, 0x42, 0x45, 0x41, 0x54, 0x00, 0x42, 0x45, 0x41, 0x55, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x89, 0xCF, 0xF2, 0x01, 0x44, 0x1F, 0x42, 0x00, 0x00, 0x00, 0x00, @@ -1140,11 +1149,13 @@ const unsigned char timelib_timezone_db_data_builtin[263343] = { /* Africa/Mogadishu */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x53, 0x4F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x09, 0xB6, 0xA3, 0xCE, 0x50, -0xE7, 0x8C, 0x4A, 0xD8, 0x01, 0x00, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x00, 0x00, 0x00, 0x23, 0x28, -0x00, 0x04, 0x45, 0x41, 0x54, 0x00, 0x42, 0x45, 0x41, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x8C, 0x7B, 0x8A, 0x01, 0x57, 0xE1, 0xDA, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x13, 0xB1, 0xEE, 0xDA, 0xFC, +0xB4, 0xC2, 0x9A, 0xD0, 0xC7, 0x91, 0x47, 0xD8, 0xED, 0x2F, 0xE1, 0xD4, 0x01, 0x02, 0x03, 0x01, +0x00, 0x00, 0x22, 0x84, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x04, 0x00, 0x00, 0x23, 0x28, +0x00, 0x08, 0x00, 0x00, 0x26, 0xAC, 0x00, 0x0D, 0x4C, 0x4D, 0x54, 0x00, 0x45, 0x41, 0x54, 0x00, +0x42, 0x45, 0x41, 0x54, 0x00, 0x42, 0x45, 0x41, 0x55, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x8C, 0x7B, 0x8A, 0x01, 0x57, 0xE1, 0xDA, 0x00, 0x00, 0x00, 0x00, /* Africa/Monrovia */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x4C, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -3306,7 +3317,7 @@ const unsigned char timelib_timezone_db_data_builtin[263343] = { /* America/Grand_Turk */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x54, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x10, 0x93, 0x0F, 0xB4, 0xFF, +0x00, 0x00, 0x00, 0x4B, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x10, 0x93, 0x0F, 0xB4, 0xFF, 0x11, 0x89, 0x65, 0xF0, 0x12, 0x79, 0x48, 0xE0, 0x13, 0x69, 0x47, 0xF0, 0x14, 0x59, 0x2A, 0xE0, 0x15, 0x49, 0x29, 0xF0, 0x16, 0x39, 0x0C, 0xE0, 0x17, 0x29, 0x0B, 0xF0, 0x18, 0x22, 0x29, 0x60, 0x19, 0x08, 0xED, 0xF0, 0x1A, 0x02, 0x0B, 0x60, 0x1A, 0xF2, 0x0A, 0x70, 0x1B, 0xE1, 0xED, 0x60, @@ -3325,15 +3336,15 @@ const unsigned char timelib_timezone_db_data_builtin[263343] = { 0x49, 0xB3, 0x6C, 0xF0, 0x4A, 0xED, 0x23, 0xE0, 0x4B, 0x9C, 0x89, 0x70, 0x4C, 0xD6, 0x40, 0x60, 0x4D, 0x7C, 0x6B, 0x70, 0x4E, 0xB6, 0x22, 0x60, 0x4F, 0x5C, 0x4D, 0x70, 0x50, 0x96, 0x04, 0x60, 0x51, 0x3C, 0x2F, 0x70, 0x52, 0x75, 0xE6, 0x60, 0x53, 0x1C, 0x11, 0x70, 0x54, 0x55, 0xC8, 0x60, +0x54, 0xFB, 0xF3, 0x70, 0x56, 0x35, 0xAA, 0x60, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, -0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x03, 0xFF, 0xFF, 0xB8, 0x01, 0x00, 0x00, 0xFF, -0xFF, 0xB9, 0xB0, 0x00, 0x04, 0xFF, 0xFF, 0xC7, 0xC0, 0x01, 0x08, 0xFF, 0xFF, 0xC7, 0xC0, 0x00, -0x0C, 0x4B, 0x4D, 0x54, 0x00, 0x45, 0x53, 0x54, 0x00, 0x45, 0x44, 0x54, 0x00, 0x41, 0x53, 0x54, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAA, 0x15, 0xAA, 0x00, 0xA6, 0x1E, -0x0A, 0x00, 0x00, 0x00, 0x00, +0x01, 0x02, 0x03, 0xFF, 0xFF, 0xB8, 0x01, 0x00, 0x00, 0xFF, 0xFF, 0xB9, 0xB0, 0x00, 0x04, 0xFF, +0xFF, 0xC7, 0xC0, 0x01, 0x08, 0xFF, 0xFF, 0xC7, 0xC0, 0x00, 0x0C, 0x4B, 0x4D, 0x54, 0x00, 0x45, +0x53, 0x54, 0x00, 0x45, 0x44, 0x54, 0x00, 0x41, 0x53, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0xAA, 0x15, 0xAA, 0x00, 0xA6, 0x1E, 0x0A, 0x00, 0x00, 0x00, 0x00, /* America/Grenada */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x47, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -9074,14 +9085,13 @@ const unsigned char timelib_timezone_db_data_builtin[263343] = { /* Asia/Pyongyang */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x4B, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0D, 0x85, 0x93, 0x7E, 0x78, -0xB0, 0xFE, 0x8D, 0xF0, 0xB8, 0x84, 0xB4, 0x78, 0xC3, 0x55, 0x3B, 0x70, 0xD2, 0x2F, 0x61, 0x70, -0xE2, 0x4F, 0x29, 0xF0, 0xF0, 0x35, 0x78, 0x80, 0x01, 0x00, 0x01, 0x02, 0x03, 0x04, 0x03, 0x00, -0x00, 0x77, 0x88, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x90, 0x00, 0x04, 0x00, 0x00, 0x7E, 0x90, 0x00, -0x09, 0x00, 0x00, 0x7E, 0x90, 0x00, 0x00, 0x00, 0x00, 0x70, 0x80, 0x00, 0x00, 0x4B, 0x53, 0x54, -0x00, 0x4A, 0x43, 0x53, 0x54, 0x00, 0x4A, 0x53, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xC4, 0xDD, 0x22, 0x01, 0xD2, 0x89, 0x98, 0x00, 0x00, 0x00, 0x00, - +0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x11, 0x8B, 0xD7, 0xF1, 0x9C, +0x92, 0xE6, 0x16, 0xF8, 0xC3, 0x55, 0x3B, 0x70, 0xD2, 0x2F, 0x61, 0x70, 0x01, 0x02, 0x03, 0x04, +0x00, 0x00, 0x75, 0xE4, 0x00, 0x00, 0x00, 0x00, 0x77, 0x88, 0x00, 0x04, 0x00, 0x00, 0x7E, 0x90, +0x00, 0x08, 0x00, 0x00, 0x7E, 0x90, 0x00, 0x0D, 0x00, 0x00, 0x7E, 0x90, 0x00, 0x04, 0x4C, 0x4D, +0x54, 0x00, 0x4B, 0x53, 0x54, 0x00, 0x4A, 0x43, 0x53, 0x54, 0x00, 0x4A, 0x53, 0x54, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC4, 0xDD, 0x22, 0x01, 0xD2, 0x89, +0x98, 0x00, 0x00, 0x00, 0x00, /* Asia/Qatar */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x51, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -9214,17 +9224,20 @@ const unsigned char timelib_timezone_db_data_builtin[263343] = { /* Asia/Seoul */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x4B, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x11, 0x85, 0x93, 0x7E, 0x78, -0xB0, 0xFE, 0x8D, 0xF0, 0xB8, 0x84, 0xB4, 0x78, 0xC3, 0x55, 0x3B, 0x70, 0xD2, 0x43, 0x27, 0xF0, -0xE2, 0x4F, 0x29, 0xF0, 0xED, 0xE1, 0x92, 0x80, 0xEE, 0x81, 0x09, 0xF0, 0xF0, 0x35, 0x78, 0x80, -0xFD, 0xA5, 0x0A, 0xF8, 0x20, 0xA3, 0x44, 0x70, 0x21, 0x6E, 0x3D, 0x60, 0x22, 0x83, 0x26, 0x70, -0x23, 0x4E, 0x1F, 0x60, 0x01, 0x00, 0x01, 0x02, 0x03, 0x05, 0x04, 0x05, 0x00, 0x03, 0x06, 0x03, -0x06, 0x03, 0x00, 0x00, 0x77, 0x88, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x90, 0x00, 0x04, 0x00, 0x00, -0x7E, 0x90, 0x00, 0x09, 0x00, 0x00, 0x7E, 0x90, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x90, 0x01, 0x0D, -0x00, 0x00, 0x70, 0x80, 0x00, 0x00, 0x00, 0x00, 0x8C, 0xA0, 0x01, 0x0D, 0x4B, 0x53, 0x54, 0x00, -0x4A, 0x43, 0x53, 0x54, 0x00, 0x4A, 0x53, 0x54, 0x00, 0x4B, 0x44, 0x54, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC2, 0xA0, 0x38, 0x01, -0xD4, 0x64, 0xDA, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x15, 0x8B, 0xD7, 0xF0, 0x78, +0x92, 0xE6, 0x16, 0xF8, 0xC3, 0x55, 0x3B, 0x70, 0xD2, 0x43, 0x27, 0xF0, 0xE2, 0x4F, 0x29, 0xF0, +0xE4, 0x6B, 0xB7, 0xF8, 0xE5, 0x13, 0x18, 0x68, 0xE6, 0x62, 0x03, 0x78, 0xE7, 0x11, 0x4C, 0xE8, +0xE8, 0x2F, 0x70, 0x78, 0xE8, 0xE7, 0xF4, 0x68, 0xEA, 0x0F, 0x52, 0x78, 0xEA, 0xC7, 0xD6, 0x68, +0xEB, 0xEF, 0x34, 0x78, 0xEC, 0xA7, 0xB8, 0x68, 0xED, 0xCF, 0x16, 0x78, 0xEE, 0x87, 0x9A, 0x68, +0xF0, 0x35, 0x71, 0x78, 0x20, 0xA3, 0x60, 0x90, 0x21, 0x6E, 0x67, 0x90, 0x22, 0x83, 0x42, 0x90, +0x23, 0x4E, 0x49, 0x90, 0x01, 0x02, 0x03, 0x04, 0x01, 0x05, 0x01, 0x05, 0x01, 0x05, 0x01, 0x05, +0x01, 0x05, 0x01, 0x05, 0x01, 0x04, 0x06, 0x04, 0x06, 0x04, 0x00, 0x00, 0x77, 0x08, 0x00, 0x00, +0x00, 0x00, 0x77, 0x88, 0x00, 0x04, 0x00, 0x00, 0x7E, 0x90, 0x00, 0x08, 0x00, 0x00, 0x7E, 0x90, +0x00, 0x0D, 0x00, 0x00, 0x7E, 0x90, 0x00, 0x04, 0x00, 0x00, 0x85, 0x98, 0x01, 0x11, 0x00, 0x00, +0x8C, 0xA0, 0x01, 0x11, 0x4C, 0x4D, 0x54, 0x00, 0x4B, 0x53, 0x54, 0x00, 0x4A, 0x43, 0x53, 0x54, +0x00, 0x4A, 0x53, 0x54, 0x00, 0x4B, 0x44, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC2, 0xA0, 0x38, 0x01, 0xD4, 0x64, 0xDA, 0x00, +0x00, 0x00, 0x00, /* Asia/Shanghai */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x43, 0x4E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -16232,12 +16245,12 @@ const unsigned char timelib_timezone_db_data_builtin[263343] = { /* Indian/Antananarivo */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x4D, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0D, 0x91, 0xF3, 0xCD, 0xF4, -0xE2, 0x33, 0xC0, 0xC0, 0xE2, 0xAB, 0xB9, 0x40, 0x01, 0x02, 0x03, 0x00, 0x00, 0x2C, 0x8C, 0x00, -0x00, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x04, 0x00, 0x00, 0x38, 0x40, 0x01, 0x08, 0x00, 0x00, 0x2A, -0x30, 0x00, 0x04, 0x4C, 0x4D, 0x54, 0x00, 0x45, 0x41, 0x54, 0x00, 0x45, 0x41, 0x53, 0x54, 0x00, -0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6C, 0x76, 0xED, 0x01, 0x5B, 0x29, 0xB2, -0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x13, 0xB1, 0xEE, 0xDA, 0xFC, +0xB4, 0xC2, 0x9A, 0xD0, 0xC7, 0x91, 0x47, 0xD8, 0xED, 0x2F, 0xE1, 0xD4, 0x01, 0x02, 0x03, 0x01, +0x00, 0x00, 0x22, 0x84, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x04, 0x00, 0x00, 0x23, 0x28, +0x00, 0x08, 0x00, 0x00, 0x26, 0xAC, 0x00, 0x0D, 0x4C, 0x4D, 0x54, 0x00, 0x45, 0x41, 0x54, 0x00, +0x42, 0x45, 0x41, 0x54, 0x00, 0x42, 0x45, 0x41, 0x55, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x6C, 0x76, 0xED, 0x01, 0x5B, 0x29, 0xB2, 0x00, 0x00, 0x00, 0x00, /* Indian/Chagos */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x49, 0x4F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -16264,11 +16277,13 @@ const unsigned char timelib_timezone_db_data_builtin[263343] = { /* Indian/Comoro */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x4B, 0x4D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x91, 0xF3, 0xD1, 0xF0, -0x01, 0x00, 0x00, 0x28, 0x90, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x04, 0x4C, 0x4D, 0x54, -0x00, 0x45, 0x41, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x80, 0x72, 0x01, 0x54, 0xAD, -0x8A, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x13, 0xB1, 0xEE, 0xDA, 0xFC, +0xB4, 0xC2, 0x9A, 0xD0, 0xC7, 0x91, 0x47, 0xD8, 0xED, 0x2F, 0xE1, 0xD4, 0x01, 0x02, 0x03, 0x01, +0x00, 0x00, 0x22, 0x84, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x04, 0x00, 0x00, 0x23, 0x28, +0x00, 0x08, 0x00, 0x00, 0x26, 0xAC, 0x00, 0x0D, 0x4C, 0x4D, 0x54, 0x00, 0x45, 0x41, 0x54, 0x00, +0x42, 0x45, 0x41, 0x54, 0x00, 0x42, 0x45, 0x41, 0x55, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x77, 0x80, 0x72, 0x01, 0x54, 0xAD, 0x8A, 0x00, 0x00, 0x00, 0x00, /* Indian/Kerguelen */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x54, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -16306,11 +16321,13 @@ const unsigned char timelib_timezone_db_data_builtin[263343] = { /* Indian/Mayotte */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x59, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x91, 0xF3, 0xD0, 0x18, -0x01, 0x00, 0x00, 0x2A, 0x68, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x04, 0x4C, 0x4D, 0x54, -0x00, 0x45, 0x41, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0xD2, 0xC2, 0x01, 0x57, 0xAD, -0xC5, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x13, 0xB1, 0xEE, 0xDA, 0xFC, +0xB4, 0xC2, 0x9A, 0xD0, 0xC7, 0x91, 0x47, 0xD8, 0xED, 0x2F, 0xE1, 0xD4, 0x01, 0x02, 0x03, 0x01, +0x00, 0x00, 0x22, 0x84, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x04, 0x00, 0x00, 0x23, 0x28, +0x00, 0x08, 0x00, 0x00, 0x26, 0xAC, 0x00, 0x0D, 0x4C, 0x4D, 0x54, 0x00, 0x45, 0x41, 0x54, 0x00, +0x42, 0x45, 0x41, 0x54, 0x00, 0x42, 0x45, 0x41, 0x55, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x75, 0xD2, 0xC2, 0x01, 0x57, 0xAD, 0xC5, 0x00, 0x00, 0x00, 0x00, /* Indian/Reunion */ 0x50, 0x48, 0x50, 0x31, 0x01, 0x52, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -17688,17 +17705,20 @@ const unsigned char timelib_timezone_db_data_builtin[263343] = { /* ROK */ 0x50, 0x48, 0x50, 0x31, 0x00, 0x3F, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x11, 0x85, 0x93, 0x7E, 0x78, -0xB0, 0xFE, 0x8D, 0xF0, 0xB8, 0x84, 0xB4, 0x78, 0xC3, 0x55, 0x3B, 0x70, 0xD2, 0x43, 0x27, 0xF0, -0xE2, 0x4F, 0x29, 0xF0, 0xED, 0xE1, 0x92, 0x80, 0xEE, 0x81, 0x09, 0xF0, 0xF0, 0x35, 0x78, 0x80, -0xFD, 0xA5, 0x0A, 0xF8, 0x20, 0xA3, 0x44, 0x70, 0x21, 0x6E, 0x3D, 0x60, 0x22, 0x83, 0x26, 0x70, -0x23, 0x4E, 0x1F, 0x60, 0x01, 0x00, 0x01, 0x02, 0x03, 0x05, 0x04, 0x05, 0x00, 0x03, 0x06, 0x03, -0x06, 0x03, 0x00, 0x00, 0x77, 0x88, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x90, 0x00, 0x04, 0x00, 0x00, -0x7E, 0x90, 0x00, 0x09, 0x00, 0x00, 0x7E, 0x90, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x90, 0x01, 0x0D, -0x00, 0x00, 0x70, 0x80, 0x00, 0x00, 0x00, 0x00, 0x8C, 0xA0, 0x01, 0x0D, 0x4B, 0x53, 0x54, 0x00, -0x4A, 0x43, 0x53, 0x54, 0x00, 0x4A, 0x53, 0x54, 0x00, 0x4B, 0x44, 0x54, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x89, 0x54, 0x40, 0x01, -0x12, 0xA8, 0x80, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x15, 0x8B, 0xD7, 0xF0, 0x78, +0x92, 0xE6, 0x16, 0xF8, 0xC3, 0x55, 0x3B, 0x70, 0xD2, 0x43, 0x27, 0xF0, 0xE2, 0x4F, 0x29, 0xF0, +0xE4, 0x6B, 0xB7, 0xF8, 0xE5, 0x13, 0x18, 0x68, 0xE6, 0x62, 0x03, 0x78, 0xE7, 0x11, 0x4C, 0xE8, +0xE8, 0x2F, 0x70, 0x78, 0xE8, 0xE7, 0xF4, 0x68, 0xEA, 0x0F, 0x52, 0x78, 0xEA, 0xC7, 0xD6, 0x68, +0xEB, 0xEF, 0x34, 0x78, 0xEC, 0xA7, 0xB8, 0x68, 0xED, 0xCF, 0x16, 0x78, 0xEE, 0x87, 0x9A, 0x68, +0xF0, 0x35, 0x71, 0x78, 0x20, 0xA3, 0x60, 0x90, 0x21, 0x6E, 0x67, 0x90, 0x22, 0x83, 0x42, 0x90, +0x23, 0x4E, 0x49, 0x90, 0x01, 0x02, 0x03, 0x04, 0x01, 0x05, 0x01, 0x05, 0x01, 0x05, 0x01, 0x05, +0x01, 0x05, 0x01, 0x05, 0x01, 0x04, 0x06, 0x04, 0x06, 0x04, 0x00, 0x00, 0x77, 0x08, 0x00, 0x00, +0x00, 0x00, 0x77, 0x88, 0x00, 0x04, 0x00, 0x00, 0x7E, 0x90, 0x00, 0x08, 0x00, 0x00, 0x7E, 0x90, +0x00, 0x0D, 0x00, 0x00, 0x7E, 0x90, 0x00, 0x04, 0x00, 0x00, 0x85, 0x98, 0x01, 0x11, 0x00, 0x00, +0x8C, 0xA0, 0x01, 0x11, 0x4C, 0x4D, 0x54, 0x00, 0x4B, 0x53, 0x54, 0x00, 0x4A, 0x43, 0x53, 0x54, +0x00, 0x4A, 0x53, 0x54, 0x00, 0x4B, 0x44, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x89, 0x54, 0x40, 0x01, 0x12, 0xA8, 0x80, 0x00, +0x00, 0x00, 0x00, /* Singapore */ 0x50, 0x48, 0x50, 0x31, 0x00, 0x3F, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -18547,4 +18567,4 @@ const unsigned char timelib_timezone_db_data_builtin[263343] = { 0x00, 0x00, 0x55, 0x54, 0x43, 0x00, 0x00, 0x00, 0x00, 0x89, 0x54, 0x40, 0x01, 0x12, 0xA8, 0x80, 0x00, 0x00, 0x00, 0x00, }; -const timelib_tzdb timezonedb_builtin = { "2014.9", 583, timezonedb_idx_builtin, timelib_timezone_db_data_builtin }; +const timelib_tzdb timezonedb_builtin = { "2014.10", 583, timezonedb_idx_builtin, timelib_timezone_db_data_builtin }; From c0db5cd93d8ce040a71eb883650723107c562e43 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 11 Nov 2014 15:22:06 +0100 Subject: [PATCH 301/398] refactor zts related config --- win32/build/config.w32 | 28 +---------------------- win32/build/config.w32.phpize.in | 33 +-------------------------- win32/build/confutils.js | 39 ++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 59 deletions(-) diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 85a96f1694f..8e63fc829a7 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -87,33 +87,7 @@ toolset_setup_common_libs(); // Set some debug/release specific options toolset_setup_build_mode(); -if (PHP_ZTS == "yes") { - ADD_FLAG("CFLAGS", "/D ZTS=1"); - ADD_FLAG("ZTS", "1"); -} else { - ADD_FLAG("ZTS", "0"); -} - -DEFINE("PHP_ZTS_ARCHIVE_POSTFIX", PHP_ZTS == "yes" ? '' : "-nts"); - -// set up the build dir and DLL name -if (PHP_DEBUG == "yes" && PHP_ZTS == "yes") { - DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Debug_TS"); - DEFINE("PHPDLL", "php" + PHP_VERSION + "ts_debug.dll"); - DEFINE("PHPLIB", "php" + PHP_VERSION + "ts_debug.lib"); -} else if (PHP_DEBUG == "yes" && PHP_ZTS == "no") { - DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Debug"); - DEFINE("PHPDLL", "php" + PHP_VERSION + "_debug.dll"); - DEFINE("PHPLIB", "php" + PHP_VERSION + "_debug.lib"); -} else if (PHP_DEBUG == "no" && PHP_ZTS == "yes") { - DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Release_TS"); - DEFINE("PHPDLL", "php" + PHP_VERSION + "ts.dll"); - DEFINE("PHPLIB", "php" + PHP_VERSION + "ts.lib"); -} else if (PHP_DEBUG == "no" && PHP_ZTS == "no") { - DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Release"); - DEFINE("PHPDLL", "php" + PHP_VERSION + ".dll"); - DEFINE("PHPLIB", "php" + PHP_VERSION + ".lib"); -} +setup_zts_stuff(); // CFLAGS, LDFLAGS and BUILD_DIR are defined // Add compiler and link flags if PGO options are selected diff --git a/win32/build/config.w32.phpize.in b/win32/build/config.w32.phpize.in index 52947c1ace8..a82369a8554 100644 --- a/win32/build/config.w32.phpize.in +++ b/win32/build/config.w32.phpize.in @@ -77,38 +77,7 @@ toolset_setup_common_libs(); // Set some debug/release specific options toolset_setup_build_mode(); -if (PHP_ZTS == "yes") { - ADD_FLAG("CFLAGS", "/D ZTS=1"); -} - -DEFINE("PHP_ZTS_ARCHIVE_POSTFIX", PHP_ZTS == "yes" ? '' : "-nts"); - -// set up the build dir and DLL name -if (PHP_DEBUG == "yes" && PHP_ZTS == "yes") { - DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Debug_TS"); - if (!MODE_PHPIZE) { - DEFINE("PHPDLL", "php" + PHP_VERSION + "ts_debug.dll"); - DEFINE("PHPLIB", "php" + PHP_VERSION + "ts_debug.lib"); - } -} else if (PHP_DEBUG == "yes" && PHP_ZTS == "no") { - DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Debug"); - if (!MODE_PHPIZE) { - DEFINE("PHPDLL", "php" + PHP_VERSION + "_debug.dll"); - DEFINE("PHPLIB", "php" + PHP_VERSION + "_debug.lib"); - } -} else if (PHP_DEBUG == "no" && PHP_ZTS == "yes") { - DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Release_TS"); - if (!MODE_PHPIZE) { - DEFINE("PHPDLL", "php" + PHP_VERSION + "ts.dll"); - DEFINE("PHPLIB", "php" + PHP_VERSION + "ts.lib"); - } -} else if (PHP_DEBUG == "no" && PHP_ZTS == "no") { - DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Release"); - if (!MODE_PHPIZE) { - DEFINE("PHPDLL", "php" + PHP_VERSION + ".dll"); - DEFINE("PHPLIB", "php" + PHP_VERSION + ".lib"); - } -} +setup_zts_stuff(); if (MODE_PHPIZE) { DEFINE("PHPDLL", PHP_DLL); diff --git a/win32/build/confutils.js b/win32/build/confutils.js index c7e8c119c02..da2ffc64293 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -2640,3 +2640,42 @@ function object_out_dir_option_handle() } } +function setup_zts_stuff() +{ + if (PHP_ZTS == "yes") { + ADD_FLAG("CFLAGS", "/D ZTS=1"); + ADD_FLAG("ZTS", "1"); + } else { + ADD_FLAG("ZTS", "0"); + } + + DEFINE("PHP_ZTS_ARCHIVE_POSTFIX", PHP_ZTS == "yes" ? '' : "-nts"); + + // set up the build dir and DLL name + if (PHP_DEBUG == "yes" && PHP_ZTS == "yes") { + DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Debug_TS"); + if (!MODE_PHPIZE) { + DEFINE("PHPDLL", "php" + PHP_VERSION + "ts_debug.dll"); + DEFINE("PHPLIB", "php" + PHP_VERSION + "ts_debug.lib"); + } + } else if (PHP_DEBUG == "yes" && PHP_ZTS == "no") { + DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Debug"); + if (!MODE_PHPIZE) { + DEFINE("PHPDLL", "php" + PHP_VERSION + "_debug.dll"); + DEFINE("PHPLIB", "php" + PHP_VERSION + "_debug.lib"); + } + } else if (PHP_DEBUG == "no" && PHP_ZTS == "yes") { + DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Release_TS"); + if (!MODE_PHPIZE) { + DEFINE("PHPDLL", "php" + PHP_VERSION + "ts.dll"); + DEFINE("PHPLIB", "php" + PHP_VERSION + "ts.lib"); + } + } else if (PHP_DEBUG == "no" && PHP_ZTS == "no") { + DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Release"); + if (!MODE_PHPIZE) { + DEFINE("PHPDLL", "php" + PHP_VERSION + ".dll"); + DEFINE("PHPLIB", "php" + PHP_VERSION + ".lib"); + } + } +} + From 9757d9adbf00d3bfabdd3532408f05e92781989f Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 11 Nov 2014 15:28:20 +0100 Subject: [PATCH 302/398] generalize --with-php-build option handling --- win32/build/config.w32 | 27 +-------------------------- win32/build/config.w32.phpize.in | 27 +-------------------------- win32/build/confutils.js | 29 +++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 52 deletions(-) diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 8e63fc829a7..6c6626773e8 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -103,32 +103,7 @@ else if (PHP_DEBUG != "yes" && PHP_PGO != "no") { // Find the php_build dir - it contains headers and libraries // that we need ARG_WITH('php-build', 'Path to where you extracted the development libraries (http://wiki.php.net/internals/windows/libs). Assumes that it is a sibling of this source dir (..\\deps) if not specified', 'no'); - -if (PHP_PHP_BUILD == 'no') { - if (FSO.FolderExists("..\\deps")) { - PHP_PHP_BUILD = "..\\deps"; - } else { - if (FSO.FolderExists("..\\php_build")) { - PHP_PHP_BUILD = "..\\php_build"; - } else { - if (X64) { - if (FSO.FolderExists("..\\win64build")) { - PHP_PHP_BUILD = "..\\win64build"; - } else if (FSO.FolderExists("..\\php-win64-dev\\php_build")) { - PHP_PHP_BUILD = "..\\php-win64-dev\\php_build"; - } - } else { - if (FSO.FolderExists("..\\win32build")) { - PHP_PHP_BUILD = "..\\win32build"; - } else if (FSO.FolderExists("..\\php-win32-dev\\php_build")) { - PHP_PHP_BUILD = "..\\php-win32-dev\\php_build"; - } - } - } - } - PHP_PHP_BUILD = FSO.GetAbsolutePathName(PHP_PHP_BUILD); -} -DEFINE("PHP_BUILD", PHP_PHP_BUILD); +php_build_option_handle(); ARG_WITH('extra-includes', 'Extra include path to use when building everything', ''); ARG_WITH('extra-libs', 'Extra library path to use when linking everything', ''); diff --git a/win32/build/config.w32.phpize.in b/win32/build/config.w32.phpize.in index a82369a8554..91b3552412d 100644 --- a/win32/build/config.w32.phpize.in +++ b/win32/build/config.w32.phpize.in @@ -87,32 +87,7 @@ if (MODE_PHPIZE) { // Find the php_build dir - it contains headers and libraries // that we need ARG_WITH('php-build', 'Path to where you extracted the development libraries (http://wiki.php.net/internals/windows/libs). Assumes that it is a sibling of this source dir (..\\deps) if not specified', 'no'); - -if (PHP_PHP_BUILD == 'no') { - if (FSO.FolderExists("..\\deps")) { - PHP_PHP_BUILD = "..\\deps"; - } else { - if (FSO.FolderExists("..\\php_build")) { - PHP_PHP_BUILD = "..\\php_build"; - } else { - if (X64) { - if (FSO.FolderExists("..\\win64build")) { - PHP_PHP_BUILD = "..\\win64build"; - } else if (FSO.FolderExists("..\\php-win64-dev\\php_build")) { - PHP_PHP_BUILD = "..\\php-win64-dev\\php_build"; - } - } else { - if (FSO.FolderExists("..\\win32build")) { - PHP_PHP_BUILD = "..\\win32build"; - } else if (FSO.FolderExists("..\\php-win32-dev\\php_build")) { - PHP_PHP_BUILD = "..\\php-win32-dev\\php_build"; - } - } - } - } - PHP_PHP_BUILD = FSO.GetAbsolutePathName(PHP_PHP_BUILD); -} -DEFINE("PHP_BUILD", PHP_PHP_BUILD); +php_build_option_handle(); ARG_WITH('extra-includes', 'Extra include path to use when building everything', ''); ARG_WITH('extra-libs', 'Extra library path to use when linking everything', ''); diff --git a/win32/build/confutils.js b/win32/build/confutils.js index da2ffc64293..1c47ace175f 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -2679,3 +2679,32 @@ function setup_zts_stuff() } } +function php_build_option_handle() +{ + if (PHP_PHP_BUILD == 'no') { + if (FSO.FolderExists("..\\deps")) { + PHP_PHP_BUILD = "..\\deps"; + } else { + if (FSO.FolderExists("..\\php_build")) { + PHP_PHP_BUILD = "..\\php_build"; + } else { + if (X64) { + if (FSO.FolderExists("..\\win64build")) { + PHP_PHP_BUILD = "..\\win64build"; + } else if (FSO.FolderExists("..\\php-win64-dev\\php_build")) { + PHP_PHP_BUILD = "..\\php-win64-dev\\php_build"; + } + } else { + if (FSO.FolderExists("..\\win32build")) { + PHP_PHP_BUILD = "..\\win32build"; + } else if (FSO.FolderExists("..\\php-win32-dev\\php_build")) { + PHP_PHP_BUILD = "..\\php-win32-dev\\php_build"; + } + } + } + } + PHP_PHP_BUILD = FSO.GetAbsolutePathName(PHP_PHP_BUILD); + } + DEFINE("PHP_BUILD", PHP_PHP_BUILD); +} + From 524f854193ef1f169fb649feb6010439379aba5c Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 11 Nov 2014 15:33:38 +0100 Subject: [PATCH 303/398] eliminate duplicated identical function definitions --- win32/build/config.w32 | 40 ------------------------------- win32/build/config.w32.phpize.in | 41 -------------------------------- win32/build/confutils.js | 40 +++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 81 deletions(-) diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 6c6626773e8..65c273a5bc0 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -114,46 +114,6 @@ var php_usual_lib_suspects = PHP_PHP_BUILD+"\\lib"; ADD_FLAG("CFLAGS", '/I "' + php_usual_include_suspects + '" '); ADD_FLAG("LDFLAGS", '/libpath:"' + php_usual_lib_suspects + '" '); -// Poke around for some headers -function probe_basic_headers() -{ - var p; - - if (PHP_PHP_BUILD != "no") { - php_usual_include_suspects += ";" + PHP_PHP_BUILD + "\\include"; - php_usual_lib_suspects += ";" + PHP_PHP_BUILD + "\\lib"; - } -} - -function add_extra_dirs() -{ - var path, i, f; - - if (PHP_EXTRA_INCLUDES.length) { - path = PHP_EXTRA_INCLUDES.split(';'); - for (i = 0; i < path.length; i++) { - f = FSO.GetAbsolutePathName(path[i]); - if (FSO.FolderExists(f)) { - ADD_FLAG("CFLAGS", '/I "' + f + '" '); - } - } - } - if (PHP_EXTRA_LIBS.length) { - path = PHP_EXTRA_LIBS.split(';'); - for (i = 0; i < path.length; i++) { - f = FSO.GetAbsolutePathName(path[i]); - if (FSO.FolderExists(f)) { - if (VS_TOOLSET && VCVERS <= 1200 && f.indexOf(" ") >= 0) { - ADD_FLAG("LDFLAGS", '/libpath:"\\"' + f + '\\"" '); - } else { - ADD_FLAG("LDFLAGS", '/libpath:"' + f + '" '); - } - } - } - } - -} - probe_basic_headers(); add_extra_dirs(); diff --git a/win32/build/config.w32.phpize.in b/win32/build/config.w32.phpize.in index 91b3552412d..8b831f0b10d 100644 --- a/win32/build/config.w32.phpize.in +++ b/win32/build/config.w32.phpize.in @@ -98,46 +98,6 @@ var php_usual_lib_suspects = PHP_PHP_BUILD+"\\lib"; ADD_FLAG("CFLAGS", '/I "' + php_usual_include_suspects + '" '); ADD_FLAG("LDFLAGS", '/libpath:"\\"' + php_usual_lib_suspects + '\\"" '); -// Poke around for some headers -function probe_basic_headers() -{ - var p; - - if (PHP_PHP_BUILD != "no") { - php_usual_include_suspects += ";" + PHP_PHP_BUILD + "\\include"; - php_usual_lib_suspects += ";" + PHP_PHP_BUILD + "\\lib"; - } -} - -function add_extra_dirs() -{ - var path, i, f; - - if (PHP_EXTRA_INCLUDES.length) { - path = PHP_EXTRA_INCLUDES.split(';'); - for (i = 0; i < path.length; i++) { - f = FSO.GetAbsolutePathName(path[i]); - if (FSO.FolderExists(f)) { - ADD_FLAG("CFLAGS", '/I "' + f + '" '); - } - } - } - if (PHP_EXTRA_LIBS.length) { - path = PHP_EXTRA_LIBS.split(';'); - for (i = 0; i < path.length; i++) { - f = FSO.GetAbsolutePathName(path[i]); - if (FSO.FolderExists(f)) { - if (VCVERS <= 1200 && f.indexOf(" ") >= 0) { - ADD_FLAG("LDFLAGS", '/libpath:"\\"' + f + '\\"" '); - } else { - ADD_FLAG("LDFLAGS", '/libpath:"' + f + '" '); - } - } - } - } - -} - probe_basic_headers(); add_extra_dirs(); @@ -147,7 +107,6 @@ STDOUT.WriteBlankLines(1); STDOUT.WriteLine("Build dir: " + get_define('BUILD_DIR')); STDOUT.WriteLine("PHP Core: " + get_define('PHPDLL') + " and " + get_define('PHPLIB')); - /* XXX inspect this for other toolsets */ if (VS_TOOLSET && VCVERS == 1200) { AC_DEFINE('ZEND_DVAL_TO_LVAL_CAST_OK', 1); diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 1c47ace175f..1aac59ea5f8 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -2708,3 +2708,43 @@ function php_build_option_handle() DEFINE("PHP_BUILD", PHP_PHP_BUILD); } +// Poke around for some headers +function probe_basic_headers() +{ + var p; + + if (PHP_PHP_BUILD != "no") { + php_usual_include_suspects += ";" + PHP_PHP_BUILD + "\\include"; + php_usual_lib_suspects += ";" + PHP_PHP_BUILD + "\\lib"; + } +} + +function add_extra_dirs() +{ + var path, i, f; + + if (PHP_EXTRA_INCLUDES.length) { + path = PHP_EXTRA_INCLUDES.split(';'); + for (i = 0; i < path.length; i++) { + f = FSO.GetAbsolutePathName(path[i]); + if (FSO.FolderExists(f)) { + ADD_FLAG("CFLAGS", '/I "' + f + '" '); + } + } + } + if (PHP_EXTRA_LIBS.length) { + path = PHP_EXTRA_LIBS.split(';'); + for (i = 0; i < path.length; i++) { + f = FSO.GetAbsolutePathName(path[i]); + if (FSO.FolderExists(f)) { + if (VS_TOOLSET && VCVERS <= 1200 && f.indexOf(" ") >= 0) { + ADD_FLAG("LDFLAGS", '/libpath:"\\"' + f + '\\"" '); + } else { + ADD_FLAG("LDFLAGS", '/libpath:"' + f + '" '); + } + } + } + } + +} + From 0e6c7c6165127b8966752433726cbafa92afc5d3 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 11 Nov 2014 20:16:13 +0100 Subject: [PATCH 304/398] fix datatype mismatch and unused var warning --- main/network.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main/network.c b/main/network.c index 9fd12854930..f44cad29a56 100644 --- a/main/network.c +++ b/main/network.c @@ -1126,17 +1126,19 @@ PHPAPI php_stream *_php_stream_sock_open_host(const char *host, unsigned short p PHPAPI int php_set_sock_blocking(php_socket_t socketd, int block TSRMLS_DC) { int ret = SUCCESS; - int flags; - int myflag = 0; #ifdef PHP_WIN32 + u_long flags; + /* with ioctlsocket, a non-zero sets nonblocking, a zero sets blocking */ flags = !block; if (ioctlsocket(socketd, FIONBIO, &flags) == SOCKET_ERROR) { ret = FAILURE; } #else - flags = fcntl(socketd, F_GETFL); + int myflag = 0; + int flags = fcntl(socketd, F_GETFL); + #ifdef O_NONBLOCK myflag = O_NONBLOCK; /* POSIX version */ #elif defined(O_NDELAY) From 1264731dd1dab4f10064190bbaee0f00d0b15b5e Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 11 Nov 2014 20:28:28 +0100 Subject: [PATCH 305/398] fix printf spec --- Zend/zend_alloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index cd8cc500005..588657d8b41 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -395,10 +395,10 @@ stderr_last_error(char *msg) MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&buf, 0, NULL)) { - fprintf(stderr, "\n%s: [0x%08x]\n", msg, err); + fprintf(stderr, "\n%s: [0x%08lx]\n", msg, err); } else { - fprintf(stderr, "\n%s: [0x%08x] %s\n", msg, err, buf); + fprintf(stderr, "\n%s: [0x%08lx] %s\n", msg, err, buf); } } #endif From db5ad4c51f5799a21a0b5bc46bbaac475b0910c6 Mon Sep 17 00:00:00 2001 From: Ferenc Kovacs Date: Wed, 12 Nov 2014 00:18:13 +0100 Subject: [PATCH 306/398] update NEWS --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 53d047215ff..b2d1a2699e0 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,10 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ???, PHP 5.4.35 +- Core: + . Fixed bug #68365 (zend_mm_heap corrupted after memory overflow in + zend_hash_copy). (Dmitry) + - Fileinfo: . Fixed bug #68283 (fileinfo: out-of-bounds read in elf note headers). (CVE-2014-3710) (Remi) From 791fc70025ce4af80dedc5034d91f5a4972b8231 Mon Sep 17 00:00:00 2001 From: Ferenc Kovacs Date: Wed, 12 Nov 2014 00:19:51 +0100 Subject: [PATCH 307/398] update NEWS --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 99a58662e7f..5a52d6afd5c 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,9 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2014, PHP 5.5.20 +- Core: + . Fixed bug #68365 (zend_mm_heap corrupted after memory overflow in + zend_hash_copy). (Dmitry) ?? ??? 2014, PHP 5.5.19 From a2e7b9162c83afbea33bb319ac9354a0b445c9a4 Mon Sep 17 00:00:00 2001 From: Ferenc Kovacs Date: Wed, 12 Nov 2014 00:21:04 +0100 Subject: [PATCH 308/398] update NEWS --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 376d7f350b9..7558645a4ab 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,8 @@ PHP NEWS . Fixed bug #68118 ($a->foo .= 'test'; can leave $a->foo undefined). (Nikita) . Fixed bug #68129 (parse_url() - incomplete support for empty usernames and passwords) (Tjerk) + . Fixed bug #68365 (zend_mm_heap corrupted after memory overflow in + zend_hash_copy). (Dmitry) - CURL: . Add CURL_SSLVERSION_TLSv1_0, CURL_SSLVERSION_TLSv1_1, and From 74d6c23b3988f72329387c866ec3294cdbc28213 Mon Sep 17 00:00:00 2001 From: Ferenc Kovacs Date: Wed, 12 Nov 2014 00:25:16 +0100 Subject: [PATCH 309/398] update NEWS --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 7558645a4ab..221e4e74804 100644 --- a/NEWS +++ b/NEWS @@ -4,7 +4,7 @@ PHP NEWS -?? ??? 2014, PHP 5.6.3 +13 Nov 2014, PHP 5.6.3 - Core: . Fixed bug #68370 ("unset($this)" can make the program crash). (Laruence) From 2323e95df92e8e11b0afde86e7a3b5055031bda8 Mon Sep 17 00:00:00 2001 From: Matteo Beccati Date: Sat, 1 Nov 2014 19:11:43 +0100 Subject: [PATCH 310/398] Fixed bug #66584 Segmentation fault on statement deallocation --- NEWS | 5 ++- ext/pdo_pgsql/pgsql_statement.c | 2 +- ext/pdo_pgsql/tests/bug66584.phpt | 66 +++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 ext/pdo_pgsql/tests/bug66584.phpt diff --git a/NEWS b/NEWS index b2d1a2699e0..2b9e544aad5 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -?? ??? ???, PHP 5.4.35 +13 Nov 2014 PHP 5.4.35 - Core: . Fixed bug #68365 (zend_mm_heap corrupted after memory overflow in @@ -14,6 +14,9 @@ PHP NEWS . Fixed bug #63595 (GMP memory management conflicts with other libraries using GMP). (Remi) +- PDO_pgsql: + . Fixed bug #66584 (Segmentation fault on statement deallocation) (Matteo) + 16 Oct 2014, PHP 5.4.34 - Fileinfo: diff --git a/ext/pdo_pgsql/pgsql_statement.c b/ext/pdo_pgsql/pgsql_statement.c index ea5a67633e6..1fa7ce4777a 100644 --- a/ext/pdo_pgsql/pgsql_statement.c +++ b/ext/pdo_pgsql/pgsql_statement.c @@ -294,7 +294,7 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data * sizeof(Oid)); } if (param->paramno >= 0) { - if (param->paramno > zend_hash_num_elements(stmt->bound_param_map)) { + if (param->paramno >= zend_hash_num_elements(stmt->bound_param_map)) { pdo_pgsql_error_stmt(stmt, PGRES_FATAL_ERROR, "HY105"); return 0; } diff --git a/ext/pdo_pgsql/tests/bug66584.phpt b/ext/pdo_pgsql/tests/bug66584.phpt new file mode 100644 index 00000000000..07742bca798 --- /dev/null +++ b/ext/pdo_pgsql/tests/bug66584.phpt @@ -0,0 +1,66 @@ +--TEST-- +PDO PgSQL Bug #66584 (Segmentation fault on statement deallocation) +--SKIPIF-- + +--FILE-- +setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + +$pdo->beginTransaction(); + +$pdo->query("CREATE TABLE b66584 (a int)"); +$pdo->query("INSERT INTO b66584 VALUES (165)"); + +for ($i = 1; $i >= 0; $i--) { + $pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, (bool)$i); + + try { + run($pdo, [0 => 1, 2 => 165, 5 => 3]); + } catch (\Exception $e) { + var_dump($e->getMessage()); + } + + try { + run($pdo, json_decode('{"0":234,"1":165,"2":221,"3":207,"4":188,"5":216,"6":1150,"7":916,"8":967,"9":987,"10":951,"11":990,"12":959,"13":896,"14":947,"15":877,"16":1000,"17":1023,"18":904,"19":856,"20":860,"21":866,"22":930,"23":974,"24":1032,"25":1016,"26":1050,"27":1059,"28":1040,"29":1064,"30":1004,"31":214,"32":189,"33":166,"34":1002,"35":167,"36":191,"37":859,"38":204,"39":181,"40":1001,"42":208,"43":198,"44":177,"45":1003,"46":858,"47":190,"48":162,"49":210,"50":171,"51":197,"52":168,"53":194,"54":209,"55":200,"56":192,"57":180,"58":232,"59":222,"60":163,"61":196,"62":217,"64":176,"65":193,"66":172,"67":195,"68":170,"69":173,"70":233,"71":223,"72":218,"73":186,"74":175,"75":224,"76":205,"77":211,"78":235,"79":1101,"80":225,"81":236,"82":1102,"83":1164,"84":1083,"85":1005,"86":861,"87":1179,"88":960,"89":991,"90":1187,"91":880,"92":1149,"93":1033,"94":931,"95":1006,"96":862,"97":1151,"98":917,"99":881,"100":1148,"101":1065,"102":867,"103":952,"104":1152,"105":918,"106":961,"107":1180,"108":992,"109":1188,"110":932,"111":933,"112":968,"113":868,"114":882,"115":1147,"116":1017,"117":1131,"118":1174,"119":1178,"120":1186,"121":869,"122":1051,"123":934,"124":969,"125":975,"126":1066,"127":237,"128":953,"129":1024,"130":1146,"131":883,"132":1145,"133":884,"134":885,"135":1144,"136":886,"137":1143,"138":1025,"139":897,"140":898,"141":899,"142":1026,"143":1142,"144":887,"145":1141,"146":888,"147":889,"148":1140,"149":1189,"150":993,"151":1139,"152":890,"153":1138,"154":891,"155":900,"156":892,"157":1137,"158":1027,"159":901,"160":1136,"161":893,"162":870,"163":1052,"164":954,"165":1041,"166":1018,"167":1165,"168":1084,"169":962,"170":1181,"171":994,"172":1190,"173":1042,"174":935,"175":226,"176":871,"177":1191,"178":995,"179":977,"180":948,"181":1175,"182":1053,"183":955,"184":1182,"185":963,"186":1067,"187":919,"188":1153,"189":920,"190":1154,"191":1055,"192":1054,"193":1056,"194":863,"195":872,"196":1028,"197":921,"198":1155,"199":936,"200":970,"201":1019,"202":1166,"203":1085,"204":1135,"205":894,"206":1034,"207":905,"208":873,"209":937,"210":902,"211":1029,"212":1007,"213":864,"214":1043,"215":1057,"216":956,"217":957,"218":939,"219":1086,"220":1167,"221":1087,"222":1168,"223":1173,"224":1108,"225":978,"226":1044,"227":1183,"228":964,"229":965,"230":1184,"231":1045,"232":874,"233":940,"234":1046,"235":979,"236":903,"237":980,"238":1156,"239":922,"240":1035,"241":906,"242":971,"243":972,"244":878,"245":1134,"246":879,"247":1133,"248":907,"249":1036,"250":908,"251":1132,"252":895,"253":909,"254":1060,"255":981,"256":1068,"257":996,"258":1192,"259":941,"260":865,"261":1008,"262":910,"263":997,"264":1193,"265":982,"266":942,"267":1020,"268":983,"269":1061,"270":949,"271":1176,"272":875,"273":911,"274":1069,"275":1157,"276":923,"277":1158,"278":924,"279":988,"280":984,"281":925,"282":1159,"283":1062,"284":1047,"285":1194,"286":998,"287":1021,"288":1030,"289":1031,"290":1070,"291":1088,"292":1169,"293":958,"294":1195,"295":999,"296":966,"297":1185,"298":944,"299":945,"300":1022,"301":1103,"302":220,"303":1099,"304":1048,"305":927,"306":1161,"307":989,"308":973,"309":1071,"310":1074,"311":1072,"312":1073,"313":912,"314":1037,"315":913,"316":914,"317":1177,"318":950,"319":1049,"320":876,"321":985,"322":915,"323":1038,"324":946,"325":1089,"326":1170,"327":1090,"328":1171,"329":1091,"330":1172,"331":1063,"332":986,"333":928,"334":1162,"335":929,"336":1163,"337":976,"338":231,"339":201,"340":1098,"341":215}', true)); + } catch (\Exception $e) { + var_dump($e->getMessage()); + } +} + +try { + $pdo->query("DROP TABLE b66584"); + $pdo->rollback(); +} catch (\Exception $e) { +} + +function run($pdo, $data) +{ + $bind = join(', ', array_fill(0, count($data), '?')); + + $stmt = $pdo->prepare("SELECT COUNT(*) FROM b66584 WHERE a IN ({$bind})"); + + var_dump(count($data)); + + $stmt->execute($data); + + var_dump($stmt->fetchColumn()); +} + +?> +--EXPECTF-- +int(3) +string(%d) "SQLSTATE%s" +int(340) +string(%d) "SQLSTATE%s" +int(3) +string(%d) "SQLSTATE%s" +int(340) +string(%d) "SQLSTATE%s" From 98b22864ff697b84e29c270c187fb316acf8e478 Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Tue, 11 Nov 2014 16:31:38 -0800 Subject: [PATCH 311/398] 5.4.36-dev --- NEWS | 2 ++ configure.in | 2 +- main/php_version.h | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 2b9e544aad5..7ea06aa7b65 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,7 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +?? ??? 20?? PHP 5.4.36 + 13 Nov 2014 PHP 5.4.35 - Core: diff --git a/configure.in b/configure.in index 91ae7fce918..8a14b49805c 100644 --- a/configure.in +++ b/configure.in @@ -119,7 +119,7 @@ int zend_sprintf(char *buffer, const char *format, ...); PHP_MAJOR_VERSION=5 PHP_MINOR_VERSION=4 -PHP_RELEASE_VERSION=35 +PHP_RELEASE_VERSION=36 PHP_EXTRA_VERSION="-dev" PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION" PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION` diff --git a/main/php_version.h b/main/php_version.h index a3e2cfc31f0..a36ea89436e 100644 --- a/main/php_version.h +++ b/main/php_version.h @@ -2,8 +2,8 @@ /* edit configure.in to change version number */ #define PHP_MAJOR_VERSION 5 #define PHP_MINOR_VERSION 4 -#define PHP_RELEASE_VERSION 35 +#define PHP_RELEASE_VERSION 36 #define PHP_EXTRA_VERSION "-dev" -#define PHP_VERSION "5.4.35-dev" -#define PHP_VERSION_ID 50435 +#define PHP_VERSION "5.4.36-dev" +#define PHP_VERSION_ID 50436 From 4571cc2195dfba340c39952fa3cbb545c5d41f0e Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Tue, 4 Nov 2014 21:48:44 -0800 Subject: [PATCH 312/398] fix copypaste error --- ext/standard/html.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/standard/html.c b/ext/standard/html.c index fd210c8086b..1d6eaa4c5c0 100644 --- a/ext/standard/html.c +++ b/ext/standard/html.c @@ -395,7 +395,7 @@ static enum entity_charset determine_charset(char *charset_hint TSRMLS_DC) if ((len == 4) /* sizeof (none|auto|pass) */ && (!memcmp("pass", charset_hint, 4) || !memcmp("auto", charset_hint, 4) || - !memcmp("auto", charset_hint, 4))) { + !memcmp("none", charset_hint, 4))) { charset_hint = NULL; len = 0; } else { From 1b143f4033d65141cdfc0615bd7e95d4b88b3f6f Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Tue, 4 Nov 2014 21:58:44 -0800 Subject: [PATCH 313/398] fix loop - size_t is unsigned so can not be negative --- ext/standard/ftp_fopen_wrapper.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c index d6eb3b8fbcc..ab75da713c7 100644 --- a/ext/standard/ftp_fopen_wrapper.c +++ b/ext/standard/ftp_fopen_wrapper.c @@ -644,11 +644,10 @@ static size_t php_ftp_dirstream_read(php_stream *stream, char *buf, size_t count efree(basename); /* Trim off trailing whitespace characters */ - tmp_len--; - while (tmp_len >= 0 && - (ent->d_name[tmp_len] == '\n' || ent->d_name[tmp_len] == '\r' || - ent->d_name[tmp_len] == '\t' || ent->d_name[tmp_len] == ' ')) { - ent->d_name[tmp_len--] = '\0'; + while (tmp_len > 0 && + (ent->d_name[tmp_len - 1] == '\n' || ent->d_name[tmp_len - 1] == '\r' || + ent->d_name[tmp_len - 1] == '\t' || ent->d_name[tmp_len - 1] == ' ')) { + ent->d_name[--tmp_len] = '\0'; } return sizeof(php_stream_dirent); From 32fd4590a5b9572e90548ce3d251defc3f6c4421 Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Tue, 4 Nov 2014 21:58:44 -0800 Subject: [PATCH 314/398] fix loop - size_t is unsigned so can not be negative --- ext/standard/ftp_fopen_wrapper.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c index ed93345bacd..01522bc7a9a 100644 --- a/ext/standard/ftp_fopen_wrapper.c +++ b/ext/standard/ftp_fopen_wrapper.c @@ -635,11 +635,10 @@ static size_t php_ftp_dirstream_read(php_stream *stream, char *buf, size_t count zend_string_release(basename); /* Trim off trailing whitespace characters */ - tmp_len--; while (tmp_len > 0 && - (ent->d_name[tmp_len] == '\n' || ent->d_name[tmp_len] == '\r' || - ent->d_name[tmp_len] == '\t' || ent->d_name[tmp_len] == ' ')) { - ent->d_name[tmp_len--] = '\0'; + (ent->d_name[tmp_len - 1] == '\n' || ent->d_name[tmp_len - 1] == '\r' || + ent->d_name[tmp_len - 1] == '\t' || ent->d_name[tmp_len - 1] == ' ')) { + ent->d_name[--tmp_len] = '\0'; } return sizeof(php_stream_dirent); From 9e072d9565425c306800354e4723b340578f6ca1 Mon Sep 17 00:00:00 2001 From: Yasuo Ohgaki Date: Wed, 12 Nov 2014 13:40:27 +0900 Subject: [PATCH 315/398] Remove unneeded md5 hashing from PHP-5.6 branch. It's removed from master already by my previous commit. --- ext/session/session.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/ext/session/session.c b/ext/session/session.c index edc8f15d5bd..d561c558b07 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -538,13 +538,6 @@ static void php_session_save_current_state(TSRMLS_D) /* {{{ */ val = php_session_encode(&vallen TSRMLS_CC); if (val) { - PHP_MD5_CTX context; - unsigned char digest[16]; - - /* Generate data's MD5 hash */ - PHP_MD5Init(&context); - PHP_MD5Update(&context, val, vallen); - PHP_MD5Final(digest, &context); ret = PS(mod)->s_write(&PS(mod_data), PS(id), val, vallen TSRMLS_CC); efree(val); } else { From 14d3e173aa08765de2a053dd267c5beba8b872c9 Mon Sep 17 00:00:00 2001 From: Julien Pauli Date: Wed, 12 Nov 2014 10:59:54 +0100 Subject: [PATCH 316/398] Fixed wrong NEWS --- NEWS | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 5a52d6afd5c..6c5cbe9cdf5 100644 --- a/NEWS +++ b/NEWS @@ -3,18 +3,18 @@ PHP NEWS ?? ??? 2014, PHP 5.5.20 - Core: - . Fixed bug #68365 (zend_mm_heap corrupted after memory overflow in - zend_hash_copy). (Dmitry) + . Fixed bug #68370 ("unset($this)" can make the program crash). (Laruence) -?? ??? 2014, PHP 5.5.19 +13 Nov 2014, PHP 5.5.19 - Core: - . Fixed bug #68370 ("unset($this)" can make the program crash). (Laruence) . Fixed bug #68095 (AddressSanitizer reports a heap buffer overflow in php_getopt()). (Stas) . Fixed bug #68118 ($a->foo .= 'test'; can leave $a->foo undefined). (Nikita) . Fixed bug #68129 (parse_url() - incomplete support for empty usernames and passwords) (Tjerk) + . Fixed bug #68365 (zend_mm_heap corrupted after memory overflow in + zend_hash_copy). (Dmitry) - CURL: . Add CURL_SSLVERSION_TLSv1_0, CURL_SSLVERSION_TLSv1_1, and From 65fee904622160781db05b0a469d67b4414cbd7f Mon Sep 17 00:00:00 2001 From: Matteo Beccati Date: Wed, 12 Nov 2014 11:21:11 +0100 Subject: [PATCH 317/398] Fixed bug #53829 Compiling PHP with large file support will replace function gzopen by gzopen64 --- NEWS | 4 ++++ ext/zlib/zlib.c | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/NEWS b/NEWS index 6c5cbe9cdf5..fa1ec8a3abd 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,10 @@ PHP NEWS - Core: . Fixed bug #68370 ("unset($this)" can make the program crash). (Laruence) +- zlib: + . Fixed bug #53829 (Compiling PHP with large file support will replace + function gzopen by gzopen64) (Sascha Kettler, Matteo) + 13 Nov 2014, PHP 5.5.19 - Core: diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 705fb5dd5f6..25804597bcb 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -34,6 +34,18 @@ #include "ext/standard/php_string.h" #include "php_zlib.h" +/* + * zlib include files can define the following preprocessor defines which rename + * the corresponding PHP functions to gzopen64, gzseek64 and gztell64 and thereby + * breaking some software, most notably PEAR's Archive_Tar, which halts execution + * without error message on gzip compressed archivesa. + * + * This only seems to happen on 32bit systems with large file support. + */ +#undef gzopen +#undef gzseek +#undef gztell + ZEND_DECLARE_MODULE_GLOBALS(zlib); /* {{{ Memory management wrappers */ From 5f15d6f0d8b352feebc96a6f5a96c016324016d0 Mon Sep 17 00:00:00 2001 From: Ferenc Kovacs Date: Wed, 12 Nov 2014 14:28:45 +0100 Subject: [PATCH 318/398] update NEWS --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index 02445078579..233b07eeb44 100644 --- a/NEWS +++ b/NEWS @@ -72,6 +72,7 @@ PHP NEWS - PDO_pgsql: . Fixed bug #68199 (PDO::pgsqlGetNotify doesn't support NOTIFY payloads) (Matteo, Alain Laporte) + . Fixed bug #66584 (Segmentation fault on statement deallocation) (Matteo) - Reflection: . Fixed bug #68103 (Duplicate entry in Reflection for class alias). (Remi) From fea84a1c9cd8db8781c6b4da6c749f0e018307cb Mon Sep 17 00:00:00 2001 From: Ferenc Kovacs Date: Wed, 12 Nov 2014 14:45:39 +0100 Subject: [PATCH 319/398] update NEWS --- NEWS | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/NEWS b/NEWS index 233b07eeb44..ec0c2e613f2 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,19 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2014, PHP 5.6.4 +- Core: + . Fixed bug #68370 ("unset($this)" can make the program crash). (Laruence) + . Fixed bug #68104 (Segfault while pre-evaluating a disabled function). + (Laruence) + +- Session: + . Fixed bug #68331 (Session custom storage callable functions not being called) + (Yasuo Ohgaki) + +- SOAP: + . Fixed bug #68361 (Segmentation fault on SoapClient::__getTypes). + (Laruence) + - zlib: . Fixed bug #53829 (Compiling PHP with large file support will replace function gzopen by gzopen64) (Sascha Kettler, Matteo) @@ -9,9 +22,6 @@ PHP NEWS 13 Nov 2014, PHP 5.6.3 - Core: - . Fixed bug #68370 ("unset($this)" can make the program crash). (Laruence) - . Fixed bug #68104 (Segfault while pre-evaluating a disabled function). - (Laruence) . Implemented 64-bit format codes for pack() and unpack(). (Leigh) . Fixed bug #51800 (proc_open on Windows hangs forever). (Anatol) . Fixed bug #67633 (A foreach on an array returned from a function not doing @@ -57,14 +67,14 @@ PHP NEWS . Fixed bug #68114 (linker error on some OS X machines with fixed width decimal support) (Keyur Govande) -- OpenSSL: - . Fixed bug #68074 (Allow to use system cipher list instead of hardcoded - value). (Remi) - - ODBC: . Fixed bug #68087 (ODBC not correctly reading DATE column when preceded by a VARCHAR column) (Keyur Govande) +- OpenSSL: + . Fixed bug #68074 (Allow to use system cipher list instead of hardcoded + value). (Remi) + - phpdbg: . Added XML protocol (-x command line flag). (Bob) . Added hard interruptions (twice SIGINT). (Bob) @@ -77,14 +87,6 @@ PHP NEWS - Reflection: . Fixed bug #68103 (Duplicate entry in Reflection for class alias). (Remi) -- Session: - . Fixed bug #68331 (Session custom storage callable functions not being called) - (Yasuo Ohgaki) - -- SOAP: - . Fixed bug #68361 (Segmentation fault on SoapClient::__getTypes). - (Laruence) - - SPL: . Fixed bug #68128 (Regression in RecursiveRegexIterator) (Tjerk) From 00e763f4990165088ace819f935c40166bfd095e Mon Sep 17 00:00:00 2001 From: Ferenc Kovacs Date: Wed, 12 Nov 2014 14:51:18 +0100 Subject: [PATCH 320/398] update NEWS --- NEWS | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index ec0c2e613f2..c96a562102a 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,10 @@ PHP NEWS . Fixed bug #68104 (Segfault while pre-evaluating a disabled function). (Laruence) +- phpdbg: + . Added XML protocol (-x command line flag). (Bob) + . Added hard interruptions (twice SIGINT). (Bob) + - Session: . Fixed bug #68331 (Session custom storage callable functions not being called) (Yasuo Ohgaki) @@ -75,10 +79,6 @@ PHP NEWS . Fixed bug #68074 (Allow to use system cipher list instead of hardcoded value). (Remi) -- phpdbg: - . Added XML protocol (-x command line flag). (Bob) - . Added hard interruptions (twice SIGINT). (Bob) - - PDO_pgsql: . Fixed bug #68199 (PDO::pgsqlGetNotify doesn't support NOTIFY payloads) (Matteo, Alain Laporte) From faaea4f304cd6693e5f76c5a5d64d46e24326806 Mon Sep 17 00:00:00 2001 From: Matteo Beccati Date: Wed, 12 Nov 2014 16:45:36 +0100 Subject: [PATCH 321/398] Fixed NEWS Some entries had been mistakenly removed in ad468d20b130c720020139b8d5f6601f6f3033ab --- NEWS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/NEWS b/NEWS index fa1ec8a3abd..83448f76cae 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,13 @@ PHP NEWS - Core: . Fixed bug #68370 ("unset($this)" can make the program crash). (Laruence) +- PDO_pgsql: + . Fixed bug #66584 (Segmentation fault on statement deallocation) (Matteo) + . Fixed bug #67462 (PDO_PGSQL::beginTransaction() wrongly throws exception + when not in transaction) (Matteo) + . Fixed bug #68351 (PDO::PARAM_BOOL and ATTR_EMULATE_PREPARES misbehaving) + (Matteo) + - zlib: . Fixed bug #53829 (Compiling PHP with large file support will replace function gzopen by gzopen64) (Sascha Kettler, Matteo) From 54868c84cebec2176208319ebbdbc92b4d7ff5a3 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 12 Nov 2014 11:00:35 +0100 Subject: [PATCH 322/398] fix int to void* cast on x64 --- sapi/cgi/fastcgi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sapi/cgi/fastcgi.c b/sapi/cgi/fastcgi.c index 0cd3096e4d3..7c50ef22706 100644 --- a/sapi/cgi/fastcgi.c +++ b/sapi/cgi/fastcgi.c @@ -435,7 +435,9 @@ int fcgi_init(void) str = getenv("_FCGI_SHUTDOWN_EVENT_"); if (str != NULL) { - HANDLE shutdown_event = (HANDLE) atoi(str); + zend_long ev; + ZEND_ATOL(ev, str); + HANDLE shutdown_event = (HANDLE) ev; if (!CreateThread(NULL, 0, fcgi_shutdown_thread, shutdown_event, 0, NULL)) { return -1; @@ -443,7 +445,9 @@ int fcgi_init(void) } str = getenv("_FCGI_MUTEX_"); if (str != NULL) { - fcgi_accept_mutex = (HANDLE) atoi(str); + zend_long mt; + ZEND_ATOL(mt, str); + fcgi_accept_mutex = (HANDLE) mt; } return is_fastcgi = 1; } else { From 79c61c71c2a75e8fd41e5994f3ee774070d02bdd Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 12 Nov 2014 11:14:56 +0100 Subject: [PATCH 323/398] generalize arch setup --- win32/build/config.w32 | 8 +------- win32/build/config.w32.phpize.in | 8 +------- win32/build/confutils.js | 11 +++++++++++ 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 65c273a5bc0..748631dddeb 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -14,13 +14,7 @@ toolset_setup_compiler(); // do we use x64 or 80x86 version of compiler? X64 = toolset_is_64(); -if (X64) { - STDOUT.WriteLine(" Detected 64-bit compiler"); -} else { - STDOUT.WriteLine(" Detected 32-bit compiler"); -} -AC_DEFINE('ARCHITECTURE', X64 ? 'x64' : 'x86', "Detected compiler architecture"); -DEFINE("PHP_ARCHITECTURE", X64 ? 'x64' : 'x86'); +toolset_setup_arch(); toolset_setup_linker(); toolset_setup_project_tools(); diff --git a/win32/build/config.w32.phpize.in b/win32/build/config.w32.phpize.in index 8b831f0b10d..6a33dc20362 100644 --- a/win32/build/config.w32.phpize.in +++ b/win32/build/config.w32.phpize.in @@ -14,13 +14,7 @@ toolset_setup_compiler(); // do we use x64 or 80x86 version of compiler? X64 = toolset_is_64(); -if (X64) { - STDOUT.WriteLine(" Detected 64-bit compiler"); -} else { - STDOUT.WriteLine(" Detected 32-bit compiler"); -} -AC_DEFINE('ARCHITECTURE', X64 ? 'x64' : 'x86', "Detected compiler architecture"); -DEFINE("PHP_ARCHITECTURE", X64 ? 'x64' : 'x86'); +toolset_setup_arch(); toolset_setup_linker(); toolset_setup_project_tools(); diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 1aac59ea5f8..94068bfa9d4 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -2502,6 +2502,17 @@ function toolset_is_64() ERROR("Unsupported toolset"); } +function toolset_setup_arch() +{ + if (X64) { + STDOUT.WriteLine(" Detected 64-bit compiler"); + } else { + STDOUT.WriteLine(" Detected 32-bit compiler"); + } + AC_DEFINE('ARCHITECTURE', X64 ? 'x64' : 'x86', "Detected compiler architecture"); + DEFINE("PHP_ARCHITECTURE", X64 ? 'x64' : 'x86'); +} + function toolset_setup_linker() { From 1acbcdeb27abefa1a6966a8d791fa2707931b79f Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 12 Nov 2014 17:05:01 +0100 Subject: [PATCH 324/398] generate response files for use by linker Object dir path can under circumstances cause that the expanded command line exceeds the length allowed by the OS. Linker can read the object lists from a file which eliminates this issue. --- win32/build/Makefile | 2 +- win32/build/confutils.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/win32/build/Makefile b/win32/build/Makefile index d6a22c162c6..c24bd70ba6c 100644 --- a/win32/build/Makefile +++ b/win32/build/Makefile @@ -90,7 +90,7 @@ $(PHPDLL_RES): win32\build\template.rc $(BUILD_DIR)\$(PHPDLL): generated_files $(PHPDEF) $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(PHPDLL_RES) $(MCFILE) # @$(CC) $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(STATIC_EXT_LIBS) $(LIBS) $(PHPDLL_RES) /link /out:$(BUILD_DIR)\$(PHPDLL) $(PHP7_PGD_OPTION) $(PHP_LDFLAGS) $(LDFLAGS) $(STATIC_EXT_LDFLAGS) - @"$(LINK)" $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(STATIC_EXT_LIBS) $(LIBS) $(PHPDLL_RES) /out:$(BUILD_DIR)\$(PHPDLL) $(PHP7_PGD_OPTION) $(PHP_LDFLAGS) $(LDFLAGS) $(STATIC_EXT_LDFLAGS) + @"$(LINK)" $(PHP_GLOBAL_OBJS_RESP) $(STATIC_EXT_OBJS_RESP) $(STATIC_EXT_LIBS) $(LIBS) $(PHPDLL_RES) /out:$(BUILD_DIR)\$(PHPDLL) $(PHP7_PGD_OPTION) $(PHP_LDFLAGS) $(LDFLAGS) $(STATIC_EXT_LDFLAGS) -@$(_VC_MANIFEST_EMBED_DLL) $(BUILD_DIR)\$(PHPLIB): $(BUILD_DIR)\$(PHPDLL) diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 94068bfa9d4..201c368a3a2 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -1336,6 +1336,7 @@ function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir) DEFINE('CFLAGS_' + EXT + '_OBJ', '$(CFLAGS_' + EXT + ')'); } else { ADD_FLAG("STATIC_EXT_OBJS", "$(" + EXT + "_GLOBAL_OBJS)"); + ADD_FLAG("STATIC_EXT_OBJS_RESP", "$(" + EXT + "_GLOBAL_OBJS_RESP)"); ADD_FLAG("STATIC_EXT_LIBS", "$(LIBS_" + EXT + ")"); ADD_FLAG("STATIC_EXT_LDFLAGS", "$(LDFLAGS_" + EXT + ")"); ADD_FLAG("STATIC_EXT_CFLAGS", "$(CFLAGS_" + EXT + ")"); @@ -1394,9 +1395,20 @@ function ADD_SOURCES(dir, file_list, target, obj_dir) sym = target.toUpperCase() + "_GLOBAL_OBJS"; flags = "CFLAGS_" + target.toUpperCase() + '_OBJ'; + var bd = get_define('BUILD_DIR'); + var respd = bd + '\\resp'; + if (!FSO.FolderExists(respd)) { + FSO.CreateFolder(respd); + } + var obj_lst_fn = respd + '\\' + sym + '.txt'; + var resp = ""; + if (configure_subst.Exists(sym)) { tv = configure_subst.Item(sym); } else { + if (FSO.FileExists(obj_lst_fn)) { + FSO.DeleteFile(obj_lst_fn, true); + } tv = ""; } @@ -1448,6 +1460,7 @@ function ADD_SOURCES(dir, file_list, target, obj_dir) src = file_list[i]; obj = src.replace(re, ".obj"); tv += " " + sub_build + obj; + resp += " " + sub_build.replace('$(BUILD_DIR)', bd) + obj; if (!PHP_MP_DISABLED) { if (i > 0) { @@ -1474,6 +1487,21 @@ function ADD_SOURCES(dir, file_list, target, obj_dir) } DEFINE(sym, tv); + + /* Generate the response file and define it to the Makefile. This can be + useful when getting the "command line too long" linker errors. */ + var obj_lst_fh = null; + if (!FSO.FileExists(obj_lst_fn)) { + obj_lst_fh = FSO.CreateTextFile(obj_lst_fn); + //STDOUT.WriteLine("Creating " + obj_lst_fn); + } else { + //STDOUT.WriteLine("Appending to " + obj_lst_fn); + obj_lst_fh = FSO.OpenTextFile(obj_lst_fn, 8); + } + + obj_lst_fh.Write(" " + resp); + obj_lst_fh.Close(); + DEFINE(sym + "_RESP", '@"' + obj_lst_fn + '"'); } function REMOVE_TARGET(dllname, flag) From 988112a2e186cbef70b4b347db7def1c7f48cce6 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 12 Nov 2014 17:16:09 +0100 Subject: [PATCH 325/398] use response files for exts and sapi linking --- win32/build/confutils.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 201c368a3a2..80a54163733 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -1120,17 +1120,17 @@ function SAPI(sapiname, file_list, makefiletarget, cflags, obj_dir) if (MODE_PHPIZE) { if (ld) { - MFO.WriteLine("\t" + ld + " /nologo /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(" + SAPI + "_GLOBAL_OBJS) $(PHPLIB) $(LDFLAGS_" + SAPI + ") $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname); + MFO.WriteLine("\t" + ld + " /nologo /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(" + SAPI + "_GLOBAL_OBJS_RESP) $(PHPLIB) $(LDFLAGS_" + SAPI + ") $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname); } else { ld = '@"$(LINK)"'; - MFO.WriteLine("\t" + ld + " /nologo " + " $(" + SAPI + "_GLOBAL_OBJS) $(PHPLIB) $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname + " /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(LDFLAGS_" + SAPI + ")"); + MFO.WriteLine("\t" + ld + " /nologo " + " $(" + SAPI + "_GLOBAL_OBJS_RESP) $(PHPLIB) $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname + " /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(LDFLAGS_" + SAPI + ")"); } } else { if (ld) { - MFO.WriteLine("\t" + ld + " /nologo /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(" + SAPI + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LDFLAGS_" + SAPI + ") $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname); + MFO.WriteLine("\t" + ld + " /nologo /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(" + SAPI + "_GLOBAL_OBJS_RESP) $(BUILD_DIR)\\$(PHPLIB) $(LDFLAGS_" + SAPI + ") $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname); } else { ld = '@"$(LINK)"'; - MFO.WriteLine("\t" + ld + " /nologo " + " $(" + SAPI + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname + " /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(LDFLAGS_" + SAPI + ")"); + MFO.WriteLine("\t" + ld + " /nologo " + " $(" + SAPI + "_GLOBAL_OBJS_RESP) $(BUILD_DIR)\\$(PHPLIB) $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname + " /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(LDFLAGS_" + SAPI + ")"); } } @@ -1316,10 +1316,10 @@ function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir) MFO.WriteBlankLines(1); if (MODE_PHPIZE) { MFO.WriteLine("$(BUILD_DIR)\\" + dllname + ": $(DEPS_" + EXT + ") $(" + EXT + "_GLOBAL_OBJS) $(PHPLIB) $(BUILD_DIR)\\" + resname); - MFO.WriteLine("\t" + ld + " $(" + EXT + "_GLOBAL_OBJS) $(PHPLIB) $(LIBS_" + EXT + ") $(LIBS) $(BUILD_DIR)\\" + resname + " /out:$(BUILD_DIR)\\" + dllname + " $(DLL_LDFLAGS) $(LDFLAGS) $(LDFLAGS_" + EXT + ")"); + MFO.WriteLine("\t" + ld + " $(" + EXT + "_GLOBAL_OBJS_RESP) $(PHPLIB) $(LIBS_" + EXT + ") $(LIBS) $(BUILD_DIR)\\" + resname + " /out:$(BUILD_DIR)\\" + dllname + " $(DLL_LDFLAGS) $(LDFLAGS) $(LDFLAGS_" + EXT + ")"); } else { MFO.WriteLine("$(BUILD_DIR)\\" + dllname + ": $(DEPS_" + EXT + ") $(" + EXT + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(BUILD_DIR)\\" + resname); - MFO.WriteLine("\t" + ld + " $(" + EXT + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LIBS_" + EXT + ") $(LIBS) $(BUILD_DIR)\\" + resname + " /out:$(BUILD_DIR)\\" + dllname + ldflags + " $(DLL_LDFLAGS) $(LDFLAGS) $(LDFLAGS_" + EXT + ")"); + MFO.WriteLine("\t" + ld + " $(" + EXT + "_GLOBAL_OBJS_RESP) $(BUILD_DIR)\\$(PHPLIB) $(LIBS_" + EXT + ") $(LIBS) $(BUILD_DIR)\\" + resname + " /out:$(BUILD_DIR)\\" + dllname + ldflags + " $(DLL_LDFLAGS) $(LDFLAGS) $(LDFLAGS_" + EXT + ")"); } MFO.WriteLine("\t-@$(_VC_MANIFEST_EMBED_DLL)"); MFO.WriteBlankLines(1); From 15f419a635997e820a8da9d46ded10b38fde3739 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 12 Nov 2014 17:23:06 +0100 Subject: [PATCH 326/398] trim when adding flags, avoid multiple spaces --- win32/build/confutils.js | 1 + 1 file changed, 1 insertion(+) diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 80a54163733..181230f4ba0 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -2066,6 +2066,7 @@ function ADD_FLAG(name, flags, target) if (target != null) { name = target.toUpperCase() + "_" + name; } + flags = flags.replace(/^\s+/, "").replace(/\s+$/, ""); if (configure_subst.Exists(name)) { var curr_flags = configure_subst.Item(name); From f00cf67d1ecee9042b4c53a64d2c9fbe50f0ca31 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 12 Nov 2014 17:30:52 +0100 Subject: [PATCH 327/398] C89 compat --- sapi/cgi/fastcgi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sapi/cgi/fastcgi.c b/sapi/cgi/fastcgi.c index 7c50ef22706..7925f87562b 100644 --- a/sapi/cgi/fastcgi.c +++ b/sapi/cgi/fastcgi.c @@ -436,8 +436,10 @@ int fcgi_init(void) str = getenv("_FCGI_SHUTDOWN_EVENT_"); if (str != NULL) { zend_long ev; + HANDLE shutdown_event; + ZEND_ATOL(ev, str); - HANDLE shutdown_event = (HANDLE) ev; + shutdown_event = (HANDLE) ev; if (!CreateThread(NULL, 0, fcgi_shutdown_thread, shutdown_event, 0, NULL)) { return -1; From d7a00464686b5f4009a2248e9b010737c19cb13a Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 12 Nov 2014 17:56:47 +0100 Subject: [PATCH 328/398] fix test cleanup --- ext/pgsql/tests/80_bug36625.phpt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ext/pgsql/tests/80_bug36625.phpt b/ext/pgsql/tests/80_bug36625.phpt index e1b7fa1b507..87dd84adc48 100644 --- a/ext/pgsql/tests/80_bug36625.phpt +++ b/ext/pgsql/tests/80_bug36625.phpt @@ -42,7 +42,13 @@ var_dump(file_exists($tracefile)); ?> ===DONE=== --CLEAN-- - + --EXPECTF-- bool(false) resource(%d) of type (pgsql result) From 29b28f7ce617c41be09db6f40fdc26e782bb882e Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 12 Nov 2014 18:05:24 +0100 Subject: [PATCH 329/398] fix test cleanup this could leave garbage after it as the test file is removed in flush (the fd could still be opened) --- Zend/tests/bug38779_1.phpt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Zend/tests/bug38779_1.phpt b/Zend/tests/bug38779_1.phpt index eefa952e366..e2a5b208c6c 100644 --- a/Zend/tests/bug38779_1.phpt +++ b/Zend/tests/bug38779_1.phpt @@ -39,6 +39,14 @@ include $filename; echo "Done\n"; ?> +--CLEAN-- + --EXPECTF-- Parse error: %s error%sin %s on line %d string(6) "flush!" From 4d7a21d0f25da3258672a24cbe109cde00830320 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 12 Nov 2014 19:06:09 +0100 Subject: [PATCH 330/398] pre create the build dir otherwise response file generation might fail --- win32/build/confutils.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 181230f4ba0..7489e052f8b 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -2717,6 +2717,10 @@ function setup_zts_stuff() DEFINE("PHPLIB", "php" + PHP_VERSION + ".lib"); } } + + if (!FSO.FolderExists(get_define('BUILD_DIR'))) { + FSO.CreateFolder(get_define('BUILD_DIR')); + } } function php_build_option_handle() From 39913c4cdf54f926d733bfe0a95be2ecfa6bff35 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Thu, 13 Nov 2014 12:20:16 +0800 Subject: [PATCH 331/398] Fixed test fails (prop read always has a IS_STRING member now) --- ext/pdo/pdo_stmt.c | 120 +++++++++++++++++++++++++++------------------ 1 file changed, 73 insertions(+), 47 deletions(-) diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 705d08bacf5..8f68aef8abd 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -2480,37 +2480,47 @@ const zend_function_entry pdo_row_functions[] = { {NULL, NULL, NULL} }; -static zval *row_prop_read(zval *object, zval *member, int type, void **cache_slot, zval *rv TSRMLS_DC) +static zend_always_inline zval *row_prop_read_impl(zval *object, zval *member, int type, void **cache_slot, zval *rv, int dim_access TSRMLS_DC) { pdo_row_t *row = (pdo_row_t *)Z_OBJ_P(object); pdo_stmt_t *stmt = row->stmt; int colno = -1; zval zobj; + zend_long lval; ZVAL_NULL(rv); if (stmt) { - if (Z_TYPE_P(member) == IS_LONG) { - if (Z_LVAL_P(member) >= 0 && Z_LVAL_P(member) < stmt->column_count) { - fetch_value(stmt, rv, Z_LVAL_P(member), NULL TSRMLS_CC); - } - } else { - convert_to_string(member); - /* TODO: replace this with a hash of available column names to column - * numbers */ - for (colno = 0; colno < stmt->column_count; colno++) { - if (strcmp(stmt->columns[colno].name, Z_STRVAL_P(member)) == 0) { - fetch_value(stmt, rv, colno, NULL TSRMLS_CC); - //??? - //Z_SET_REFCOUNT_P(rv, 0); - //Z_UNSET_ISREF_P(rv); - return rv; + if (dim_access) { + if (Z_TYPE_P(member) == IS_LONG) { + if (Z_LVAL_P(member) >= 0 && Z_LVAL_P(member) < stmt->column_count) { + fetch_value(stmt, rv, Z_LVAL_P(member), NULL TSRMLS_CC); } + return rv; } - if (strcmp(Z_STRVAL_P(member), "queryString") == 0) { - ZVAL_OBJ(&zobj, &stmt->std); - //zval_ptr_dtor(rv); - return std_object_handlers.read_property(&zobj, member, type, cache_slot, rv TSRMLS_CC); + convert_to_string(member); + } else { + if (is_numeric_string_ex(Z_STRVAL_P(member), Z_STRLEN_P(member), &lval, NULL, 0, NULL) == IS_LONG) { + if (lval >= 0 && lval < stmt->column_count) { + fetch_value(stmt, rv, lval, NULL TSRMLS_CC); + } + return rv; } + } + /* TODO: replace this with a hash of available column names to column + * numbers */ + for (colno = 0; colno < stmt->column_count; colno++) { + if (strcmp(stmt->columns[colno].name, Z_STRVAL_P(member)) == 0) { + fetch_value(stmt, rv, colno, NULL TSRMLS_CC); + //??? + //Z_SET_REFCOUNT_P(rv, 0); + //Z_UNSET_ISREF_P(rv); + return rv; + } + } + if (strcmp(Z_STRVAL_P(member), "queryString") == 0) { + ZVAL_OBJ(&zobj, &stmt->std); + //zval_ptr_dtor(rv); + return std_object_handlers.read_property(&zobj, member, type, cache_slot, rv TSRMLS_CC); } } @@ -2521,9 +2531,50 @@ static zval *row_prop_read(zval *object, zval *member, int type, void **cache_sl return rv; } +static zend_always_inline int row_prop_exists_impl(zval *object, zval *member, int check_empty, void **cache_slot, int dim_access TSRMLS_DC) +{ + pdo_row_t *row = (pdo_row_t *)Z_OBJ_P(object); + pdo_stmt_t *stmt = row->stmt; + int colno = -1; + zend_long lval; + + if (stmt) { + if (dim_access) { + if (Z_TYPE_P(member) == IS_LONG) { + return Z_LVAL_P(member) >= 0 && Z_LVAL_P(member) < stmt->column_count; + } + convert_to_string(member); + } else { + if (is_numeric_string_ex(Z_STRVAL_P(member), Z_STRLEN_P(member), &lval, NULL, 0, NULL) == IS_LONG) { + return lval >= 0 && lval < stmt->column_count; + } + } + + /* TODO: replace this with a hash of available column names to column + * numbers */ + for (colno = 0; colno < stmt->column_count; colno++) { + if (strcmp(stmt->columns[colno].name, Z_STRVAL_P(member)) == 0) { + return 1; + } + } + } + + return 0; +} + +static zval *row_prop_read(zval *object, zval *member, int type, void **cache_slot, zval *rv TSRMLS_DC) +{ + return row_prop_read_impl(object, member, type, cache_slot, rv, 0 TSRMLS_CC); +} + +static int row_prop_exists(zval *object, zval *member, int check_empty, void **cache_slot TSRMLS_DC) +{ + return row_prop_exists_impl(object, member, check_empty, cache_slot, 0 TSRMLS_CC); +} + static zval *row_dim_read(zval *object, zval *member, int type, zval *rv TSRMLS_DC) { - return row_prop_read(object, member, type, NULL, rv TSRMLS_CC); + return row_prop_read_impl(object, member, type, NULL, rv, 1 TSRMLS_CC); } static void row_prop_write(zval *object, zval *member, zval *value, void **cache_slot TSRMLS_DC) @@ -2536,34 +2587,9 @@ static void row_dim_write(zval *object, zval *member, zval *value TSRMLS_DC) php_error_docref(NULL TSRMLS_CC, E_WARNING, "This PDORow is not from a writable result set"); } -static int row_prop_exists(zval *object, zval *member, int check_empty, void **cache_slot TSRMLS_DC) -{ - pdo_row_t *row = (pdo_row_t *)Z_OBJ_P(object); - pdo_stmt_t *stmt = row->stmt; - int colno = -1; - - if (stmt) { - if (Z_TYPE_P(member) == IS_LONG) { - return Z_LVAL_P(member) >= 0 && Z_LVAL_P(member) < stmt->column_count; - } else { - convert_to_string(member); - - /* TODO: replace this with a hash of available column names to column - * numbers */ - for (colno = 0; colno < stmt->column_count; colno++) { - if (strcmp(stmt->columns[colno].name, Z_STRVAL_P(member)) == 0) { - return 1; - } - } - } - } - - return 0; -} - static int row_dim_exists(zval *object, zval *member, int check_empty TSRMLS_DC) { - return row_prop_exists(object, member, check_empty, NULL TSRMLS_CC); + return row_prop_exists_impl(object, member, check_empty, NULL, 1 TSRMLS_CC); } static void row_prop_delete(zval *object, zval *offset, void **cache_slot TSRMLS_DC) From 241b1a78401771c78a8f6c76dbad43de6053c558 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Thu, 13 Nov 2014 14:16:08 +0800 Subject: [PATCH 332/398] Revert "Fixed test fails (prop read always has a IS_STRING member now)" This reverts commit 39913c4cdf54f926d733bfe0a95be2ecfa6bff35. --- ext/pdo/pdo_stmt.c | 116 ++++++++++++++++++--------------------------- 1 file changed, 45 insertions(+), 71 deletions(-) diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 8f68aef8abd..705d08bacf5 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -2480,48 +2480,38 @@ const zend_function_entry pdo_row_functions[] = { {NULL, NULL, NULL} }; -static zend_always_inline zval *row_prop_read_impl(zval *object, zval *member, int type, void **cache_slot, zval *rv, int dim_access TSRMLS_DC) +static zval *row_prop_read(zval *object, zval *member, int type, void **cache_slot, zval *rv TSRMLS_DC) { pdo_row_t *row = (pdo_row_t *)Z_OBJ_P(object); pdo_stmt_t *stmt = row->stmt; int colno = -1; zval zobj; - zend_long lval; ZVAL_NULL(rv); if (stmt) { - if (dim_access) { - if (Z_TYPE_P(member) == IS_LONG) { - if (Z_LVAL_P(member) >= 0 && Z_LVAL_P(member) < stmt->column_count) { - fetch_value(stmt, rv, Z_LVAL_P(member), NULL TSRMLS_CC); - } - return rv; + if (Z_TYPE_P(member) == IS_LONG) { + if (Z_LVAL_P(member) >= 0 && Z_LVAL_P(member) < stmt->column_count) { + fetch_value(stmt, rv, Z_LVAL_P(member), NULL TSRMLS_CC); } - convert_to_string(member); } else { - if (is_numeric_string_ex(Z_STRVAL_P(member), Z_STRLEN_P(member), &lval, NULL, 0, NULL) == IS_LONG) { - if (lval >= 0 && lval < stmt->column_count) { - fetch_value(stmt, rv, lval, NULL TSRMLS_CC); + convert_to_string(member); + /* TODO: replace this with a hash of available column names to column + * numbers */ + for (colno = 0; colno < stmt->column_count; colno++) { + if (strcmp(stmt->columns[colno].name, Z_STRVAL_P(member)) == 0) { + fetch_value(stmt, rv, colno, NULL TSRMLS_CC); + //??? + //Z_SET_REFCOUNT_P(rv, 0); + //Z_UNSET_ISREF_P(rv); + return rv; } - return rv; } - } - /* TODO: replace this with a hash of available column names to column - * numbers */ - for (colno = 0; colno < stmt->column_count; colno++) { - if (strcmp(stmt->columns[colno].name, Z_STRVAL_P(member)) == 0) { - fetch_value(stmt, rv, colno, NULL TSRMLS_CC); - //??? - //Z_SET_REFCOUNT_P(rv, 0); - //Z_UNSET_ISREF_P(rv); - return rv; + if (strcmp(Z_STRVAL_P(member), "queryString") == 0) { + ZVAL_OBJ(&zobj, &stmt->std); + //zval_ptr_dtor(rv); + return std_object_handlers.read_property(&zobj, member, type, cache_slot, rv TSRMLS_CC); } } - if (strcmp(Z_STRVAL_P(member), "queryString") == 0) { - ZVAL_OBJ(&zobj, &stmt->std); - //zval_ptr_dtor(rv); - return std_object_handlers.read_property(&zobj, member, type, cache_slot, rv TSRMLS_CC); - } } //??? @@ -2531,50 +2521,9 @@ static zend_always_inline zval *row_prop_read_impl(zval *object, zval *member, i return rv; } -static zend_always_inline int row_prop_exists_impl(zval *object, zval *member, int check_empty, void **cache_slot, int dim_access TSRMLS_DC) -{ - pdo_row_t *row = (pdo_row_t *)Z_OBJ_P(object); - pdo_stmt_t *stmt = row->stmt; - int colno = -1; - zend_long lval; - - if (stmt) { - if (dim_access) { - if (Z_TYPE_P(member) == IS_LONG) { - return Z_LVAL_P(member) >= 0 && Z_LVAL_P(member) < stmt->column_count; - } - convert_to_string(member); - } else { - if (is_numeric_string_ex(Z_STRVAL_P(member), Z_STRLEN_P(member), &lval, NULL, 0, NULL) == IS_LONG) { - return lval >= 0 && lval < stmt->column_count; - } - } - - /* TODO: replace this with a hash of available column names to column - * numbers */ - for (colno = 0; colno < stmt->column_count; colno++) { - if (strcmp(stmt->columns[colno].name, Z_STRVAL_P(member)) == 0) { - return 1; - } - } - } - - return 0; -} - -static zval *row_prop_read(zval *object, zval *member, int type, void **cache_slot, zval *rv TSRMLS_DC) -{ - return row_prop_read_impl(object, member, type, cache_slot, rv, 0 TSRMLS_CC); -} - -static int row_prop_exists(zval *object, zval *member, int check_empty, void **cache_slot TSRMLS_DC) -{ - return row_prop_exists_impl(object, member, check_empty, cache_slot, 0 TSRMLS_CC); -} - static zval *row_dim_read(zval *object, zval *member, int type, zval *rv TSRMLS_DC) { - return row_prop_read_impl(object, member, type, NULL, rv, 1 TSRMLS_CC); + return row_prop_read(object, member, type, NULL, rv TSRMLS_CC); } static void row_prop_write(zval *object, zval *member, zval *value, void **cache_slot TSRMLS_DC) @@ -2587,9 +2536,34 @@ static void row_dim_write(zval *object, zval *member, zval *value TSRMLS_DC) php_error_docref(NULL TSRMLS_CC, E_WARNING, "This PDORow is not from a writable result set"); } +static int row_prop_exists(zval *object, zval *member, int check_empty, void **cache_slot TSRMLS_DC) +{ + pdo_row_t *row = (pdo_row_t *)Z_OBJ_P(object); + pdo_stmt_t *stmt = row->stmt; + int colno = -1; + + if (stmt) { + if (Z_TYPE_P(member) == IS_LONG) { + return Z_LVAL_P(member) >= 0 && Z_LVAL_P(member) < stmt->column_count; + } else { + convert_to_string(member); + + /* TODO: replace this with a hash of available column names to column + * numbers */ + for (colno = 0; colno < stmt->column_count; colno++) { + if (strcmp(stmt->columns[colno].name, Z_STRVAL_P(member)) == 0) { + return 1; + } + } + } + } + + return 0; +} + static int row_dim_exists(zval *object, zval *member, int check_empty TSRMLS_DC) { - return row_prop_exists_impl(object, member, check_empty, NULL, 1 TSRMLS_CC); + return row_prop_exists(object, member, check_empty, NULL TSRMLS_CC); } static void row_prop_delete(zval *object, zval *offset, void **cache_slot TSRMLS_DC) From 6771f5590c88c5550ccd43c9ac4c5c4448bf45ef Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Thu, 13 Nov 2014 14:23:25 +0800 Subject: [PATCH 333/398] Another fix for test fail --- ext/pdo/pdo_stmt.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 705d08bacf5..dbc98c6e5f3 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -2486,6 +2486,7 @@ static zval *row_prop_read(zval *object, zval *member, int type, void **cache_sl pdo_stmt_t *stmt = row->stmt; int colno = -1; zval zobj; + zend_long lval; ZVAL_NULL(rv); if (stmt) { @@ -2493,6 +2494,11 @@ static zval *row_prop_read(zval *object, zval *member, int type, void **cache_sl if (Z_LVAL_P(member) >= 0 && Z_LVAL_P(member) < stmt->column_count) { fetch_value(stmt, rv, Z_LVAL_P(member), NULL TSRMLS_CC); } + } else if (Z_TYPE_P(member) == IS_STRING + && is_numeric_string_ex(Z_STRVAL_P(member), Z_STRLEN_P(member), &lval, NULL, 0, NULL) == IS_LONG) { + if (lval >= 0 && lval < stmt->column_count) { + fetch_value(stmt, rv, lval, NULL TSRMLS_CC); + } } else { convert_to_string(member); /* TODO: replace this with a hash of available column names to column @@ -2541,19 +2547,24 @@ static int row_prop_exists(zval *object, zval *member, int check_empty, void **c pdo_row_t *row = (pdo_row_t *)Z_OBJ_P(object); pdo_stmt_t *stmt = row->stmt; int colno = -1; + zend_long lval; if (stmt) { if (Z_TYPE_P(member) == IS_LONG) { return Z_LVAL_P(member) >= 0 && Z_LVAL_P(member) < stmt->column_count; + } else if (Z_TYPE_P(member) == IS_STRING) { + if (is_numeric_string_ex(Z_STRVAL_P(member), Z_STRLEN_P(member), &lval, NULL, 0, NULL) == IS_LONG) { + return lval >=0 && lval < stmt->column_count; + } } else { convert_to_string(member); + } - /* TODO: replace this with a hash of available column names to column - * numbers */ - for (colno = 0; colno < stmt->column_count; colno++) { - if (strcmp(stmt->columns[colno].name, Z_STRVAL_P(member)) == 0) { - return 1; - } + /* TODO: replace this with a hash of available column names to column + * numbers */ + for (colno = 0; colno < stmt->column_count; colno++) { + if (strcmp(stmt->columns[colno].name, Z_STRVAL_P(member)) == 0) { + return 1; } } } From 8644f4624cfcf95dc71005b37b7102e2c96f2466 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 13 Nov 2014 08:17:39 +0100 Subject: [PATCH 334/398] set the vc++ next name --- win32/build/confutils.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 7489e052f8b..59a522c56bb 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -63,8 +63,7 @@ VC_VERSIONS[1500] = 'MSVC9 (Visual C++ 2008)'; VC_VERSIONS[1600] = 'MSVC10 (Visual C++ 2010)'; VC_VERSIONS[1700] = 'MSVC11 (Visual C++ 2012)'; VC_VERSIONS[1800] = 'MSVC12 (Visual C++ 2013)'; -/* XXX update after the final rename */ -VC_VERSIONS[1900] = 'MSVC14 (Visual C++ CTP14)'; +VC_VERSIONS[1900] = 'MSVC14 (Visual C++ 2015)'; var VC_VERSIONS_SHORT = new Array(); VC_VERSIONS_SHORT[1200] = 'VC6'; From 191fe09e33226ddd7f4e52a0b9143db2be156f96 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 13 Nov 2014 10:47:57 +0100 Subject: [PATCH 335/398] HAVE_STRNLEN should be in all toolsets --- win32/build/config.w32 | 2 +- win32/build/config.w32.phpize.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 748631dddeb..61e1882ce4c 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -146,7 +146,7 @@ ADD_SOURCES("win32", "inet.c fnmatch.c sockets.c"); if (VS_TOOLSET && VCVERS <= 1300) { ADD_SOURCES("win32", "strtoi64.c"); } -if (VS_TOOLSET && VCVERS >= 1400 || ICC_TOOLSET) { +if (VS_TOOLSET && VCVERS >= 1400 || !VS_TOOLSET) { AC_DEFINE('HAVE_STRNLEN', 1); } diff --git a/win32/build/config.w32.phpize.in b/win32/build/config.w32.phpize.in index 6a33dc20362..97f1f7d6388 100644 --- a/win32/build/config.w32.phpize.in +++ b/win32/build/config.w32.phpize.in @@ -106,7 +106,7 @@ if (VS_TOOLSET && VCVERS == 1200) { AC_DEFINE('ZEND_DVAL_TO_LVAL_CAST_OK', 1); } -if (ICC_TOOLSET || VS_TOOLSET && VCVERS >= 1400) { +if (!VS_TOOLSET || VS_TOOLSET && VCVERS >= 1400) { AC_DEFINE('HAVE_STRNLEN', 1); } From b6c8349be0410090874e8ace322b2bdb1e2e52a7 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 13 Nov 2014 11:20:09 +0100 Subject: [PATCH 336/398] pass vc++ version to clang, that will be forwarded to _MSC_VER --- win32/build/confutils.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 59a522c56bb..f201f48e86b 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -2604,6 +2604,9 @@ function toolset_setup_common_cflags() ADD_FLAG('CFLAGS', '-m32'); } ADD_FLAG("CFLAGS", " /fallback "); + + var vc_ver = probe_binary(PATH_PROG('cl', null)); + ADD_FLAG("CFLAGS", "-fms-compatibility-version=" + vc_ver); } } From 9b19f516a5f701790f0407327264b17e5b003b71 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 13 Nov 2014 11:43:01 +0100 Subject: [PATCH 337/398] add a configure option to suppress uncritical warns with clang --- win32/build/config.w32 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 61e1882ce4c..aae27f2ca2e 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -239,3 +239,10 @@ if (PHP_ANALYZER == "vs") { PHP_ANALYZER = "no" } +if (CLANG_TOOLSET) { + ARG_WITH("uncritical-warn-choke", "Disable some uncritical warnings", "yes"); + if (PHP_UNCRITICAL_WARN_CHOKE != "no") { + ADD_FLAG("CFLAGS", "-Wno-ignored-attributes -Wno-deprecated-declarations -Wno-missing-braces -Wno-msvc-include -Wno-invalid-source-encoding"); + } +} + From 1b156207446e0c5ec8a9476ad0966b5daa82f516 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 13 Nov 2014 13:08:00 +0100 Subject: [PATCH 338/398] Fix build with gmp < 4.2 See 3d6d863ccbd10d212352462b587ae1573af4f1d1 and acd7fcf55f81955e4837c750a5e45f83d3c55ba2 --- ext/gmp/gmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index e9c1ad34164..de61f1ca5f3 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -1776,7 +1776,7 @@ static void gmp_init_random(TSRMLS_D) #if GMP_42_OR_NEWER gmp_randinit_mt(GMPG(rand_state)); #else - gmp_randinit_lc_2exp(GMPG(rand_state), 32L); + gmp_randinit_lc_2exp_size(GMPG(rand_state), 32L); #endif /* Seed */ gmp_randseed_ui(GMPG(rand_state), GENERATE_SEED()); From 1f432c85b0431d5d4182cb8e80bac5df6c4df632 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 13 Nov 2014 17:36:08 +0300 Subject: [PATCH 339/398] Micro optimization --- Zend/zend_vm_def.h | 9 ++++----- Zend/zend_vm_execute.h | 18 ++++++++---------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 9e8e628362b..f2a6fd15fd4 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -3124,12 +3124,11 @@ ZEND_VM_HANDLER(67, ZEND_SEND_REF, VAR|CV, ANY) ZVAL_COPY_VALUE(arg, varptr); } else if (OP1_TYPE == IS_VAR && UNEXPECTED(Z_TYPE_P(EX_VAR(opline->op1.var)) != IS_INDIRECT)) { - ZVAL_COPY_VALUE(arg, varptr); - ZVAL_MAKE_REF(arg); + ZVAL_NEW_REF(arg, varptr); } else { - ZVAL_MAKE_REF(varptr); - Z_ADDREF_P(varptr); - ZVAL_REF(arg, Z_REF_P(varptr)); + ZVAL_NEW_REF(arg, varptr); + Z_ADDREF_P(arg); + ZVAL_REF(varptr, Z_REF_P(arg)); } FREE_OP1_VAR_PTR(); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 8f4de2f8f6f..776cc98dc61 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -16544,12 +16544,11 @@ static int ZEND_FASTCALL ZEND_SEND_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG ZVAL_COPY_VALUE(arg, varptr); } else if (IS_VAR == IS_VAR && UNEXPECTED(Z_TYPE_P(EX_VAR(opline->op1.var)) != IS_INDIRECT)) { - ZVAL_COPY_VALUE(arg, varptr); - ZVAL_MAKE_REF(arg); + ZVAL_NEW_REF(arg, varptr); } else { - ZVAL_MAKE_REF(varptr); - Z_ADDREF_P(varptr); - ZVAL_REF(arg, Z_REF_P(varptr)); + ZVAL_NEW_REF(arg, varptr); + Z_ADDREF_P(arg); + ZVAL_REF(varptr, Z_REF_P(arg)); } if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; @@ -34339,12 +34338,11 @@ static int ZEND_FASTCALL ZEND_SEND_REF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS ZVAL_COPY_VALUE(arg, varptr); } else if (IS_CV == IS_VAR && UNEXPECTED(Z_TYPE_P(EX_VAR(opline->op1.var)) != IS_INDIRECT)) { - ZVAL_COPY_VALUE(arg, varptr); - ZVAL_MAKE_REF(arg); + ZVAL_NEW_REF(arg, varptr); } else { - ZVAL_MAKE_REF(varptr); - Z_ADDREF_P(varptr); - ZVAL_REF(arg, Z_REF_P(varptr)); + ZVAL_NEW_REF(arg, varptr); + Z_ADDREF_P(arg); + ZVAL_REF(varptr, Z_REF_P(arg)); } ZEND_VM_NEXT_OPCODE(); From 0f7f800d8a6570ba64c9da175a5ba9715edae7ce Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 13 Nov 2014 12:31:29 +0100 Subject: [PATCH 340/398] added missing type specifier --- win32/winutil.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win32/winutil.h b/win32/winutil.h index 74d72062c49..f29b593c8dd 100644 --- a/win32/winutil.h +++ b/win32/winutil.h @@ -20,7 +20,7 @@ PHPAPI char *php_win32_error_to_msg(HRESULT error); #define php_win_err() php_win32_error_to_msg(GetLastError()) int php_win32_check_trailing_space(const char * path, const int path_len); -PHPAPI php_win32_get_random_bytes(unsigned char *buf, size_t size); +PHPAPI int php_win32_get_random_bytes(unsigned char *buf, size_t size); #ifdef ZTS void php_win32_init_rng_lock(); From cf979ca6fe0309f494897283bb95f8abf2398d72 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 13 Nov 2014 12:34:10 +0100 Subject: [PATCH 341/398] remove unused vars --- win32/winutil.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/win32/winutil.c b/win32/winutil.c index eab3df9cdaf..f13a7852126 100644 --- a/win32/winutil.c +++ b/win32/winutil.c @@ -79,10 +79,7 @@ void php_win32_free_rng_lock() PHPAPI int php_win32_get_random_bytes(unsigned char *buf, size_t size) { /* {{{ */ - unsigned int has_contextg = 0; - BOOL ret; - size_t i = 0; #ifdef ZTS tsrm_mutex_lock(php_lock_win32_cryptoctx); From c865472ef0c431cf3c6ec153736881d13e8a6883 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 13 Nov 2014 14:17:41 +0100 Subject: [PATCH 342/398] fix datatype mismatches, remove dead part of code --- ext/com_dotnet/com_typeinfo.c | 6 +++--- ext/com_dotnet/com_variant.c | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ext/com_dotnet/com_typeinfo.c b/ext/com_dotnet/com_typeinfo.c index 17b69d2460e..ac5777cef19 100644 --- a/ext/com_dotnet/com_typeinfo.c +++ b/ext/com_dotnet/com_typeinfo.c @@ -71,7 +71,7 @@ PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib(char *search_string, int codep if (FAILED(hr) && (major == NULL || minor == NULL)) { IDispatch *disp = NULL; ITypeInfo *info = NULL; - int idx; + UINT idx; if (SUCCEEDED(hr = CoCreateInstance(&clsid, NULL, CLSCTX_SERVER, &IID_IDispatch, (LPVOID*)&disp)) && SUCCEEDED(hr = IDispatch_GetTypeInfo(disp, 0, LANG_NEUTRAL, &info))) { @@ -96,7 +96,7 @@ PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib(char *search_string, int codep DWORD VersionCount; char version[20]; char *libname; - DWORD libnamelen; + long libnamelen; if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_CLASSES_ROOT, "TypeLib", 0, KEY_READ, &hkey) && ERROR_SUCCESS == RegQueryInfoKey(hkey, NULL, NULL, NULL, &SubKeys, @@ -116,7 +116,7 @@ PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib(char *search_string, int codep continue; } /* get the default value for this key and compare */ - libnamelen = (DWORD)strlen(search_string)+1; + libnamelen = (long)strlen(search_string)+1; if (ERROR_SUCCESS == RegQueryValue(hsubkey, version, libname, &libnamelen)) { if (0 == stricmp(libname, search_string)) { char *str = NULL; diff --git a/ext/com_dotnet/com_variant.c b/ext/com_dotnet/com_variant.c index 6a81eed102a..7317b8d0e46 100644 --- a/ext/com_dotnet/com_variant.c +++ b/ext/com_dotnet/com_variant.c @@ -39,8 +39,7 @@ static void safe_array_from_zval(VARIANT *v, zval *z, int codepage TSRMLS_DC) HashPosition pos; int keytype; zend_string *strindex; - zend_long intindex = -1; - zend_long max_index = 0; + zend_ulong intindex = 0; VARIANT *va; zval *item; @@ -54,15 +53,15 @@ static void safe_array_from_zval(VARIANT *v, zval *z, int codepage TSRMLS_DC) goto bogus; } else if (HASH_KEY_NON_EXISTENT == keytype) { break; - } - if (intindex > max_index) { - max_index = intindex; + } else if (intindex > UINT_MAX) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "COM: max number %u of elements in safe array exceeded", UINT_MAX); + break; } } /* allocate the structure */ bound.lLbound = 0; - bound.cElements = (ULONG)(intindex + 1); + bound.cElements = zend_hash_num_elements(HASH_OF(z)); sa = SafeArrayCreate(VT_VARIANT, 1, &bound); /* get a lock on the array itself */ From 5f81cfe097219dfc77eb63ad6613246f07f16850 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 13 Nov 2014 14:27:38 +0100 Subject: [PATCH 343/398] fix datatype mismatch and kick unused var --- ext/com_dotnet/com_com.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ext/com_dotnet/com_com.c b/ext/com_dotnet/com_com.c index e1a9503dffd..7de6d949bbf 100644 --- a/ext/com_dotnet/com_com.c +++ b/ext/com_dotnet/com_com.c @@ -254,7 +254,7 @@ PHP_FUNCTION(com_create_instance) ITypeLib_Release(TL); } } else if (obj->typeinfo && COMG(autoreg_on)) { - int idx; + UINT idx; if (SUCCEEDED(ITypeInfo_GetContainingTypeLib(obj->typeinfo, &TL, &idx))) { /* check if the library is already in the cache by getting its name */ @@ -693,7 +693,6 @@ PHP_FUNCTION(com_event_sink) { zval *object, *sinkobject, *sink=NULL; char *dispname = NULL, *typelibname = NULL; - zend_bool gotguid = 0; php_com_dotnet_object *obj; ITypeInfo *typeinfo = NULL; From 50825aa879cb8d3d2ae0e80496468ee4310ec890 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 13 Nov 2014 14:29:21 +0100 Subject: [PATCH 344/398] extend warn list to exclude --- win32/build/config.w32 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/win32/build/config.w32 b/win32/build/config.w32 index aae27f2ca2e..148ab6783cb 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -242,7 +242,8 @@ if (PHP_ANALYZER == "vs") { if (CLANG_TOOLSET) { ARG_WITH("uncritical-warn-choke", "Disable some uncritical warnings", "yes"); if (PHP_UNCRITICAL_WARN_CHOKE != "no") { - ADD_FLAG("CFLAGS", "-Wno-ignored-attributes -Wno-deprecated-declarations -Wno-missing-braces -Wno-msvc-include -Wno-invalid-source-encoding"); + ADD_FLAG("CFLAGS", "-Wno-ignored-attributes -Wno-deprecated-declarations -Wno-missing-braces \ + -Wno-logical-op-parentheses -Wno-msvc-include -Wno-invalid-source-encoding -Wno-unknown-pragmas"); } } From e5acd78f7a55c32b84d367975e3b123ea0c3a010 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 13 Nov 2014 15:27:53 +0100 Subject: [PATCH 345/398] fix datatype mismatch --- ext/com_dotnet/com_extension.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/com_dotnet/com_extension.c b/ext/com_dotnet/com_extension.c index 7e158659501..e4ed4916af4 100644 --- a/ext/com_dotnet/com_extension.c +++ b/ext/com_dotnet/com_extension.c @@ -387,7 +387,7 @@ PHP_MINIT_FUNCTION(com_dotnet) #define COM_ERR_CONST(x) { \ zend_long __tmp; \ - ULongToUIntPtr(x, &__tmp); \ + ULongToIntPtr(x, &__tmp); \ REGISTER_LONG_CONSTANT(#x, __tmp, CONST_CS|CONST_PERSISTENT); \ } From 14ccac0237853f05beb72f3b05156d0765210bfb Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 13 Nov 2014 15:45:28 +0100 Subject: [PATCH 346/398] fix datatype mismatch --- Zend/zend_execute_API.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 5edc65e93ea..eaa84103f93 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -51,8 +51,8 @@ static WNDCLASS wc; static HWND timeout_window; static HANDLE timeout_thread_event; static HANDLE timeout_thread_handle; -static DWORD timeout_thread_id; -static int timeout_thread_initialized=0; +static unsigned timeout_thread_id; +static volatile long timeout_thread_initialized=0; #endif #if 0&&ZEND_DEBUG From e6ea376a91514c59d21f4b53ccbb8c06fa42447b Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 13 Nov 2014 16:00:00 +0100 Subject: [PATCH 347/398] avoid repeated strlen usage, remove unused vars --- TSRM/tsrm_win32.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c index 7194dffd610..9765874448d 100644 --- a/TSRM/tsrm_win32.c +++ b/TSRM/tsrm_win32.c @@ -106,16 +106,18 @@ TSRM_API void tsrm_win32_shutdown(void) char * tsrm_win32_get_path_sid_key(const char *pathname TSRMLS_DC) { PSID pSid = TWG(impersonation_token_sid); - DWORD sid_len = pSid ? GetLengthSid(pSid) : 0; TCHAR *ptcSid = NULL; char *bucket_key = NULL; + size_t ptc_sid_len, pathname_len; + + pathname_len = strlen(pathname); if (!pSid) { - bucket_key = (char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, strlen(pathname) + 1); + bucket_key = (char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, pathname_len + 1); if (!bucket_key) { return NULL; } - memcpy(bucket_key, pathname, strlen(pathname)); + memcpy(bucket_key, pathname, pathname_len); return bucket_key; } @@ -123,14 +125,16 @@ char * tsrm_win32_get_path_sid_key(const char *pathname TSRMLS_DC) return NULL; } - bucket_key = (char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, strlen(pathname) + strlen(ptcSid) + 1); + + ptc_sid_len = strlen(ptcSid); + bucket_key = (char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, pathname_len + ptc_sid_len + 1); if (!bucket_key) { LocalFree(ptcSid); return NULL; } - memcpy(bucket_key, ptcSid, strlen(ptcSid)); - memcpy(bucket_key + strlen(ptcSid), pathname, strlen(pathname) + 1); + memcpy(bucket_key, ptcSid, ptc_sid_len); + memcpy(bucket_key + ptc_sid_len, pathname, pathname_len + 1); LocalFree(ptcSid); return bucket_key; @@ -139,11 +143,8 @@ char * tsrm_win32_get_path_sid_key(const char *pathname TSRMLS_DC) PSID tsrm_win32_get_token_sid(HANDLE hToken) { - BOOL bSuccess = FALSE; DWORD dwLength = 0; PTOKEN_USER pTokenUser = NULL; - PSID sid; - PSID *ppsid = &sid; DWORD sid_len; PSID pResultSid = NULL; @@ -204,7 +205,6 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode TSRMLS_DC) BYTE * psec_desc = NULL; BOOL fAccess = FALSE; - BOOL bucket_key_alloc = FALSE; realpath_cache_bucket * bucket = NULL; char * real_path = NULL; @@ -242,7 +242,6 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode TSRMLS_DC) was impersonating already, this function uses that impersonation context. */ if(!OpenThreadToken(GetCurrentThread(), TOKEN_ALL_ACCESS, TRUE, &thread_token)) { - DWORD err = GetLastError(); if (GetLastError() == ERROR_NO_TOKEN) { if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &thread_token)) { TWG(impersonation_token) = NULL; From 063a06b8e569b1256f94b62154f17b234201a86f Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Fri, 14 Nov 2014 10:58:27 +0100 Subject: [PATCH 348/398] NEWS for 1b156207446e0c5ec8a9476ad0966b5daa82f516 --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 379336c4c3d..ce4da51be6f 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,9 @@ PHP NEWS . Fixed bug #68104 (Segfault while pre-evaluating a disabled function). (Laruence) +GMP: + . Fixed bug #68419 (build error with gmp 4.1). (Remi) + - PDO_pgsql: . Fixed bug #67462 (PDO_PGSQL::beginTransaction() wrongly throws exception when not in transaction) (Matteo) From 23db11976889c3600cf7853fe0fd687a1c9435e6 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Fri, 14 Nov 2014 17:29:31 +0100 Subject: [PATCH 349/398] Fix bug #68423i PHP-FPM will no longer load all pools The hash need to be unique per IP + Port Previous version have (IPv4 only) sprintf(key, "%u.%u.%u.%u:%u", IPQUAD(&sa_in->sin_addr), (unsigned int) ntohs(sa_in->sin_port)); --- sapi/fpm/fpm/fpm_sockets.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/sapi/fpm/fpm/fpm_sockets.c b/sapi/fpm/fpm/fpm_sockets.c index da14d63d8c3..3e4f09c50fb 100644 --- a/sapi/fpm/fpm/fpm_sockets.c +++ b/sapi/fpm/fpm/fpm_sockets.c @@ -85,13 +85,24 @@ static void *fpm_get_in_addr(struct sockaddr *sa) /* {{{ */ } /* }}} */ +static int fpm_get_in_port(struct sockaddr *sa) /* {{{ */ +{ + if (sa->sa_family == AF_INET) { + return ntohs(((struct sockaddr_in*)sa)->sin_port); + } + + return ntohs(((struct sockaddr_in6*)sa)->sin6_port); +} +/* }}} */ + static int fpm_sockets_hash_op(int sock, struct sockaddr *sa, char *key, int type, int op) /* {{{ */ { if (key == NULL) { switch (type) { case FPM_AF_INET : { - key = alloca(INET6_ADDRSTRLEN); - inet_ntop(sa->sa_family, fpm_get_in_addr(sa), key, sizeof key); + key = alloca(INET6_ADDRSTRLEN+10); + inet_ntop(sa->sa_family, fpm_get_in_addr(sa), key, INET6_ADDRSTRLEN); + sprintf(key+strlen(key), ":%d", fpm_get_in_port(sa)); break; } @@ -246,7 +257,7 @@ static int fpm_socket_af_inet_listening_socket(struct fpm_worker_pool_s *wp) /* char *addr = NULL; int addr_len; int port = 0; - int sock; + int sock = -1; int status; if (port_str) { /* this is host:port pair */ From 3b4a6dc11496dbdf22a5a83966f963107d20234e Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 14 Nov 2014 09:46:06 +0100 Subject: [PATCH 350/398] removed useless check the offset member is an unsigned --- ext/reflection/php_reflection.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index b972c2899c7..e9c59ea86e9 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -3359,12 +3359,10 @@ static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value continue; } prop = NULL; - if (prop_info->offset >= 0) { - if (statics && (prop_info->flags & ZEND_ACC_STATIC) != 0) { - prop = &ce->default_static_members_table[prop_info->offset]; - } else if (!statics && (prop_info->flags & ZEND_ACC_STATIC) == 0) { - prop = &ce->default_properties_table[OBJ_PROP_TO_NUM(prop_info->offset)]; - } + if (statics && (prop_info->flags & ZEND_ACC_STATIC) != 0) { + prop = &ce->default_static_members_table[prop_info->offset]; + } else if (!statics && (prop_info->flags & ZEND_ACC_STATIC) == 0) { + prop = &ce->default_properties_table[OBJ_PROP_TO_NUM(prop_info->offset)]; } if (!prop) { continue; From e1d0ca7cae51b3f3c5baef83fc81f397e9e64ded Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 14 Nov 2014 10:05:53 +0100 Subject: [PATCH 351/398] fix unused var warning --- main/streams/xp_socket.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c index 746d9c93d92..7427a794b44 100644 --- a/main/streams/xp_socket.c +++ b/main/streams/xp_socket.c @@ -233,10 +233,11 @@ static int php_sockop_flush(php_stream *stream TSRMLS_DC) static int php_sockop_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC) { - php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract; #if ZEND_WIN32 return 0; #else + php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract; + return zend_fstat(sock->socket, &ssb->sb); #endif } From 8434a7f2abb6ee5be0a4b38c1a7add6cdc21a426 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 14 Nov 2014 10:17:43 +0100 Subject: [PATCH 352/398] validate sockets portable way --- ext/mysqlnd/mysqlnd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c index 41f34e366af..08a10dbbd1d 100644 --- a/ext/mysqlnd/mysqlnd.c +++ b/ext/mysqlnd/mysqlnd.c @@ -1306,7 +1306,7 @@ static int mysqlnd_stream_array_to_fd_set(MYSQLND ** conn_array, fd_set * fds, p stream = (*p)->data->net->data->m.get_stream((*p)->data->net TSRMLS_CC); DBG_INF_FMT("conn=%llu stream=%p", (*p)->data->thread_id, stream); if (stream != NULL && SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, - (void*)&this_fd, 1) && this_fd >= 0) { + (void*)&this_fd, 1) && ZEND_VALID_SOCKET(this_fd)) { PHP_SAFE_FD_SET(this_fd, fds); @@ -1336,7 +1336,7 @@ static int mysqlnd_stream_array_from_fd_set(MYSQLND ** conn_array, fd_set * fds stream = (*fwd)->data->net->data->m.get_stream((*fwd)->data->net TSRMLS_CC); DBG_INF_FMT("conn=%llu stream=%p", (*fwd)->data->thread_id, stream); if (stream != NULL && SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, - (void*)&this_fd, 1) && this_fd >= 0) { + (void*)&this_fd, 1) && ZEND_VALID_SOCKET(this_fd)) { if (PHP_SAFE_FD_ISSET(this_fd, fds)) { if (disproportion) { *bckwd = *fwd; From b7eee5bfaf12588d9b3558c82f35ea9d14791a02 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 14 Nov 2014 10:20:03 +0100 Subject: [PATCH 353/398] added comment --- Zend/zend_portability.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index f056b163388..73a4f3b9626 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -394,6 +394,7 @@ char *alloca(); #define ZEND_SECURE_ZERO(var, size) memset((var), 0, (size)) #endif +/* This check should only be used on network socket, not file descriptors */ #ifdef ZEND_WIN32 #define ZEND_VALID_SOCKET(sock) (INVALID_SOCKET != (sock)) #else From dbddbcc950aec9956aaa942d1983981110984edd Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 14 Nov 2014 10:31:35 +0100 Subject: [PATCH 354/398] remove unused var --- ext/standard/exec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ext/standard/exec.c b/ext/standard/exec.c index 6106fe2c86b..01aaa71f39e 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -242,7 +242,6 @@ PHP_FUNCTION(passthru) PHPAPI zend_string *php_escape_shell_cmd(char *str) { register int x, y, l = (int)strlen(str); - char *p = NULL; size_t estimate = (2 * l) + 1; zend_string *cmd; From a85ce501da60999ded0f93d9889efa6792b2a6ec Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 14 Nov 2014 11:27:23 +0100 Subject: [PATCH 355/398] partial cleanup to work with size_t str length in password_hash php_crypt() and co use int, though this is fair enough. Could be refactored later for tidiness reasons. --- ext/standard/password.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/ext/standard/password.c b/ext/standard/password.c index c58c28ab3cd..cd2170b036a 100644 --- a/ext/standard/password.c +++ b/ext/standard/password.c @@ -345,12 +345,11 @@ PHP_FUNCTION(password_hash) if (options && (option_buffer = zend_symtable_str_find(options, "salt", sizeof("salt")-1)) != NULL) { char *buffer; - size_t buffer_len_int = 0; - size_t buffer_len; + size_t buffer_len = 0; switch (Z_TYPE_P(option_buffer)) { case IS_STRING: buffer = estrndup(Z_STRVAL_P(option_buffer), Z_STRLEN_P(option_buffer)); - buffer_len_int = Z_STRLEN_P(option_buffer); + buffer_len = Z_STRLEN_P(option_buffer); break; case IS_LONG: case IS_DOUBLE: @@ -361,7 +360,7 @@ PHP_FUNCTION(password_hash) convert_to_string(&cast_option_buffer); if (Z_TYPE(cast_option_buffer) == IS_STRING) { buffer = estrndup(Z_STRVAL(cast_option_buffer), Z_STRLEN(cast_option_buffer)); - buffer_len_int = Z_STRLEN(cast_option_buffer); + buffer_len = Z_STRLEN(cast_option_buffer); zval_dtor(&cast_option_buffer); break; } @@ -377,16 +376,18 @@ PHP_FUNCTION(password_hash) php_error_docref(NULL TSRMLS_CC, E_WARNING, "Non-string salt parameter supplied"); RETURN_NULL(); } - if (buffer_len_int < 0) { + + /* XXX all the crypt related APIs work with int for string length. + That should be revised for size_t and then we maybe don't require + the > INT_MAX check. */ + if (buffer_len > INT_MAX) { efree(hash_format); efree(buffer); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Supplied salt is too long"); - } - buffer_len = (size_t) buffer_len_int; - if (buffer_len < required_salt_len) { + } else if (buffer_len < required_salt_len) { efree(hash_format); efree(buffer); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Provided salt is too short: %lu expecting %lu", (unsigned long) buffer_len, (unsigned long) required_salt_len); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Provided salt is too short: %zd expecting %zd", buffer_len, required_salt_len); RETURN_NULL(); } else if (php_password_salt_is_alphabet(buffer, buffer_len) == FAILURE) { salt = safe_emalloc(required_salt_len, 1, 1); @@ -394,7 +395,7 @@ PHP_FUNCTION(password_hash) efree(hash_format); efree(buffer); efree(salt); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Provided salt is too short: %lu", (unsigned long) buffer_len); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Provided salt is too short: %zd", buffer_len); RETURN_NULL(); } salt_len = required_salt_len; From 034a88135f325b15ccfd8726f13b7501aaa03858 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 14 Nov 2014 13:57:57 +0100 Subject: [PATCH 356/398] separate LDFLAGS and ARFLAGS to fix the unknown opts warns --- win32/build/config.w32 | 1 + win32/build/config.w32.phpize.in | 1 + win32/build/confutils.js | 10 +++++++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 148ab6783cb..7ca0293f3fc 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -107,6 +107,7 @@ var php_usual_lib_suspects = PHP_PHP_BUILD+"\\lib"; ADD_FLAG("CFLAGS", '/I "' + php_usual_include_suspects + '" '); ADD_FLAG("LDFLAGS", '/libpath:"' + php_usual_lib_suspects + '" '); +ADD_FLAG("ARFLAGS", '/libpath:"' + php_usual_lib_suspects + '" '); probe_basic_headers(); add_extra_dirs(); diff --git a/win32/build/config.w32.phpize.in b/win32/build/config.w32.phpize.in index 97f1f7d6388..a340af0e60a 100644 --- a/win32/build/config.w32.phpize.in +++ b/win32/build/config.w32.phpize.in @@ -91,6 +91,7 @@ var php_usual_lib_suspects = PHP_PHP_BUILD+"\\lib"; ADD_FLAG("CFLAGS", '/I "' + php_usual_include_suspects + '" '); ADD_FLAG("LDFLAGS", '/libpath:"\\"' + php_usual_lib_suspects + '\\"" '); +ADD_FLAG("ARFLAGS", '/libpath:"\\"' + php_usual_lib_suspects + '\\"" '); probe_basic_headers(); add_extra_dirs(); diff --git a/win32/build/confutils.js b/win32/build/confutils.js index f201f48e86b..bcf0d1dac92 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -716,6 +716,7 @@ function CHECK_LIB(libnames, target, path_to_check, common_name) var libdir = FSO.GetParentFolderName(location); libname = FSO.GetFileName(location); ADD_FLAG("LDFLAGS" + target, '/libpath:"' + libdir + '" '); + ADD_FLAG("ARFLAGS" + target, '/libpath:"' + libdir + '" '); ADD_FLAG("LIBS" + target, libname); STDOUT.WriteLine(location); @@ -785,6 +786,7 @@ function OLD_CHECK_LIB(libnames, target, path_to_check) if (typeof(p) == "string") { ADD_FLAG("LDFLAGS" + target, '/libpath:"' + p + '" '); + ADD_FLAG("ARFLAGS" + target, '/libpath:"' + p + '" '); ADD_FLAG("LIBS" + target, libname); have = 1; } else if (p == true) { @@ -1096,7 +1098,7 @@ function SAPI(sapiname, file_list, makefiletarget, cflags, obj_dir) ldflags = "/dll $(LDFLAGS)"; manifest = "-@$(_VC_MANIFEST_EMBED_DLL)"; } else if (makefiletarget.match(new RegExp("\\.lib$"))) { - ldflags = "$(LDFLAGS)"; + ldflags = "$(ARFLAGS)"; ld = "$(MAKE_LIB)"; } else { ldflags = "$(LDFLAGS)"; @@ -1119,14 +1121,14 @@ function SAPI(sapiname, file_list, makefiletarget, cflags, obj_dir) if (MODE_PHPIZE) { if (ld) { - MFO.WriteLine("\t" + ld + " /nologo /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(" + SAPI + "_GLOBAL_OBJS_RESP) $(PHPLIB) $(LDFLAGS_" + SAPI + ") $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname); + MFO.WriteLine("\t" + ld + " /nologo /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(" + SAPI + "_GLOBAL_OBJS_RESP) $(PHPLIB) $(ARFLAGS_" + SAPI + ") $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname); } else { ld = '@"$(LINK)"'; MFO.WriteLine("\t" + ld + " /nologo " + " $(" + SAPI + "_GLOBAL_OBJS_RESP) $(PHPLIB) $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname + " /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(LDFLAGS_" + SAPI + ")"); } } else { if (ld) { - MFO.WriteLine("\t" + ld + " /nologo /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(" + SAPI + "_GLOBAL_OBJS_RESP) $(BUILD_DIR)\\$(PHPLIB) $(LDFLAGS_" + SAPI + ") $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname); + MFO.WriteLine("\t" + ld + " /nologo /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(" + SAPI + "_GLOBAL_OBJS_RESP) $(BUILD_DIR)\\$(PHPLIB) $(ARFLAGS_" + SAPI + ") $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname); } else { ld = '@"$(LINK)"'; MFO.WriteLine("\t" + ld + " /nologo " + " $(" + SAPI + "_GLOBAL_OBJS_RESP) $(BUILD_DIR)\\$(PHPLIB) $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname + " /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(LDFLAGS_" + SAPI + ")"); @@ -2785,8 +2787,10 @@ function add_extra_dirs() if (FSO.FolderExists(f)) { if (VS_TOOLSET && VCVERS <= 1200 && f.indexOf(" ") >= 0) { ADD_FLAG("LDFLAGS", '/libpath:"\\"' + f + '\\"" '); + ADD_FLAG("ARFLAGS", '/libpath:"\\"' + f + '\\"" '); } else { ADD_FLAG("LDFLAGS", '/libpath:"' + f + '" '); + ADD_FLAG("ARFLAGS", '/libpath:"' + f + '" '); } } } From 1ae7743a079e8c7afa7b7d2da465a8445c4cb226 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 14 Nov 2014 17:38:03 +0100 Subject: [PATCH 357/398] less spaces in the makefile generated commands --- win32/build/confutils.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/win32/build/confutils.js b/win32/build/confutils.js index bcf0d1dac92..7d02f99ad6e 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -1999,8 +1999,9 @@ function generate_makefile() // that is part of the build dir flags (CFLAGS_BD_XXX) from being // seen as a line continuation character MF.WriteLine(keys[i] + "=" + - //word_wrap_and_indent(1, configure_subst.Item(keys[i]), ' \\', '\t') + " " - configure_subst.Item(keys[i]) + " " + /* \s+\/ eliminates extra whitespace caused when using \ for string continuation, + whereby \/ is the start of the next compiler switch */ + trim(configure_subst.Item(keys[i])).replace(/\s+\//gm, " /") + " " ); MF.WriteBlankLines(1); } @@ -2067,7 +2068,7 @@ function ADD_FLAG(name, flags, target) if (target != null) { name = target.toUpperCase() + "_" + name; } - flags = flags.replace(/^\s+/, "").replace(/\s+$/, ""); + flags = trim(flags); if (configure_subst.Exists(name)) { var curr_flags = configure_subst.Item(name); @@ -2798,3 +2799,8 @@ function add_extra_dirs() } +function trim(s) +{ + return s.replace(/^\s+/, "").replace(/\s+$/, ""); +} + From 5112fdd670175f4eab4529c84ccf4774f5577797 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Fri, 14 Nov 2014 19:09:50 +0100 Subject: [PATCH 358/398] Fix bug #68421 access.format='%R' doesn't log ipv6 address --- sapi/fpm/fpm/fastcgi.c | 10 ++++++++-- sapi/fpm/fpm/fastcgi.h | 2 +- sapi/fpm/fpm/fpm_log.c | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/sapi/fpm/fpm/fastcgi.c b/sapi/fpm/fpm/fastcgi.c index d77b6f8ca70..86fca17c5f7 100644 --- a/sapi/fpm/fpm/fastcgi.c +++ b/sapi/fpm/fpm/fastcgi.c @@ -137,6 +137,7 @@ typedef union _sa_t { struct sockaddr sa; struct sockaddr_un sa_unix; struct sockaddr_in sa_inet; + struct sockaddr_in6 sa_inet6; } sa_t; static HashTable fcgi_mgmt_vars; @@ -1094,12 +1095,17 @@ void fcgi_free_mgmt_var_cb(void * ptr) pefree(*var, 1); } -char *fcgi_get_last_client_ip() /* {{{ */ +const char *fcgi_get_last_client_ip() /* {{{ */ { + static char str[INET6_ADDRSTRLEN]; + if (client_sa.sa.sa_family == AF_UNIX) { return NULL; } - return inet_ntoa(client_sa.sa_inet.sin_addr); + if (client_sa.sa.sa_family == AF_INET) { + return inet_ntop(client_sa.sa.sa_family, &client_sa.sa_inet.sin_addr, str, INET6_ADDRSTRLEN); + } + return inet_ntop(client_sa.sa.sa_family, &client_sa.sa_inet6.sin6_addr, str, INET6_ADDRSTRLEN); } /* }}} */ /* diff --git a/sapi/fpm/fpm/fastcgi.h b/sapi/fpm/fpm/fastcgi.h index 34f9eef9da9..f5cfe9f66a9 100644 --- a/sapi/fpm/fpm/fastcgi.h +++ b/sapi/fpm/fpm/fastcgi.h @@ -133,7 +133,7 @@ int fcgi_flush(fcgi_request *req, int close); void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len); void fcgi_free_mgmt_var_cb(void * ptr); -char *fcgi_get_last_client_ip(); +const char *fcgi_get_last_client_ip(); /* * Local variables: diff --git a/sapi/fpm/fpm/fpm_log.c b/sapi/fpm/fpm/fpm_log.c index 4e1a057db19..c71281b0b97 100644 --- a/sapi/fpm/fpm/fpm_log.c +++ b/sapi/fpm/fpm/fpm_log.c @@ -367,7 +367,7 @@ int fpm_log_write(char *log_format TSRMLS_DC) /* {{{ */ case 'R': /* remote IP address */ if (!test) { - char *tmp = fcgi_get_last_client_ip(); + const char *tmp = fcgi_get_last_client_ip(); len2 = snprintf(b, FPM_LOG_BUFFER - len, "%s", tmp ? tmp : "-"); } break; From e4974f6cc6dab92926039fbc82027d1ef76a9f9e Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Fri, 14 Nov 2014 19:13:53 +0100 Subject: [PATCH 359/398] NEWS --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 83448f76cae..a9c44438dca 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,10 @@ PHP NEWS - Core: . Fixed bug #68370 ("unset($this)" can make the program crash). (Laruence) +- FPM: + . Fixed bug #68421 (access.format='%R' doesn't log ipv6 address). (Remi) + . Fixed Bug #68423 (PHP-FPM will no longer load all pools). (Remi) + - PDO_pgsql: . Fixed bug #66584 (Segmentation fault on statement deallocation) (Matteo) . Fixed bug #67462 (PDO_PGSQL::beginTransaction() wrongly throws exception From 548352aa1e091e2d1c48c68f087c5ccf669e30ae Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Fri, 14 Nov 2014 19:14:42 +0100 Subject: [PATCH 360/398] NEWS --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index ce4da51be6f..575a13d215b 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,10 @@ PHP NEWS . Fixed bug #68104 (Segfault while pre-evaluating a disabled function). (Laruence) +- FPM: + . Fixed bug #68421 (access.format='%R' doesn't log ipv6 address). (Remi) + . Fixed Bug #68423 (PHP-FPM will no longer load all pools). (Remi) + GMP: . Fixed bug #68419 (build error with gmp 4.1). (Remi) From 82c2e3f20148b88b0721b6887edb9280b45e90f2 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 14 Nov 2014 22:19:41 +0100 Subject: [PATCH 361/398] fix build ifdef this var declaration to avoid the vs warning --- ext/standard/exec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ext/standard/exec.c b/ext/standard/exec.c index 01aaa71f39e..15e4876af55 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -244,6 +244,9 @@ PHPAPI zend_string *php_escape_shell_cmd(char *str) register int x, y, l = (int)strlen(str); size_t estimate = (2 * l) + 1; zend_string *cmd; +#ifndef PHP_WIN32 + char *p = NULL; +#endif TSRMLS_FETCH(); From 1d9bb287c566425a9ab4b8de62940565fe357270 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Sat, 15 Nov 2014 08:08:23 +0100 Subject: [PATCH 362/398] Fixed Bug #68420 listen=9000 listens to ipv6 localhost instead of all addresses Restore default behavior when no address configured: Listen on all IPv4 addresses. At some time we could consider to switch to all IPv6 but this will be a BC break. --- sapi/fpm/fpm/fpm_sockets.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/sapi/fpm/fpm/fpm_sockets.c b/sapi/fpm/fpm/fpm_sockets.c index 3e4f09c50fb..9d9def35c7c 100644 --- a/sapi/fpm/fpm/fpm_sockets.c +++ b/sapi/fpm/fpm/fpm_sockets.c @@ -274,13 +274,23 @@ static int fpm_socket_af_inet_listening_socket(struct fpm_worker_pool_s *wp) /* return -1; } - // strip brackets from address for getaddrinfo - if (addr != NULL) { - addr_len = strlen(addr); - if (addr[0] == '[' && addr[addr_len - 1] == ']') { - addr[addr_len - 1] = '\0'; - addr++; - } + if (!addr) { + /* no address: default documented behavior, all IPv4 addresses */ + struct sockaddr_in sa_in; + + memset(&sa_in, 0, sizeof(sa_in)); + sa_in.sin_family = AF_INET; + sa_in.sin_port = htons(port); + sa_in.sin_addr.s_addr = htonl(INADDR_ANY); + free(dup_address); + return fpm_sockets_get_listening_socket(wp, (struct sockaddr *) &sa_in, sizeof(struct sockaddr_in)); + } + + /* strip brackets from address for getaddrinfo */ + addr_len = strlen(addr); + if (addr[0] == '[' && addr[addr_len - 1] == ']') { + addr[addr_len - 1] = '\0'; + addr++; } memset(&hints, 0, sizeof hints); From 69b9381901e8ab9372ef034a54833461c9e7bb76 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Sat, 15 Nov 2014 08:13:56 +0100 Subject: [PATCH 363/398] NEWS --- NEWS | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index a9c44438dca..60b0dca5b5d 100644 --- a/NEWS +++ b/NEWS @@ -6,8 +6,10 @@ PHP NEWS . Fixed bug #68370 ("unset($this)" can make the program crash). (Laruence) - FPM: + . Fixed bug #68420 (listen=9000 listens to ipv6 localhost instead of all + addresses). (Remi) . Fixed bug #68421 (access.format='%R' doesn't log ipv6 address). (Remi) - . Fixed Bug #68423 (PHP-FPM will no longer load all pools). (Remi) + . Fixed bug #68423 (PHP-FPM will no longer load all pools). (Remi) - PDO_pgsql: . Fixed bug #66584 (Segmentation fault on statement deallocation) (Matteo) From 51acb9dddd3466ed6f290f283bfa67682b3b2462 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Sat, 15 Nov 2014 08:14:43 +0100 Subject: [PATCH 364/398] NEWS --- NEWS | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 575a13d215b..c173e629059 100644 --- a/NEWS +++ b/NEWS @@ -8,8 +8,10 @@ PHP NEWS (Laruence) - FPM: + . Fixed bug #68420 (listen=9000 listens to ipv6 localhost instead of all + addresses). (Remi) . Fixed bug #68421 (access.format='%R' doesn't log ipv6 address). (Remi) - . Fixed Bug #68423 (PHP-FPM will no longer load all pools). (Remi) + . Fixed bug #68423 (PHP-FPM will no longer load all pools). (Remi) GMP: . Fixed bug #68419 (build error with gmp 4.1). (Remi) From 23fd22f9ede39c5885a332cf6e6f5785c5f3fcba Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Sun, 16 Nov 2014 17:59:36 +0100 Subject: [PATCH 365/398] improve comments about FPM listen option --- sapi/fpm/php-fpm.conf.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sapi/fpm/php-fpm.conf.in b/sapi/fpm/php-fpm.conf.in index 631bc46f42a..f22c2ff8b72 100644 --- a/sapi/fpm/php-fpm.conf.in +++ b/sapi/fpm/php-fpm.conf.in @@ -150,11 +150,13 @@ group = @php_fpm_group@ ; The address on which to accept FastCGI requests. ; Valid syntaxes are: -; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on +; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on ; a specific port; ; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on ; a specific port; -; 'port' - to listen on a TCP socket to all addresses on a +; 'port' - to listen on a TCP socket to all IPv4 addresses on a +; specific port; +; '[::]:port' - to listen on a TCP socket to all addresses on a ; specific port; ; '/path/to/unix/socket' - to listen on a unix socket. ; Note: This value is mandatory. From 54fa42475120f3ab61f50732fa2d68c3af07f259 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 17 Nov 2014 08:36:14 +0300 Subject: [PATCH 366/398] Micro optimization --- Zend/zend_execute.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 1551789c481..8a8cbbffafb 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -456,15 +456,15 @@ static zend_always_inline zval *_get_zval_ptr_ptr_var(uint32_t var, const zend_e if (EXPECTED(Z_TYPE_P(ret) == IS_INDIRECT)) { should_free->var = NULL; - return Z_INDIRECT_P(ret); - } else if (!Z_REFCOUNTED_P(ret) || Z_REFCOUNT_P(ret) == 1) { - should_free->var = ret; - return ret; + ret = Z_INDIRECT_P(ret); } else { - Z_DELREF_P(ret); - should_free->var = NULL; - return ret; + should_free->var = ret; + if (Z_REFCOUNTED_P(ret) && Z_REFCOUNT_P(ret) > 1) { + should_free->var = NULL; + Z_DELREF_P(ret); + } } + return ret; } static inline zval *_get_zval_ptr_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC) From 4657289e87e18bb8967d5a8b0163c772d410e2b8 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 17 Nov 2014 06:53:38 +0100 Subject: [PATCH 367/398] Improve fix bug #68421 access.format='%R' doesn't log ipv6 address Log IPv4-Mapped-Ipv6 address as IPv4 (not as IPv6) --- sapi/fpm/fpm/fastcgi.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/sapi/fpm/fpm/fastcgi.c b/sapi/fpm/fpm/fastcgi.c index 86fca17c5f7..d1db0ec293e 100644 --- a/sapi/fpm/fpm/fastcgi.c +++ b/sapi/fpm/fpm/fastcgi.c @@ -1099,13 +1099,23 @@ const char *fcgi_get_last_client_ip() /* {{{ */ { static char str[INET6_ADDRSTRLEN]; - if (client_sa.sa.sa_family == AF_UNIX) { - return NULL; - } + /* Ipv4 */ if (client_sa.sa.sa_family == AF_INET) { return inet_ntop(client_sa.sa.sa_family, &client_sa.sa_inet.sin_addr, str, INET6_ADDRSTRLEN); } - return inet_ntop(client_sa.sa.sa_family, &client_sa.sa_inet6.sin6_addr, str, INET6_ADDRSTRLEN); +#ifdef IN6_IS_ADDR_V4MAPPED + /* Ipv4-Mapped-Ipv6 */ + if (client_sa.sa.sa_family == AF_INET6 + && IN6_IS_ADDR_V4MAPPED(&client_sa.sa_inet6.sin6_addr)) { + return inet_ntop(AF_INET, ((char *)&client_sa.sa_inet6.sin6_addr)+12, str, INET6_ADDRSTRLEN); + } +#endif + /* Ipv6 */ + if (client_sa.sa.sa_family == AF_INET6) { + return inet_ntop(client_sa.sa.sa_family, &client_sa.sa_inet6.sin6_addr, str, INET6_ADDRSTRLEN); + } + /* Unix socket */ + return NULL; } /* }}} */ /* From 4475cbdc8577ec704bf7d6a6c753e5e4066fec19 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 17 Nov 2014 06:57:59 +0100 Subject: [PATCH 368/398] comment about ipv4-mapped in fpm conf --- sapi/fpm/php-fpm.conf.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sapi/fpm/php-fpm.conf.in b/sapi/fpm/php-fpm.conf.in index f22c2ff8b72..9d752956604 100644 --- a/sapi/fpm/php-fpm.conf.in +++ b/sapi/fpm/php-fpm.conf.in @@ -156,8 +156,8 @@ group = @php_fpm_group@ ; a specific port; ; 'port' - to listen on a TCP socket to all IPv4 addresses on a ; specific port; -; '[::]:port' - to listen on a TCP socket to all addresses on a -; specific port; +; '[::]:port' - to listen on a TCP socket to all addresses +; (IPv6 and IPv4-mapped) on a specific port; ; '/path/to/unix/socket' - to listen on a unix socket. ; Note: This value is mandatory. listen = 127.0.0.1:9000 From 3a8103ae4738824ebb27a9a739e253740580ed36 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 17 Nov 2014 09:22:13 +0100 Subject: [PATCH 369/398] Fixed bug #68428 allowed_client is IPv4 only --- sapi/fpm/fpm/fastcgi.c | 72 +++++++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 22 deletions(-) diff --git a/sapi/fpm/fpm/fastcgi.c b/sapi/fpm/fpm/fastcgi.c index d1db0ec293e..36e37b79d39 100644 --- a/sapi/fpm/fpm/fastcgi.c +++ b/sapi/fpm/fpm/fastcgi.c @@ -144,7 +144,7 @@ static HashTable fcgi_mgmt_vars; static int is_initialized = 0; static int in_shutdown = 0; -static in_addr_t *allowed_clients = NULL; +static sa_t *allowed_clients = NULL; static sa_t client_sa; @@ -267,14 +267,18 @@ void fcgi_set_allowed_clients(char *ip) *end = 0; end++; } - allowed_clients[n] = inet_addr(cur); - if (allowed_clients[n] == INADDR_NONE) { + if (inet_pton(AF_INET, cur, &allowed_clients[n].sa_inet.sin_addr)>0) { + allowed_clients[n].sa.sa_family = AF_INET; + n++; + } else if (inet_pton(AF_INET6, cur, &allowed_clients[n].sa_inet6.sin6_addr)>0) { + allowed_clients[n].sa.sa_family = AF_INET6; + n++; + } else { zlog(ZLOG_ERROR, "Wrong IP address '%s' in listen.allowed_clients", cur); } - n++; cur = end; } - allowed_clients[n] = INADDR_NONE; + allowed_clients[n].sa.sa_family = 0; free(ip); } } @@ -760,6 +764,43 @@ void fcgi_close(fcgi_request *req, int force, int destroy) } } +static int fcgi_is_allowed() { + int i; + + if (client_sa.sa.sa_family == AF_UNIX) { + return 1; + } + if (!allowed_clients) { + return 1; + } + if (client_sa.sa.sa_family == AF_INET) { + for (i=0 ; allowed_clients[i].sa.sa_family ; i++) { + if (allowed_clients[i].sa.sa_family == AF_INET + && !memcmp(&client_sa.sa_inet.sin_addr, &allowed_clients[i].sa_inet.sin_addr, 4)) { + return 1; + } + } + } + if (client_sa.sa.sa_family == AF_INET6) { + for (i=0 ; allowed_clients[i].sa.sa_family ; i++) { + if (allowed_clients[i].sa.sa_family == AF_INET6 + && !memcmp(&client_sa.sa_inet6.sin6_addr, &allowed_clients[i].sa_inet6.sin6_addr, 12)) { + return 1; + } +#ifdef IN6_IS_ADDR_V4MAPPED + if (allowed_clients[i].sa.sa_family == AF_INET + && IN6_IS_ADDR_V4MAPPED(&client_sa.sa_inet6.sin6_addr) + && !memcmp(((char *)&client_sa.sa_inet6.sin6_addr)+12, &allowed_clients[i].sa_inet.sin_addr, 4)) { + return 1; + } +#endif + } + } + + zlog(ZLOG_ERROR, "Connection disallowed: IP address '%s' has been dropped.", fcgi_get_last_client_ip()); + return 0; +} + int fcgi_accept_request(fcgi_request *req) { #ifdef _WIN32 @@ -810,23 +851,10 @@ int fcgi_accept_request(fcgi_request *req) FCGI_UNLOCK(req->listen_socket); client_sa = sa; - if (sa.sa.sa_family == AF_INET && req->fd >= 0 && allowed_clients) { - int n = 0; - int allowed = 0; - - while (allowed_clients[n] != INADDR_NONE) { - if (allowed_clients[n] == sa.sa_inet.sin_addr.s_addr) { - allowed = 1; - break; - } - n++; - } - if (!allowed) { - zlog(ZLOG_ERROR, "Connection disallowed: IP address '%s' has been dropped.", inet_ntoa(sa.sa_inet.sin_addr)); - closesocket(req->fd); - req->fd = -1; - continue; - } + if (req->fd >= 0 && !fcgi_is_allowed()) { + closesocket(req->fd); + req->fd = -1; + continue; } } From 6d9b4ca5fc806f77f75cd88f34fb1952a4731f9b Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 17 Nov 2014 09:23:16 +0100 Subject: [PATCH 370/398] NEWS --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index 60b0dca5b5d..2d3dd86385a 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,7 @@ PHP NEWS addresses). (Remi) . Fixed bug #68421 (access.format='%R' doesn't log ipv6 address). (Remi) . Fixed bug #68423 (PHP-FPM will no longer load all pools). (Remi) + . Fixed bug #68428 (listen.allowed_clients is IPv4 only). (Remi) - PDO_pgsql: . Fixed bug #66584 (Segmentation fault on statement deallocation) (Matteo) From 82c71158c1f73f5ee386845417aa8315658a9f2a Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 17 Nov 2014 09:23:47 +0100 Subject: [PATCH 371/398] NEWS --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index c173e629059..620940d5094 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,7 @@ PHP NEWS addresses). (Remi) . Fixed bug #68421 (access.format='%R' doesn't log ipv6 address). (Remi) . Fixed bug #68423 (PHP-FPM will no longer load all pools). (Remi) + . Fixed bug #68428 (listen.allowed_clients is IPv4 only). (Remi) GMP: . Fixed bug #68419 (build error with gmp 4.1). (Remi) From 1504e9c9df0b504d08d46ef249eef75c39576055 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 17 Nov 2014 08:48:32 +0100 Subject: [PATCH 372/398] fix incompatible pointer types --- Zend/zend_execute_API.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 9d4eebf0100..f5ee01463a8 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -1341,6 +1341,10 @@ ZEND_API void zend_timeout(int dummy) /* {{{ */ #ifdef ZEND_WIN32 static LRESULT CALLBACK zend_timeout_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) /* {{{ */ { +#ifdef ZTS + THREAD_T thread_id = (THREAD_T)wParam; +#endif + switch (message) { case WM_DESTROY: PostQuitMessage(0); @@ -1355,7 +1359,7 @@ static LRESULT CALLBACK zend_timeout_WndProc(HWND hWnd, UINT message, WPARAM wPa #endif SetTimer(timeout_window, wParam, lParam*1000, NULL); #ifdef ZTS - tsrm_ls = ts_resource_ex(0, &wParam); + tsrm_ls = ts_resource_ex(0, &thread_id); if (!tsrm_ls) { /* shouldn't normally happen */ break; @@ -1372,7 +1376,7 @@ static LRESULT CALLBACK zend_timeout_WndProc(HWND hWnd, UINT message, WPARAM wPa #ifdef ZTS void ***tsrm_ls; - tsrm_ls = ts_resource_ex(0, &wParam); + tsrm_ls = ts_resource_ex(0, &thread_id); if (!tsrm_ls) { /* Thread died before receiving its timeout? */ break; From 873a460c7cccd98a7dde8eceace9a5ffc7e49a10 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 17 Nov 2014 08:48:32 +0100 Subject: [PATCH 373/398] fix incompatible pointer types --- Zend/zend_execute_API.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index ef4835f9af5..1f3cab24bfd 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -1236,6 +1236,10 @@ ZEND_API void zend_timeout(int dummy) /* {{{ */ #ifdef ZEND_WIN32 static LRESULT CALLBACK zend_timeout_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) /* {{{ */ { +#ifdef ZTS + THREAD_T thread_id = (THREAD_T)wParam; +#endif + switch (message) { case WM_DESTROY: PostQuitMessage(0); @@ -1250,7 +1254,7 @@ static LRESULT CALLBACK zend_timeout_WndProc(HWND hWnd, UINT message, WPARAM wPa #endif SetTimer(timeout_window, wParam, lParam*1000, NULL); #ifdef ZTS - tsrm_ls = ts_resource_ex(0, &wParam); + tsrm_ls = ts_resource_ex(0, &thread_id); if (!tsrm_ls) { /* shouldn't normally happen */ break; @@ -1267,7 +1271,7 @@ static LRESULT CALLBACK zend_timeout_WndProc(HWND hWnd, UINT message, WPARAM wPa #ifdef ZTS void ***tsrm_ls; - tsrm_ls = ts_resource_ex(0, &wParam); + tsrm_ls = ts_resource_ex(0, &thread_id); if (!tsrm_ls) { /* Thread died before receiving its timeout? */ break; From 317d7c62eec25c06b9a2620b8ba455cd2fa4739d Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 17 Nov 2014 08:47:48 +0100 Subject: [PATCH 374/398] fix incompatible pointer types --- Zend/zend_execute_API.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index eaa84103f93..5b31f465ca9 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -1166,6 +1166,10 @@ ZEND_API void zend_timeout(int dummy) /* {{{ */ #ifdef ZEND_WIN32 static LRESULT CALLBACK zend_timeout_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) /* {{{ */ { +#ifdef ZTS + THREAD_T thread_id = (THREAD_T)wParam; +#endif + switch (message) { case WM_DESTROY: PostQuitMessage(0); @@ -1180,7 +1184,7 @@ static LRESULT CALLBACK zend_timeout_WndProc(HWND hWnd, UINT message, WPARAM wPa #endif SetTimer(timeout_window, wParam, lParam*1000, NULL); #ifdef ZTS - tsrm_ls = ts_resource_ex(0, &wParam); + tsrm_ls = ts_resource_ex(0, &thread_id); if (!tsrm_ls) { /* shouldn't normally happen */ break; @@ -1197,7 +1201,7 @@ static LRESULT CALLBACK zend_timeout_WndProc(HWND hWnd, UINT message, WPARAM wPa #ifdef ZTS void ***tsrm_ls; - tsrm_ls = ts_resource_ex(0, &wParam); + tsrm_ls = ts_resource_ex(0, &thread_id); if (!tsrm_ls) { /* Thread died before receiving its timeout? */ break; From 09f9f7ce5030973052bca5043425bd9f20ad7a7e Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 17 Nov 2014 09:35:20 +0100 Subject: [PATCH 375/398] update fpm configuration for #68428 --- sapi/fpm/php-fpm.conf.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sapi/fpm/php-fpm.conf.in b/sapi/fpm/php-fpm.conf.in index 9d752956604..2b1566047f5 100644 --- a/sapi/fpm/php-fpm.conf.in +++ b/sapi/fpm/php-fpm.conf.in @@ -175,7 +175,7 @@ listen = 127.0.0.1:9000 ;listen.group = @php_fpm_group@ ;listen.mode = 0660 -; List of ipv4 addresses of FastCGI clients which are allowed to connect. +; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect. ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address ; must be separated by a comma. If this value is left blank, connections will be From d9fd670fdc4a8096ce1877b2419edb04f60280c4 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 17 Nov 2014 09:35:20 +0100 Subject: [PATCH 376/398] update fpm configuration for #68428 --- sapi/fpm/php-fpm.conf.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sapi/fpm/php-fpm.conf.in b/sapi/fpm/php-fpm.conf.in index 9d752956604..2b1566047f5 100644 --- a/sapi/fpm/php-fpm.conf.in +++ b/sapi/fpm/php-fpm.conf.in @@ -175,7 +175,7 @@ listen = 127.0.0.1:9000 ;listen.group = @php_fpm_group@ ;listen.mode = 0660 -; List of ipv4 addresses of FastCGI clients which are allowed to connect. +; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect. ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address ; must be separated by a comma. If this value is left blank, connections will be From ab2215deb37b1f5b7b1dbc06bdb81280cf3ce0bf Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 17 Nov 2014 09:35:20 +0100 Subject: [PATCH 377/398] update fpm configuration for #68428 --- sapi/fpm/php-fpm.conf.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sapi/fpm/php-fpm.conf.in b/sapi/fpm/php-fpm.conf.in index 238e59c77d1..bcdfe56a101 100644 --- a/sapi/fpm/php-fpm.conf.in +++ b/sapi/fpm/php-fpm.conf.in @@ -175,7 +175,7 @@ listen = 127.0.0.1:9000 ;listen.group = @php_fpm_group@ ;listen.mode = 0660 -; List of ipv4 addresses of FastCGI clients which are allowed to connect. +; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect. ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address ; must be separated by a comma. If this value is left blank, connections will be From 76019b86c0ede959e000c164b02ed8b1d8bb29e1 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 17 Nov 2014 14:06:50 +0300 Subject: [PATCH 378/398] Reorder fields for most often access pattern --- Zend/zend_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_types.h b/Zend/zend_types.h index 383f77caa41..b07a62668cd 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -145,9 +145,9 @@ struct _zend_string { }; typedef struct _Bucket { + zval val; zend_ulong h; /* hash value (or numeric index) */ zend_string *key; /* string key or NULL for numerics */ - zval val; } Bucket; typedef struct _HashTable { From d8868b654e9e6780468bc300d7e62df54ecf5a43 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 17 Nov 2014 15:22:04 +0100 Subject: [PATCH 379/398] Add new FPM test for IPv4/IPv6 Use 9000+PHP_INT_SIZE as poprt - to avoid using default 9000 - to allow multipole 32/64 bits simultaneous run --- sapi/fpm/tests/002.phpt | 5 ++-- sapi/fpm/tests/003.phpt | 5 ++-- sapi/fpm/tests/004.phpt | 62 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 sapi/fpm/tests/004.phpt diff --git a/sapi/fpm/tests/002.phpt b/sapi/fpm/tests/002.phpt index 2ef6cedc385..ce878661eaf 100644 --- a/sapi/fpm/tests/002.phpt +++ b/sapi/fpm/tests/002.phpt @@ -8,12 +8,13 @@ FPM: Startup and connect include "include.inc"; $logfile = dirname(__FILE__).'/php-fpm.log.tmp'; +$port = 9000+PHP_INT_SIZE; $cfg = << +--FILE-- + +--EXPECTF-- +string(%d) "[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d +" +string(%d) "[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections +" +Done IPv4 +Done IPv6 +--CLEAN-- + From c746dcd7fd87fa4739bf16d65e39375d8ffafb2e Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 18 Nov 2014 09:05:48 +0300 Subject: [PATCH 380/398] Get rid of zend_free_op structure (use zval* instead). Get rid of useless TSRMLS arguments. --- Zend/zend_execute.c | 88 +- Zend/zend_execute.h | 5 +- Zend/zend_vm_def.h | 16 +- Zend/zend_vm_execute.h | 3696 ++++++++++++++++++++-------------------- Zend/zend_vm_gen.php | 88 +- 5 files changed, 1934 insertions(+), 1959 deletions(-) diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 8a8cbbffafb..4fcd1de6b80 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -99,13 +99,13 @@ static const zend_internal_function zend_pass_function = { } while (0) #define FREE_OP(should_free) \ - if (should_free.var) { \ - zval_ptr_dtor_nogc(should_free.var); \ + if (should_free) { \ + zval_ptr_dtor_nogc(should_free); \ } #define FREE_OP_VAR_PTR(should_free) \ - if (should_free.var) { \ - zval_ptr_dtor_nogc(should_free.var); \ + if (should_free) { \ + zval_ptr_dtor_nogc(should_free); \ } /* End of zend_execute_locks.h */ @@ -183,29 +183,29 @@ ZEND_API zval* zend_get_compiled_variable_value(const zend_execute_data *execute return EX_VAR(var); } -static zend_always_inline zval *_get_zval_ptr_tmp(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free TSRMLS_DC) +static zend_always_inline zval *_get_zval_ptr_tmp(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free) { zval *ret = EX_VAR(var); - should_free->var = ret; + *should_free = ret; ZEND_ASSERT(Z_TYPE_P(ret) != IS_REFERENCE); return ret; } -static zend_always_inline zval *_get_zval_ptr_var(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free TSRMLS_DC) +static zend_always_inline zval *_get_zval_ptr_var(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free) { zval *ret = EX_VAR(var); - should_free->var = ret; + *should_free = ret; return ret; } -static zend_always_inline zval *_get_zval_ptr_var_deref(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free TSRMLS_DC) +static zend_always_inline zval *_get_zval_ptr_var_deref(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free) { zval *ret = EX_VAR(var); - should_free->var = ret; + *should_free = ret; ZVAL_DEREF(ret); return ret; } @@ -392,75 +392,53 @@ static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_W(const zend_execu static inline zval *_get_zval_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC) { - zval *ret; - switch (op_type) { case IS_CONST: - should_free->var = NULL; + *should_free = NULL; return node->zv; - break; case IS_TMP_VAR: - ret = EX_VAR(node->var); - should_free->var = ret; - return ret; - break; + return _get_zval_ptr_tmp(node->var, execute_data, should_free); case IS_VAR: - return _get_zval_ptr_var(node->var, execute_data, should_free TSRMLS_CC); - break; - case IS_UNUSED: - should_free->var = NULL; - return NULL; - break; + return _get_zval_ptr_var(node->var, execute_data, should_free); case IS_CV: - default: - should_free->var = NULL; + *should_free = NULL; return _get_zval_ptr_cv(execute_data, node->var, type TSRMLS_CC); - break; + default: + *should_free = NULL; + return NULL; } - return NULL; } static inline zval *_get_zval_ptr_deref(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC) { - zval *ret; - switch (op_type) { case IS_CONST: - should_free->var = NULL; + *should_free = NULL; return node->zv; - break; case IS_TMP_VAR: - ret = EX_VAR(node->var); - should_free->var = ret; - return ret; - break; + return _get_zval_ptr_tmp(node->var, execute_data, should_free); case IS_VAR: - return _get_zval_ptr_var_deref(node->var, execute_data, should_free TSRMLS_CC); - break; - case IS_UNUSED: - should_free->var = NULL; - return NULL; - break; + return _get_zval_ptr_var_deref(node->var, execute_data, should_free); case IS_CV: - default: - should_free->var = NULL; + *should_free = NULL; return _get_zval_ptr_cv_deref(execute_data, node->var, type TSRMLS_CC); - break; + default: + *should_free = NULL; + return NULL; } - return NULL; } -static zend_always_inline zval *_get_zval_ptr_ptr_var(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free TSRMLS_DC) +static zend_always_inline zval *_get_zval_ptr_ptr_var(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free) { zval *ret = EX_VAR(var); if (EXPECTED(Z_TYPE_P(ret) == IS_INDIRECT)) { - should_free->var = NULL; + *should_free = NULL; ret = Z_INDIRECT_P(ret); } else { - should_free->var = ret; + *should_free = ret; if (Z_REFCOUNTED_P(ret) && Z_REFCOUNT_P(ret) > 1) { - should_free->var = NULL; + *should_free = NULL; Z_DELREF_P(ret); } } @@ -470,15 +448,15 @@ static zend_always_inline zval *_get_zval_ptr_ptr_var(uint32_t var, const zend_e static inline zval *_get_zval_ptr_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC) { if (op_type == IS_CV) { - should_free->var = NULL; + *should_free = NULL; return _get_zval_ptr_cv(execute_data, node->var, type TSRMLS_CC); } else /* if (op_type == IS_VAR) */ { ZEND_ASSERT(op_type == IS_VAR); - return _get_zval_ptr_ptr_var(node->var, execute_data, should_free TSRMLS_CC); + return _get_zval_ptr_ptr_var(node->var, execute_data, should_free); } } -static zend_always_inline zval *_get_obj_zval_ptr_unused(zend_execute_data *execute_data TSRMLS_DC) +static zend_always_inline zval *_get_obj_zval_ptr_unused(zend_execute_data *execute_data) { if (EXPECTED(Z_OBJ(EX(This)) != NULL)) { return &EX(This); @@ -492,7 +470,7 @@ static inline zval *_get_obj_zval_ptr(int op_type, znode_op *op, zend_execute_da { if (op_type == IS_UNUSED) { if (EXPECTED(Z_OBJ(EX(This)) != NULL)) { - should_free->var = NULL; + *should_free = NULL; return &EX(This); } else { zend_error_noreturn(E_ERROR, "Using $this when not in object context"); @@ -505,7 +483,7 @@ static inline zval *_get_obj_zval_ptr_ptr(int op_type, const znode_op *node, zen { if (op_type == IS_UNUSED) { if (EXPECTED(Z_OBJ(EX(This)) != NULL)) { - should_free->var = NULL; + *should_free = NULL; return &EX(This); } else { zend_error_noreturn(E_ERROR, "Using $this when not in object context"); diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index 982413e0322..bfa3394e0db 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -261,10 +261,7 @@ ZEND_API int zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler ZEND_API user_opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode); /* former zend_execute_locks.h */ -typedef struct _zend_free_op { - zval *var; -/* int is_var; */ -} zend_free_op; +typedef zval* zend_free_op; ZEND_API zval *zend_get_zval_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC); diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index f2a6fd15fd4..7ea7929a696 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -1199,7 +1199,7 @@ ZEND_VM_HANDLER(84, ZEND_FETCH_DIM_W, VAR|CV, CONST|TMP|VAR|UNUSED|CV) ZVAL_DEREF(container); zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR_DEREF(BP_VAR_R), OP2_TYPE TSRMLS_CC); FREE_OP2(); - if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } FREE_OP1_VAR_PTR(); @@ -1222,7 +1222,7 @@ ZEND_VM_HANDLER(87, ZEND_FETCH_DIM_RW, VAR|CV, CONST|TMP|VAR|UNUSED|CV) ZVAL_DEREF(container); zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR_DEREF(BP_VAR_R), OP2_TYPE TSRMLS_CC); FREE_OP2(); - if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } FREE_OP1_VAR_PTR(); @@ -1263,7 +1263,7 @@ ZEND_VM_HANDLER(93, ZEND_FETCH_DIM_FUNC_ARG, CONST|TMP|VAR|CV, CONST|TMP|VAR|UNU } ZVAL_DEREF(container); zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR_DEREF(BP_VAR_R), OP2_TYPE TSRMLS_CC); - if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } FREE_OP2(); @@ -1296,7 +1296,7 @@ ZEND_VM_HANDLER(96, ZEND_FETCH_DIM_UNSET, VAR|CV, CONST|TMP|VAR|CV) ZVAL_DEREF(container); zend_fetch_dimension_address_UNSET(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR_DEREF(BP_VAR_R), OP2_TYPE TSRMLS_CC); FREE_OP2(); - if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } FREE_OP1_VAR_PTR(); @@ -1376,7 +1376,7 @@ ZEND_VM_HANDLER(85, ZEND_FETCH_OBJ_W, VAR|UNUSED|CV, CONST|TMP|VAR|CV) zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, OP2_TYPE, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); FREE_OP2(); - if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } FREE_OP1_VAR_PTR(); @@ -1400,7 +1400,7 @@ ZEND_VM_HANDLER(88, ZEND_FETCH_OBJ_RW, VAR|UNUSED|CV, CONST|TMP|VAR|CV) } zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, OP2_TYPE, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); FREE_OP2(); - if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } FREE_OP1_VAR_PTR(); @@ -1484,7 +1484,7 @@ ZEND_VM_HANDLER(94, ZEND_FETCH_OBJ_FUNC_ARG, CONST|TMP|VAR|UNUSED|CV, CONST|TMP| } zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, OP2_TYPE, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); FREE_OP2(); - if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } FREE_OP1_VAR_PTR(); @@ -1510,7 +1510,7 @@ ZEND_VM_HANDLER(97, ZEND_FETCH_OBJ_UNSET, VAR|UNUSED|CV, CONST|TMP|VAR|CV) } zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, OP2_TYPE, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); FREE_OP2(); - if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } FREE_OP1_VAR_PTR(); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 776cc98dc61..6680da3458e 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -1752,7 +1752,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ ZEND_VM_NEXT_OPCODE(); } else { zend_free_op free_op2; - zval *class_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *class_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_TMP_VAR == IS_CONST) { if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) { @@ -1772,7 +1772,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ zend_error_noreturn(E_ERROR, "Class name must be a valid object or a string"); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -1809,7 +1809,7 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_TMP_HANDLER(ZEND_OPCODE_H zval *function_name_ptr; SAVE_OPLINE(); - function_name_ptr = function_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + function_name_ptr = function_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); ZVAL_DEREF(function_name); if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) { @@ -1824,7 +1824,7 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_TMP_HANDLER(ZEND_OPCODE_H zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(function_name)); } zend_string_free(lcname); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); fbc = Z_FUNC_P(func); called_scope = NULL; @@ -1841,7 +1841,7 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_TMP_HANDLER(ZEND_OPCODE_H /* Delay closure destruction until its invocation */ fbc->common.prototype = (zend_function*)Z_OBJ_P(function_name_ptr); } else if (IS_TMP_VAR == IS_CV) { - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } } else if (EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY) && zend_hash_num_elements(Z_ARRVAL_P(function_name)) == 2) { @@ -1908,7 +1908,7 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_TMP_HANDLER(ZEND_OPCODE_H GC_REFCOUNT(object)++; /* For $this pointer */ } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else { if (UNEXPECTED(EG(exception) != NULL)) { HANDLE_EXCEPTION(); @@ -1938,7 +1938,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ ZEND_VM_NEXT_OPCODE(); } else { zend_free_op free_op2; - zval *class_name = _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *class_name = _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2); if (IS_VAR == IS_CONST) { if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) { @@ -1958,7 +1958,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ zend_error_noreturn(E_ERROR, "Class name must be a valid object or a string"); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -1995,7 +1995,7 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_VAR_HANDLER(ZEND_OPCODE_H zval *function_name_ptr; SAVE_OPLINE(); - function_name_ptr = function_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + function_name_ptr = function_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); ZVAL_DEREF(function_name); if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) { @@ -2010,7 +2010,7 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_VAR_HANDLER(ZEND_OPCODE_H zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(function_name)); } zend_string_free(lcname); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); fbc = Z_FUNC_P(func); called_scope = NULL; @@ -2022,12 +2022,12 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_VAR_HANDLER(ZEND_OPCODE_H if (object) { GC_REFCOUNT(object)++; } - if (IS_VAR == IS_VAR && (free_op2.var != NULL) && Z_REFCOUNT_P(function_name) == 1 && + if (IS_VAR == IS_VAR && (free_op2 != NULL) && Z_REFCOUNT_P(function_name) == 1 && fbc->common.fn_flags & ZEND_ACC_CLOSURE) { /* Delay closure destruction until its invocation */ fbc->common.prototype = (zend_function*)Z_OBJ_P(function_name_ptr); } else if (IS_VAR == IS_CV) { - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } } else if (EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY) && zend_hash_num_elements(Z_ARRVAL_P(function_name)) == 2) { @@ -2094,7 +2094,7 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_VAR_HANDLER(ZEND_OPCODE_H GC_REFCOUNT(object)++; /* For $this pointer */ } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else { if (UNEXPECTED(EG(exception) != NULL)) { HANDLE_EXCEPTION(); @@ -3946,7 +3946,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CONST_CONST_HANDLER(ZEND_ } ZVAL_DEREF(container); zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, opline->op2.zv, IS_CONST TSRMLS_CC); - if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -4093,7 +4093,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CONST_CONST_HANDLER(ZEND_ } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CONST, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -5023,9 +5023,9 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_add_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -5038,9 +5038,9 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_sub_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -5053,9 +5053,9 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_mul_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -5068,9 +5068,9 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_div_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -5083,9 +5083,9 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_mod_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -5098,9 +5098,9 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); shift_left_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -5113,9 +5113,9 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); shift_right_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -5128,9 +5128,9 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); concat_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -5143,9 +5143,9 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); fast_is_identical_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -5159,9 +5159,9 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_CONST_TMP_HANDLER(ZEND_OPCO SAVE_OPLINE(); fast_is_not_identical_function(result, opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -5175,9 +5175,9 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); fast_equal_function(result, opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -5191,9 +5191,9 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); fast_not_equal_function(result, opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -5207,9 +5207,9 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); fast_is_smaller_function(result, opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -5223,9 +5223,9 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_CONST_TMP_HANDLER(ZEND_O SAVE_OPLINE(); fast_is_smaller_or_equal_function(result, opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -5238,9 +5238,9 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); bitwise_or_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -5253,9 +5253,9 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); bitwise_and_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -5268,9 +5268,9 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); bitwise_xor_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -5283,9 +5283,9 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); boolean_xor_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -5298,8 +5298,8 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HA SAVE_OPLINE(); container = opline->op1.zv; - zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2), IS_TMP_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -5313,8 +5313,8 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_IS_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); container = opline->op1.zv; - zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2), IS_TMP_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -5337,19 +5337,19 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CONST_TMP_HANDLER(ZEND_OP zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } ZVAL_DEREF(container); - zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR TSRMLS_CC); - if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2), IS_TMP_VAR TSRMLS_CC); + if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else { if (IS_TMP_VAR == IS_UNUSED) { zend_error_noreturn(E_ERROR, "Cannot use [] for reading"); } container = opline->op1.zv; - zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2), IS_TMP_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); } CHECK_EXCEPTION(); @@ -5366,7 +5366,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HA SAVE_OPLINE(); container = opline->op1.zv; - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if ((IS_CONST != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -5405,7 +5405,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HA } while (0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -5421,7 +5421,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); container = opline->op1.zv; - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if ((IS_CONST != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -5459,7 +5459,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_H } while (0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -5476,7 +5476,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CONST_TMP_HANDLER(ZEND_OP zval *property; SAVE_OPLINE(); - property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); container = NULL; if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR) { @@ -5486,8 +5486,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CONST_TMP_HANDLER(ZEND_OP zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CONST, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -5537,7 +5537,7 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_TMP_HANDLER(ZE } else if (IS_TMP_VAR != IS_UNUSED) { zend_free_op free_op2; - function_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_TMP_VAR != IS_CONST) { if (UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { if (UNEXPECTED(EG(exception) != NULL)) { @@ -5565,7 +5565,7 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_TMP_HANDLER(ZE } } if (IS_TMP_VAR != IS_CONST) { - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } } else { if (UNEXPECTED(ce->constructor == NULL)) { @@ -5626,7 +5626,7 @@ static int ZEND_FASTCALL ZEND_INIT_USER_CALL_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE { USE_OPLINE zend_free_op free_op2; - zval *function_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *function_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); zend_fcall_info_cache fcc; char *error = NULL; zend_function *func; @@ -5671,7 +5671,7 @@ static int ZEND_FASTCALL ZEND_INIT_USER_CALL_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION, func, opline->extended_value, called_scope, object, EX(call) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -5685,9 +5685,9 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); fast_equal_function(result, opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -5729,7 +5729,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_TMP_HANDLER(ZEND_OPC if (IS_TMP_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); zend_string *str; zend_ulong hval; @@ -5772,7 +5772,7 @@ str_index: /* do nothing */ break; } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else { zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr); } @@ -5822,7 +5822,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CONST_TMP_HANDLER(ZEND SAVE_OPLINE(); container = opline->op1.zv; - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_CONST != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { HashTable *ht = Z_ARRVAL_P(container); @@ -5918,7 +5918,7 @@ num_index_prop: result = ((opline->extended_value & ZEND_ISSET) == 0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_BOOL(EX_VAR(opline->result.var), result); CHECK_EXCEPTION(); @@ -5935,7 +5935,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_CONST_TMP_HANDLER(ZEN SAVE_OPLINE(); container = opline->op1.zv; - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_CONST == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { if (EXPECTED(Z_OBJ_HT_P(container)->has_property)) { @@ -5951,7 +5951,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_CONST_TMP_HANDLER(ZEN result = ((opline->extended_value & ZEND_ISSET) == 0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_BOOL(EX_VAR(opline->result.var), result); CHECK_EXCEPTION(); @@ -6041,7 +6041,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ /* Set the new yielded key */ if (IS_TMP_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *key = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *key = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); /* Consts, temporary variables and references need copying */ if (IS_TMP_VAR == IS_CONST) { @@ -6097,9 +6097,9 @@ static int ZEND_FASTCALL ZEND_POW_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); pow_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -6112,9 +6112,9 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_add_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -6127,9 +6127,9 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_sub_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -6142,9 +6142,9 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_mul_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -6157,9 +6157,9 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_div_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -6172,9 +6172,9 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_mod_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -6187,9 +6187,9 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); shift_left_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -6202,9 +6202,9 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); shift_right_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -6217,9 +6217,9 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); concat_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -6232,9 +6232,9 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); fast_is_identical_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -6248,9 +6248,9 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_CONST_VAR_HANDLER(ZEND_OPCO SAVE_OPLINE(); fast_is_not_identical_function(result, opline->op1.zv, - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -6264,9 +6264,9 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); fast_equal_function(result, opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -6280,9 +6280,9 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); fast_not_equal_function(result, opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -6296,9 +6296,9 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); fast_is_smaller_function(result, opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -6312,9 +6312,9 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_CONST_VAR_HANDLER(ZEND_O SAVE_OPLINE(); fast_is_smaller_or_equal_function(result, opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -6327,9 +6327,9 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); bitwise_or_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -6342,9 +6342,9 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); bitwise_and_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -6357,9 +6357,9 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); bitwise_xor_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -6372,9 +6372,9 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); boolean_xor_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -6535,8 +6535,8 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HA SAVE_OPLINE(); container = opline->op1.zv; - zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2), IS_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -6550,8 +6550,8 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_IS_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); container = opline->op1.zv; - zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2), IS_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -6574,19 +6574,19 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CONST_VAR_HANDLER(ZEND_OP zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } ZVAL_DEREF(container); - zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR TSRMLS_CC); - if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2), IS_VAR TSRMLS_CC); + if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else { if (IS_VAR == IS_UNUSED) { zend_error_noreturn(E_ERROR, "Cannot use [] for reading"); } container = opline->op1.zv; - zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2), IS_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); } CHECK_EXCEPTION(); @@ -6603,7 +6603,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HA SAVE_OPLINE(); container = opline->op1.zv; - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if ((IS_CONST != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -6642,7 +6642,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HA } while (0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -6658,7 +6658,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); container = opline->op1.zv; - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if ((IS_CONST != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -6696,7 +6696,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_H } while (0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -6713,7 +6713,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CONST_VAR_HANDLER(ZEND_OP zval *property; SAVE_OPLINE(); - property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); container = NULL; if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR) { @@ -6723,8 +6723,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CONST_VAR_HANDLER(ZEND_OP zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CONST, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -6774,7 +6774,7 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_VAR_HANDLER(ZE } else if (IS_VAR != IS_UNUSED) { zend_free_op free_op2; - function_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_VAR != IS_CONST) { if (UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { if (UNEXPECTED(EG(exception) != NULL)) { @@ -6802,7 +6802,7 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_VAR_HANDLER(ZE } } if (IS_VAR != IS_CONST) { - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } } else { if (UNEXPECTED(ce->constructor == NULL)) { @@ -6863,7 +6863,7 @@ static int ZEND_FASTCALL ZEND_INIT_USER_CALL_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE { USE_OPLINE zend_free_op free_op2; - zval *function_name = _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *function_name = _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2); zend_fcall_info_cache fcc; char *error = NULL; zend_function *func; @@ -6908,7 +6908,7 @@ static int ZEND_FASTCALL ZEND_INIT_USER_CALL_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION, func, opline->extended_value, called_scope, object, EX(call) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -6922,9 +6922,9 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); fast_equal_function(result, opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -6966,7 +6966,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_VAR_HANDLER(ZEND_OPC if (IS_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); zend_string *str; zend_ulong hval; @@ -7009,7 +7009,7 @@ str_index: /* do nothing */ break; } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else { zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr); } @@ -7204,7 +7204,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CONST_VAR_HANDLER(ZEND SAVE_OPLINE(); container = opline->op1.zv; - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_CONST != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { HashTable *ht = Z_ARRVAL_P(container); @@ -7300,7 +7300,7 @@ num_index_prop: result = ((opline->extended_value & ZEND_ISSET) == 0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_BOOL(EX_VAR(opline->result.var), result); CHECK_EXCEPTION(); @@ -7317,7 +7317,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_CONST_VAR_HANDLER(ZEN SAVE_OPLINE(); container = opline->op1.zv; - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_CONST == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { if (EXPECTED(Z_OBJ_HT_P(container)->has_property)) { @@ -7333,7 +7333,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_CONST_VAR_HANDLER(ZEN result = ((opline->extended_value & ZEND_ISSET) == 0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_BOOL(EX_VAR(opline->result.var), result); CHECK_EXCEPTION(); @@ -7423,7 +7423,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_ /* Set the new yielded key */ if (IS_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *key = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *key = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); /* Consts, temporary variables and references need copying */ if (IS_VAR == IS_CONST) { @@ -7432,7 +7432,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_ ZVAL_COPY_VALUE(&generator->key, key); } else if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && Z_ISREF_P(key)) { ZVAL_DUP(&generator->key, Z_REFVAL_P(key)); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else { ZVAL_COPY_VALUE(&generator->key, key); if (IS_VAR == IS_CV) { @@ -7479,9 +7479,9 @@ static int ZEND_FASTCALL ZEND_POW_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); pow_function(EX_VAR(opline->result.var), opline->op1.zv, - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -7652,7 +7652,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CONST_UNUSED_HANDLER(ZEND } ZVAL_DEREF(container); zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, NULL, IS_UNUSED TSRMLS_CC); - if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -8537,7 +8537,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CONST_CV_HANDLER(ZEND_OPC } ZVAL_DEREF(container); zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV TSRMLS_CC); - if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -8684,7 +8684,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CONST_CV_HANDLER(ZEND_OPC } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CONST, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -9357,8 +9357,8 @@ static int ZEND_FASTCALL ZEND_BW_NOT_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); bitwise_not_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -9370,8 +9370,8 @@ static int ZEND_FASTCALL ZEND_BOOL_NOT_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); boolean_not_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -9383,11 +9383,11 @@ static int ZEND_FASTCALL ZEND_ECHO_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval *z; SAVE_OPLINE(); - z = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + z = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); zend_print_variable(z TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -9407,7 +9407,7 @@ static int ZEND_FASTCALL ZEND_JMPZ_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval *val; SAVE_OPLINE(); - val = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + val = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (IS_TMP_VAR == IS_TMP_VAR) { if (Z_TYPE_P(val) == IS_TRUE) { @@ -9424,7 +9424,7 @@ static int ZEND_FASTCALL ZEND_JMPZ_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } else { opline = opline->op2.jmp_addr; } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); if (UNEXPECTED(EG(exception) != NULL)) { HANDLE_EXCEPTION(); } @@ -9438,7 +9438,7 @@ static int ZEND_FASTCALL ZEND_JMPNZ_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval *val; SAVE_OPLINE(); - val = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + val = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (IS_TMP_VAR == IS_TMP_VAR) { if (Z_TYPE_P(val) == IS_TRUE) { @@ -9455,7 +9455,7 @@ static int ZEND_FASTCALL ZEND_JMPNZ_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } else { opline++; } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); if (UNEXPECTED(EG(exception) != NULL)) { HANDLE_EXCEPTION(); } @@ -9469,7 +9469,7 @@ static int ZEND_FASTCALL ZEND_JMPZNZ_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval *val; SAVE_OPLINE(); - val = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + val = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (IS_TMP_VAR == IS_TMP_VAR) { if (EXPECTED(Z_TYPE_P(val) == IS_TRUE)) { @@ -9486,7 +9486,7 @@ static int ZEND_FASTCALL ZEND_JMPZNZ_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } else { opline = opline->op2.jmp_addr; } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); if (UNEXPECTED(EG(exception) != NULL)) { HANDLE_EXCEPTION(); } @@ -9500,7 +9500,7 @@ static int ZEND_FASTCALL ZEND_JMPZ_EX_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS zval *val; SAVE_OPLINE(); - val = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + val = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (IS_TMP_VAR == IS_TMP_VAR) { if (Z_TYPE_P(val) == IS_TRUE) { @@ -9515,11 +9515,11 @@ static int ZEND_FASTCALL ZEND_JMPZ_EX_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS } if (i_zend_is_true(val TSRMLS_CC)) { - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); ZVAL_TRUE(EX_VAR(opline->result.var)); opline++; } else { - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); ZVAL_FALSE(EX_VAR(opline->result.var)); opline = opline->op2.jmp_addr; } @@ -9536,7 +9536,7 @@ static int ZEND_FASTCALL ZEND_JMPNZ_EX_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG zval *val; SAVE_OPLINE(); - val = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + val = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (IS_TMP_VAR == IS_TMP_VAR) { if (Z_TYPE_P(val) == IS_TRUE) { @@ -9556,7 +9556,7 @@ static int ZEND_FASTCALL ZEND_JMPNZ_EX_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG ZVAL_FALSE(EX_VAR(opline->result.var)); opline++; } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); if (UNEXPECTED(EG(exception) != NULL)) { HANDLE_EXCEPTION(); } @@ -9580,10 +9580,10 @@ static int ZEND_FASTCALL ZEND_RETURN_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_free_op free_op1; SAVE_OPLINE(); - retval_ptr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + retval_ptr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (!EX(return_value)) { - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } else { if (IS_TMP_VAR == IS_CONST || IS_TMP_VAR == IS_TMP_VAR) { ZVAL_COPY_VALUE(EX(return_value), retval_ptr); @@ -9619,10 +9619,10 @@ static int ZEND_FASTCALL ZEND_RETURN_BY_REF_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLE /* Not supposed to happen, but we'll allow it */ zend_error(E_NOTICE, "Only variable references should be returned by reference"); - retval_ptr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + retval_ptr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (!EX(return_value)) { if (IS_TMP_VAR == IS_TMP_VAR) { - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } } else { ZVAL_COPY_VALUE(EX(return_value), retval_ptr); @@ -9672,7 +9672,7 @@ static int ZEND_FASTCALL ZEND_THROW_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_free_op free_op1; SAVE_OPLINE(); - value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (IS_TMP_VAR == IS_CONST || UNEXPECTED(Z_TYPE_P(value) != IS_OBJECT)) { if (UNEXPECTED(EG(exception) != NULL)) { @@ -9699,7 +9699,7 @@ static int ZEND_FASTCALL ZEND_SEND_VAL_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG zend_free_op free_op1; SAVE_OPLINE(); - value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); arg = ZEND_CALL_ARG(EX(call), opline->op2.num); EX(call)->num_args = opline->op2.num; ZVAL_COPY_VALUE(arg, value); @@ -9721,7 +9721,7 @@ static int ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) { zend_error_noreturn(E_ERROR, "Cannot pass parameter %d by reference", opline->op2.num); } - value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); arg = ZEND_CALL_ARG(EX(call), opline->op2.num); EX(call)->num_args = opline->op2.num; ZVAL_COPY_VALUE(arg, value); @@ -9741,8 +9741,8 @@ static int ZEND_FASTCALL ZEND_BOOL_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); /* PHP 3.0 returned "" for false and 1 for true, here we use 0 and 1 for now */ - ZVAL_BOOL(retval, i_zend_is_true(_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC) TSRMLS_CC)); - zval_ptr_dtor_nogc(free_op1.var); + ZVAL_BOOL(retval, i_zend_is_true(_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1) TSRMLS_CC)); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -9758,7 +9758,7 @@ static int ZEND_FASTCALL ZEND_CLONE_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_object_clone_obj_t clone_call; SAVE_OPLINE(); - obj = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + obj = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (IS_TMP_VAR == IS_CONST || (IS_TMP_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(obj) != IS_OBJECT))) { @@ -9814,7 +9814,7 @@ static int ZEND_FASTCALL ZEND_CAST_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval *result = EX_VAR(opline->result.var); SAVE_OPLINE(); - expr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + expr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); switch (opline->extended_value) { case IS_NULL: @@ -9902,7 +9902,7 @@ static int ZEND_FASTCALL ZEND_CAST_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -9917,7 +9917,7 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_TMP_HANDLER(ZEND_OPCODE_HAND zend_bool failure_retval=0; SAVE_OPLINE(); - inc_filename = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + inc_filename = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); ZVAL_UNDEF(&tmp_inc_filename); if (Z_TYPE_P(inc_filename) != IS_STRING) { @@ -9989,7 +9989,7 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_TMP_HANDLER(ZEND_OPCODE_HAND if (Z_TYPE(tmp_inc_filename) != IS_UNDEF) { zval_ptr_dtor(&tmp_inc_filename); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); if (UNEXPECTED(EG(exception) != NULL)) { HANDLE_EXCEPTION(); } else if (EXPECTED(new_op_array != NULL)) { @@ -10064,7 +10064,7 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG if (Z_REFCOUNTED_P(array_ref)) Z_ADDREF_P(array_ref); } } else { - array_ptr = array_ref = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + array_ptr = array_ref = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); ZVAL_DEREF(array_ptr); if (IS_TMP_VAR == IS_TMP_VAR) { ZVAL_COPY_VALUE(&tmp, array_ptr); @@ -10228,14 +10228,14 @@ static int ZEND_FASTCALL ZEND_EXIT_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); if (IS_TMP_VAR != IS_UNUSED) { zend_free_op free_op1; - zval *ptr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval *ptr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (Z_TYPE_P(ptr) == IS_LONG) { EG(exit_status) = Z_LVAL_P(ptr); } else { zend_print_variable(ptr TSRMLS_CC); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } #endif zend_bailout(); @@ -10264,7 +10264,7 @@ static int ZEND_FASTCALL ZEND_JMP_SET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS int is_ref = 0; SAVE_OPLINE(); - value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if ((IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) && Z_ISREF_P(value)) { is_ref = 1; @@ -10280,12 +10280,12 @@ static int ZEND_FASTCALL ZEND_JMP_SET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value); } else if (IS_TMP_VAR == IS_VAR && is_ref) { if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } ZEND_VM_JMP(opline->op2.jmp_addr); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -10298,7 +10298,7 @@ static int ZEND_FASTCALL ZEND_COALESCE_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG int is_ref = 0; SAVE_OPLINE(); - value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if ((IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) && Z_ISREF_P(value)) { is_ref = 1; @@ -10315,12 +10315,12 @@ static int ZEND_FASTCALL ZEND_COALESCE_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value); } else if (IS_TMP_VAR == IS_VAR && is_ref) { if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } ZEND_VM_JMP(opline->op2.jmp_addr); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -10332,11 +10332,11 @@ static int ZEND_FASTCALL ZEND_QM_ASSIGN_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR zval *value; SAVE_OPLINE(); - value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if ((IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) && Z_ISREF_P(value)) { ZVAL_COPY(EX_VAR(opline->result.var), Z_REFVAL_P(value)); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } else { ZVAL_COPY_VALUE(EX_VAR(opline->result.var), value); if (IS_TMP_VAR == IS_CONST) { @@ -10357,7 +10357,7 @@ static int ZEND_FASTCALL ZEND_STRLEN_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_free_op free_op1; SAVE_OPLINE(); - value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (EXPECTED(Z_TYPE_P(value) == IS_STRING)) { ZVAL_LONG(EX_VAR(opline->result.var), Z_STRLEN_P(value)); } else { @@ -10385,7 +10385,7 @@ strlen_error: ZVAL_NULL(EX_VAR(opline->result.var)); } } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -10397,7 +10397,7 @@ static int ZEND_FASTCALL ZEND_TYPE_CHECK_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_A zend_free_op free_op1; SAVE_OPLINE(); - value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); switch (opline->extended_value) { case IS_NULL: case IS_LONG: @@ -10432,7 +10432,7 @@ static int ZEND_FASTCALL ZEND_TYPE_CHECK_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_A break; EMPTY_SWITCH_DEFAULT_CASE() } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -10444,9 +10444,9 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_add_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -10459,9 +10459,9 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_sub_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -10474,9 +10474,9 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_mul_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -10489,9 +10489,9 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_div_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -10504,9 +10504,9 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_mod_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -10519,9 +10519,9 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); shift_left_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -10534,9 +10534,9 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); shift_right_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -10549,9 +10549,9 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); concat_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -10564,9 +10564,9 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); fast_is_identical_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -10580,9 +10580,9 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_TMP_CONST_HANDLER(ZEND_OPCO SAVE_OPLINE(); fast_is_not_identical_function(result, - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -10596,9 +10596,9 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); fast_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -10612,9 +10612,9 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); fast_not_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -10628,9 +10628,9 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); fast_is_smaller_function(result, - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -10644,9 +10644,9 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_TMP_CONST_HANDLER(ZEND_O SAVE_OPLINE(); fast_is_smaller_or_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -10659,9 +10659,9 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); bitwise_or_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -10674,9 +10674,9 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); bitwise_and_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -10689,9 +10689,9 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); bitwise_xor_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -10704,9 +10704,9 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); boolean_xor_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -10722,7 +10722,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_CONST(int type, HashTable *target_symbol_table; SAVE_OPLINE(); - varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (IS_TMP_VAR == IS_CONST) { name = Z_STR_P(varname); @@ -10745,7 +10745,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_CONST(int type, if (IS_TMP_VAR != IS_CONST) { zend_string_release(name); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -10755,7 +10755,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_CONST(int type, ce = Z_CE_P(EX_VAR(opline->op2.var)); } retval = zend_std_get_static_property(ce, name, 0, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(varname)) : NULL) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } else { target_symbol_table = zend_get_target_symbol_table(execute_data, opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC); retval = zend_hash_find(target_symbol_table, name); @@ -10803,7 +10803,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_CONST(int type, zval_update_constant(retval, 1 TSRMLS_CC); } } else if ((opline->extended_value & ZEND_FETCH_TYPE_MASK) != ZEND_FETCH_GLOBAL_LOCK) { - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } } @@ -10867,10 +10867,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HA zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, opline->op2.zv, IS_CONST TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -10882,10 +10882,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_IS_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_H zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, opline->op2.zv, IS_CONST TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -10908,7 +10908,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_TMP_CONST_HANDLER(ZEND_OP } ZVAL_DEREF(container); zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, opline->op2.zv, IS_CONST TSRMLS_CC); - if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -10917,10 +10917,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_TMP_CONST_HANDLER(ZEND_OP if (IS_CONST == IS_UNUSED) { zend_error_noreturn(E_ERROR, "Cannot use [] for reading"); } - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, opline->op2.zv, IS_CONST TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -10935,7 +10935,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HA zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); offset = opline->op2.zv; if ((IS_TMP_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || @@ -10975,7 +10975,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HA } while (0); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -10989,7 +10989,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_H zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); offset = opline->op2.zv; if ((IS_TMP_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || @@ -11028,7 +11028,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_H } while (0); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -11055,7 +11055,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_TMP_CONST_HANDLER(ZEND_OP } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_TMP_VAR, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -11073,7 +11073,7 @@ static int ZEND_FASTCALL ZEND_FETCH_LIST_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HAN zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { @@ -11159,7 +11159,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_CONST_HANDLER(ZEND_OPCO zend_error_noreturn(E_ERROR, "Method name must be a string"); } - object = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + object = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (IS_TMP_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { uint32_t nesting = 1; @@ -11251,7 +11251,7 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); fast_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); CHECK_EXCEPTION(); @@ -11275,7 +11275,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_CONST_HANDLER(ZEND_OPC Z_ADDREF_P(expr_ptr); } else { - expr_ptr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + expr_ptr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (IS_TMP_VAR == IS_TMP_VAR) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; @@ -11407,7 +11407,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HAND ZEND_VM_NEXT_OPCODE(); } - varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); ZVAL_UNDEF(&tmp); if (IS_TMP_VAR != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { @@ -11427,7 +11427,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HAND if (IS_TMP_VAR != IS_CONST) { zval_dtor(&tmp); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); HANDLE_EXCEPTION(); } if (UNEXPECTED(ce == NULL)) { @@ -11447,7 +11447,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HAND if (IS_TMP_VAR != IS_CONST) { zval_dtor(&tmp); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -11474,7 +11474,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_TMP_CONST_HANDLER(ZEND_OPC ZEND_VM_NEXT_OPCODE(); } else { zend_free_op free_op1; - zval tmp, *varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval tmp, *varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (IS_TMP_VAR != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { ZVAL_STR(&tmp, zval_get_string(varname)); @@ -11507,7 +11507,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_TMP_CONST_HANDLER(ZEND_OPC if (IS_TMP_VAR != IS_CONST && varname == &tmp) { zval_dtor(&tmp); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); if (opline->extended_value & ZEND_ISSET) { ZVAL_BOOL(EX_VAR(opline->result.var), @@ -11533,7 +11533,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_TMP_CONST_HANDLER(ZEND zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); offset = opline->op2.zv; if (IS_TMP_VAR != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { @@ -11631,7 +11631,7 @@ num_index_prop: } ZVAL_BOOL(EX_VAR(opline->result.var), result); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -11645,7 +11645,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_TMP_CONST_HANDLER(ZEN zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); offset = opline->op2.zv; if (IS_TMP_VAR == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { @@ -11663,7 +11663,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_TMP_CONST_HANDLER(ZEN } ZVAL_BOOL(EX_VAR(opline->result.var), result); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -11676,7 +11676,7 @@ static int ZEND_FASTCALL ZEND_INSTANCEOF_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HAN zend_bool result; SAVE_OPLINE(); - expr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + expr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (Z_TYPE_P(expr) == IS_OBJECT) { zend_class_entry *ce; @@ -11688,7 +11688,7 @@ static int ZEND_FASTCALL ZEND_INSTANCEOF_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HAN ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, ZEND_FETCH_CLASS_NO_AUTOLOAD TSRMLS_CC); if (UNEXPECTED(ce == NULL)) { ZVAL_FALSE(EX_VAR(opline->result.var)); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -11702,7 +11702,7 @@ static int ZEND_FASTCALL ZEND_INSTANCEOF_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HAN result = 0; } ZVAL_BOOL(EX_VAR(opline->result.var), result); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -11736,7 +11736,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_ zend_error(E_NOTICE, "Only variable references should be yielded by reference"); - value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); ZVAL_COPY_VALUE(&generator->value, value); if (Z_OPT_REFCOUNTED(generator->value)) Z_SET_REFCOUNT(generator->value, 1); @@ -11765,7 +11765,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_ } } else { - zval *value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval *value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); /* Consts, temporary variables and references need copying */ if (IS_TMP_VAR == IS_CONST) { @@ -11845,9 +11845,9 @@ static int ZEND_FASTCALL ZEND_POW_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); pow_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -11860,10 +11860,10 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_add_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -11875,10 +11875,10 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_sub_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -11890,10 +11890,10 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_mul_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -11905,10 +11905,10 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_div_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -11920,10 +11920,10 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_mod_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -11935,10 +11935,10 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_left_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -11950,10 +11950,10 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_right_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -11965,10 +11965,10 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); concat_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -11980,10 +11980,10 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); fast_is_identical_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -11996,10 +11996,10 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE SAVE_OPLINE(); fast_is_not_identical_function(result, - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -12012,10 +12012,10 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); fast_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -12028,10 +12028,10 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); fast_not_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -12044,10 +12044,10 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); fast_is_smaller_function(result, - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -12060,10 +12060,10 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_TMP_TMP_HANDLER(ZEND_OPC SAVE_OPLINE(); fast_is_smaller_or_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -12075,10 +12075,10 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); bitwise_or_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -12090,10 +12090,10 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); bitwise_and_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -12105,10 +12105,10 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); bitwise_xor_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -12120,10 +12120,10 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); boolean_xor_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -12135,10 +12135,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HAND zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - zval_ptr_dtor_nogc(free_op1.var); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); + zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2), IS_TMP_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -12150,10 +12150,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_IS_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HAN zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - zval_ptr_dtor_nogc(free_op1.var); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); + zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2), IS_TMP_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -12175,20 +12175,20 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_TMP_TMP_HANDLER(ZEND_OPCO zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } ZVAL_DEREF(container); - zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR TSRMLS_CC); - if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2), IS_TMP_VAR TSRMLS_CC); + if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else { if (IS_TMP_VAR == IS_UNUSED) { zend_error_noreturn(E_ERROR, "Cannot use [] for reading"); } - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - zval_ptr_dtor_nogc(free_op1.var); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); + zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2), IS_TMP_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); + zval_ptr_dtor_nogc(free_op1); } CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -12203,8 +12203,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HAND zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if ((IS_TMP_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -12243,8 +12243,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HAND } while (0); } - zval_ptr_dtor_nogc(free_op2.var); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op2); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -12258,8 +12258,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HAN zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if ((IS_TMP_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -12297,8 +12297,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HAN } while (0); } - zval_ptr_dtor_nogc(free_op2.var); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op2); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -12314,7 +12314,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_TMP_TMP_HANDLER(ZEND_OPCO zval *property; SAVE_OPLINE(); - property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); container = NULL; if (IS_TMP_VAR == IS_CONST || IS_TMP_VAR == IS_TMP_VAR) { @@ -12324,8 +12324,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_TMP_TMP_HANDLER(ZEND_OPCO zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_TMP_VAR, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -12346,7 +12346,7 @@ static int ZEND_FASTCALL ZEND_ADD_VAR_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ int use_copy = 0; SAVE_OPLINE(); - var = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + var = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_TMP_VAR == IS_UNUSED) { /* Initialize for erealloc in add_string_to_string */ @@ -12374,7 +12374,7 @@ static int ZEND_FASTCALL ZEND_ADD_VAR_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ * which aren't affected by FREE_OP(Ts, )'s anyway, unless they're * string offsets or overloaded objects */ - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -12392,7 +12392,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE SAVE_OPLINE(); - function_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_TMP_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { @@ -12402,18 +12402,18 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE zend_error_noreturn(E_ERROR, "Method name must be a string"); } - object = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + object = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (IS_TMP_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { uint32_t nesting = 1; if (UNEXPECTED(EG(exception) != NULL)) { - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); HANDLE_EXCEPTION(); } zend_error(E_RECOVERABLE_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object))); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); if (EG(exception) != NULL) { HANDLE_EXCEPTION(); @@ -12481,7 +12481,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION, fbc, opline->extended_value, called_scope, obj, EX(call) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -12495,10 +12495,10 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); fast_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -12520,7 +12520,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_TMP_HANDLER(ZEND_OPCOD Z_ADDREF_P(expr_ptr); } else { - expr_ptr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + expr_ptr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (IS_TMP_VAR == IS_TMP_VAR) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; @@ -12540,7 +12540,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_TMP_HANDLER(ZEND_OPCOD if (IS_TMP_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); zend_string *str; zend_ulong hval; @@ -12583,7 +12583,7 @@ str_index: /* do nothing */ break; } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else { zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr); } @@ -12632,8 +12632,8 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_TMP_TMP_HANDLER(ZEND_O zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_TMP_VAR != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { HashTable *ht = Z_ARRVAL_P(container); @@ -12729,9 +12729,9 @@ num_index_prop: result = ((opline->extended_value & ZEND_ISSET) == 0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_BOOL(EX_VAR(opline->result.var), result); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -12745,8 +12745,8 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_TMP_TMP_HANDLER(ZEND_ zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_TMP_VAR == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { if (EXPECTED(Z_OBJ_HT_P(container)->has_property)) { @@ -12762,9 +12762,9 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_TMP_TMP_HANDLER(ZEND_ result = ((opline->extended_value & ZEND_ISSET) == 0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_BOOL(EX_VAR(opline->result.var), result); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -12798,7 +12798,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR zend_error(E_NOTICE, "Only variable references should be yielded by reference"); - value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); ZVAL_COPY_VALUE(&generator->value, value); if (Z_OPT_REFCOUNTED(generator->value)) Z_SET_REFCOUNT(generator->value, 1); @@ -12827,7 +12827,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR } } else { - zval *value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval *value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); /* Consts, temporary variables and references need copying */ if (IS_TMP_VAR == IS_CONST) { @@ -12852,7 +12852,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR /* Set the new yielded key */ if (IS_TMP_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *key = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *key = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); /* Consts, temporary variables and references need copying */ if (IS_TMP_VAR == IS_CONST) { @@ -12907,10 +12907,10 @@ static int ZEND_FASTCALL ZEND_POW_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); pow_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -12922,10 +12922,10 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_add_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -12937,10 +12937,10 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_sub_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -12952,10 +12952,10 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_mul_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -12967,10 +12967,10 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_div_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -12982,10 +12982,10 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_mod_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -12997,10 +12997,10 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_left_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -13012,10 +13012,10 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_right_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -13027,10 +13027,10 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); concat_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -13042,10 +13042,10 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); fast_is_identical_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -13058,10 +13058,10 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE SAVE_OPLINE(); fast_is_not_identical_function(result, - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -13074,10 +13074,10 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); fast_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -13090,10 +13090,10 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); fast_not_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -13106,10 +13106,10 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); fast_is_smaller_function(result, - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -13122,10 +13122,10 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_TMP_VAR_HANDLER(ZEND_OPC SAVE_OPLINE(); fast_is_smaller_or_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -13137,10 +13137,10 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); bitwise_or_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -13152,10 +13152,10 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); bitwise_and_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -13167,10 +13167,10 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); bitwise_xor_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -13182,10 +13182,10 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); boolean_xor_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -13200,7 +13200,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_VAR(int type, ZE HashTable *target_symbol_table; SAVE_OPLINE(); - varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (IS_TMP_VAR == IS_CONST) { name = Z_STR_P(varname); @@ -13223,7 +13223,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_VAR(int type, ZE if (IS_TMP_VAR != IS_CONST) { zend_string_release(name); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -13233,7 +13233,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_VAR(int type, ZE ce = Z_CE_P(EX_VAR(opline->op2.var)); } retval = zend_std_get_static_property(ce, name, 0, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(varname)) : NULL) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } else { target_symbol_table = zend_get_target_symbol_table(execute_data, opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC); retval = zend_hash_find(target_symbol_table, name); @@ -13281,7 +13281,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_VAR(int type, ZE zval_update_constant(retval, 1 TSRMLS_CC); } } else if ((opline->extended_value & ZEND_FETCH_TYPE_MASK) != ZEND_FETCH_GLOBAL_LOCK) { - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } } @@ -13345,10 +13345,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HAND zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - zval_ptr_dtor_nogc(free_op1.var); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); + zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2), IS_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -13360,10 +13360,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_IS_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HAN zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - zval_ptr_dtor_nogc(free_op1.var); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); + zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2), IS_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -13385,20 +13385,20 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_TMP_VAR_HANDLER(ZEND_OPCO zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } ZVAL_DEREF(container); - zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR TSRMLS_CC); - if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2), IS_VAR TSRMLS_CC); + if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else { if (IS_VAR == IS_UNUSED) { zend_error_noreturn(E_ERROR, "Cannot use [] for reading"); } - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - zval_ptr_dtor_nogc(free_op1.var); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); + zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2), IS_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); + zval_ptr_dtor_nogc(free_op1); } CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -13413,8 +13413,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HAND zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if ((IS_TMP_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -13453,8 +13453,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HAND } while (0); } - zval_ptr_dtor_nogc(free_op2.var); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op2); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -13468,8 +13468,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HAN zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if ((IS_TMP_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -13507,8 +13507,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HAN } while (0); } - zval_ptr_dtor_nogc(free_op2.var); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op2); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -13524,7 +13524,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_TMP_VAR_HANDLER(ZEND_OPCO zval *property; SAVE_OPLINE(); - property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); container = NULL; if (IS_TMP_VAR == IS_CONST || IS_TMP_VAR == IS_TMP_VAR) { @@ -13534,8 +13534,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_TMP_VAR_HANDLER(ZEND_OPCO zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_TMP_VAR, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -13556,7 +13556,7 @@ static int ZEND_FASTCALL ZEND_ADD_VAR_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ int use_copy = 0; SAVE_OPLINE(); - var = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + var = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_TMP_VAR == IS_UNUSED) { /* Initialize for erealloc in add_string_to_string */ @@ -13584,7 +13584,7 @@ static int ZEND_FASTCALL ZEND_ADD_VAR_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ * which aren't affected by FREE_OP(Ts, )'s anyway, unless they're * string offsets or overloaded objects */ - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -13602,7 +13602,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE SAVE_OPLINE(); - function_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { @@ -13612,18 +13612,18 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE zend_error_noreturn(E_ERROR, "Method name must be a string"); } - object = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + object = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (IS_TMP_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { uint32_t nesting = 1; if (UNEXPECTED(EG(exception) != NULL)) { - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); HANDLE_EXCEPTION(); } zend_error(E_RECOVERABLE_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object))); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); if (EG(exception) != NULL) { HANDLE_EXCEPTION(); @@ -13691,7 +13691,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION, fbc, opline->extended_value, called_scope, obj, EX(call) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -13705,10 +13705,10 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); fast_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -13730,7 +13730,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_VAR_HANDLER(ZEND_OPCOD Z_ADDREF_P(expr_ptr); } else { - expr_ptr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + expr_ptr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (IS_TMP_VAR == IS_TMP_VAR) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; @@ -13750,7 +13750,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_VAR_HANDLER(ZEND_OPCOD if (IS_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); zend_string *str; zend_ulong hval; @@ -13793,7 +13793,7 @@ str_index: /* do nothing */ break; } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else { zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr); } @@ -13862,7 +13862,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLE ZEND_VM_NEXT_OPCODE(); } - varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); ZVAL_UNDEF(&tmp); if (IS_TMP_VAR != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { @@ -13882,7 +13882,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLE if (IS_TMP_VAR != IS_CONST) { zval_dtor(&tmp); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); HANDLE_EXCEPTION(); } if (UNEXPECTED(ce == NULL)) { @@ -13902,7 +13902,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLE if (IS_TMP_VAR != IS_CONST) { zval_dtor(&tmp); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -13929,7 +13929,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_TMP_VAR_HANDLER(ZEND_OPCOD ZEND_VM_NEXT_OPCODE(); } else { zend_free_op free_op1; - zval tmp, *varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval tmp, *varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (IS_TMP_VAR != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { ZVAL_STR(&tmp, zval_get_string(varname)); @@ -13962,7 +13962,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_TMP_VAR_HANDLER(ZEND_OPCOD if (IS_TMP_VAR != IS_CONST && varname == &tmp) { zval_dtor(&tmp); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); if (opline->extended_value & ZEND_ISSET) { ZVAL_BOOL(EX_VAR(opline->result.var), @@ -13988,8 +13988,8 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_TMP_VAR_HANDLER(ZEND_O zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_TMP_VAR != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { HashTable *ht = Z_ARRVAL_P(container); @@ -14085,9 +14085,9 @@ num_index_prop: result = ((opline->extended_value & ZEND_ISSET) == 0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_BOOL(EX_VAR(opline->result.var), result); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -14101,8 +14101,8 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_TMP_VAR_HANDLER(ZEND_ zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_TMP_VAR == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { if (EXPECTED(Z_OBJ_HT_P(container)->has_property)) { @@ -14118,9 +14118,9 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_TMP_VAR_HANDLER(ZEND_ result = ((opline->extended_value & ZEND_ISSET) == 0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_BOOL(EX_VAR(opline->result.var), result); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -14133,7 +14133,7 @@ static int ZEND_FASTCALL ZEND_INSTANCEOF_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDL zend_bool result; SAVE_OPLINE(); - expr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + expr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (Z_TYPE_P(expr) == IS_OBJECT) { zend_class_entry *ce; @@ -14145,7 +14145,7 @@ static int ZEND_FASTCALL ZEND_INSTANCEOF_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDL ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, ZEND_FETCH_CLASS_NO_AUTOLOAD TSRMLS_CC); if (UNEXPECTED(ce == NULL)) { ZVAL_FALSE(EX_VAR(opline->result.var)); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -14159,7 +14159,7 @@ static int ZEND_FASTCALL ZEND_INSTANCEOF_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDL result = 0; } ZVAL_BOOL(EX_VAR(opline->result.var), result); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -14193,7 +14193,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR zend_error(E_NOTICE, "Only variable references should be yielded by reference"); - value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); ZVAL_COPY_VALUE(&generator->value, value); if (Z_OPT_REFCOUNTED(generator->value)) Z_SET_REFCOUNT(generator->value, 1); @@ -14222,7 +14222,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR } } else { - zval *value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval *value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); /* Consts, temporary variables and references need copying */ if (IS_TMP_VAR == IS_CONST) { @@ -14247,7 +14247,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR /* Set the new yielded key */ if (IS_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *key = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *key = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); /* Consts, temporary variables and references need copying */ if (IS_VAR == IS_CONST) { @@ -14256,7 +14256,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR ZVAL_COPY_VALUE(&generator->key, key); } else if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && Z_ISREF_P(key)) { ZVAL_DUP(&generator->key, Z_REFVAL_P(key)); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else { ZVAL_COPY_VALUE(&generator->key, key); if (IS_VAR == IS_CV) { @@ -14302,10 +14302,10 @@ static int ZEND_FASTCALL ZEND_POW_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); pow_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -14320,7 +14320,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_UNUSED(int type, HashTable *target_symbol_table; SAVE_OPLINE(); - varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (IS_TMP_VAR == IS_CONST) { name = Z_STR_P(varname); @@ -14343,7 +14343,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_UNUSED(int type, if (IS_TMP_VAR != IS_CONST) { zend_string_release(name); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -14353,7 +14353,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_UNUSED(int type, ce = Z_CE_P(EX_VAR(opline->op2.var)); } retval = zend_std_get_static_property(ce, name, 0, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(varname)) : NULL) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } else { target_symbol_table = zend_get_target_symbol_table(execute_data, opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC); retval = zend_hash_find(target_symbol_table, name); @@ -14401,7 +14401,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_UNUSED(int type, zval_update_constant(retval, 1 TSRMLS_CC); } } else if ((opline->extended_value & ZEND_FETCH_TYPE_MASK) != ZEND_FETCH_GLOBAL_LOCK) { - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } } @@ -14476,7 +14476,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_TMP_UNUSED_HANDLER(ZEND_O } ZVAL_DEREF(container); zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, NULL, IS_UNUSED TSRMLS_CC); - if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -14485,10 +14485,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_TMP_UNUSED_HANDLER(ZEND_O if (IS_UNUSED == IS_UNUSED) { zend_error_noreturn(E_ERROR, "Cannot use [] for reading"); } - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, NULL, IS_UNUSED TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -14511,7 +14511,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_UNUSED_HANDLER(ZEND_OP Z_ADDREF_P(expr_ptr); } else { - expr_ptr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + expr_ptr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (IS_TMP_VAR == IS_TMP_VAR) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; @@ -14643,7 +14643,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_TMP_UNUSED_HANDLER(ZEND_OPCODE_HAN ZEND_VM_NEXT_OPCODE(); } - varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); ZVAL_UNDEF(&tmp); if (IS_TMP_VAR != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { @@ -14663,7 +14663,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_TMP_UNUSED_HANDLER(ZEND_OPCODE_HAN if (IS_TMP_VAR != IS_CONST) { zval_dtor(&tmp); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); HANDLE_EXCEPTION(); } if (UNEXPECTED(ce == NULL)) { @@ -14683,7 +14683,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_TMP_UNUSED_HANDLER(ZEND_OPCODE_HAN if (IS_TMP_VAR != IS_CONST) { zval_dtor(&tmp); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -14710,7 +14710,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_TMP_UNUSED_HANDLER(ZEND_OP ZEND_VM_NEXT_OPCODE(); } else { zend_free_op free_op1; - zval tmp, *varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval tmp, *varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (IS_TMP_VAR != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { ZVAL_STR(&tmp, zval_get_string(varname)); @@ -14743,7 +14743,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_TMP_UNUSED_HANDLER(ZEND_OP if (IS_TMP_VAR != IS_CONST && varname == &tmp) { zval_dtor(&tmp); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); if (opline->extended_value & ZEND_ISSET) { ZVAL_BOOL(EX_VAR(opline->result.var), @@ -14788,7 +14788,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_UNUSED_HANDLER(ZEND_OPCODE_HANDLER zend_error(E_NOTICE, "Only variable references should be yielded by reference"); - value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); ZVAL_COPY_VALUE(&generator->value, value); if (Z_OPT_REFCOUNTED(generator->value)) Z_SET_REFCOUNT(generator->value, 1); @@ -14817,7 +14817,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_UNUSED_HANDLER(ZEND_OPCODE_HANDLER } } else { - zval *value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval *value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); /* Consts, temporary variables and references need copying */ if (IS_TMP_VAR == IS_CONST) { @@ -14897,9 +14897,9 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_add_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -14912,9 +14912,9 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_sub_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -14927,9 +14927,9 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_mul_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -14942,9 +14942,9 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_div_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -14957,9 +14957,9 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_mod_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -14972,9 +14972,9 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_left_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -14987,9 +14987,9 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_right_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -15002,9 +15002,9 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); concat_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -15017,9 +15017,9 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); fast_is_identical_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -15033,9 +15033,9 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_ SAVE_OPLINE(); fast_is_not_identical_function(result, - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -15049,9 +15049,9 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); fast_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -15065,9 +15065,9 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); fast_not_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -15081,9 +15081,9 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLE SAVE_OPLINE(); fast_is_smaller_function(result, - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -15097,9 +15097,9 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_TMP_CV_HANDLER(ZEND_OPCO SAVE_OPLINE(); fast_is_smaller_or_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -15112,9 +15112,9 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); bitwise_or_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -15127,9 +15127,9 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); bitwise_and_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -15142,9 +15142,9 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); bitwise_xor_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -15157,9 +15157,9 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); boolean_xor_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -15172,10 +15172,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDL zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -15187,10 +15187,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_IS_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HAND zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -15213,7 +15213,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_TMP_CV_HANDLER(ZEND_OPCOD } ZVAL_DEREF(container); zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV TSRMLS_CC); - if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -15222,10 +15222,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_TMP_CV_HANDLER(ZEND_OPCOD if (IS_CV == IS_UNUSED) { zend_error_noreturn(E_ERROR, "Cannot use [] for reading"); } - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -15240,7 +15240,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDL zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if ((IS_TMP_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || @@ -15280,7 +15280,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDL } while (0); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -15294,7 +15294,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HAND zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if ((IS_TMP_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || @@ -15333,7 +15333,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HAND } while (0); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -15360,7 +15360,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_TMP_CV_HANDLER(ZEND_OPCOD } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_TMP_VAR, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -15436,7 +15436,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_ zend_error_noreturn(E_ERROR, "Method name must be a string"); } - object = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + object = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (IS_TMP_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { uint32_t nesting = 1; @@ -15528,7 +15528,7 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -15552,7 +15552,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_CV_HANDLER(ZEND_OPCODE Z_ADDREF_P(expr_ptr); } else { - expr_ptr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + expr_ptr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); if (IS_TMP_VAR == IS_TMP_VAR) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; @@ -15664,7 +15664,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_TMP_CV_HANDLER(ZEND_OP zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_TMP_VAR != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { @@ -15762,7 +15762,7 @@ num_index_prop: } ZVAL_BOOL(EX_VAR(opline->result.var), result); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -15776,7 +15776,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_TMP_CV_HANDLER(ZEND_O zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_TMP_VAR == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { @@ -15794,7 +15794,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_TMP_CV_HANDLER(ZEND_O } ZVAL_BOOL(EX_VAR(opline->result.var), result); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -15828,7 +15828,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG zend_error(E_NOTICE, "Only variable references should be yielded by reference"); - value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); ZVAL_COPY_VALUE(&generator->value, value); if (Z_OPT_REFCOUNTED(generator->value)) Z_SET_REFCOUNT(generator->value, 1); @@ -15857,7 +15857,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG } } else { - zval *value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval *value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); /* Consts, temporary variables and references need copying */ if (IS_TMP_VAR == IS_CONST) { @@ -15937,9 +15937,9 @@ static int ZEND_FASTCALL ZEND_POW_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); pow_function(EX_VAR(opline->result.var), - _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -15952,8 +15952,8 @@ static int ZEND_FASTCALL ZEND_BW_NOT_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); bitwise_not_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -15965,8 +15965,8 @@ static int ZEND_FASTCALL ZEND_BOOL_NOT_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); boolean_not_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -15978,7 +15978,7 @@ static int ZEND_FASTCALL ZEND_PRE_INC_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS zval *var_ptr; SAVE_OPLINE(); - var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(var_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot increment/decrement overloaded objects nor string offsets"); @@ -16009,7 +16009,7 @@ static int ZEND_FASTCALL ZEND_PRE_INC_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS ZVAL_COPY(EX_VAR(opline->result.var), var_ptr); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -16021,7 +16021,7 @@ static int ZEND_FASTCALL ZEND_PRE_DEC_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS zval *var_ptr; SAVE_OPLINE(); - var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(var_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot increment/decrement overloaded objects nor string offsets"); @@ -16052,7 +16052,7 @@ static int ZEND_FASTCALL ZEND_PRE_DEC_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS ZVAL_COPY(EX_VAR(opline->result.var), var_ptr); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -16064,7 +16064,7 @@ static int ZEND_FASTCALL ZEND_POST_INC_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG zval *var_ptr; SAVE_OPLINE(); - var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(var_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot increment/decrement overloaded objects nor string offsets"); @@ -16092,7 +16092,7 @@ static int ZEND_FASTCALL ZEND_POST_INC_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG increment_function(var_ptr); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -16104,7 +16104,7 @@ static int ZEND_FASTCALL ZEND_POST_DEC_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG zval *var_ptr; SAVE_OPLINE(); - var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(var_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot increment/decrement overloaded objects nor string offsets"); @@ -16132,7 +16132,7 @@ static int ZEND_FASTCALL ZEND_POST_DEC_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG decrement_function(var_ptr); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -16144,11 +16144,11 @@ static int ZEND_FASTCALL ZEND_ECHO_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval *z; SAVE_OPLINE(); - z = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + z = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); zend_print_variable(z TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -16168,7 +16168,7 @@ static int ZEND_FASTCALL ZEND_JMPZ_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval *val; SAVE_OPLINE(); - val = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + val = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_TMP_VAR) { if (Z_TYPE_P(val) == IS_TRUE) { @@ -16185,7 +16185,7 @@ static int ZEND_FASTCALL ZEND_JMPZ_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } else { opline = opline->op2.jmp_addr; } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); if (UNEXPECTED(EG(exception) != NULL)) { HANDLE_EXCEPTION(); } @@ -16199,7 +16199,7 @@ static int ZEND_FASTCALL ZEND_JMPNZ_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval *val; SAVE_OPLINE(); - val = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + val = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_TMP_VAR) { if (Z_TYPE_P(val) == IS_TRUE) { @@ -16216,7 +16216,7 @@ static int ZEND_FASTCALL ZEND_JMPNZ_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } else { opline++; } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); if (UNEXPECTED(EG(exception) != NULL)) { HANDLE_EXCEPTION(); } @@ -16230,7 +16230,7 @@ static int ZEND_FASTCALL ZEND_JMPZNZ_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval *val; SAVE_OPLINE(); - val = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + val = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_TMP_VAR) { if (EXPECTED(Z_TYPE_P(val) == IS_TRUE)) { @@ -16247,7 +16247,7 @@ static int ZEND_FASTCALL ZEND_JMPZNZ_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } else { opline = opline->op2.jmp_addr; } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); if (UNEXPECTED(EG(exception) != NULL)) { HANDLE_EXCEPTION(); } @@ -16261,7 +16261,7 @@ static int ZEND_FASTCALL ZEND_JMPZ_EX_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS zval *val; SAVE_OPLINE(); - val = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + val = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_TMP_VAR) { if (Z_TYPE_P(val) == IS_TRUE) { @@ -16276,11 +16276,11 @@ static int ZEND_FASTCALL ZEND_JMPZ_EX_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS } if (i_zend_is_true(val TSRMLS_CC)) { - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); ZVAL_TRUE(EX_VAR(opline->result.var)); opline++; } else { - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); ZVAL_FALSE(EX_VAR(opline->result.var)); opline = opline->op2.jmp_addr; } @@ -16297,7 +16297,7 @@ static int ZEND_FASTCALL ZEND_JMPNZ_EX_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG zval *val; SAVE_OPLINE(); - val = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + val = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_TMP_VAR) { if (Z_TYPE_P(val) == IS_TRUE) { @@ -16317,7 +16317,7 @@ static int ZEND_FASTCALL ZEND_JMPNZ_EX_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG ZVAL_FALSE(EX_VAR(opline->result.var)); opline++; } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); if (UNEXPECTED(EG(exception) != NULL)) { HANDLE_EXCEPTION(); } @@ -16341,10 +16341,10 @@ static int ZEND_FASTCALL ZEND_RETURN_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_free_op free_op1; SAVE_OPLINE(); - retval_ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + retval_ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); if (!EX(return_value)) { - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } else { if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR) { ZVAL_COPY_VALUE(EX(return_value), retval_ptr); @@ -16355,7 +16355,7 @@ static int ZEND_FASTCALL ZEND_RETURN_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } } else if ((IS_VAR == IS_CV || IS_VAR == IS_VAR) && Z_ISREF_P(retval_ptr)) { ZVAL_COPY(EX(return_value), Z_REFVAL_P(retval_ptr)); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } else { ZVAL_COPY_VALUE(EX(return_value), retval_ptr); if (IS_VAR == IS_CV) { @@ -16380,10 +16380,10 @@ static int ZEND_FASTCALL ZEND_RETURN_BY_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLE /* Not supposed to happen, but we'll allow it */ zend_error(E_NOTICE, "Only variable references should be returned by reference"); - retval_ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + retval_ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); if (!EX(return_value)) { if (IS_VAR == IS_TMP_VAR) { - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } } else { ZVAL_COPY_VALUE(EX(return_value), retval_ptr); @@ -16395,7 +16395,7 @@ static int ZEND_FASTCALL ZEND_RETURN_BY_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLE break; } - retval_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + retval_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(retval_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot return string offsets by reference"); @@ -16423,7 +16423,7 @@ static int ZEND_FASTCALL ZEND_RETURN_BY_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLE } } while (0); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; return zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } @@ -16434,7 +16434,7 @@ static int ZEND_FASTCALL ZEND_THROW_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_free_op free_op1; SAVE_OPLINE(); - value = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_CONST || UNEXPECTED(Z_TYPE_P(value) != IS_OBJECT)) { if (UNEXPECTED(EG(exception) != NULL)) { @@ -16450,7 +16450,7 @@ static int ZEND_FASTCALL ZEND_THROW_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_throw_exception_object(value TSRMLS_CC); zend_exception_restore(TSRMLS_C); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); HANDLE_EXCEPTION(); } @@ -16460,12 +16460,12 @@ static int ZEND_FASTCALL ZEND_SEND_VAR_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG zval *varptr, *arg; zend_free_op free_op1; - varptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + varptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); arg = ZEND_CALL_ARG(EX(call), opline->op2.num); EX(call)->num_args = opline->op2.num; if ((IS_VAR == IS_CV || IS_VAR == IS_VAR) && Z_ISREF_P(varptr)) { ZVAL_COPY(arg, Z_REFVAL_P(varptr)); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } else { ZVAL_COPY_VALUE(arg, varptr); if (IS_VAR == IS_CV) { @@ -16492,7 +16492,7 @@ static int ZEND_FASTCALL ZEND_SEND_VAR_NO_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HAND } } - varptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + varptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); if ((!(opline->extended_value & ZEND_ARG_SEND_FUNCTION) || (Z_VAR_FLAGS_P(varptr) & IS_VAR_RET_REF)) && (Z_ISREF_P(varptr) || Z_TYPE_P(varptr) == IS_OBJECT)) { @@ -16513,7 +16513,7 @@ static int ZEND_FASTCALL ZEND_SEND_VAR_NO_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HAND arg = ZEND_CALL_ARG(EX(call), opline->op2.num); EX(call)->num_args = opline->op2.num; ZVAL_COPY(arg, varptr); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -16526,7 +16526,7 @@ static int ZEND_FASTCALL ZEND_SEND_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG zval *varptr, *arg; SAVE_OPLINE(); - varptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + varptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(varptr == NULL)) { zend_error_noreturn(E_ERROR, "Only variables can be passed by reference"); @@ -16551,7 +16551,7 @@ static int ZEND_FASTCALL ZEND_SEND_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG ZVAL_REF(varptr, Z_REF_P(arg)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; ZEND_VM_NEXT_OPCODE(); } @@ -16564,12 +16564,12 @@ static int ZEND_FASTCALL ZEND_SEND_VAR_EX_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) { return ZEND_SEND_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } - varptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + varptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); arg = ZEND_CALL_ARG(EX(call), opline->op2.num); EX(call)->num_args = opline->op2.num; if ((IS_VAR == IS_CV || IS_VAR == IS_VAR) && Z_ISREF_P(varptr)) { ZVAL_COPY(arg, Z_REFVAL_P(varptr)); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } else { ZVAL_COPY_VALUE(arg, varptr); if (IS_VAR == IS_CV) { @@ -16585,7 +16585,7 @@ static int ZEND_FASTCALL ZEND_SEND_USER_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR zval *arg, *param, tmp; zend_free_op free_op1; - arg = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + arg = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); param = ZEND_CALL_ARG(EX(call), opline->op2.num); if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) { @@ -16625,7 +16625,7 @@ static int ZEND_FASTCALL ZEND_SEND_USER_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR EX(call)->called_scope = NULL; Z_OBJ(EX(call)->This) = NULL; - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -16653,7 +16653,7 @@ static int ZEND_FASTCALL ZEND_SEND_USER_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR EX(call)->num_args = opline->op2.num; - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -16666,8 +16666,8 @@ static int ZEND_FASTCALL ZEND_BOOL_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); /* PHP 3.0 returned "" for false and 1 for true, here we use 0 and 1 for now */ - ZVAL_BOOL(retval, i_zend_is_true(_get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC) TSRMLS_CC)); - zval_ptr_dtor_nogc(free_op1.var); + ZVAL_BOOL(retval, i_zend_is_true(_get_zval_ptr_var(opline->op1.var, execute_data, &free_op1) TSRMLS_CC)); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -16749,7 +16749,7 @@ static int ZEND_FASTCALL ZEND_CLONE_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_object_clone_obj_t clone_call; SAVE_OPLINE(); - obj = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + obj = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_CONST || (IS_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(obj) != IS_OBJECT))) { @@ -16792,7 +16792,7 @@ static int ZEND_FASTCALL ZEND_CLONE_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval_ptr_dtor(EX_VAR(opline->result.var)); } } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -16805,7 +16805,7 @@ static int ZEND_FASTCALL ZEND_CAST_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval *result = EX_VAR(opline->result.var); SAVE_OPLINE(); - expr = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + expr = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); switch (opline->extended_value) { case IS_NULL: @@ -16849,7 +16849,7 @@ static int ZEND_FASTCALL ZEND_CAST_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (Z_OPT_REFCOUNTED_P(expr)) Z_ADDREF_P(expr); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -16894,7 +16894,7 @@ static int ZEND_FASTCALL ZEND_CAST_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -16909,7 +16909,7 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_VAR_HANDLER(ZEND_OPCODE_HAND zend_bool failure_retval=0; SAVE_OPLINE(); - inc_filename = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + inc_filename = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); ZVAL_UNDEF(&tmp_inc_filename); if (Z_TYPE_P(inc_filename) != IS_STRING) { @@ -16981,7 +16981,7 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_VAR_HANDLER(ZEND_OPCODE_HAND if (Z_TYPE(tmp_inc_filename) != IS_UNDEF) { zval_ptr_dtor(&tmp_inc_filename); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); if (UNEXPECTED(EG(exception) != NULL)) { HANDLE_EXCEPTION(); } else if (EXPECTED(new_op_array != NULL)) { @@ -17037,7 +17037,7 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG if ((IS_VAR == IS_CV || IS_VAR == IS_VAR) && (opline->extended_value & ZEND_FE_FETCH_BYREF)) { - array_ptr = array_ref = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + array_ptr = array_ref = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); ZVAL_DEREF(array_ptr); if (Z_TYPE_P(array_ptr) == IS_ARRAY) { SEPARATE_ARRAY(array_ptr); @@ -17056,7 +17056,7 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG if (Z_REFCOUNTED_P(array_ref)) Z_ADDREF_P(array_ref); } } else { - array_ptr = array_ref = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + array_ptr = array_ref = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); ZVAL_DEREF(array_ptr); if (IS_VAR == IS_TMP_VAR) { ZVAL_COPY_VALUE(&tmp, array_ptr); @@ -17123,14 +17123,14 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG iter = ce->get_iterator(ce, array_ptr, opline->extended_value & ZEND_FE_FETCH_BYREF TSRMLS_CC); if (IS_VAR == IS_VAR && !(opline->extended_value & ZEND_FE_FETCH_BYREF)) { - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } if (iter && EXPECTED(EG(exception) == NULL)) { ZVAL_OBJ(&iterator, &iter->std); array_ptr = array_ref = &iterator; } else { if (IS_VAR == IS_VAR && opline->extended_value & ZEND_FE_FETCH_BYREF) { - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; } if (!EG(exception)) { zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Object of type %s did not create an Iterator", ce->name->val); @@ -17149,7 +17149,7 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG if (UNEXPECTED(EG(exception) != NULL)) { zval_ptr_dtor(array_ref); if (IS_VAR == IS_VAR && opline->extended_value & ZEND_FE_FETCH_BYREF) { - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; } HANDLE_EXCEPTION(); } @@ -17158,7 +17158,7 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG if (UNEXPECTED(EG(exception) != NULL)) { zval_ptr_dtor(array_ref); if (IS_VAR == IS_VAR && opline->extended_value & ZEND_FE_FETCH_BYREF) { - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; } HANDLE_EXCEPTION(); } @@ -17172,7 +17172,7 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG if (pos >= fe_ht->nNumUsed) { is_empty = 1; if (IS_VAR == IS_VAR && opline->extended_value & ZEND_FE_FETCH_BYREF) { - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; } ZEND_VM_JMP(opline->op2.jmp_addr); } @@ -17202,7 +17202,7 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG } if (IS_VAR == IS_VAR && opline->extended_value & ZEND_FE_FETCH_BYREF) { - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; } if (is_empty) { ZEND_VM_JMP(opline->op2.jmp_addr); @@ -17470,14 +17470,14 @@ static int ZEND_FASTCALL ZEND_EXIT_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); if (IS_VAR != IS_UNUSED) { zend_free_op free_op1; - zval *ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval *ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); if (Z_TYPE_P(ptr) == IS_LONG) { EG(exit_status) = Z_LVAL_P(ptr); } else { zend_print_variable(ptr TSRMLS_CC); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } #endif zend_bailout(); @@ -17492,7 +17492,7 @@ static int ZEND_FASTCALL ZEND_JMP_SET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS int is_ref = 0; SAVE_OPLINE(); - value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && Z_ISREF_P(value)) { is_ref = 1; @@ -17508,12 +17508,12 @@ static int ZEND_FASTCALL ZEND_JMP_SET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value); } else if (IS_VAR == IS_VAR && is_ref) { if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } ZEND_VM_JMP(opline->op2.jmp_addr); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -17526,7 +17526,7 @@ static int ZEND_FASTCALL ZEND_COALESCE_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG int is_ref = 0; SAVE_OPLINE(); - value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && Z_ISREF_P(value)) { is_ref = 1; @@ -17543,12 +17543,12 @@ static int ZEND_FASTCALL ZEND_COALESCE_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value); } else if (IS_VAR == IS_VAR && is_ref) { if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } ZEND_VM_JMP(opline->op2.jmp_addr); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -17560,11 +17560,11 @@ static int ZEND_FASTCALL ZEND_QM_ASSIGN_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR zval *value; SAVE_OPLINE(); - value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && Z_ISREF_P(value)) { ZVAL_COPY(EX_VAR(opline->result.var), Z_REFVAL_P(value)); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } else { ZVAL_COPY_VALUE(EX_VAR(opline->result.var), value); if (IS_VAR == IS_CONST) { @@ -17585,7 +17585,7 @@ static int ZEND_FASTCALL ZEND_STRLEN_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_free_op free_op1; SAVE_OPLINE(); - value = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); if (EXPECTED(Z_TYPE_P(value) == IS_STRING)) { ZVAL_LONG(EX_VAR(opline->result.var), Z_STRLEN_P(value)); } else { @@ -17613,7 +17613,7 @@ strlen_error: ZVAL_NULL(EX_VAR(opline->result.var)); } } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -17625,7 +17625,7 @@ static int ZEND_FASTCALL ZEND_TYPE_CHECK_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_A zend_free_op free_op1; SAVE_OPLINE(); - value = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); switch (opline->extended_value) { case IS_NULL: case IS_LONG: @@ -17660,7 +17660,7 @@ static int ZEND_FASTCALL ZEND_TYPE_CHECK_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_A break; EMPTY_SWITCH_DEFAULT_CASE() } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -17672,9 +17672,9 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_add_function(EX_VAR(opline->result.var), - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -17687,9 +17687,9 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_sub_function(EX_VAR(opline->result.var), - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -17702,9 +17702,9 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_mul_function(EX_VAR(opline->result.var), - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -17717,9 +17717,9 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_div_function(EX_VAR(opline->result.var), - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -17732,9 +17732,9 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_mod_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -17747,9 +17747,9 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); shift_left_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -17762,9 +17762,9 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); shift_right_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -17777,9 +17777,9 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); concat_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -17792,9 +17792,9 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); fast_is_identical_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -17808,9 +17808,9 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_VAR_CONST_HANDLER(ZEND_OPCO SAVE_OPLINE(); fast_is_not_identical_function(result, - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -17824,9 +17824,9 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); fast_equal_function(result, - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -17840,9 +17840,9 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); fast_not_equal_function(result, - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -17856,9 +17856,9 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); fast_is_smaller_function(result, - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -17872,9 +17872,9 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_VAR_CONST_HANDLER(ZEND_O SAVE_OPLINE(); fast_is_smaller_or_equal_function(result, - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -17887,9 +17887,9 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); bitwise_or_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -17902,9 +17902,9 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); bitwise_and_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -17917,9 +17917,9 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); bitwise_xor_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -17932,9 +17932,9 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); boolean_xor_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -17944,7 +17944,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_VAR_CONST(int (*b { USE_OPLINE zend_free_op free_op1, free_op_data1; - zval *object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval *object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); zval *property = opline->op2.zv; zval *value; zval *zptr; @@ -18026,7 +18026,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_VAR_CONST(int (*b FREE_OP(free_op_data1); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; /* assign_obj has two opcodes! */ CHECK_EXCEPTION(); ZEND_VM_INC_OPCODE(); @@ -18041,7 +18041,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_VAR_CONST(int (*b zval *value, *container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } @@ -18049,7 +18049,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_VAR_CONST(int (*b ZVAL_DEREF(container); } if (IS_VAR == IS_UNUSED || UNEXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { - if (IS_VAR == IS_VAR && !(free_op1.var != NULL)) { + if (IS_VAR == IS_VAR && !(free_op1 != NULL)) { Z_ADDREF_P(container); /* undo the effect of get_obj_zval_ptr_ptr() */ } return zend_binary_assign_op_obj_helper_SPEC_VAR_CONST(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); @@ -18082,7 +18082,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_VAR_CONST(int (*b } FREE_OP(free_op_data1); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_INC_OPCODE(); ZEND_VM_NEXT_OPCODE(); @@ -18097,7 +18097,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_VAR_CONST(int (*binar SAVE_OPLINE(); value = opline->op2.zv; - var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(var_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use assign-op operators with overloaded objects nor string offsets"); @@ -18118,7 +18118,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_VAR_CONST(int (*binar } } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -18276,7 +18276,7 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_VAR_CONST(incdec_t zval *zptr; SAVE_OPLINE(); - object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); property = opline->op2.zv; retval = EX_VAR(opline->result.var); @@ -18294,7 +18294,7 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_VAR_CONST(incdec_t if (RETURN_VALUE_USED(opline)) { ZVAL_NULL(retval); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -18341,7 +18341,7 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_VAR_CONST(incdec_t } } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -18366,7 +18366,7 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_VAR_CONST(incdec_ zval *zptr; SAVE_OPLINE(); - object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); property = opline->op2.zv; retval = EX_VAR(opline->result.var); @@ -18382,7 +18382,7 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_VAR_CONST(incdec_ zend_error(E_WARNING, "Attempt to increment/decrement property of non-object"); ZVAL_NULL(retval); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -18425,7 +18425,7 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_VAR_CONST(incdec_ } } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -18450,7 +18450,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_CONST(int type, HashTable *target_symbol_table; SAVE_OPLINE(); - varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_CONST) { name = Z_STR_P(varname); @@ -18473,7 +18473,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_CONST(int type, if (IS_VAR != IS_CONST) { zend_string_release(name); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -18483,7 +18483,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_CONST(int type, ce = Z_CE_P(EX_VAR(opline->op2.var)); } retval = zend_std_get_static_property(ce, name, 0, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(varname)) : NULL) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } else { target_symbol_table = zend_get_target_symbol_table(execute_data, opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC); retval = zend_hash_find(target_symbol_table, name); @@ -18531,7 +18531,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_CONST(int type, zval_update_constant(retval, 1 TSRMLS_CC); } } else if ((opline->extended_value & ZEND_FETCH_TYPE_MASK) != ZEND_FETCH_GLOBAL_LOCK) { - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } } @@ -18595,10 +18595,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HA zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, opline->op2.zv, IS_CONST TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -18610,7 +18610,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_W_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HA zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -18618,10 +18618,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_W_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HA ZVAL_DEREF(container); zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, opline->op2.zv, IS_CONST TSRMLS_CC); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -18633,7 +18633,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_H zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -18641,10 +18641,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_H ZVAL_DEREF(container); zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, opline->op2.zv, IS_CONST TSRMLS_CC); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -18656,10 +18656,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_IS_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_H zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, opline->op2.zv, IS_CONST TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -18676,25 +18676,25 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_VAR_CONST_HANDLER(ZEND_OP if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR) { zend_error_noreturn(E_ERROR, "Cannot use temporary expression in write context"); } - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } ZVAL_DEREF(container); zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, opline->op2.zv, IS_CONST TSRMLS_CC); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; } else { if (IS_CONST == IS_UNUSED) { zend_error_noreturn(E_ERROR, "Cannot use [] for reading"); } - container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, opline->op2.zv, IS_CONST TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -18707,7 +18707,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_VAR_CONST_HANDLER(ZEND_OPCOD zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -18715,10 +18715,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_VAR_CONST_HANDLER(ZEND_OPCOD ZVAL_DEREF(container); zend_fetch_dimension_address_UNSET(EX_VAR(opline->result.var), container, opline->op2.zv, IS_CONST TSRMLS_CC); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -18732,7 +18732,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HA zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); offset = opline->op2.zv; if ((IS_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || @@ -18772,7 +18772,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HA } while (0); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -18787,17 +18787,17 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HA SAVE_OPLINE(); property = opline->op2.zv; - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -18811,17 +18811,17 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); property = opline->op2.zv; - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -18835,7 +18835,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_H zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); offset = opline->op2.zv; if ((IS_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || @@ -18874,7 +18874,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_H } while (0); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -18891,7 +18891,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_VAR_CONST_HANDLER(ZEND_OP SAVE_OPLINE(); property = opline->op2.zv; - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR) { zend_error_noreturn(E_ERROR, "Cannot use temporary expression in write context"); @@ -18901,10 +18901,10 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_VAR_CONST_HANDLER(ZEND_OP } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else { @@ -18919,7 +18919,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_VAR_CONST_HANDLER(ZEND_OPCOD zval *container, *property; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); property = opline->op2.zv; if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { @@ -18927,10 +18927,10 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_VAR_CONST_HANDLER(ZEND_OPCOD } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -18942,7 +18942,7 @@ static int ZEND_FASTCALL ZEND_FETCH_LIST_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAN zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { @@ -18976,7 +18976,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAN zval *property_name; SAVE_OPLINE(); - object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); property_name = opline->op2.zv; if (IS_VAR == IS_VAR && UNEXPECTED(object == NULL)) { @@ -18984,7 +18984,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAN } zend_assign_to_object(RETURN_VALUE_USED(opline)?EX_VAR(opline->result.var):NULL, object, IS_VAR, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_OBJ, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property_name)) : NULL) TSRMLS_CC); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; /* assign_obj has two opcodes! */ CHECK_EXCEPTION(); ZEND_VM_INC_OPCODE(); @@ -18998,7 +18998,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAN zval *object_ptr; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -19046,7 +19046,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAN } } } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; /* assign_dim has two opcodes! */ CHECK_EXCEPTION(); ZEND_VM_INC_OPCODE(); @@ -19062,7 +19062,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); value = opline->op2.zv; - variable_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + variable_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(variable_ptr == &EG(error_zval))) { if (IS_CONST == IS_TMP_VAR) { @@ -19076,7 +19076,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER if (RETURN_VALUE_USED(opline)) { ZVAL_COPY(EX_VAR(opline->result.var), value); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; } /* zend_assign_to_variable() always takes care of op2, never free it! */ @@ -19107,7 +19107,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_CONST_HANDLER(ZEND_OPCO zend_error_noreturn(E_ERROR, "Method name must be a string"); } - object = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + object = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); if (IS_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { uint32_t nesting = 1; @@ -19119,7 +19119,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_CONST_HANDLER(ZEND_OPCO zend_error(E_RECOVERABLE_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object))); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); if (EG(exception) != NULL) { HANDLE_EXCEPTION(); @@ -19187,7 +19187,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_CONST_HANDLER(ZEND_OPCO EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION, fbc, opline->extended_value, called_scope, obj, EX(call) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -19325,7 +19325,7 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); fast_equal_function(result, - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); CHECK_EXCEPTION(); @@ -19439,15 +19439,15 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CONST_HANDLER(ZEND_OPC SAVE_OPLINE(); if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && (opline->extended_value & ZEND_ARRAY_ELEMENT_REF)) { - expr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + expr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(expr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); } ZVAL_MAKE_REF(expr_ptr); Z_ADDREF_P(expr_ptr); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; } else { - expr_ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + expr_ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_TMP_VAR) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; @@ -19459,7 +19459,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CONST_HANDLER(ZEND_OPC } else if ((IS_VAR == IS_CV || IS_VAR == IS_VAR) && Z_ISREF_P(expr_ptr)) { expr_ptr = Z_REFVAL_P(expr_ptr); if (Z_REFCOUNTED_P(expr_ptr)) Z_ADDREF_P(expr_ptr); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } else if (IS_VAR == IS_CV && Z_REFCOUNTED_P(expr_ptr)) { Z_ADDREF_P(expr_ptr); } @@ -19579,7 +19579,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAND ZEND_VM_NEXT_OPCODE(); } - varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); ZVAL_UNDEF(&tmp); if (IS_VAR != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { @@ -19599,7 +19599,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAND if (IS_VAR != IS_CONST) { zval_dtor(&tmp); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); HANDLE_EXCEPTION(); } if (UNEXPECTED(ce == NULL)) { @@ -19619,7 +19619,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAND if (IS_VAR != IS_CONST) { zval_dtor(&tmp); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -19633,7 +19633,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAND zend_ulong hval; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); } @@ -19704,7 +19704,7 @@ num_index_dim: } else { } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -19717,7 +19717,7 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAND zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); } @@ -19732,7 +19732,7 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAND } } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -19759,7 +19759,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_VAR_CONST_HANDLER(ZEND_OPC ZEND_VM_NEXT_OPCODE(); } else { zend_free_op free_op1; - zval tmp, *varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval tmp, *varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { ZVAL_STR(&tmp, zval_get_string(varname)); @@ -19792,7 +19792,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_VAR_CONST_HANDLER(ZEND_OPC if (IS_VAR != IS_CONST && varname == &tmp) { zval_dtor(&tmp); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); if (opline->extended_value & ZEND_ISSET) { ZVAL_BOOL(EX_VAR(opline->result.var), @@ -19818,7 +19818,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_VAR_CONST_HANDLER(ZEND zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); offset = opline->op2.zv; if (IS_VAR != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { @@ -19916,7 +19916,7 @@ num_index_prop: } ZVAL_BOOL(EX_VAR(opline->result.var), result); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -19930,7 +19930,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_VAR_CONST_HANDLER(ZEN zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); offset = opline->op2.zv; if (IS_VAR == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { @@ -19948,7 +19948,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_VAR_CONST_HANDLER(ZEN } ZVAL_BOOL(EX_VAR(opline->result.var), result); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -19961,7 +19961,7 @@ static int ZEND_FASTCALL ZEND_INSTANCEOF_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAN zend_bool result; SAVE_OPLINE(); - expr = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + expr = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); if (Z_TYPE_P(expr) == IS_OBJECT) { zend_class_entry *ce; @@ -19973,7 +19973,7 @@ static int ZEND_FASTCALL ZEND_INSTANCEOF_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAN ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, ZEND_FETCH_CLASS_NO_AUTOLOAD TSRMLS_CC); if (UNEXPECTED(ce == NULL)) { ZVAL_FALSE(EX_VAR(opline->result.var)); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -19987,7 +19987,7 @@ static int ZEND_FASTCALL ZEND_INSTANCEOF_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAN result = 0; } ZVAL_BOOL(EX_VAR(opline->result.var), result); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20021,7 +20021,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ zend_error(E_NOTICE, "Only variable references should be yielded by reference"); - value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); ZVAL_COPY_VALUE(&generator->value, value); if (Z_OPT_REFCOUNTED(generator->value)) Z_SET_REFCOUNT(generator->value, 1); @@ -20030,7 +20030,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ zval_opt_copy_ctor(&generator->value); } } else { - zval *value_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval *value_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(value_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); @@ -20048,10 +20048,10 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ } ZVAL_COPY(&generator->value, value_ptr); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; } } else { - zval *value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval *value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); /* Consts, temporary variables and references need copying */ if (IS_VAR == IS_CONST) { @@ -20060,7 +20060,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ ZVAL_COPY_VALUE(&generator->value, value); } else if ((IS_VAR == IS_CV || IS_VAR == IS_VAR) && Z_ISREF_P(value)) { ZVAL_DUP(&generator->value, Z_REFVAL_P(value)); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } else { ZVAL_COPY_VALUE(&generator->value, value); if (IS_VAR == IS_CV) { @@ -20131,9 +20131,9 @@ static int ZEND_FASTCALL ZEND_POW_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); pow_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), opline->op2.zv TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -20151,10 +20151,10 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_add_function(EX_VAR(opline->result.var), - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20166,10 +20166,10 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_sub_function(EX_VAR(opline->result.var), - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20181,10 +20181,10 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_mul_function(EX_VAR(opline->result.var), - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20196,10 +20196,10 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_div_function(EX_VAR(opline->result.var), - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20211,10 +20211,10 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_mod_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20226,10 +20226,10 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_left_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20241,10 +20241,10 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_right_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20256,10 +20256,10 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); concat_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20271,10 +20271,10 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); fast_is_identical_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20287,10 +20287,10 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE SAVE_OPLINE(); fast_is_not_identical_function(result, - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20303,10 +20303,10 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); fast_equal_function(result, - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20319,10 +20319,10 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); fast_not_equal_function(result, - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20335,10 +20335,10 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); fast_is_smaller_function(result, - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20351,10 +20351,10 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_VAR_TMP_HANDLER(ZEND_OPC SAVE_OPLINE(); fast_is_smaller_or_equal_function(result, - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20366,10 +20366,10 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); bitwise_or_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20381,10 +20381,10 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); bitwise_and_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20396,10 +20396,10 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); bitwise_xor_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20411,10 +20411,10 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); boolean_xor_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20423,8 +20423,8 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_VAR_TMP(int (*bin { USE_OPLINE zend_free_op free_op1, free_op2, free_op_data1; - zval *object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - zval *property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); + zval *property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); zval *value; zval *zptr; @@ -20440,7 +20440,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_VAR_TMP(int (*bin if (IS_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { zend_error(E_WARNING, "Attempt to assign property of non-object"); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); FREE_OP(free_op_data1); if (RETURN_VALUE_USED(opline)) { @@ -20502,11 +20502,11 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_VAR_TMP(int (*bin } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); FREE_OP(free_op_data1); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; /* assign_obj has two opcodes! */ CHECK_EXCEPTION(); ZEND_VM_INC_OPCODE(); @@ -20521,7 +20521,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_VAR_TMP(int (*bin zval *value, *container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } @@ -20529,12 +20529,12 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_VAR_TMP(int (*bin ZVAL_DEREF(container); } if (IS_VAR == IS_UNUSED || UNEXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { - if (IS_VAR == IS_VAR && !(free_op1.var != NULL)) { + if (IS_VAR == IS_VAR && !(free_op1 != NULL)) { Z_ADDREF_P(container); /* undo the effect of get_obj_zval_ptr_ptr() */ } return zend_binary_assign_op_obj_helper_SPEC_VAR_TMP(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } else { - zval *dim = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *dim = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); zend_fetch_dimension_address_RW(&rv, container, dim, IS_TMP_VAR TSRMLS_CC); value = get_zval_ptr_deref((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); @@ -20561,9 +20561,9 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_VAR_TMP(int (*bin } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); FREE_OP(free_op_data1); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_INC_OPCODE(); ZEND_VM_NEXT_OPCODE(); @@ -20577,8 +20577,8 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_VAR_TMP(int (*binary_ zval *value; SAVE_OPLINE(); - value = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); - var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); + var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(var_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use assign-op operators with overloaded objects nor string offsets"); @@ -20599,8 +20599,8 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_VAR_TMP(int (*binary_ } } - zval_ptr_dtor_nogc(free_op2.var); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + zval_ptr_dtor_nogc(free_op2); + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20758,8 +20758,8 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_VAR_TMP(incdec_t i zval *zptr; SAVE_OPLINE(); - object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); retval = EX_VAR(opline->result.var); if (IS_VAR == IS_VAR && UNEXPECTED(object == NULL)) { @@ -20772,11 +20772,11 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_VAR_TMP(incdec_t i if (IS_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { zend_error(E_WARNING, "Attempt to increment/decrement property of non-object"); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); if (RETURN_VALUE_USED(opline)) { ZVAL_NULL(retval); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20823,8 +20823,8 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_VAR_TMP(incdec_t i } } - zval_ptr_dtor_nogc(free_op2.var); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + zval_ptr_dtor_nogc(free_op2); + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20849,8 +20849,8 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_VAR_TMP(incdec_t zval *zptr; SAVE_OPLINE(); - object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); retval = EX_VAR(opline->result.var); if (IS_VAR == IS_VAR && UNEXPECTED(object == NULL)) { @@ -20863,9 +20863,9 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_VAR_TMP(incdec_t if (IS_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { zend_error(E_WARNING, "Attempt to increment/decrement property of non-object"); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_NULL(retval); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20908,8 +20908,8 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_VAR_TMP(incdec_t } } - zval_ptr_dtor_nogc(free_op2.var); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + zval_ptr_dtor_nogc(free_op2); + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20931,10 +20931,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAND zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - zval_ptr_dtor_nogc(free_op1.var); + container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); + zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2), IS_TMP_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20946,18 +20946,18 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_W_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAND zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } ZVAL_DEREF(container); - zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2), IS_TMP_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20969,18 +20969,18 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAN zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } ZVAL_DEREF(container); - zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2), IS_TMP_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20992,10 +20992,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_IS_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAN zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - zval_ptr_dtor_nogc(free_op1.var); + container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); + zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2), IS_TMP_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -21012,25 +21012,25 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_VAR_TMP_HANDLER(ZEND_OPCO if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR) { zend_error_noreturn(E_ERROR, "Cannot use temporary expression in write context"); } - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } ZVAL_DEREF(container); - zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR TSRMLS_CC); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2), IS_TMP_VAR TSRMLS_CC); + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - zval_ptr_dtor_nogc(free_op2.var); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + zval_ptr_dtor_nogc(free_op2); + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; } else { if (IS_TMP_VAR == IS_UNUSED) { zend_error_noreturn(E_ERROR, "Cannot use [] for reading"); } - container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - zval_ptr_dtor_nogc(free_op1.var); + container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); + zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2), IS_TMP_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); + zval_ptr_dtor_nogc(free_op1); } CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -21043,18 +21043,18 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_ zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } ZVAL_DEREF(container); - zend_fetch_dimension_address_UNSET(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zend_fetch_dimension_address_UNSET(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2), IS_TMP_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -21068,8 +21068,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAND zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if ((IS_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -21108,8 +21108,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAND } while (0); } - zval_ptr_dtor_nogc(free_op2.var); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op2); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -21122,19 +21122,19 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAND zval *container; SAVE_OPLINE(); - property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -21147,18 +21147,18 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAN zval *container; SAVE_OPLINE(); - property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -21172,8 +21172,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAN zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if ((IS_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -21211,8 +21211,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAN } while (0); } - zval_ptr_dtor_nogc(free_op2.var); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op2); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -21228,8 +21228,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_VAR_TMP_HANDLER(ZEND_OPCO zval *property; SAVE_OPLINE(); - property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR) { zend_error_noreturn(E_ERROR, "Cannot use temporary expression in write context"); @@ -21238,11 +21238,11 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_VAR_TMP_HANDLER(ZEND_OPCO zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else { @@ -21257,18 +21257,18 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_ zval *container, *property; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -21281,15 +21281,15 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDL zval *property_name; SAVE_OPLINE(); - object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - property_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); + property_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_VAR == IS_VAR && UNEXPECTED(object == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } zend_assign_to_object(RETURN_VALUE_USED(opline)?EX_VAR(opline->result.var):NULL, object, IS_VAR, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_OBJ, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property_name)) : NULL) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + zval_ptr_dtor_nogc(free_op2); + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; /* assign_obj has two opcodes! */ CHECK_EXCEPTION(); ZEND_VM_INC_OPCODE(); @@ -21303,7 +21303,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDL zval *object_ptr; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -21311,27 +21311,27 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDL ZVAL_DEREF(object_ptr); if (UNEXPECTED(Z_TYPE_P(object_ptr) == IS_OBJECT)) { zend_free_op free_op2; - zval *property_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *property_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); zend_assign_to_object(RETURN_VALUE_USED(opline)?EX_VAR(opline->result.var):NULL, object_ptr, IS_VAR, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_DIM, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property_name)) : NULL) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else { zend_free_op free_op2, free_op_data1; zval rv; zval *value; - zval *dim = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *dim = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); zval *variable_ptr; if (UNEXPECTED(Z_TYPE_P(object_ptr) == IS_STRING) && EXPECTED(Z_STRLEN_P(object_ptr) != 0)) { zend_long offset = zend_fetch_string_offset(object_ptr, dim, BP_VAR_W TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); value = get_zval_ptr_deref((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); zend_assign_to_string_offset(object_ptr, offset, value, (RETURN_VALUE_USED(opline) ? EX_VAR(opline->result.var) : NULL) TSRMLS_CC); FREE_OP(free_op_data1); } else { zend_fetch_dimension_address_W(&rv, object_ptr, dim, IS_TMP_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); value = get_zval_ptr_deref((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); ZEND_ASSERT(Z_TYPE(rv) == IS_INDIRECT); variable_ptr = Z_INDIRECT(rv); @@ -21351,7 +21351,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDL } } } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; /* assign_dim has two opcodes! */ CHECK_EXCEPTION(); ZEND_VM_INC_OPCODE(); @@ -21366,12 +21366,12 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_A zval *variable_ptr; SAVE_OPLINE(); - value = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); - variable_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); + variable_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(variable_ptr == &EG(error_zval))) { if (IS_TMP_VAR == IS_TMP_VAR) { - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } if (RETURN_VALUE_USED(opline)) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -21381,7 +21381,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_A if (RETURN_VALUE_USED(opline)) { ZVAL_COPY(EX_VAR(opline->result.var), value); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; } /* zend_assign_to_variable() always takes care of op2, never free it! */ @@ -21402,7 +21402,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE SAVE_OPLINE(); - function_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_TMP_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { @@ -21412,19 +21412,19 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE zend_error_noreturn(E_ERROR, "Method name must be a string"); } - object = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + object = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); if (IS_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { uint32_t nesting = 1; if (UNEXPECTED(EG(exception) != NULL)) { - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); HANDLE_EXCEPTION(); } zend_error(E_RECOVERABLE_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object))); - zval_ptr_dtor_nogc(free_op2.var); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op2); + zval_ptr_dtor_nogc(free_op1); if (EG(exception) != NULL) { HANDLE_EXCEPTION(); @@ -21492,8 +21492,8 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION, fbc, opline->extended_value, called_scope, obj, EX(call) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op2); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -21538,7 +21538,7 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_TMP_HANDLER(ZEND } else if (IS_TMP_VAR != IS_UNUSED) { zend_free_op free_op2; - function_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_TMP_VAR != IS_CONST) { if (UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { if (UNEXPECTED(EG(exception) != NULL)) { @@ -21566,7 +21566,7 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_TMP_HANDLER(ZEND } } if (IS_TMP_VAR != IS_CONST) { - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } } else { if (UNEXPECTED(ce->constructor == NULL)) { @@ -21631,10 +21631,10 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); fast_equal_function(result, - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -21648,15 +21648,15 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_TMP_HANDLER(ZEND_OPCOD SAVE_OPLINE(); if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && (opline->extended_value & ZEND_ARRAY_ELEMENT_REF)) { - expr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + expr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(expr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); } ZVAL_MAKE_REF(expr_ptr); Z_ADDREF_P(expr_ptr); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; } else { - expr_ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + expr_ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_TMP_VAR) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; @@ -21668,7 +21668,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_TMP_HANDLER(ZEND_OPCOD } else if ((IS_VAR == IS_CV || IS_VAR == IS_VAR) && Z_ISREF_P(expr_ptr)) { expr_ptr = Z_REFVAL_P(expr_ptr); if (Z_REFCOUNTED_P(expr_ptr)) Z_ADDREF_P(expr_ptr); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } else if (IS_VAR == IS_CV && Z_REFCOUNTED_P(expr_ptr)) { Z_ADDREF_P(expr_ptr); } @@ -21676,7 +21676,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_TMP_HANDLER(ZEND_OPCOD if (IS_TMP_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); zend_string *str; zend_ulong hval; @@ -21719,7 +21719,7 @@ str_index: /* do nothing */ break; } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else { zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr); } @@ -21767,7 +21767,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLE zend_ulong hval; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); } @@ -21775,7 +21775,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLE ZVAL_DEREF(container); SEPARATE_ZVAL_NOREF(container); } - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_VAR != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { HashTable *ht = Z_ARRVAL_P(container); @@ -21822,7 +21822,7 @@ num_index_dim: zend_error(E_WARNING, "Illegal offset type in unset"); break; } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else if (IS_VAR == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { if (UNEXPECTED(Z_OBJ_HT_P(container)->unset_dimension == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use object as array"); @@ -21831,14 +21831,14 @@ num_index_dim: //??? zval_copy_ctor(offset); //??? } Z_OBJ_HT_P(container)->unset_dimension(container, offset TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else if (UNEXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); ZEND_VM_CONTINUE(); /* bailed out before */ } else { - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -21851,11 +21851,11 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLE zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); } - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); ZVAL_DEREF(container); if (IS_VAR == IS_UNUSED || Z_TYPE_P(container) == IS_OBJECT) { @@ -21865,8 +21865,8 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLE zend_error(E_NOTICE, "Trying to unset property of non-object"); } } - zval_ptr_dtor_nogc(free_op2.var); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + zval_ptr_dtor_nogc(free_op2); + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -21881,8 +21881,8 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_VAR_TMP_HANDLER(ZEND_O zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_VAR != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { HashTable *ht = Z_ARRVAL_P(container); @@ -21978,9 +21978,9 @@ num_index_prop: result = ((opline->extended_value & ZEND_ISSET) == 0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_BOOL(EX_VAR(opline->result.var), result); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -21994,8 +21994,8 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_VAR_TMP_HANDLER(ZEND_ zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_VAR == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { if (EXPECTED(Z_OBJ_HT_P(container)->has_property)) { @@ -22011,9 +22011,9 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_VAR_TMP_HANDLER(ZEND_ result = ((opline->extended_value & ZEND_ISSET) == 0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_BOOL(EX_VAR(opline->result.var), result); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22047,7 +22047,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR zend_error(E_NOTICE, "Only variable references should be yielded by reference"); - value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); ZVAL_COPY_VALUE(&generator->value, value); if (Z_OPT_REFCOUNTED(generator->value)) Z_SET_REFCOUNT(generator->value, 1); @@ -22056,7 +22056,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR zval_opt_copy_ctor(&generator->value); } } else { - zval *value_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval *value_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(value_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); @@ -22074,10 +22074,10 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR } ZVAL_COPY(&generator->value, value_ptr); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; } } else { - zval *value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval *value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); /* Consts, temporary variables and references need copying */ if (IS_VAR == IS_CONST) { @@ -22086,7 +22086,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR ZVAL_COPY_VALUE(&generator->value, value); } else if ((IS_VAR == IS_CV || IS_VAR == IS_VAR) && Z_ISREF_P(value)) { ZVAL_DUP(&generator->value, Z_REFVAL_P(value)); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } else { ZVAL_COPY_VALUE(&generator->value, value); if (IS_VAR == IS_CV) { @@ -22102,7 +22102,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR /* Set the new yielded key */ if (IS_TMP_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *key = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *key = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); /* Consts, temporary variables and references need copying */ if (IS_TMP_VAR == IS_CONST) { @@ -22157,10 +22157,10 @@ static int ZEND_FASTCALL ZEND_POW_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); pow_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22177,10 +22177,10 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_add_function(EX_VAR(opline->result.var), - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22192,10 +22192,10 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_sub_function(EX_VAR(opline->result.var), - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22207,10 +22207,10 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_mul_function(EX_VAR(opline->result.var), - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22222,10 +22222,10 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_div_function(EX_VAR(opline->result.var), - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22237,10 +22237,10 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_mod_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22252,10 +22252,10 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_left_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22267,10 +22267,10 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_right_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22282,10 +22282,10 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); concat_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22297,10 +22297,10 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); fast_is_identical_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22313,10 +22313,10 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE SAVE_OPLINE(); fast_is_not_identical_function(result, - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22329,10 +22329,10 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); fast_equal_function(result, - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22345,10 +22345,10 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); fast_not_equal_function(result, - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22361,10 +22361,10 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); fast_is_smaller_function(result, - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22377,10 +22377,10 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_VAR_VAR_HANDLER(ZEND_OPC SAVE_OPLINE(); fast_is_smaller_or_equal_function(result, - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22392,10 +22392,10 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); bitwise_or_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22407,10 +22407,10 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); bitwise_and_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22422,10 +22422,10 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); bitwise_xor_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22437,10 +22437,10 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); boolean_xor_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22449,8 +22449,8 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_VAR_VAR(int (*bin { USE_OPLINE zend_free_op free_op1, free_op2, free_op_data1; - zval *object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - zval *property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); + zval *property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); zval *value; zval *zptr; @@ -22466,7 +22466,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_VAR_VAR(int (*bin if (IS_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { zend_error(E_WARNING, "Attempt to assign property of non-object"); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); FREE_OP(free_op_data1); if (RETURN_VALUE_USED(opline)) { @@ -22528,11 +22528,11 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_VAR_VAR(int (*bin } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); FREE_OP(free_op_data1); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; /* assign_obj has two opcodes! */ CHECK_EXCEPTION(); ZEND_VM_INC_OPCODE(); @@ -22547,7 +22547,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_VAR_VAR(int (*bin zval *value, *container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } @@ -22555,12 +22555,12 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_VAR_VAR(int (*bin ZVAL_DEREF(container); } if (IS_VAR == IS_UNUSED || UNEXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { - if (IS_VAR == IS_VAR && !(free_op1.var != NULL)) { + if (IS_VAR == IS_VAR && !(free_op1 != NULL)) { Z_ADDREF_P(container); /* undo the effect of get_obj_zval_ptr_ptr() */ } return zend_binary_assign_op_obj_helper_SPEC_VAR_VAR(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } else { - zval *dim = _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *dim = _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2); zend_fetch_dimension_address_RW(&rv, container, dim, IS_VAR TSRMLS_CC); value = get_zval_ptr_deref((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); @@ -22587,9 +22587,9 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_VAR_VAR(int (*bin } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); FREE_OP(free_op_data1); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_INC_OPCODE(); ZEND_VM_NEXT_OPCODE(); @@ -22603,8 +22603,8 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_VAR_VAR(int (*binary_ zval *value; SAVE_OPLINE(); - value = _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); - var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2); + var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(var_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use assign-op operators with overloaded objects nor string offsets"); @@ -22625,8 +22625,8 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_VAR_VAR(int (*binary_ } } - zval_ptr_dtor_nogc(free_op2.var); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + zval_ptr_dtor_nogc(free_op2); + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22784,8 +22784,8 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_VAR_VAR(incdec_t i zval *zptr; SAVE_OPLINE(); - object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); retval = EX_VAR(opline->result.var); if (IS_VAR == IS_VAR && UNEXPECTED(object == NULL)) { @@ -22798,11 +22798,11 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_VAR_VAR(incdec_t i if (IS_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { zend_error(E_WARNING, "Attempt to increment/decrement property of non-object"); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); if (RETURN_VALUE_USED(opline)) { ZVAL_NULL(retval); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22849,8 +22849,8 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_VAR_VAR(incdec_t i } } - zval_ptr_dtor_nogc(free_op2.var); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + zval_ptr_dtor_nogc(free_op2); + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22875,8 +22875,8 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_VAR_VAR(incdec_t zval *zptr; SAVE_OPLINE(); - object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); retval = EX_VAR(opline->result.var); if (IS_VAR == IS_VAR && UNEXPECTED(object == NULL)) { @@ -22889,9 +22889,9 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_VAR_VAR(incdec_t if (IS_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { zend_error(E_WARNING, "Attempt to increment/decrement property of non-object"); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_NULL(retval); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22934,8 +22934,8 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_VAR_VAR(incdec_t } } - zval_ptr_dtor_nogc(free_op2.var); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + zval_ptr_dtor_nogc(free_op2); + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22960,7 +22960,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_VAR(int type, ZE HashTable *target_symbol_table; SAVE_OPLINE(); - varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_CONST) { name = Z_STR_P(varname); @@ -22983,7 +22983,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_VAR(int type, ZE if (IS_VAR != IS_CONST) { zend_string_release(name); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -22993,7 +22993,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_VAR(int type, ZE ce = Z_CE_P(EX_VAR(opline->op2.var)); } retval = zend_std_get_static_property(ce, name, 0, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(varname)) : NULL) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } else { target_symbol_table = zend_get_target_symbol_table(execute_data, opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC); retval = zend_hash_find(target_symbol_table, name); @@ -23041,7 +23041,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_VAR(int type, ZE zval_update_constant(retval, 1 TSRMLS_CC); } } else if ((opline->extended_value & ZEND_FETCH_TYPE_MASK) != ZEND_FETCH_GLOBAL_LOCK) { - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } } @@ -23105,10 +23105,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAND zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - zval_ptr_dtor_nogc(free_op1.var); + container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); + zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2), IS_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -23120,18 +23120,18 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_W_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAND zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } ZVAL_DEREF(container); - zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2), IS_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -23143,18 +23143,18 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAN zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } ZVAL_DEREF(container); - zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2), IS_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -23166,10 +23166,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_IS_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAN zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - zval_ptr_dtor_nogc(free_op1.var); + container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); + zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2), IS_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -23186,25 +23186,25 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_VAR_VAR_HANDLER(ZEND_OPCO if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR) { zend_error_noreturn(E_ERROR, "Cannot use temporary expression in write context"); } - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } ZVAL_DEREF(container); - zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR TSRMLS_CC); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2), IS_VAR TSRMLS_CC); + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - zval_ptr_dtor_nogc(free_op2.var); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + zval_ptr_dtor_nogc(free_op2); + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; } else { if (IS_VAR == IS_UNUSED) { zend_error_noreturn(E_ERROR, "Cannot use [] for reading"); } - container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - zval_ptr_dtor_nogc(free_op1.var); + container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); + zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2), IS_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); + zval_ptr_dtor_nogc(free_op1); } CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -23217,18 +23217,18 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_ zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } ZVAL_DEREF(container); - zend_fetch_dimension_address_UNSET(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zend_fetch_dimension_address_UNSET(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2), IS_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -23242,8 +23242,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAND zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if ((IS_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -23282,8 +23282,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAND } while (0); } - zval_ptr_dtor_nogc(free_op2.var); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op2); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -23296,19 +23296,19 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAND zval *container; SAVE_OPLINE(); - property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -23321,18 +23321,18 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAN zval *container; SAVE_OPLINE(); - property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -23346,8 +23346,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAN zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if ((IS_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -23385,8 +23385,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAN } while (0); } - zval_ptr_dtor_nogc(free_op2.var); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op2); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -23402,8 +23402,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_VAR_VAR_HANDLER(ZEND_OPCO zval *property; SAVE_OPLINE(); - property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR) { zend_error_noreturn(E_ERROR, "Cannot use temporary expression in write context"); @@ -23412,11 +23412,11 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_VAR_VAR_HANDLER(ZEND_OPCO zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else { @@ -23431,18 +23431,18 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_ zval *container, *property; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -23455,15 +23455,15 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDL zval *property_name; SAVE_OPLINE(); - object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - property_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); + property_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_VAR == IS_VAR && UNEXPECTED(object == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } zend_assign_to_object(RETURN_VALUE_USED(opline)?EX_VAR(opline->result.var):NULL, object, IS_VAR, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_OBJ, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property_name)) : NULL) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + zval_ptr_dtor_nogc(free_op2); + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; /* assign_obj has two opcodes! */ CHECK_EXCEPTION(); ZEND_VM_INC_OPCODE(); @@ -23477,7 +23477,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDL zval *object_ptr; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -23485,27 +23485,27 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDL ZVAL_DEREF(object_ptr); if (UNEXPECTED(Z_TYPE_P(object_ptr) == IS_OBJECT)) { zend_free_op free_op2; - zval *property_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *property_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); zend_assign_to_object(RETURN_VALUE_USED(opline)?EX_VAR(opline->result.var):NULL, object_ptr, IS_VAR, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_DIM, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property_name)) : NULL) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else { zend_free_op free_op2, free_op_data1; zval rv; zval *value; - zval *dim = _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *dim = _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2); zval *variable_ptr; if (UNEXPECTED(Z_TYPE_P(object_ptr) == IS_STRING) && EXPECTED(Z_STRLEN_P(object_ptr) != 0)) { zend_long offset = zend_fetch_string_offset(object_ptr, dim, BP_VAR_W TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); value = get_zval_ptr_deref((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); zend_assign_to_string_offset(object_ptr, offset, value, (RETURN_VALUE_USED(opline) ? EX_VAR(opline->result.var) : NULL) TSRMLS_CC); FREE_OP(free_op_data1); } else { zend_fetch_dimension_address_W(&rv, object_ptr, dim, IS_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); value = get_zval_ptr_deref((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); ZEND_ASSERT(Z_TYPE(rv) == IS_INDIRECT); variable_ptr = Z_INDIRECT(rv); @@ -23525,7 +23525,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDL } } } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; /* assign_dim has two opcodes! */ CHECK_EXCEPTION(); ZEND_VM_INC_OPCODE(); @@ -23540,12 +23540,12 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_A zval *variable_ptr; SAVE_OPLINE(); - value = _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); - variable_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2); + variable_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(variable_ptr == &EG(error_zval))) { if (IS_VAR == IS_TMP_VAR) { - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } if (RETURN_VALUE_USED(opline)) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -23555,11 +23555,11 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_A if (RETURN_VALUE_USED(opline)) { ZVAL_COPY(EX_VAR(opline->result.var), value); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; } /* zend_assign_to_variable() always takes care of op2, never free it! */ - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -23573,7 +23573,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDL zval *value_ptr; SAVE_OPLINE(); - value_ptr = _get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + value_ptr = _get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_VAR == IS_VAR && UNEXPECTED(value_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets nor overloaded objects"); @@ -23582,22 +23582,22 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDL (value_ptr == &EG(uninitialized_zval) || (opline->extended_value == ZEND_RETURNS_FUNCTION && !(Z_VAR_FLAGS_P(value_ptr) & IS_VAR_RET_REF)))) { - if (!(free_op2.var != NULL)) { + if (!(free_op2 != NULL)) { PZVAL_LOCK(value_ptr); /* undo the effect of get_zval_ptr_ptr() */ } zend_error(E_STRICT, "Only variables should be assigned by reference"); if (UNEXPECTED(EG(exception) != NULL)) { - if (free_op2.var) {zval_ptr_dtor_nogc(free_op2.var);}; + if (free_op2) {zval_ptr_dtor_nogc(free_op2);}; HANDLE_EXCEPTION(); } return ZEND_ASSIGN_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } else if (IS_VAR == IS_VAR && opline->extended_value == ZEND_RETURNS_NEW) { - if (!(free_op2.var != NULL)) { + if (!(free_op2 != NULL)) { PZVAL_LOCK(value_ptr); } } - variable_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + variable_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(variable_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets nor overloaded objects"); } @@ -23614,7 +23614,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDL } if (IS_VAR == IS_VAR && opline->extended_value == ZEND_RETURNS_NEW) { - if (!(free_op2.var != NULL)) { + if (!(free_op2 != NULL)) { Z_DELREF_P(variable_ptr); } } @@ -23623,8 +23623,8 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDL ZVAL_COPY(EX_VAR(opline->result.var), variable_ptr); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; - if (free_op2.var) {zval_ptr_dtor_nogc(free_op2.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; + if (free_op2) {zval_ptr_dtor_nogc(free_op2);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -23642,7 +23642,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE SAVE_OPLINE(); - function_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { @@ -23652,19 +23652,19 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE zend_error_noreturn(E_ERROR, "Method name must be a string"); } - object = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + object = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); if (IS_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { uint32_t nesting = 1; if (UNEXPECTED(EG(exception) != NULL)) { - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); HANDLE_EXCEPTION(); } zend_error(E_RECOVERABLE_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object))); - zval_ptr_dtor_nogc(free_op2.var); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op2); + zval_ptr_dtor_nogc(free_op1); if (EG(exception) != NULL) { HANDLE_EXCEPTION(); @@ -23732,8 +23732,8 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION, fbc, opline->extended_value, called_scope, obj, EX(call) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op2); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -23778,7 +23778,7 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_VAR_HANDLER(ZEND } else if (IS_VAR != IS_UNUSED) { zend_free_op free_op2; - function_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_VAR != IS_CONST) { if (UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { if (UNEXPECTED(EG(exception) != NULL)) { @@ -23806,7 +23806,7 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_VAR_HANDLER(ZEND } } if (IS_VAR != IS_CONST) { - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } } else { if (UNEXPECTED(ce->constructor == NULL)) { @@ -23871,10 +23871,10 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); fast_equal_function(result, - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -23888,15 +23888,15 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_VAR_HANDLER(ZEND_OPCOD SAVE_OPLINE(); if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && (opline->extended_value & ZEND_ARRAY_ELEMENT_REF)) { - expr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + expr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(expr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); } ZVAL_MAKE_REF(expr_ptr); Z_ADDREF_P(expr_ptr); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; } else { - expr_ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + expr_ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_TMP_VAR) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; @@ -23908,7 +23908,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_VAR_HANDLER(ZEND_OPCOD } else if ((IS_VAR == IS_CV || IS_VAR == IS_VAR) && Z_ISREF_P(expr_ptr)) { expr_ptr = Z_REFVAL_P(expr_ptr); if (Z_REFCOUNTED_P(expr_ptr)) Z_ADDREF_P(expr_ptr); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } else if (IS_VAR == IS_CV && Z_REFCOUNTED_P(expr_ptr)) { Z_ADDREF_P(expr_ptr); } @@ -23916,7 +23916,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_VAR_HANDLER(ZEND_OPCOD if (IS_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); zend_string *str; zend_ulong hval; @@ -23959,7 +23959,7 @@ str_index: /* do nothing */ break; } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else { zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr); } @@ -24028,7 +24028,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLE ZEND_VM_NEXT_OPCODE(); } - varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); ZVAL_UNDEF(&tmp); if (IS_VAR != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { @@ -24048,7 +24048,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLE if (IS_VAR != IS_CONST) { zval_dtor(&tmp); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); HANDLE_EXCEPTION(); } if (UNEXPECTED(ce == NULL)) { @@ -24068,7 +24068,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLE if (IS_VAR != IS_CONST) { zval_dtor(&tmp); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -24082,7 +24082,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLE zend_ulong hval; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); } @@ -24090,7 +24090,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLE ZVAL_DEREF(container); SEPARATE_ZVAL_NOREF(container); } - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_VAR != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { HashTable *ht = Z_ARRVAL_P(container); @@ -24137,7 +24137,7 @@ num_index_dim: zend_error(E_WARNING, "Illegal offset type in unset"); break; } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else if (IS_VAR == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { if (UNEXPECTED(Z_OBJ_HT_P(container)->unset_dimension == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use object as array"); @@ -24146,14 +24146,14 @@ num_index_dim: //??? zval_copy_ctor(offset); //??? } Z_OBJ_HT_P(container)->unset_dimension(container, offset TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else if (UNEXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); ZEND_VM_CONTINUE(); /* bailed out before */ } else { - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -24166,11 +24166,11 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLE zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); } - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); ZVAL_DEREF(container); if (IS_VAR == IS_UNUSED || Z_TYPE_P(container) == IS_OBJECT) { @@ -24180,8 +24180,8 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLE zend_error(E_NOTICE, "Trying to unset property of non-object"); } } - zval_ptr_dtor_nogc(free_op2.var); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + zval_ptr_dtor_nogc(free_op2); + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -24208,7 +24208,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_VAR_VAR_HANDLER(ZEND_OPCOD ZEND_VM_NEXT_OPCODE(); } else { zend_free_op free_op1; - zval tmp, *varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval tmp, *varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { ZVAL_STR(&tmp, zval_get_string(varname)); @@ -24241,7 +24241,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_VAR_VAR_HANDLER(ZEND_OPCOD if (IS_VAR != IS_CONST && varname == &tmp) { zval_dtor(&tmp); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); if (opline->extended_value & ZEND_ISSET) { ZVAL_BOOL(EX_VAR(opline->result.var), @@ -24267,8 +24267,8 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_VAR_VAR_HANDLER(ZEND_O zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_VAR != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { HashTable *ht = Z_ARRVAL_P(container); @@ -24364,9 +24364,9 @@ num_index_prop: result = ((opline->extended_value & ZEND_ISSET) == 0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_BOOL(EX_VAR(opline->result.var), result); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -24380,8 +24380,8 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_VAR_VAR_HANDLER(ZEND_ zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_VAR == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { if (EXPECTED(Z_OBJ_HT_P(container)->has_property)) { @@ -24397,9 +24397,9 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_VAR_VAR_HANDLER(ZEND_ result = ((opline->extended_value & ZEND_ISSET) == 0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_BOOL(EX_VAR(opline->result.var), result); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -24412,7 +24412,7 @@ static int ZEND_FASTCALL ZEND_INSTANCEOF_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDL zend_bool result; SAVE_OPLINE(); - expr = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + expr = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); if (Z_TYPE_P(expr) == IS_OBJECT) { zend_class_entry *ce; @@ -24424,7 +24424,7 @@ static int ZEND_FASTCALL ZEND_INSTANCEOF_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDL ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, ZEND_FETCH_CLASS_NO_AUTOLOAD TSRMLS_CC); if (UNEXPECTED(ce == NULL)) { ZVAL_FALSE(EX_VAR(opline->result.var)); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -24438,7 +24438,7 @@ static int ZEND_FASTCALL ZEND_INSTANCEOF_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDL result = 0; } ZVAL_BOOL(EX_VAR(opline->result.var), result); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -24472,7 +24472,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR zend_error(E_NOTICE, "Only variable references should be yielded by reference"); - value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); ZVAL_COPY_VALUE(&generator->value, value); if (Z_OPT_REFCOUNTED(generator->value)) Z_SET_REFCOUNT(generator->value, 1); @@ -24481,7 +24481,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR zval_opt_copy_ctor(&generator->value); } } else { - zval *value_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval *value_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(value_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); @@ -24499,10 +24499,10 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR } ZVAL_COPY(&generator->value, value_ptr); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; } } else { - zval *value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval *value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); /* Consts, temporary variables and references need copying */ if (IS_VAR == IS_CONST) { @@ -24511,7 +24511,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR ZVAL_COPY_VALUE(&generator->value, value); } else if ((IS_VAR == IS_CV || IS_VAR == IS_VAR) && Z_ISREF_P(value)) { ZVAL_DUP(&generator->value, Z_REFVAL_P(value)); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } else { ZVAL_COPY_VALUE(&generator->value, value); if (IS_VAR == IS_CV) { @@ -24527,7 +24527,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR /* Set the new yielded key */ if (IS_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *key = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *key = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); /* Consts, temporary variables and references need copying */ if (IS_VAR == IS_CONST) { @@ -24536,7 +24536,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR ZVAL_COPY_VALUE(&generator->key, key); } else if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && Z_ISREF_P(key)) { ZVAL_DUP(&generator->key, Z_REFVAL_P(key)); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else { ZVAL_COPY_VALUE(&generator->key, key); if (IS_VAR == IS_CV) { @@ -24582,10 +24582,10 @@ static int ZEND_FASTCALL ZEND_POW_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); pow_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); - zval_ptr_dtor_nogc(free_op2.var); + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); + zval_ptr_dtor_nogc(free_op1); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -24599,7 +24599,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_VAR_UNUSED(int (* { USE_OPLINE zend_free_op free_op1, free_op_data1; - zval *object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval *object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); zval *property = NULL; zval *value; zval *zptr; @@ -24681,7 +24681,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_VAR_UNUSED(int (* FREE_OP(free_op_data1); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; /* assign_obj has two opcodes! */ CHECK_EXCEPTION(); ZEND_VM_INC_OPCODE(); @@ -24696,7 +24696,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_VAR_UNUSED(int (* zval *value, *container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } @@ -24704,7 +24704,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_VAR_UNUSED(int (* ZVAL_DEREF(container); } if (IS_VAR == IS_UNUSED || UNEXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { - if (IS_VAR == IS_VAR && !(free_op1.var != NULL)) { + if (IS_VAR == IS_VAR && !(free_op1 != NULL)) { Z_ADDREF_P(container); /* undo the effect of get_obj_zval_ptr_ptr() */ } return zend_binary_assign_op_obj_helper_SPEC_VAR_UNUSED(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); @@ -24737,7 +24737,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_VAR_UNUSED(int (* } FREE_OP(free_op_data1); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_INC_OPCODE(); ZEND_VM_NEXT_OPCODE(); @@ -24752,7 +24752,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_VAR_UNUSED(int (*bina SAVE_OPLINE(); value = NULL; - var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(var_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use assign-op operators with overloaded objects nor string offsets"); @@ -24773,7 +24773,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_VAR_UNUSED(int (*bina } } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -24931,7 +24931,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_UNUSED(int type, HashTable *target_symbol_table; SAVE_OPLINE(); - varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_CONST) { name = Z_STR_P(varname); @@ -24954,7 +24954,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_UNUSED(int type, if (IS_VAR != IS_CONST) { zend_string_release(name); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -24964,7 +24964,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_UNUSED(int type, ce = Z_CE_P(EX_VAR(opline->op2.var)); } retval = zend_std_get_static_property(ce, name, 0, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(varname)) : NULL) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } else { target_symbol_table = zend_get_target_symbol_table(execute_data, opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC); retval = zend_hash_find(target_symbol_table, name); @@ -25012,7 +25012,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_UNUSED(int type, zval_update_constant(retval, 1 TSRMLS_CC); } } else if ((opline->extended_value & ZEND_FETCH_TYPE_MASK) != ZEND_FETCH_GLOBAL_LOCK) { - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } } @@ -25076,7 +25076,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_W_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_H zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -25084,10 +25084,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_W_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_H ZVAL_DEREF(container); zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, NULL, IS_UNUSED TSRMLS_CC); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -25099,7 +25099,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_ zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -25107,10 +25107,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_ ZVAL_DEREF(container); zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, NULL, IS_UNUSED TSRMLS_CC); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -25127,25 +25127,25 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_VAR_UNUSED_HANDLER(ZEND_O if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR) { zend_error_noreturn(E_ERROR, "Cannot use temporary expression in write context"); } - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } ZVAL_DEREF(container); zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, NULL, IS_UNUSED TSRMLS_CC); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; } else { if (IS_UNUSED == IS_UNUSED) { zend_error_noreturn(E_ERROR, "Cannot use [] for reading"); } - container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, NULL, IS_UNUSED TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -25158,7 +25158,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HA zval *object_ptr; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -25206,7 +25206,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HA } } } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; /* assign_dim has two opcodes! */ CHECK_EXCEPTION(); ZEND_VM_INC_OPCODE(); @@ -25346,15 +25346,15 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_UNUSED_HANDLER(ZEND_OP SAVE_OPLINE(); if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && (opline->extended_value & ZEND_ARRAY_ELEMENT_REF)) { - expr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + expr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(expr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); } ZVAL_MAKE_REF(expr_ptr); Z_ADDREF_P(expr_ptr); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; } else { - expr_ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + expr_ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_TMP_VAR) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; @@ -25366,7 +25366,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_UNUSED_HANDLER(ZEND_OP } else if ((IS_VAR == IS_CV || IS_VAR == IS_VAR) && Z_ISREF_P(expr_ptr)) { expr_ptr = Z_REFVAL_P(expr_ptr); if (Z_REFCOUNTED_P(expr_ptr)) Z_ADDREF_P(expr_ptr); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } else if (IS_VAR == IS_CV && Z_REFCOUNTED_P(expr_ptr)) { Z_ADDREF_P(expr_ptr); } @@ -25486,7 +25486,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HAN ZEND_VM_NEXT_OPCODE(); } - varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); ZVAL_UNDEF(&tmp); if (IS_VAR != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { @@ -25506,7 +25506,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HAN if (IS_VAR != IS_CONST) { zval_dtor(&tmp); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); HANDLE_EXCEPTION(); } if (UNEXPECTED(ce == NULL)) { @@ -25526,7 +25526,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HAN if (IS_VAR != IS_CONST) { zval_dtor(&tmp); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -25553,7 +25553,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_VAR_UNUSED_HANDLER(ZEND_OP ZEND_VM_NEXT_OPCODE(); } else { zend_free_op free_op1; - zval tmp, *varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval tmp, *varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { ZVAL_STR(&tmp, zval_get_string(varname)); @@ -25586,7 +25586,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_VAR_UNUSED_HANDLER(ZEND_OP if (IS_VAR != IS_CONST && varname == &tmp) { zval_dtor(&tmp); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); if (opline->extended_value & ZEND_ISSET) { ZVAL_BOOL(EX_VAR(opline->result.var), @@ -25649,7 +25649,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HANDLER zend_error(E_NOTICE, "Only variable references should be yielded by reference"); - value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); ZVAL_COPY_VALUE(&generator->value, value); if (Z_OPT_REFCOUNTED(generator->value)) Z_SET_REFCOUNT(generator->value, 1); @@ -25658,7 +25658,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HANDLER zval_opt_copy_ctor(&generator->value); } } else { - zval *value_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval *value_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(value_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); @@ -25676,10 +25676,10 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HANDLER } ZVAL_COPY(&generator->value, value_ptr); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; } } else { - zval *value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval *value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); /* Consts, temporary variables and references need copying */ if (IS_VAR == IS_CONST) { @@ -25688,7 +25688,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HANDLER ZVAL_COPY_VALUE(&generator->value, value); } else if ((IS_VAR == IS_CV || IS_VAR == IS_VAR) && Z_ISREF_P(value)) { ZVAL_DUP(&generator->value, Z_REFVAL_P(value)); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } else { ZVAL_COPY_VALUE(&generator->value, value); if (IS_VAR == IS_CV) { @@ -25764,9 +25764,9 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_add_function(EX_VAR(opline->result.var), - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -25779,9 +25779,9 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_sub_function(EX_VAR(opline->result.var), - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -25794,9 +25794,9 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_mul_function(EX_VAR(opline->result.var), - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -25809,9 +25809,9 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_div_function(EX_VAR(opline->result.var), - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -25824,9 +25824,9 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_mod_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -25839,9 +25839,9 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_left_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -25854,9 +25854,9 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_right_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -25869,9 +25869,9 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); concat_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -25884,9 +25884,9 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); fast_is_identical_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -25900,9 +25900,9 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_ SAVE_OPLINE(); fast_is_not_identical_function(result, - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -25916,9 +25916,9 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); fast_equal_function(result, - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -25932,9 +25932,9 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); fast_not_equal_function(result, - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -25948,9 +25948,9 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLE SAVE_OPLINE(); fast_is_smaller_function(result, - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -25964,9 +25964,9 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_VAR_CV_HANDLER(ZEND_OPCO SAVE_OPLINE(); fast_is_smaller_or_equal_function(result, - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -25979,9 +25979,9 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); bitwise_or_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -25994,9 +25994,9 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); bitwise_and_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -26009,9 +26009,9 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); bitwise_xor_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -26024,9 +26024,9 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); boolean_xor_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -26036,7 +26036,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_VAR_CV(int (*bina { USE_OPLINE zend_free_op free_op1, free_op_data1; - zval *object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval *object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); zval *property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); zval *value; zval *zptr; @@ -26118,7 +26118,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_VAR_CV(int (*bina FREE_OP(free_op_data1); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; /* assign_obj has two opcodes! */ CHECK_EXCEPTION(); ZEND_VM_INC_OPCODE(); @@ -26133,7 +26133,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_VAR_CV(int (*bina zval *value, *container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } @@ -26141,7 +26141,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_VAR_CV(int (*bina ZVAL_DEREF(container); } if (IS_VAR == IS_UNUSED || UNEXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { - if (IS_VAR == IS_VAR && !(free_op1.var != NULL)) { + if (IS_VAR == IS_VAR && !(free_op1 != NULL)) { Z_ADDREF_P(container); /* undo the effect of get_obj_zval_ptr_ptr() */ } return zend_binary_assign_op_obj_helper_SPEC_VAR_CV(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); @@ -26174,7 +26174,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_VAR_CV(int (*bina } FREE_OP(free_op_data1); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_INC_OPCODE(); ZEND_VM_NEXT_OPCODE(); @@ -26189,7 +26189,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_VAR_CV(int (*binary_o SAVE_OPLINE(); value = _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); - var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(var_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use assign-op operators with overloaded objects nor string offsets"); @@ -26210,7 +26210,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_VAR_CV(int (*binary_o } } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -26368,7 +26368,7 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_VAR_CV(incdec_t in zval *zptr; SAVE_OPLINE(); - object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); retval = EX_VAR(opline->result.var); @@ -26386,7 +26386,7 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_VAR_CV(incdec_t in if (RETURN_VALUE_USED(opline)) { ZVAL_NULL(retval); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -26433,7 +26433,7 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_VAR_CV(incdec_t in } } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -26458,7 +26458,7 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_VAR_CV(incdec_t i zval *zptr; SAVE_OPLINE(); - object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); retval = EX_VAR(opline->result.var); @@ -26474,7 +26474,7 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_VAR_CV(incdec_t i zend_error(E_WARNING, "Attempt to increment/decrement property of non-object"); ZVAL_NULL(retval); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -26517,7 +26517,7 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_VAR_CV(incdec_t i } } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -26539,10 +26539,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDL zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -26554,7 +26554,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_W_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDL zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -26562,10 +26562,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_W_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDL ZVAL_DEREF(container); zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV TSRMLS_CC); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -26577,7 +26577,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HAND zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -26585,10 +26585,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HAND ZVAL_DEREF(container); zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV TSRMLS_CC); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -26600,10 +26600,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_IS_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HAND zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -26620,25 +26620,25 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_VAR_CV_HANDLER(ZEND_OPCOD if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR) { zend_error_noreturn(E_ERROR, "Cannot use temporary expression in write context"); } - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } ZVAL_DEREF(container); zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV TSRMLS_CC); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; } else { if (IS_CV == IS_UNUSED) { zend_error_noreturn(E_ERROR, "Cannot use [] for reading"); } - container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -26651,7 +26651,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_H zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -26659,10 +26659,10 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_H ZVAL_DEREF(container); zend_fetch_dimension_address_UNSET(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV TSRMLS_CC); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -26676,7 +26676,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDL zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if ((IS_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || @@ -26716,7 +26716,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDL } while (0); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -26731,17 +26731,17 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -26755,17 +26755,17 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -26779,7 +26779,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HAND zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if ((IS_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || @@ -26818,7 +26818,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HAND } while (0); } - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -26835,7 +26835,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_VAR_CV_HANDLER(ZEND_OPCOD SAVE_OPLINE(); property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR) { zend_error_noreturn(E_ERROR, "Cannot use temporary expression in write context"); @@ -26845,10 +26845,10 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_VAR_CV_HANDLER(ZEND_OPCOD } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else { @@ -26863,7 +26863,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_H zval *container, *property; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { @@ -26871,10 +26871,10 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_H } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); - if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -26887,7 +26887,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLE zval *property_name; SAVE_OPLINE(); - object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + object = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); property_name = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(object == NULL)) { @@ -26895,7 +26895,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLE } zend_assign_to_object(RETURN_VALUE_USED(opline)?EX_VAR(opline->result.var):NULL, object, IS_VAR, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_OBJ, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property_name)) : NULL) TSRMLS_CC); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; /* assign_obj has two opcodes! */ CHECK_EXCEPTION(); ZEND_VM_INC_OPCODE(); @@ -26909,7 +26909,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLE zval *object_ptr; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -26957,7 +26957,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLE } } } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; /* assign_dim has two opcodes! */ CHECK_EXCEPTION(); ZEND_VM_INC_OPCODE(); @@ -26973,7 +26973,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); value = _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); - variable_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + variable_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(variable_ptr == &EG(error_zval))) { if (IS_CV == IS_TMP_VAR) { @@ -26987,7 +26987,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_AR if (RETURN_VALUE_USED(opline)) { ZVAL_COPY(EX_VAR(opline->result.var), value); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; } /* zend_assign_to_variable() always takes care of op2, never free it! */ @@ -27028,7 +27028,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLE } } - variable_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + variable_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(variable_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets nor overloaded objects"); } @@ -27054,7 +27054,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLE ZVAL_COPY(EX_VAR(opline->result.var), variable_ptr); } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -27082,7 +27082,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_ zend_error_noreturn(E_ERROR, "Method name must be a string"); } - object = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + object = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); if (IS_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { uint32_t nesting = 1; @@ -27094,7 +27094,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_ zend_error(E_RECOVERABLE_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object))); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); if (EG(exception) != NULL) { HANDLE_EXCEPTION(); @@ -27162,7 +27162,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_ EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION, fbc, opline->extended_value, called_scope, obj, EX(call) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -27300,7 +27300,7 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_equal_function(result, - _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -27316,15 +27316,15 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CV_HANDLER(ZEND_OPCODE SAVE_OPLINE(); if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && (opline->extended_value & ZEND_ARRAY_ELEMENT_REF)) { - expr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + expr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(expr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); } ZVAL_MAKE_REF(expr_ptr); Z_ADDREF_P(expr_ptr); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; } else { - expr_ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + expr_ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_TMP_VAR) { ZVAL_COPY_VALUE(&new_expr, expr_ptr); expr_ptr = &new_expr; @@ -27336,7 +27336,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CV_HANDLER(ZEND_OPCODE } else if ((IS_VAR == IS_CV || IS_VAR == IS_VAR) && Z_ISREF_P(expr_ptr)) { expr_ptr = Z_REFVAL_P(expr_ptr); if (Z_REFCOUNTED_P(expr_ptr)) Z_ADDREF_P(expr_ptr); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } else if (IS_VAR == IS_CV && Z_REFCOUNTED_P(expr_ptr)) { Z_ADDREF_P(expr_ptr); } @@ -27435,7 +27435,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER zend_ulong hval; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); } @@ -27506,7 +27506,7 @@ num_index_dim: } else { } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -27519,7 +27519,7 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); } @@ -27534,7 +27534,7 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER } } - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -27549,7 +27549,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_VAR_CV_HANDLER(ZEND_OP zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_VAR != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { @@ -27647,7 +27647,7 @@ num_index_prop: } ZVAL_BOOL(EX_VAR(opline->result.var), result); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -27661,7 +27661,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_VAR_CV_HANDLER(ZEND_O zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1); offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_VAR == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { @@ -27679,7 +27679,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_VAR_CV_HANDLER(ZEND_O } ZVAL_BOOL(EX_VAR(opline->result.var), result); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -27713,7 +27713,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG zend_error(E_NOTICE, "Only variable references should be yielded by reference"); - value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); ZVAL_COPY_VALUE(&generator->value, value); if (Z_OPT_REFCOUNTED(generator->value)) Z_SET_REFCOUNT(generator->value, 1); @@ -27722,7 +27722,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG zval_opt_copy_ctor(&generator->value); } } else { - zval *value_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval *value_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1); if (IS_VAR == IS_VAR && UNEXPECTED(value_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); @@ -27740,10 +27740,10 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG } ZVAL_COPY(&generator->value, value_ptr); - if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}; + if (free_op1) {zval_ptr_dtor_nogc(free_op1);}; } } else { - zval *value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zval *value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); /* Consts, temporary variables and references need copying */ if (IS_VAR == IS_CONST) { @@ -27752,7 +27752,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG ZVAL_COPY_VALUE(&generator->value, value); } else if ((IS_VAR == IS_CV || IS_VAR == IS_VAR) && Z_ISREF_P(value)) { ZVAL_DUP(&generator->value, Z_REFVAL_P(value)); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); } else { ZVAL_COPY_VALUE(&generator->value, value); if (IS_VAR == IS_CV) { @@ -27823,9 +27823,9 @@ static int ZEND_FASTCALL ZEND_POW_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); pow_function(EX_VAR(opline->result.var), - _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op1.var); + zval_ptr_dtor_nogc(free_op1); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -27846,7 +27846,7 @@ static int ZEND_FASTCALL ZEND_CLONE_SPEC_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARG zend_object_clone_obj_t clone_call; SAVE_OPLINE(); - obj = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + obj = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_CONST || (IS_UNUSED != IS_UNUSED && UNEXPECTED(Z_TYPE_P(obj) != IS_OBJECT))) { @@ -27920,7 +27920,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_UNUSED_CONST(int { USE_OPLINE zend_free_op free_op_data1; - zval *object = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + zval *object = _get_obj_zval_ptr_unused(execute_data); zval *property = opline->op2.zv; zval *value; zval *zptr; @@ -28016,7 +28016,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_UNUSED_CONST(int zval *value, *container; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } @@ -28251,7 +28251,7 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_UNUSED_CONST(incde zval *zptr; SAVE_OPLINE(); - object = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + object = _get_obj_zval_ptr_unused(execute_data); property = opline->op2.zv; retval = EX_VAR(opline->result.var); @@ -28341,7 +28341,7 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_UNUSED_CONST(incd zval *zptr; SAVE_OPLINE(); - object = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + object = _get_obj_zval_ptr_unused(execute_data); property = opline->op2.zv; retval = EX_VAR(opline->result.var); @@ -28424,7 +28424,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE zval *offset; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); offset = opline->op2.zv; if ((IS_UNUSED != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || @@ -28479,14 +28479,14 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE SAVE_OPLINE(); property = opline->op2.zv; - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -28503,14 +28503,14 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCOD SAVE_OPLINE(); property = opline->op2.zv; - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); - if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -28527,7 +28527,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCOD zval *offset; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); offset = opline->op2.zv; if ((IS_UNUSED != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || @@ -28583,7 +28583,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_UNUSED_CONST_HANDLER(ZEND SAVE_OPLINE(); property = opline->op2.zv; - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_CONST || IS_UNUSED == IS_TMP_VAR) { zend_error_noreturn(E_ERROR, "Cannot use temporary expression in write context"); @@ -28593,7 +28593,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_UNUSED_CONST_HANDLER(ZEND } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -28611,7 +28611,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_UNUSED_CONST_HANDLER(ZEND_OP zval *container, *property; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); property = opline->op2.zv; if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { @@ -28619,7 +28619,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_UNUSED_CONST_HANDLER(ZEND_OP } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); - if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -28635,7 +28635,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE_ zval *property_name; SAVE_OPLINE(); - object = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + object = _get_obj_zval_ptr_unused(execute_data); property_name = opline->op2.zv; if (IS_UNUSED == IS_VAR && UNEXPECTED(object == NULL)) { @@ -28710,7 +28710,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_CONST_HANDLER(ZEND_O zend_error_noreturn(E_ERROR, "Method name must be a string"); } - object = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + object = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { uint32_t nesting = 1; @@ -28932,7 +28932,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE_H zend_ulong hval; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); } @@ -29016,7 +29016,7 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE_H zval *offset; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); } @@ -29046,7 +29046,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_UNUSED_CONST_HANDLER(Z zval *offset; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); offset = opline->op2.zv; if (IS_UNUSED != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { @@ -29158,7 +29158,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_UNUSED_CONST_HANDLER( zval *offset; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); offset = opline->op2.zv; if (IS_UNUSED == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { @@ -29321,8 +29321,8 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_UNUSED_TMP(int (* { USE_OPLINE zend_free_op free_op2, free_op_data1; - zval *object = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); - zval *property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *object = _get_obj_zval_ptr_unused(execute_data); + zval *property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); zval *value; zval *zptr; @@ -29338,7 +29338,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_UNUSED_TMP(int (* if (IS_UNUSED != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { zend_error(E_WARNING, "Attempt to assign property of non-object"); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); FREE_OP(free_op_data1); if (RETURN_VALUE_USED(opline)) { @@ -29400,7 +29400,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_UNUSED_TMP(int (* } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); FREE_OP(free_op_data1); } @@ -29418,7 +29418,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_UNUSED_TMP(int (* zval *value, *container; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } @@ -29431,7 +29431,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_UNUSED_TMP(int (* } return zend_binary_assign_op_obj_helper_SPEC_UNUSED_TMP(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } else { - zval *dim = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *dim = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); zend_fetch_dimension_address_RW(&rv, container, dim, IS_TMP_VAR TSRMLS_CC); value = get_zval_ptr_deref((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); @@ -29458,7 +29458,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_UNUSED_TMP(int (* } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); FREE_OP(free_op_data1); CHECK_EXCEPTION(); @@ -29474,7 +29474,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_UNUSED_TMP(int (*bina zval *value; SAVE_OPLINE(); - value = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); var_ptr = NULL; if (IS_UNUSED == IS_VAR && UNEXPECTED(var_ptr == NULL)) { @@ -29496,7 +29496,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_UNUSED_TMP(int (*bina } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -29655,8 +29655,8 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_UNUSED_TMP(incdec_ zval *zptr; SAVE_OPLINE(); - object = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); - property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + object = _get_obj_zval_ptr_unused(execute_data); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); retval = EX_VAR(opline->result.var); if (IS_UNUSED == IS_VAR && UNEXPECTED(object == NULL)) { @@ -29669,7 +29669,7 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_UNUSED_TMP(incdec_ if (IS_UNUSED != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { zend_error(E_WARNING, "Attempt to increment/decrement property of non-object"); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); if (RETURN_VALUE_USED(opline)) { ZVAL_NULL(retval); } @@ -29720,7 +29720,7 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_UNUSED_TMP(incdec_ } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -29746,8 +29746,8 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_UNUSED_TMP(incdec zval *zptr; SAVE_OPLINE(); - object = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); - property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + object = _get_obj_zval_ptr_unused(execute_data); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); retval = EX_VAR(opline->result.var); if (IS_UNUSED == IS_VAR && UNEXPECTED(object == NULL)) { @@ -29760,7 +29760,7 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_UNUSED_TMP(incdec if (IS_UNUSED != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { zend_error(E_WARNING, "Attempt to increment/decrement property of non-object"); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_NULL(retval); CHECK_EXCEPTION(); @@ -29805,7 +29805,7 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_UNUSED_TMP(incdec } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -29830,8 +29830,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_H zval *offset; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if ((IS_UNUSED != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -29870,7 +29870,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_H } while (0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -29884,16 +29884,16 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_H zval *container; SAVE_OPLINE(); - property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -29909,15 +29909,15 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_ zval *container; SAVE_OPLINE(); - property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); + container = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -29934,8 +29934,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_ zval *offset; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if ((IS_UNUSED != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -29973,7 +29973,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_ } while (0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -29990,8 +29990,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_UNUSED_TMP_HANDLER(ZEND_O zval *property; SAVE_OPLINE(); - property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); + container = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_CONST || IS_UNUSED == IS_TMP_VAR) { zend_error_noreturn(E_ERROR, "Cannot use temporary expression in write context"); @@ -30000,8 +30000,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_UNUSED_TMP_HANDLER(ZEND_O zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -30019,15 +30019,15 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCO zval *container, *property; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); - property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -30043,14 +30043,14 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HA zval *property_name; SAVE_OPLINE(); - object = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); - property_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + object = _get_obj_zval_ptr_unused(execute_data); + property_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_UNUSED == IS_VAR && UNEXPECTED(object == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } zend_assign_to_object(RETURN_VALUE_USED(opline)?EX_VAR(opline->result.var):NULL, object, IS_UNUSED, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_OBJ, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property_name)) : NULL) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); /* assign_obj has two opcodes! */ CHECK_EXCEPTION(); @@ -30068,7 +30068,7 @@ static int ZEND_FASTCALL ZEND_ADD_VAR_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HANDL int use_copy = 0; SAVE_OPLINE(); - var = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + var = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_UNUSED == IS_UNUSED) { /* Initialize for erealloc in add_string_to_string */ @@ -30096,7 +30096,7 @@ static int ZEND_FASTCALL ZEND_ADD_VAR_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HANDL * which aren't affected by FREE_OP(Ts, )'s anyway, unless they're * string offsets or overloaded objects */ - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -30114,7 +30114,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_TMP_HANDLER(ZEND_OPC SAVE_OPLINE(); - function_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_TMP_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { @@ -30124,18 +30124,18 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_TMP_HANDLER(ZEND_OPC zend_error_noreturn(E_ERROR, "Method name must be a string"); } - object = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + object = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { uint32_t nesting = 1; if (UNEXPECTED(EG(exception) != NULL)) { - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); HANDLE_EXCEPTION(); } zend_error(E_RECOVERABLE_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object))); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); if (EG(exception) != NULL) { HANDLE_EXCEPTION(); @@ -30203,7 +30203,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_TMP_HANDLER(ZEND_OPC EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION, fbc, opline->extended_value, called_scope, obj, EX(call) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -30249,7 +30249,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HAN zend_ulong hval; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); } @@ -30257,7 +30257,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HAN ZVAL_DEREF(container); SEPARATE_ZVAL_NOREF(container); } - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_UNUSED != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { HashTable *ht = Z_ARRVAL_P(container); @@ -30304,7 +30304,7 @@ num_index_dim: zend_error(E_WARNING, "Illegal offset type in unset"); break; } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else if (IS_UNUSED == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { if (UNEXPECTED(Z_OBJ_HT_P(container)->unset_dimension == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use object as array"); @@ -30313,12 +30313,12 @@ num_index_dim: //??? zval_copy_ctor(offset); //??? } Z_OBJ_HT_P(container)->unset_dimension(container, offset TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else if (UNEXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); ZEND_VM_CONTINUE(); /* bailed out before */ } else { - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } CHECK_EXCEPTION(); @@ -30333,11 +30333,11 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HAN zval *offset; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); } - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); ZVAL_DEREF(container); if (IS_UNUSED == IS_UNUSED || Z_TYPE_P(container) == IS_OBJECT) { @@ -30347,7 +30347,7 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HAN zend_error(E_NOTICE, "Trying to unset property of non-object"); } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -30363,8 +30363,8 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_UNUSED_TMP_HANDLER(ZEN zval *offset; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_UNUSED != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { HashTable *ht = Z_ARRVAL_P(container); @@ -30460,7 +30460,7 @@ num_index_prop: result = ((opline->extended_value & ZEND_ISSET) == 0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_BOOL(EX_VAR(opline->result.var), result); CHECK_EXCEPTION(); @@ -30476,8 +30476,8 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_UNUSED_TMP_HANDLER(ZE zval *offset; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_UNUSED == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { if (EXPECTED(Z_OBJ_HT_P(container)->has_property)) { @@ -30493,7 +30493,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_UNUSED_TMP_HANDLER(ZE result = ((opline->extended_value & ZEND_ISSET) == 0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_BOOL(EX_VAR(opline->result.var), result); CHECK_EXCEPTION(); @@ -30583,7 +30583,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HANDLER /* Set the new yielded key */ if (IS_TMP_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *key = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *key = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); /* Consts, temporary variables and references need copying */ if (IS_TMP_VAR == IS_CONST) { @@ -30640,8 +30640,8 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_UNUSED_VAR(int (* { USE_OPLINE zend_free_op free_op2, free_op_data1; - zval *object = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); - zval *property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *object = _get_obj_zval_ptr_unused(execute_data); + zval *property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); zval *value; zval *zptr; @@ -30657,7 +30657,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_UNUSED_VAR(int (* if (IS_UNUSED != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { zend_error(E_WARNING, "Attempt to assign property of non-object"); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); FREE_OP(free_op_data1); if (RETURN_VALUE_USED(opline)) { @@ -30719,7 +30719,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_UNUSED_VAR(int (* } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); FREE_OP(free_op_data1); } @@ -30737,7 +30737,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_UNUSED_VAR(int (* zval *value, *container; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } @@ -30750,7 +30750,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_UNUSED_VAR(int (* } return zend_binary_assign_op_obj_helper_SPEC_UNUSED_VAR(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } else { - zval *dim = _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *dim = _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2); zend_fetch_dimension_address_RW(&rv, container, dim, IS_VAR TSRMLS_CC); value = get_zval_ptr_deref((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); @@ -30777,7 +30777,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_UNUSED_VAR(int (* } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); FREE_OP(free_op_data1); CHECK_EXCEPTION(); @@ -30793,7 +30793,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_UNUSED_VAR(int (*bina zval *value; SAVE_OPLINE(); - value = _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + value = _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2); var_ptr = NULL; if (IS_UNUSED == IS_VAR && UNEXPECTED(var_ptr == NULL)) { @@ -30815,7 +30815,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_UNUSED_VAR(int (*bina } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -30974,8 +30974,8 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_UNUSED_VAR(incdec_ zval *zptr; SAVE_OPLINE(); - object = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); - property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + object = _get_obj_zval_ptr_unused(execute_data); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); retval = EX_VAR(opline->result.var); if (IS_UNUSED == IS_VAR && UNEXPECTED(object == NULL)) { @@ -30988,7 +30988,7 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_UNUSED_VAR(incdec_ if (IS_UNUSED != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { zend_error(E_WARNING, "Attempt to increment/decrement property of non-object"); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); if (RETURN_VALUE_USED(opline)) { ZVAL_NULL(retval); } @@ -31039,7 +31039,7 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_UNUSED_VAR(incdec_ } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -31065,8 +31065,8 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_UNUSED_VAR(incdec zval *zptr; SAVE_OPLINE(); - object = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); - property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + object = _get_obj_zval_ptr_unused(execute_data); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); retval = EX_VAR(opline->result.var); if (IS_UNUSED == IS_VAR && UNEXPECTED(object == NULL)) { @@ -31079,7 +31079,7 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_UNUSED_VAR(incdec if (IS_UNUSED != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { zend_error(E_WARNING, "Attempt to increment/decrement property of non-object"); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_NULL(retval); CHECK_EXCEPTION(); @@ -31124,7 +31124,7 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_UNUSED_VAR(incdec } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -31149,8 +31149,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_H zval *offset; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if ((IS_UNUSED != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -31189,7 +31189,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_H } while (0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -31203,16 +31203,16 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_H zval *container; SAVE_OPLINE(); - property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -31228,15 +31228,15 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_ zval *container; SAVE_OPLINE(); - property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); + container = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -31253,8 +31253,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_ zval *offset; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if ((IS_UNUSED != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -31292,7 +31292,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_ } while (0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -31309,8 +31309,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_UNUSED_VAR_HANDLER(ZEND_O zval *property; SAVE_OPLINE(); - property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); + container = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_CONST || IS_UNUSED == IS_TMP_VAR) { zend_error_noreturn(E_ERROR, "Cannot use temporary expression in write context"); @@ -31319,8 +31319,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_UNUSED_VAR_HANDLER(ZEND_O zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -31338,15 +31338,15 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCO zval *container, *property; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); - property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -31362,14 +31362,14 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HA zval *property_name; SAVE_OPLINE(); - object = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); - property_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + object = _get_obj_zval_ptr_unused(execute_data); + property_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_UNUSED == IS_VAR && UNEXPECTED(object == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } zend_assign_to_object(RETURN_VALUE_USED(opline)?EX_VAR(opline->result.var):NULL, object, IS_UNUSED, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_OBJ, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property_name)) : NULL) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); /* assign_obj has two opcodes! */ CHECK_EXCEPTION(); @@ -31387,7 +31387,7 @@ static int ZEND_FASTCALL ZEND_ADD_VAR_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HANDL int use_copy = 0; SAVE_OPLINE(); - var = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + var = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_UNUSED == IS_UNUSED) { /* Initialize for erealloc in add_string_to_string */ @@ -31415,7 +31415,7 @@ static int ZEND_FASTCALL ZEND_ADD_VAR_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HANDL * which aren't affected by FREE_OP(Ts, )'s anyway, unless they're * string offsets or overloaded objects */ - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -31433,7 +31433,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_VAR_HANDLER(ZEND_OPC SAVE_OPLINE(); - function_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { @@ -31443,18 +31443,18 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_VAR_HANDLER(ZEND_OPC zend_error_noreturn(E_ERROR, "Method name must be a string"); } - object = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + object = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { uint32_t nesting = 1; if (UNEXPECTED(EG(exception) != NULL)) { - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); HANDLE_EXCEPTION(); } zend_error(E_RECOVERABLE_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object))); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); if (EG(exception) != NULL) { HANDLE_EXCEPTION(); @@ -31522,7 +31522,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_VAR_HANDLER(ZEND_OPC EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION, fbc, opline->extended_value, called_scope, obj, EX(call) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -31568,7 +31568,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HAN zend_ulong hval; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); } @@ -31576,7 +31576,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HAN ZVAL_DEREF(container); SEPARATE_ZVAL_NOREF(container); } - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_UNUSED != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { HashTable *ht = Z_ARRVAL_P(container); @@ -31623,7 +31623,7 @@ num_index_dim: zend_error(E_WARNING, "Illegal offset type in unset"); break; } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else if (IS_UNUSED == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { if (UNEXPECTED(Z_OBJ_HT_P(container)->unset_dimension == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use object as array"); @@ -31632,12 +31632,12 @@ num_index_dim: //??? zval_copy_ctor(offset); //??? } Z_OBJ_HT_P(container)->unset_dimension(container, offset TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else if (UNEXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); ZEND_VM_CONTINUE(); /* bailed out before */ } else { - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } CHECK_EXCEPTION(); @@ -31652,11 +31652,11 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HAN zval *offset; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); } - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); ZVAL_DEREF(container); if (IS_UNUSED == IS_UNUSED || Z_TYPE_P(container) == IS_OBJECT) { @@ -31666,7 +31666,7 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HAN zend_error(E_NOTICE, "Trying to unset property of non-object"); } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -31682,8 +31682,8 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_UNUSED_VAR_HANDLER(ZEN zval *offset; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_UNUSED != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { HashTable *ht = Z_ARRVAL_P(container); @@ -31779,7 +31779,7 @@ num_index_prop: result = ((opline->extended_value & ZEND_ISSET) == 0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_BOOL(EX_VAR(opline->result.var), result); CHECK_EXCEPTION(); @@ -31795,8 +31795,8 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_UNUSED_VAR_HANDLER(ZE zval *offset; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_UNUSED == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { if (EXPECTED(Z_OBJ_HT_P(container)->has_property)) { @@ -31812,7 +31812,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_UNUSED_VAR_HANDLER(ZE result = ((opline->extended_value & ZEND_ISSET) == 0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_BOOL(EX_VAR(opline->result.var), result); CHECK_EXCEPTION(); @@ -31902,7 +31902,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HANDLER /* Set the new yielded key */ if (IS_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *key = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *key = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); /* Consts, temporary variables and references need copying */ if (IS_VAR == IS_CONST) { @@ -31911,7 +31911,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HANDLER ZVAL_COPY_VALUE(&generator->key, key); } else if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && Z_ISREF_P(key)) { ZVAL_DUP(&generator->key, Z_REFVAL_P(key)); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else { ZVAL_COPY_VALUE(&generator->key, key); if (IS_VAR == IS_CV) { @@ -31959,7 +31959,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_UNUSED_UNUSED(int { USE_OPLINE zend_free_op free_op_data1; - zval *object = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + zval *object = _get_obj_zval_ptr_unused(execute_data); zval *property = NULL; zval *value; zval *zptr; @@ -32055,7 +32055,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_UNUSED_UNUSED(int zval *value, *container; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } @@ -32451,7 +32451,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_UNUSED_CV(int (*b { USE_OPLINE zend_free_op free_op_data1; - zval *object = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + zval *object = _get_obj_zval_ptr_unused(execute_data); zval *property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); zval *value; zval *zptr; @@ -32547,7 +32547,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_UNUSED_CV(int (*b zval *value, *container; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } @@ -32782,7 +32782,7 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_UNUSED_CV(incdec_t zval *zptr; SAVE_OPLINE(); - object = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + object = _get_obj_zval_ptr_unused(execute_data); property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); retval = EX_VAR(opline->result.var); @@ -32872,7 +32872,7 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_UNUSED_CV(incdec_ zval *zptr; SAVE_OPLINE(); - object = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + object = _get_obj_zval_ptr_unused(execute_data); property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); retval = EX_VAR(opline->result.var); @@ -32955,7 +32955,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HA zval *offset; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if ((IS_UNUSED != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || @@ -33010,14 +33010,14 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HA SAVE_OPLINE(); property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -33034,14 +33034,14 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); - if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -33058,7 +33058,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_H zval *offset; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if ((IS_UNUSED != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || @@ -33114,7 +33114,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_UNUSED_CV_HANDLER(ZEND_OP SAVE_OPLINE(); property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_CONST || IS_UNUSED == IS_TMP_VAR) { zend_error_noreturn(E_ERROR, "Cannot use temporary expression in write context"); @@ -33124,7 +33124,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_UNUSED_CV_HANDLER(ZEND_OP } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -33142,7 +33142,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_UNUSED_CV_HANDLER(ZEND_OPCOD zval *container, *property; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { @@ -33150,7 +33150,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_UNUSED_CV_HANDLER(ZEND_OPCOD } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); - if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -33166,7 +33166,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HAN zval *property_name; SAVE_OPLINE(); - object = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + object = _get_obj_zval_ptr_unused(execute_data); property_name = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_UNUSED == IS_VAR && UNEXPECTED(object == NULL)) { @@ -33246,7 +33246,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_CV_HANDLER(ZEND_OPCO zend_error_noreturn(E_ERROR, "Method name must be a string"); } - object = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + object = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { uint32_t nesting = 1; @@ -33370,7 +33370,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HAND zend_ulong hval; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); } @@ -33454,7 +33454,7 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HAND zval *offset; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); } @@ -33484,7 +33484,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_UNUSED_CV_HANDLER(ZEND zval *offset; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_UNUSED != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { @@ -33596,7 +33596,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_UNUSED_CV_HANDLER(ZEN zval *offset; SAVE_OPLINE(); - container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); + container = _get_obj_zval_ptr_unused(execute_data); offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_UNUSED == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { @@ -36087,7 +36087,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_W_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HAN ZVAL_DEREF(container); zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, opline->op2.zv, IS_CONST TSRMLS_CC); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -36110,7 +36110,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HA ZVAL_DEREF(container); zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, opline->op2.zv, IS_CONST TSRMLS_CC); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -36151,7 +36151,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CV_CONST_HANDLER(ZEND_OPC } ZVAL_DEREF(container); zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, opline->op2.zv, IS_CONST TSRMLS_CC); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -36184,7 +36184,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_CV_CONST_HANDLER(ZEND_OPCODE ZVAL_DEREF(container); zend_fetch_dimension_address_UNSET(EX_VAR(opline->result.var), container, opline->op2.zv, IS_CONST TSRMLS_CC); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -36263,7 +36263,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HAN zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -36287,7 +36287,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HA } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -36370,7 +36370,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CV_CONST_HANDLER(ZEND_OPC } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -36396,7 +36396,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_CV_CONST_HANDLER(ZEND_OPCODE } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -37452,9 +37452,9 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_add_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -37467,9 +37467,9 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_sub_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -37482,9 +37482,9 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_mul_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -37497,9 +37497,9 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_div_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -37512,9 +37512,9 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_mod_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -37527,9 +37527,9 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_left_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -37542,9 +37542,9 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_right_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -37557,9 +37557,9 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); concat_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -37572,9 +37572,9 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); fast_is_identical_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -37588,9 +37588,9 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_ SAVE_OPLINE(); fast_is_not_identical_function(result, _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -37604,9 +37604,9 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); fast_equal_function(result, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -37620,9 +37620,9 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); fast_not_equal_function(result, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -37636,9 +37636,9 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLE SAVE_OPLINE(); fast_is_smaller_function(result, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -37652,9 +37652,9 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_CV_TMP_HANDLER(ZEND_OPCO SAVE_OPLINE(); fast_is_smaller_or_equal_function(result, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -37667,9 +37667,9 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); bitwise_or_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -37682,9 +37682,9 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); bitwise_and_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -37697,9 +37697,9 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); bitwise_xor_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -37712,9 +37712,9 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); boolean_xor_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -37724,7 +37724,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_CV_TMP(int (*bina USE_OPLINE zend_free_op free_op2, free_op_data1; zval *object = _get_zval_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); - zval *property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); zval *value; zval *zptr; @@ -37740,7 +37740,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_CV_TMP(int (*bina if (IS_CV != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { zend_error(E_WARNING, "Attempt to assign property of non-object"); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); FREE_OP(free_op_data1); if (RETURN_VALUE_USED(opline)) { @@ -37802,7 +37802,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_CV_TMP(int (*bina } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); FREE_OP(free_op_data1); } @@ -37833,7 +37833,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_CV_TMP(int (*bina } return zend_binary_assign_op_obj_helper_SPEC_CV_TMP(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } else { - zval *dim = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *dim = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); zend_fetch_dimension_address_RW(&rv, container, dim, IS_TMP_VAR TSRMLS_CC); value = get_zval_ptr_deref((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); @@ -37860,7 +37860,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_CV_TMP(int (*bina } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); FREE_OP(free_op_data1); CHECK_EXCEPTION(); @@ -37876,7 +37876,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_CV_TMP(int (*binary_o zval *value; SAVE_OPLINE(); - value = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); var_ptr = _get_zval_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(var_ptr == NULL)) { @@ -37898,7 +37898,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_CV_TMP(int (*binary_o } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -38058,7 +38058,7 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_CV_TMP(incdec_t in SAVE_OPLINE(); object = _get_zval_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); - property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); retval = EX_VAR(opline->result.var); if (IS_CV == IS_VAR && UNEXPECTED(object == NULL)) { @@ -38071,7 +38071,7 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_CV_TMP(incdec_t in if (IS_CV != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { zend_error(E_WARNING, "Attempt to increment/decrement property of non-object"); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); if (RETURN_VALUE_USED(opline)) { ZVAL_NULL(retval); } @@ -38122,7 +38122,7 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_CV_TMP(incdec_t in } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -38149,7 +38149,7 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_CV_TMP(incdec_t i SAVE_OPLINE(); object = _get_zval_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); - property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); retval = EX_VAR(opline->result.var); if (IS_CV == IS_VAR && UNEXPECTED(object == NULL)) { @@ -38162,7 +38162,7 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_CV_TMP(incdec_t i if (IS_CV != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { zend_error(E_WARNING, "Attempt to increment/decrement property of non-object"); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_NULL(retval); CHECK_EXCEPTION(); @@ -38207,7 +38207,7 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_CV_TMP(incdec_t i } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -38231,8 +38231,8 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); container = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); - zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2), IS_TMP_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -38251,9 +38251,9 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_W_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDL zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } ZVAL_DEREF(container); - zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2), IS_TMP_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -38274,9 +38274,9 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HAND zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } ZVAL_DEREF(container); - zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2), IS_TMP_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -38292,8 +38292,8 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_IS_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); container = _get_zval_ptr_cv_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); - zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2), IS_TMP_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -38316,19 +38316,19 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CV_TMP_HANDLER(ZEND_OPCOD zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } ZVAL_DEREF(container); - zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR TSRMLS_CC); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2), IS_TMP_VAR TSRMLS_CC); + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else { if (IS_TMP_VAR == IS_UNUSED) { zend_error_noreturn(E_ERROR, "Cannot use [] for reading"); } container = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); - zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2), IS_TMP_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); } CHECK_EXCEPTION(); @@ -38348,9 +38348,9 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_H zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } ZVAL_DEREF(container); - zend_fetch_dimension_address_UNSET(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zend_fetch_dimension_address_UNSET(EX_VAR(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2), IS_TMP_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -38368,7 +38368,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); container = _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if ((IS_CV != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -38407,7 +38407,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDL } while (0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -38421,7 +38421,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDL zval *container; SAVE_OPLINE(); - property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); container = _get_zval_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { @@ -38429,8 +38429,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDL } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -38446,15 +38446,15 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HAND zval *container; SAVE_OPLINE(); - property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); container = _get_zval_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -38472,7 +38472,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); container = _get_zval_ptr_cv_deref_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if ((IS_CV != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -38510,7 +38510,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HAND } while (0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -38527,7 +38527,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CV_TMP_HANDLER(ZEND_OPCOD zval *property; SAVE_OPLINE(); - property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); container = _get_zval_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_CONST || IS_CV == IS_TMP_VAR) { @@ -38537,8 +38537,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CV_TMP_HANDLER(ZEND_OPCOD zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -38557,14 +38557,14 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); container = _get_zval_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC); - property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -38581,13 +38581,13 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLE SAVE_OPLINE(); object = _get_zval_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); - property_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + property_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_CV == IS_VAR && UNEXPECTED(object == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } zend_assign_to_object(RETURN_VALUE_USED(opline)?EX_VAR(opline->result.var):NULL, object, IS_CV, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_OBJ, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property_name)) : NULL) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); /* assign_obj has two opcodes! */ CHECK_EXCEPTION(); @@ -38610,27 +38610,27 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLE ZVAL_DEREF(object_ptr); if (UNEXPECTED(Z_TYPE_P(object_ptr) == IS_OBJECT)) { zend_free_op free_op2; - zval *property_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *property_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); zend_assign_to_object(RETURN_VALUE_USED(opline)?EX_VAR(opline->result.var):NULL, object_ptr, IS_CV, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_DIM, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property_name)) : NULL) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else { zend_free_op free_op2, free_op_data1; zval rv; zval *value; - zval *dim = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *dim = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); zval *variable_ptr; if (UNEXPECTED(Z_TYPE_P(object_ptr) == IS_STRING) && EXPECTED(Z_STRLEN_P(object_ptr) != 0)) { zend_long offset = zend_fetch_string_offset(object_ptr, dim, BP_VAR_W TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); value = get_zval_ptr_deref((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); zend_assign_to_string_offset(object_ptr, offset, value, (RETURN_VALUE_USED(opline) ? EX_VAR(opline->result.var) : NULL) TSRMLS_CC); FREE_OP(free_op_data1); } else { zend_fetch_dimension_address_W(&rv, object_ptr, dim, IS_TMP_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); value = get_zval_ptr_deref((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); ZEND_ASSERT(Z_TYPE(rv) == IS_INDIRECT); variable_ptr = Z_INDIRECT(rv); @@ -38665,12 +38665,12 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR zval *variable_ptr; SAVE_OPLINE(); - value = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); variable_ptr = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(variable_ptr == &EG(error_zval))) { if (IS_TMP_VAR == IS_TMP_VAR) { - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } if (RETURN_VALUE_USED(opline)) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -38701,7 +38701,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_ SAVE_OPLINE(); - function_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_TMP_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { @@ -38717,12 +38717,12 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_ uint32_t nesting = 1; if (UNEXPECTED(EG(exception) != NULL)) { - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); HANDLE_EXCEPTION(); } zend_error(E_RECOVERABLE_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object))); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); if (EG(exception) != NULL) { HANDLE_EXCEPTION(); @@ -38790,7 +38790,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_ EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION, fbc, opline->extended_value, called_scope, obj, EX(call) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -38805,9 +38805,9 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_equal_function(result, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -38849,7 +38849,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_TMP_HANDLER(ZEND_OPCODE if (IS_TMP_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); zend_string *str; zend_ulong hval; @@ -38892,7 +38892,7 @@ str_index: /* do nothing */ break; } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else { zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr); } @@ -38948,7 +38948,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER ZVAL_DEREF(container); SEPARATE_ZVAL_NOREF(container); } - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_CV != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { HashTable *ht = Z_ARRVAL_P(container); @@ -38995,7 +38995,7 @@ num_index_dim: zend_error(E_WARNING, "Illegal offset type in unset"); break; } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else if (IS_CV == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { if (UNEXPECTED(Z_OBJ_HT_P(container)->unset_dimension == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use object as array"); @@ -39004,12 +39004,12 @@ num_index_dim: //??? zval_copy_ctor(offset); //??? } Z_OBJ_HT_P(container)->unset_dimension(container, offset TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else if (UNEXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); ZEND_VM_CONTINUE(); /* bailed out before */ } else { - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } CHECK_EXCEPTION(); @@ -39028,7 +39028,7 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); } - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); ZVAL_DEREF(container); if (IS_CV == IS_UNUSED || Z_TYPE_P(container) == IS_OBJECT) { @@ -39038,7 +39038,7 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER zend_error(E_NOTICE, "Trying to unset property of non-object"); } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -39055,7 +39055,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CV_TMP_HANDLER(ZEND_OP SAVE_OPLINE(); container = _get_zval_ptr_cv_deref_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_CV != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { HashTable *ht = Z_ARRVAL_P(container); @@ -39151,7 +39151,7 @@ num_index_prop: result = ((opline->extended_value & ZEND_ISSET) == 0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_BOOL(EX_VAR(opline->result.var), result); CHECK_EXCEPTION(); @@ -39168,7 +39168,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_CV_TMP_HANDLER(ZEND_O SAVE_OPLINE(); container = _get_zval_ptr_cv_deref_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); - offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); if (IS_CV == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { if (EXPECTED(Z_OBJ_HT_P(container)->has_property)) { @@ -39184,7 +39184,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_CV_TMP_HANDLER(ZEND_O result = ((opline->extended_value & ZEND_ISSET) == 0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_BOOL(EX_VAR(opline->result.var), result); CHECK_EXCEPTION(); @@ -39274,7 +39274,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG /* Set the new yielded key */ if (IS_TMP_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *key = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *key = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2); /* Consts, temporary variables and references need copying */ if (IS_TMP_VAR == IS_CONST) { @@ -39330,9 +39330,9 @@ static int ZEND_FASTCALL ZEND_POW_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); pow_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -39350,9 +39350,9 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_add_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -39365,9 +39365,9 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_sub_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -39380,9 +39380,9 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_mul_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -39395,9 +39395,9 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_div_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -39410,9 +39410,9 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_mod_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -39425,9 +39425,9 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_left_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -39440,9 +39440,9 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_right_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -39455,9 +39455,9 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); concat_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -39470,9 +39470,9 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); fast_is_identical_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -39486,9 +39486,9 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_ SAVE_OPLINE(); fast_is_not_identical_function(result, _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -39502,9 +39502,9 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); fast_equal_function(result, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -39518,9 +39518,9 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); fast_not_equal_function(result, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -39534,9 +39534,9 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLE SAVE_OPLINE(); fast_is_smaller_function(result, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -39550,9 +39550,9 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_CV_VAR_HANDLER(ZEND_OPCO SAVE_OPLINE(); fast_is_smaller_or_equal_function(result, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -39565,9 +39565,9 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); bitwise_or_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -39580,9 +39580,9 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); bitwise_and_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -39595,9 +39595,9 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); bitwise_xor_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -39610,9 +39610,9 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); boolean_xor_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -39622,7 +39622,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_CV_VAR(int (*bina USE_OPLINE zend_free_op free_op2, free_op_data1; zval *object = _get_zval_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); - zval *property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); zval *value; zval *zptr; @@ -39638,7 +39638,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_CV_VAR(int (*bina if (IS_CV != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { zend_error(E_WARNING, "Attempt to assign property of non-object"); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); FREE_OP(free_op_data1); if (RETURN_VALUE_USED(opline)) { @@ -39700,7 +39700,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_CV_VAR(int (*bina } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); FREE_OP(free_op_data1); } @@ -39731,7 +39731,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_CV_VAR(int (*bina } return zend_binary_assign_op_obj_helper_SPEC_CV_VAR(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } else { - zval *dim = _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *dim = _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2); zend_fetch_dimension_address_RW(&rv, container, dim, IS_VAR TSRMLS_CC); value = get_zval_ptr_deref((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); @@ -39758,7 +39758,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_dim_helper_SPEC_CV_VAR(int (*bina } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); FREE_OP(free_op_data1); CHECK_EXCEPTION(); @@ -39774,7 +39774,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_CV_VAR(int (*binary_o zval *value; SAVE_OPLINE(); - value = _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + value = _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2); var_ptr = _get_zval_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(var_ptr == NULL)) { @@ -39796,7 +39796,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_CV_VAR(int (*binary_o } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -39956,7 +39956,7 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_CV_VAR(incdec_t in SAVE_OPLINE(); object = _get_zval_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); - property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); retval = EX_VAR(opline->result.var); if (IS_CV == IS_VAR && UNEXPECTED(object == NULL)) { @@ -39969,7 +39969,7 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_CV_VAR(incdec_t in if (IS_CV != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { zend_error(E_WARNING, "Attempt to increment/decrement property of non-object"); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); if (RETURN_VALUE_USED(opline)) { ZVAL_NULL(retval); } @@ -40020,7 +40020,7 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_CV_VAR(incdec_t in } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -40047,7 +40047,7 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_CV_VAR(incdec_t i SAVE_OPLINE(); object = _get_zval_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); - property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); retval = EX_VAR(opline->result.var); if (IS_CV == IS_VAR && UNEXPECTED(object == NULL)) { @@ -40060,7 +40060,7 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_CV_VAR(incdec_t i if (IS_CV != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { zend_error(E_WARNING, "Attempt to increment/decrement property of non-object"); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_NULL(retval); CHECK_EXCEPTION(); @@ -40105,7 +40105,7 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_CV_VAR(incdec_t i } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -40277,8 +40277,8 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); container = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); - zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2), IS_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -40297,9 +40297,9 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_W_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDL zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } ZVAL_DEREF(container); - zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2), IS_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -40320,9 +40320,9 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HAND zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } ZVAL_DEREF(container); - zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2), IS_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -40338,8 +40338,8 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_IS_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); container = _get_zval_ptr_cv_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); - zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2), IS_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -40362,19 +40362,19 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CV_VAR_HANDLER(ZEND_OPCOD zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } ZVAL_DEREF(container); - zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR TSRMLS_CC); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2), IS_VAR TSRMLS_CC); + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else { if (IS_VAR == IS_UNUSED) { zend_error_noreturn(E_ERROR, "Cannot use [] for reading"); } container = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); - zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2), IS_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); } CHECK_EXCEPTION(); @@ -40394,9 +40394,9 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_H zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } ZVAL_DEREF(container); - zend_fetch_dimension_address_UNSET(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zend_fetch_dimension_address_UNSET(EX_VAR(opline->result.var), container, _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2), IS_VAR TSRMLS_CC); + zval_ptr_dtor_nogc(free_op2); + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -40414,7 +40414,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); container = _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if ((IS_CV != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -40453,7 +40453,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDL } while (0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -40467,7 +40467,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDL zval *container; SAVE_OPLINE(); - property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); container = _get_zval_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { @@ -40475,8 +40475,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDL } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -40492,15 +40492,15 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HAND zval *container; SAVE_OPLINE(); - property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); container = _get_zval_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -40518,7 +40518,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); container = _get_zval_ptr_cv_deref_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if ((IS_CV != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -40556,7 +40556,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HAND } while (0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -40573,7 +40573,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CV_VAR_HANDLER(ZEND_OPCOD zval *property; SAVE_OPLINE(); - property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); container = _get_zval_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_CONST || IS_CV == IS_TMP_VAR) { @@ -40583,8 +40583,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CV_VAR_HANDLER(ZEND_OPCOD zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -40603,14 +40603,14 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); container = _get_zval_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC); - property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + zval_ptr_dtor_nogc(free_op2); + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -40627,13 +40627,13 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLE SAVE_OPLINE(); object = _get_zval_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); - property_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + property_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_CV == IS_VAR && UNEXPECTED(object == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } zend_assign_to_object(RETURN_VALUE_USED(opline)?EX_VAR(opline->result.var):NULL, object, IS_CV, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_OBJ, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property_name)) : NULL) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); /* assign_obj has two opcodes! */ CHECK_EXCEPTION(); @@ -40656,27 +40656,27 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLE ZVAL_DEREF(object_ptr); if (UNEXPECTED(Z_TYPE_P(object_ptr) == IS_OBJECT)) { zend_free_op free_op2; - zval *property_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *property_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); zend_assign_to_object(RETURN_VALUE_USED(opline)?EX_VAR(opline->result.var):NULL, object_ptr, IS_CV, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_DIM, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property_name)) : NULL) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else { zend_free_op free_op2, free_op_data1; zval rv; zval *value; - zval *dim = _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *dim = _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2); zval *variable_ptr; if (UNEXPECTED(Z_TYPE_P(object_ptr) == IS_STRING) && EXPECTED(Z_STRLEN_P(object_ptr) != 0)) { zend_long offset = zend_fetch_string_offset(object_ptr, dim, BP_VAR_W TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); value = get_zval_ptr_deref((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); zend_assign_to_string_offset(object_ptr, offset, value, (RETURN_VALUE_USED(opline) ? EX_VAR(opline->result.var) : NULL) TSRMLS_CC); FREE_OP(free_op_data1); } else { zend_fetch_dimension_address_W(&rv, object_ptr, dim, IS_VAR TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); value = get_zval_ptr_deref((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); ZEND_ASSERT(Z_TYPE(rv) == IS_INDIRECT); variable_ptr = Z_INDIRECT(rv); @@ -40711,12 +40711,12 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR zval *variable_ptr; SAVE_OPLINE(); - value = _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + value = _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2); variable_ptr = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(variable_ptr == &EG(error_zval))) { if (IS_VAR == IS_TMP_VAR) { - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } if (RETURN_VALUE_USED(opline)) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -40730,7 +40730,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR } /* zend_assign_to_variable() always takes care of op2, never free it! */ - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -40744,7 +40744,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLE zval *value_ptr; SAVE_OPLINE(); - value_ptr = _get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + value_ptr = _get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_VAR == IS_VAR && UNEXPECTED(value_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets nor overloaded objects"); @@ -40753,17 +40753,17 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLE (value_ptr == &EG(uninitialized_zval) || (opline->extended_value == ZEND_RETURNS_FUNCTION && !(Z_VAR_FLAGS_P(value_ptr) & IS_VAR_RET_REF)))) { - if (!(free_op2.var != NULL)) { + if (!(free_op2 != NULL)) { PZVAL_LOCK(value_ptr); /* undo the effect of get_zval_ptr_ptr() */ } zend_error(E_STRICT, "Only variables should be assigned by reference"); if (UNEXPECTED(EG(exception) != NULL)) { - if (free_op2.var) {zval_ptr_dtor_nogc(free_op2.var);}; + if (free_op2) {zval_ptr_dtor_nogc(free_op2);}; HANDLE_EXCEPTION(); } return ZEND_ASSIGN_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } else if (IS_VAR == IS_VAR && opline->extended_value == ZEND_RETURNS_NEW) { - if (!(free_op2.var != NULL)) { + if (!(free_op2 != NULL)) { PZVAL_LOCK(value_ptr); } } @@ -40785,7 +40785,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLE } if (IS_VAR == IS_VAR && opline->extended_value == ZEND_RETURNS_NEW) { - if (!(free_op2.var != NULL)) { + if (!(free_op2 != NULL)) { Z_DELREF_P(variable_ptr); } } @@ -40794,7 +40794,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLE ZVAL_COPY(EX_VAR(opline->result.var), variable_ptr); } - if (free_op2.var) {zval_ptr_dtor_nogc(free_op2.var);}; + if (free_op2) {zval_ptr_dtor_nogc(free_op2);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -40812,7 +40812,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_ SAVE_OPLINE(); - function_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { @@ -40828,12 +40828,12 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_ uint32_t nesting = 1; if (UNEXPECTED(EG(exception) != NULL)) { - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); HANDLE_EXCEPTION(); } zend_error(E_RECOVERABLE_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object))); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); if (EG(exception) != NULL) { HANDLE_EXCEPTION(); @@ -40901,7 +40901,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_ EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION, fbc, opline->extended_value, called_scope, obj, EX(call) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -40916,9 +40916,9 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_equal_function(result, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -40960,7 +40960,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_VAR_HANDLER(ZEND_OPCODE if (IS_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); zend_string *str; zend_ulong hval; @@ -41003,7 +41003,7 @@ str_index: /* do nothing */ break; } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else { zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr); } @@ -41134,7 +41134,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER ZVAL_DEREF(container); SEPARATE_ZVAL_NOREF(container); } - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_CV != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { HashTable *ht = Z_ARRVAL_P(container); @@ -41181,7 +41181,7 @@ num_index_dim: zend_error(E_WARNING, "Illegal offset type in unset"); break; } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else if (IS_CV == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { if (UNEXPECTED(Z_OBJ_HT_P(container)->unset_dimension == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use object as array"); @@ -41190,12 +41190,12 @@ num_index_dim: //??? zval_copy_ctor(offset); //??? } Z_OBJ_HT_P(container)->unset_dimension(container, offset TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else if (UNEXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); ZEND_VM_CONTINUE(); /* bailed out before */ } else { - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } CHECK_EXCEPTION(); @@ -41214,7 +41214,7 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); } - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); ZVAL_DEREF(container); if (IS_CV == IS_UNUSED || Z_TYPE_P(container) == IS_OBJECT) { @@ -41224,7 +41224,7 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER zend_error(E_NOTICE, "Trying to unset property of non-object"); } } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -41311,7 +41311,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CV_VAR_HANDLER(ZEND_OP SAVE_OPLINE(); container = _get_zval_ptr_cv_deref_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_CV != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { HashTable *ht = Z_ARRVAL_P(container); @@ -41407,7 +41407,7 @@ num_index_prop: result = ((opline->extended_value & ZEND_ISSET) == 0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_BOOL(EX_VAR(opline->result.var), result); CHECK_EXCEPTION(); @@ -41424,7 +41424,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_CV_VAR_HANDLER(ZEND_O SAVE_OPLINE(); container = _get_zval_ptr_cv_deref_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); - offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); if (IS_CV == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { if (EXPECTED(Z_OBJ_HT_P(container)->has_property)) { @@ -41440,7 +41440,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_CV_VAR_HANDLER(ZEND_O result = ((opline->extended_value & ZEND_ISSET) == 0); } - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); ZVAL_BOOL(EX_VAR(opline->result.var), result); CHECK_EXCEPTION(); @@ -41569,7 +41569,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG /* Set the new yielded key */ if (IS_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *key = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *key = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2); /* Consts, temporary variables and references need copying */ if (IS_VAR == IS_CONST) { @@ -41578,7 +41578,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG ZVAL_COPY_VALUE(&generator->key, key); } else if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && Z_ISREF_P(key)) { ZVAL_DUP(&generator->key, Z_REFVAL_P(key)); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); } else { ZVAL_COPY_VALUE(&generator->key, key); if (IS_VAR == IS_CV) { @@ -41625,9 +41625,9 @@ static int ZEND_FASTCALL ZEND_POW_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); pow_function(EX_VAR(opline->result.var), _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), - _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2) TSRMLS_CC); - zval_ptr_dtor_nogc(free_op2.var); + zval_ptr_dtor_nogc(free_op2); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -42125,7 +42125,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_W_SPEC_CV_UNUSED_HANDLER(ZEND_OPCODE_HA ZVAL_DEREF(container); zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, NULL, IS_UNUSED TSRMLS_CC); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -42148,7 +42148,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_CV_UNUSED_HANDLER(ZEND_OPCODE_H ZVAL_DEREF(container); zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, NULL, IS_UNUSED TSRMLS_CC); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -42174,7 +42174,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CV_UNUSED_HANDLER(ZEND_OP } ZVAL_DEREF(container); zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, NULL, IS_UNUSED TSRMLS_CC); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -43458,7 +43458,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_W_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLE ZVAL_DEREF(container); zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV TSRMLS_CC); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -43481,7 +43481,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDL ZVAL_DEREF(container); zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV TSRMLS_CC); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -43522,7 +43522,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CV_CV_HANDLER(ZEND_OPCODE } ZVAL_DEREF(container); zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV TSRMLS_CC); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -43555,7 +43555,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HA ZVAL_DEREF(container); zend_fetch_dimension_address_UNSET(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV TSRMLS_CC); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -43634,7 +43634,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLE zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -43658,7 +43658,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDL } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -43741,7 +43741,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CV_CV_HANDLER(ZEND_OPCODE } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } @@ -43767,7 +43767,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HA } zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); - if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { + if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); } diff --git a/Zend/zend_vm_gen.php b/Zend/zend_vm_gen.php index 69c25085aaa..9aaa73aaaf2 100644 --- a/Zend/zend_vm_gen.php +++ b/Zend/zend_vm_gen.php @@ -100,18 +100,18 @@ $op2_type = array( ); $op1_free = array( - "ANY" => "(free_op1.var != NULL)", + "ANY" => "(free_op1 != NULL)", "TMP" => "1", - "VAR" => "(free_op1.var != NULL)", + "VAR" => "(free_op1 != NULL)", "CONST" => "0", "UNUSED" => "0", "CV" => "0", ); $op2_free = array( - "ANY" => "(free_op2.var != NULL)", + "ANY" => "(free_op2 != NULL)", "TMP" => "1", - "VAR" => "(free_op2.var != NULL)", + "VAR" => "(free_op2 != NULL)", "CONST" => "0", "UNUSED" => "0", "CV" => "0", @@ -119,8 +119,8 @@ $op2_free = array( $op1_get_zval_ptr = array( "ANY" => "get_zval_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)", - "TMP" => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)", - "VAR" => "_get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)", + "TMP" => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1)", + "VAR" => "_get_zval_ptr_var(opline->op1.var, execute_data, &free_op1)", "CONST" => "opline->op1.zv", "UNUSED" => "NULL", "CV" => "_get_zval_ptr_cv_\\1(execute_data, opline->op1.var TSRMLS_CC)", @@ -128,8 +128,8 @@ $op1_get_zval_ptr = array( $op2_get_zval_ptr = array( "ANY" => "get_zval_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)", - "TMP" => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)", - "VAR" => "_get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)", + "TMP" => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2)", + "VAR" => "_get_zval_ptr_var(opline->op2.var, execute_data, &free_op2)", "CONST" => "opline->op2.zv", "UNUSED" => "NULL", "CV" => "_get_zval_ptr_cv_\\1(execute_data, opline->op2.var TSRMLS_CC)", @@ -138,7 +138,7 @@ $op2_get_zval_ptr = array( $op1_get_zval_ptr_ptr = array( "ANY" => "get_zval_ptr_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)", "TMP" => "NULL", - "VAR" => "_get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)", + "VAR" => "_get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1)", "CONST" => "NULL", "UNUSED" => "NULL", "CV" => "_get_zval_ptr_cv_\\1(execute_data, opline->op1.var TSRMLS_CC)", @@ -147,7 +147,7 @@ $op1_get_zval_ptr_ptr = array( $op2_get_zval_ptr_ptr = array( "ANY" => "get_zval_ptr_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)", "TMP" => "NULL", - "VAR" => "_get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)", + "VAR" => "_get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2)", "CONST" => "NULL", "UNUSED" => "NULL", "CV" => "_get_zval_ptr_cv_\\1(execute_data, opline->op2.var TSRMLS_CC)", @@ -155,8 +155,8 @@ $op2_get_zval_ptr_ptr = array( $op1_get_zval_ptr_deref = array( "ANY" => "get_zval_ptr_deref(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)", - "TMP" => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)", - "VAR" => "_get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)", + "TMP" => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1)", + "VAR" => "_get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1)", "CONST" => "opline->op1.zv", "UNUSED" => "NULL", "CV" => "_get_zval_ptr_cv_deref_\\1(execute_data, opline->op1.var TSRMLS_CC)", @@ -164,8 +164,8 @@ $op1_get_zval_ptr_deref = array( $op2_get_zval_ptr_deref = array( "ANY" => "get_zval_ptr_deref(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)", - "TMP" => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)", - "VAR" => "_get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)", + "TMP" => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2)", + "VAR" => "_get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2)", "CONST" => "opline->op2.zv", "UNUSED" => "NULL", "CV" => "_get_zval_ptr_cv_deref_\\1(execute_data, opline->op2.var TSRMLS_CC)", @@ -174,7 +174,7 @@ $op2_get_zval_ptr_deref = array( $op1_get_zval_ptr_ptr_undef = array( "ANY" => "get_zval_ptr_ptr_undef(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)", "TMP" => "NULL", - "VAR" => "_get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)", + "VAR" => "_get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1)", "CONST" => "NULL", "UNUSED" => "NULL", "CV" => "_get_zval_ptr_cv_undef_\\1(execute_data, opline->op1.var TSRMLS_CC)", @@ -183,7 +183,7 @@ $op1_get_zval_ptr_ptr_undef = array( $op2_get_zval_ptr_ptr_undef = array( "ANY" => "get_zval_ptr_ptr_undef(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)", "TMP" => "NULL", - "VAR" => "_get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)", + "VAR" => "_get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2)", "CONST" => "NULL", "UNUSED" => "NULL", "CV" => "_get_zval_ptr_cv_undef_\\1(execute_data, opline->op2.var TSRMLS_CC)", @@ -191,62 +191,62 @@ $op2_get_zval_ptr_ptr_undef = array( $op1_get_obj_zval_ptr = array( "ANY" => "get_obj_zval_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)", - "TMP" => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)", - "VAR" => "_get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)", + "TMP" => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1)", + "VAR" => "_get_zval_ptr_var(opline->op1.var, execute_data, &free_op1)", "CONST" => "opline->op1.zv", - "UNUSED" => "_get_obj_zval_ptr_unused(TSRMLS_C)", + "UNUSED" => "_get_obj_zval_ptr_unused(execute_data)", "CV" => "_get_zval_ptr_cv_\\1(execute_data, opline->op1.var TSRMLS_CC)", ); $op2_get_obj_zval_ptr = array( "ANY" => "get_obj_zval_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)", - "TMP" => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)", - "VAR" => "_get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)", + "TMP" => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2)", + "VAR" => "_get_zval_ptr_var(opline->op2.var, execute_data, &free_op2)", "CONST" => "opline->op2.zv", - "UNUSED" => "_get_obj_zval_ptr_unused(TSRMLS_C)", + "UNUSED" => "_get_obj_zval_ptr_unused(execute_data)", "CV" => "_get_zval_ptr_cv_\\1(execute_data, opline->op2.var TSRMLS_CC)", ); $op1_get_obj_zval_ptr_deref = array( "ANY" => "get_obj_zval_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)", - "TMP" => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)", - "VAR" => "_get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)", + "TMP" => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1)", + "VAR" => "_get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1)", "CONST" => "opline->op1.zv", - "UNUSED" => "_get_obj_zval_ptr_unused(execute_data TSRMLS_CC)", + "UNUSED" => "_get_obj_zval_ptr_unused(execute_data)", "CV" => "_get_zval_ptr_cv_deref_\\1(execute_data, opline->op1.var TSRMLS_CC)", ); $op2_get_obj_zval_ptr_deref = array( "ANY" => "get_obj_zval_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)", - "TMP" => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)", - "VAR" => "_get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)", + "TMP" => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2)", + "VAR" => "_get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2)", "CONST" => "opline->op2.zv", - "UNUSED" => "_get_obj_zval_ptr_unused(execute_data TSRMLS_CC)", + "UNUSED" => "_get_obj_zval_ptr_unused(execute_data)", "CV" => "_get_zval_ptr_cv_deref_\\1(execute_data, opline->op2.var TSRMLS_CC)", ); $op1_get_obj_zval_ptr_ptr = array( "ANY" => "get_obj_zval_ptr_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)", "TMP" => "NULL", - "VAR" => "_get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)", + "VAR" => "_get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1)", "CONST" => "NULL", - "UNUSED" => "_get_obj_zval_ptr_unused(execute_data TSRMLS_CC)", + "UNUSED" => "_get_obj_zval_ptr_unused(execute_data)", "CV" => "_get_zval_ptr_cv_\\1(execute_data, opline->op1.var TSRMLS_CC)", ); $op2_get_obj_zval_ptr_ptr = array( "ANY" => "get_obj_zval_ptr_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)", "TMP" => "NULL", - "VAR" => "_get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)", + "VAR" => "_get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2)", "CONST" => "NULL", - "UNUSED" => "_get_obj_zval_ptr_unused(execute_data TSRMLS_CC)", + "UNUSED" => "_get_obj_zval_ptr_unused(execute_data)", "CV" => "_get_zval_ptr_cv_\\1(execute_data, opline->op2.var TSRMLS_CC)", ); $op1_free_op = array( "ANY" => "FREE_OP(free_op1)", - "TMP" => "zval_ptr_dtor_nogc(free_op1.var)", - "VAR" => "zval_ptr_dtor_nogc(free_op1.var)", + "TMP" => "zval_ptr_dtor_nogc(free_op1)", + "VAR" => "zval_ptr_dtor_nogc(free_op1)", "CONST" => "", "UNUSED" => "", "CV" => "", @@ -254,44 +254,44 @@ $op1_free_op = array( $op2_free_op = array( "ANY" => "FREE_OP(free_op2)", - "TMP" => "zval_ptr_dtor_nogc(free_op2.var)", - "VAR" => "zval_ptr_dtor_nogc(free_op2.var)", + "TMP" => "zval_ptr_dtor_nogc(free_op2)", + "VAR" => "zval_ptr_dtor_nogc(free_op2)", "CONST" => "", "UNUSED" => "", "CV" => "", ); $op1_free_op_if_var = array( - "ANY" => "if (opline->op1_type == IS_VAR) {zval_ptr_dtor_nogc(free_op1.var);}", + "ANY" => "if (opline->op1_type == IS_VAR) {zval_ptr_dtor_nogc(free_op1);}", "TMP" => "", - "VAR" => "zval_ptr_dtor_nogc(free_op1.var)", + "VAR" => "zval_ptr_dtor_nogc(free_op1)", "CONST" => "", "UNUSED" => "", "CV" => "", ); $op2_free_op_if_var = array( - "ANY" => "if (opline->op1_type == IS_VAR) {zval_ptr_dtor_nogc(free_op1.var);}", + "ANY" => "if (opline->op2_type == IS_VAR) {zval_ptr_dtor_nogc(free_op2);}", "TMP" => "", - "VAR" => "zval_ptr_dtor_nogc(free_op2.var)", + "VAR" => "zval_ptr_dtor_nogc(free_op2)", "CONST" => "", "UNUSED" => "", "CV" => "", ); $op1_free_op_var_ptr = array( - "ANY" => "if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}", + "ANY" => "if (free_op1) {zval_ptr_dtor_nogc(free_op1);}", "TMP" => "", - "VAR" => "if (free_op1.var) {zval_ptr_dtor_nogc(free_op1.var);}", + "VAR" => "if (free_op1) {zval_ptr_dtor_nogc(free_op1);}", "CONST" => "", "UNUSED" => "", "CV" => "", ); $op2_free_op_var_ptr = array( - "ANY" => "if (free_op2.var) {zval_ptr_dtor_nogc(free_op2.var);}", + "ANY" => "if (free_op2) {zval_ptr_dtor_nogc(free_op2);}", "TMP" => "", - "VAR" => "if (free_op2.var) {zval_ptr_dtor_nogc(free_op2.var);}", + "VAR" => "if (free_op2) {zval_ptr_dtor_nogc(free_op2);}", "CONST" => "", "UNUSED" => "", "CV" => "", From a740f9e7838ef11e36923874cfc796e6e719048f Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 18 Nov 2014 08:01:18 +0100 Subject: [PATCH 381/398] Include small MIT FastCGI client library from https://github.com/adoy/PHP-FastCGI-Client Add run_request function to easily run a FastCGI call, which is needed for new tests. --- sapi/fpm/tests/fcgi.inc | 592 +++++++++++++++++++++++++++++++++++++ sapi/fpm/tests/include.inc | 24 +- 2 files changed, 615 insertions(+), 1 deletion(-) create mode 100644 sapi/fpm/tests/fcgi.inc diff --git a/sapi/fpm/tests/fcgi.inc b/sapi/fpm/tests/fcgi.inc new file mode 100644 index 00000000000..b31676260da --- /dev/null +++ b/sapi/fpm/tests/fcgi.inc @@ -0,0 +1,592 @@ + + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +namespace Adoy\FastCGI; + +class TimedOutException extends \Exception {} +class ForbiddenException extends \Exception {} + +/** + * Handles communication with a FastCGI application + * + * @author Pierrick Charron + * @version 1.0 + */ +class Client +{ + const VERSION_1 = 1; + + const BEGIN_REQUEST = 1; + const ABORT_REQUEST = 2; + const END_REQUEST = 3; + const PARAMS = 4; + const STDIN = 5; + const STDOUT = 6; + const STDERR = 7; + const DATA = 8; + const GET_VALUES = 9; + const GET_VALUES_RESULT = 10; + const UNKNOWN_TYPE = 11; + const MAXTYPE = self::UNKNOWN_TYPE; + + const RESPONDER = 1; + const AUTHORIZER = 2; + const FILTER = 3; + + const REQUEST_COMPLETE = 0; + const CANT_MPX_CONN = 1; + const OVERLOADED = 2; + const UNKNOWN_ROLE = 3; + + const MAX_CONNS = 'MAX_CONNS'; + const MAX_REQS = 'MAX_REQS'; + const MPXS_CONNS = 'MPXS_CONNS'; + + const HEADER_LEN = 8; + + const REQ_STATE_WRITTEN = 1; + const REQ_STATE_OK = 2; + const REQ_STATE_ERR = 3; + const REQ_STATE_TIMED_OUT = 4; + + /** + * Socket + * @var Resource + */ + private $_sock = null; + + /** + * Host + * @var String + */ + private $_host = null; + + /** + * Port + * @var Integer + */ + private $_port = null; + + /** + * Keep Alive + * @var Boolean + */ + private $_keepAlive = false; + + /** + * Outstanding request statuses keyed by request id + * + * Each request is an array with following form: + * + * array( + * 'state' => REQ_STATE_* + * 'response' => null | string + * ) + * + * @var array + */ + private $_requests = array(); + + /** + * Use persistent sockets to connect to backend + * @var Boolean + */ + private $_persistentSocket = false; + + /** + * Connect timeout in milliseconds + * @var Integer + */ + private $_connectTimeout = 5000; + + /** + * Read/Write timeout in milliseconds + * @var Integer + */ + private $_readWriteTimeout = 5000; + + /** + * Constructor + * + * @param String $host Host of the FastCGI application + * @param Integer $port Port of the FastCGI application + */ + public function __construct($host, $port) + { + $this->_host = $host; + $this->_port = $port; + } + + /** + * Define whether or not the FastCGI application should keep the connection + * alive at the end of a request + * + * @param Boolean $b true if the connection should stay alive, false otherwise + */ + public function setKeepAlive($b) + { + $this->_keepAlive = (boolean)$b; + if (!$this->_keepAlive && $this->_sock) { + fclose($this->_sock); + } + } + + /** + * Get the keep alive status + * + * @return Boolean true if the connection should stay alive, false otherwise + */ + public function getKeepAlive() + { + return $this->_keepAlive; + } + + /** + * Define whether or not PHP should attempt to re-use sockets opened by previous + * request for efficiency + * + * @param Boolean $b true if persistent socket should be used, false otherwise + */ + public function setPersistentSocket($b) + { + $was_persistent = ($this->_sock && $this->_persistentSocket); + $this->_persistentSocket = (boolean)$b; + if (!$this->_persistentSocket && $was_persistent) { + fclose($this->_sock); + } + } + + /** + * Get the pesistent socket status + * + * @return Boolean true if the socket should be persistent, false otherwise + */ + public function getPersistentSocket() + { + return $this->_persistentSocket; + } + + + /** + * Set the connect timeout + * + * @param Integer number of milliseconds before connect will timeout + */ + public function setConnectTimeout($timeoutMs) + { + $this->_connectTimeout = $timeoutMs; + } + + /** + * Get the connect timeout + * + * @return Integer number of milliseconds before connect will timeout + */ + public function getConnectTimeout() + { + return $this->_connectTimeout; + } + + /** + * Set the read/write timeout + * + * @param Integer number of milliseconds before read or write call will timeout + */ + public function setReadWriteTimeout($timeoutMs) + { + $this->_readWriteTimeout = $timeoutMs; + $this->set_ms_timeout($this->_readWriteTimeout); + } + + /** + * Get the read timeout + * + * @return Integer number of milliseconds before read will timeout + */ + public function getReadWriteTimeout() + { + return $this->_readWriteTimeout; + } + + /** + * Helper to avoid duplicating milliseconds to secs/usecs in a few places + * + * @param Integer millisecond timeout + * @return Boolean + */ + private function set_ms_timeout($timeoutMs) { + if (!$this->_sock) { + return false; + } + return stream_set_timeout($this->_sock, floor($timeoutMs / 1000), ($timeoutMs % 1000) * 1000); + } + + + /** + * Create a connection to the FastCGI application + */ + private function connect() + { + if (!$this->_sock) { + if ($this->_persistentSocket) { + $this->_sock = pfsockopen($this->_host, $this->_port, $errno, $errstr, $this->_connectTimeout/1000); + } else { + $this->_sock = fsockopen($this->_host, $this->_port, $errno, $errstr, $this->_connectTimeout/1000); + } + + if (!$this->_sock) { + throw new \Exception('Unable to connect to FastCGI application: ' . $errstr); + } + + if (!$this->set_ms_timeout($this->_readWriteTimeout)) { + throw new \Exception('Unable to set timeout on socket'); + } + } + } + + /** + * Build a FastCGI packet + * + * @param Integer $type Type of the packet + * @param String $content Content of the packet + * @param Integer $requestId RequestId + */ + private function buildPacket($type, $content, $requestId = 1) + { + $clen = strlen($content); + return chr(self::VERSION_1) /* version */ + . chr($type) /* type */ + . chr(($requestId >> 8) & 0xFF) /* requestIdB1 */ + . chr($requestId & 0xFF) /* requestIdB0 */ + . chr(($clen >> 8 ) & 0xFF) /* contentLengthB1 */ + . chr($clen & 0xFF) /* contentLengthB0 */ + . chr(0) /* paddingLength */ + . chr(0) /* reserved */ + . $content; /* content */ + } + + /** + * Build an FastCGI Name value pair + * + * @param String $name Name + * @param String $value Value + * @return String FastCGI Name value pair + */ + private function buildNvpair($name, $value) + { + $nlen = strlen($name); + $vlen = strlen($value); + if ($nlen < 128) { + /* nameLengthB0 */ + $nvpair = chr($nlen); + } else { + /* nameLengthB3 & nameLengthB2 & nameLengthB1 & nameLengthB0 */ + $nvpair = chr(($nlen >> 24) | 0x80) . chr(($nlen >> 16) & 0xFF) . chr(($nlen >> 8) & 0xFF) . chr($nlen & 0xFF); + } + if ($vlen < 128) { + /* valueLengthB0 */ + $nvpair .= chr($vlen); + } else { + /* valueLengthB3 & valueLengthB2 & valueLengthB1 & valueLengthB0 */ + $nvpair .= chr(($vlen >> 24) | 0x80) . chr(($vlen >> 16) & 0xFF) . chr(($vlen >> 8) & 0xFF) . chr($vlen & 0xFF); + } + /* nameData & valueData */ + return $nvpair . $name . $value; + } + + /** + * Read a set of FastCGI Name value pairs + * + * @param String $data Data containing the set of FastCGI NVPair + * @return array of NVPair + */ + private function readNvpair($data, $length = null) + { + $array = array(); + + if ($length === null) { + $length = strlen($data); + } + + $p = 0; + + while ($p != $length) { + + $nlen = ord($data{$p++}); + if ($nlen >= 128) { + $nlen = ($nlen & 0x7F << 24); + $nlen |= (ord($data{$p++}) << 16); + $nlen |= (ord($data{$p++}) << 8); + $nlen |= (ord($data{$p++})); + } + $vlen = ord($data{$p++}); + if ($vlen >= 128) { + $vlen = ($nlen & 0x7F << 24); + $vlen |= (ord($data{$p++}) << 16); + $vlen |= (ord($data{$p++}) << 8); + $vlen |= (ord($data{$p++})); + } + $array[substr($data, $p, $nlen)] = substr($data, $p+$nlen, $vlen); + $p += ($nlen + $vlen); + } + + return $array; + } + + /** + * Decode a FastCGI Packet + * + * @param String $data String containing all the packet + * @return array + */ + private function decodePacketHeader($data) + { + $ret = array(); + $ret['version'] = ord($data{0}); + $ret['type'] = ord($data{1}); + $ret['requestId'] = (ord($data{2}) << 8) + ord($data{3}); + $ret['contentLength'] = (ord($data{4}) << 8) + ord($data{5}); + $ret['paddingLength'] = ord($data{6}); + $ret['reserved'] = ord($data{7}); + return $ret; + } + + /** + * Read a FastCGI Packet + * + * @return array + */ + private function readPacket() + { + if ($packet = fread($this->_sock, self::HEADER_LEN)) { + $resp = $this->decodePacketHeader($packet); + $resp['content'] = ''; + if ($resp['contentLength']) { + $len = $resp['contentLength']; + while ($len && $buf=fread($this->_sock, $len)) { + $len -= strlen($buf); + $resp['content'] .= $buf; + } + } + if ($resp['paddingLength']) { + $buf = fread($this->_sock, $resp['paddingLength']); + } + return $resp; + } else { + return false; + } + } + + /** + * Get Informations on the FastCGI application + * + * @param array $requestedInfo information to retrieve + * @return array + */ + public function getValues(array $requestedInfo) + { + $this->connect(); + + $request = ''; + foreach ($requestedInfo as $info) { + $request .= $this->buildNvpair($info, ''); + } + fwrite($this->_sock, $this->buildPacket(self::GET_VALUES, $request, 0)); + + $resp = $this->readPacket(); + if ($resp['type'] == self::GET_VALUES_RESULT) { + return $this->readNvpair($resp['content'], $resp['length']); + } else { + throw new \Exception('Unexpected response type, expecting GET_VALUES_RESULT'); + } + } + + /** + * Execute a request to the FastCGI application + * + * @param array $params Array of parameters + * @param String $stdin Content + * @return String + */ + public function request(array $params, $stdin) + { + $id = $this->async_request($params, $stdin); + return $this->wait_for_response($id); + } + + /** + * Execute a request to the FastCGI application asyncronously + * + * This sends request to application and returns the assigned ID for that request. + * + * You should keep this id for later use with wait_for_response(). Ids are chosen randomly + * rather than seqentially to guard against false-positives when using persistent sockets. + * In that case it is possible that a delayed response to a request made by a previous script + * invocation comes back on this socket and is mistaken for response to request made with same ID + * during this request. + * + * @param array $params Array of parameters + * @param String $stdin Content + * @return Integer + */ + public function async_request(array $params, $stdin) + { + $this->connect(); + + // Pick random number between 1 and max 16 bit unsigned int 65535 + $id = mt_rand(1, (1 << 16) - 1); + + // Using persistent sockets implies you want them keept alive by server! + $keepAlive = intval($this->_keepAlive || $this->_persistentSocket); + + $request = $this->buildPacket(self::BEGIN_REQUEST + ,chr(0) . chr(self::RESPONDER) . chr($keepAlive) . str_repeat(chr(0), 5) + ,$id + ); + + $paramsRequest = ''; + foreach ($params as $key => $value) { + $paramsRequest .= $this->buildNvpair($key, $value, $id); + } + if ($paramsRequest) { + $request .= $this->buildPacket(self::PARAMS, $paramsRequest, $id); + } + $request .= $this->buildPacket(self::PARAMS, '', $id); + + if ($stdin) { + $request .= $this->buildPacket(self::STDIN, $stdin, $id); + } + $request .= $this->buildPacket(self::STDIN, '', $id); + + if (fwrite($this->_sock, $request) === false || fflush($this->_sock) === false) { + + $info = stream_get_meta_data($this->_sock); + + if ($info['timed_out']) { + throw new TimedOutException('Write timed out'); + } + + // Broken pipe, tear down so future requests might succeed + fclose($this->_sock); + throw new \Exception('Failed to write request to socket'); + } + + $this->_requests[$id] = array( + 'state' => self::REQ_STATE_WRITTEN, + 'response' => null + ); + + return $id; + } + + /** + * Blocking call that waits for response to specific request + * + * @param Integer $requestId + * @param Integer $timeoutMs [optional] the number of milliseconds to wait. Defaults to the ReadWriteTimeout value set. + * @return string response body + */ + public function wait_for_response($requestId, $timeoutMs = 0) { + + if (!isset($this->_requests[$requestId])) { + throw new \Exception('Invalid request id given'); + } + + // If we already read the response during an earlier call for different id, just return it + if ($this->_requests[$requestId]['state'] == self::REQ_STATE_OK + || $this->_requests[$requestId]['state'] == self::REQ_STATE_ERR + ) { + return $this->_requests[$requestId]['response']; + } + + if ($timeoutMs > 0) { + // Reset timeout on socket for now + $this->set_ms_timeout($timeoutMs); + } else { + $timeoutMs = $this->_readWriteTimeout; + } + + // Need to manually check since we might do several reads none of which timeout themselves + // but still not get the response requested + $startTime = microtime(true); + + do { + $resp = $this->readPacket(); + + if ($resp['type'] == self::STDOUT || $resp['type'] == self::STDERR) { + if ($resp['type'] == self::STDERR) { + $this->_requests[$resp['requestId']]['state'] = self::REQ_STATE_ERR; + } + $this->_requests[$resp['requestId']]['response'] .= $resp['content']; + } + if ($resp['type'] == self::END_REQUEST) { + $this->_requests[$resp['requestId']]['state'] = self::REQ_STATE_OK; + if ($resp['requestId'] == $requestId) { + break; + } + } + if (microtime(true) - $startTime >= ($timeoutMs * 1000)) { + // Reset + $this->set_ms_timeout($this->_readWriteTimeout); + throw new \Exception('Timed out'); + } + } while ($resp); + + if (!is_array($resp)) { + $info = stream_get_meta_data($this->_sock); + + // We must reset timeout but it must be AFTER we get info + $this->set_ms_timeout($this->_readWriteTimeout); + + if ($info['timed_out']) { + throw new TimedOutException('Read timed out'); + } + + if ($info['unread_bytes'] == 0 + && $info['blocked'] + && $info['eof']) { + throw new ForbiddenException('Not in white list. Check listen.allowed_clients.'); + } + + throw new \Exception('Read failed'); + } + + // Reset timeout + $this->set_ms_timeout($this->_readWriteTimeout); + + switch (ord($resp['content']{4})) { + case self::CANT_MPX_CONN: + throw new \Exception('This app can\'t multiplex [CANT_MPX_CONN]'); + break; + case self::OVERLOADED: + throw new \Exception('New request rejected; too busy [OVERLOADED]'); + break; + case self::UNKNOWN_ROLE: + throw new \Exception('Role value not known [UNKNOWN_ROLE]'); + break; + case self::REQUEST_COMPLETE: + return $this->_requests[$requestId]['response']; + } + } +} diff --git a/sapi/fpm/tests/include.inc b/sapi/fpm/tests/include.inc index 983cbd34541..5d01ae693da 100644 --- a/sapi/fpm/tests/include.inc +++ b/sapi/fpm/tests/include.inc @@ -76,4 +76,26 @@ function run_fpm_till($needle, $config, $max = 10) /* {{{ */ } /* }}} */ -?> +function run_request($host, $port, $uri='/ping', $query='') { + require_once 'fcgi.inc'; + $client = new Adoy\FastCGI\Client($host, $port); + $params = array( + 'GATEWAY_INTERFACE' => 'FastCGI/1.0', + 'REQUEST_METHOD' => 'GET', + 'SCRIPT_FILENAME' => $uri, + 'SCRIPT_NAME' => $uri, + 'QUERY_STRING' => $query, + 'REQUEST_URI' => $uri . ($query ? '?'.$query : ""), + 'DOCUMENT_URI' => $uri, + 'SERVER_SOFTWARE' => 'php/fcgiclient', + 'REMOTE_ADDR' => '127.0.0.1', + 'REMOTE_PORT' => '9985', + 'SERVER_ADDR' => '127.0.0.1', + 'SERVER_PORT' => '80', + 'SERVER_NAME' => php_uname('n'), + 'SERVER_PROTOCOL' => 'HTTP/1.1', + 'CONTENT_TYPE' => '', + 'CONTENT_LENGTH' => 0 + ); + return $client->request($params, false)."\n"; +} From 8c0cc49b9bf714a307f84708ec22fceab397c00c Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 18 Nov 2014 08:07:45 +0100 Subject: [PATCH 382/398] Add various tests for FPM - covering recent bugs (68420, 68421, 68423, 68428) - for UDS - for ping and status URI - for multi pool and multi mode --- sapi/fpm/tests/002.phpt | 5 +-- sapi/fpm/tests/003.phpt | 5 +-- sapi/fpm/tests/005.phpt | 58 ++++++++++++++++++++++++++++ sapi/fpm/tests/006.phpt | 58 ++++++++++++++++++++++++++++ sapi/fpm/tests/007.phpt | 69 +++++++++++++++++++++++++++++++++ sapi/fpm/tests/008.phpt | 85 +++++++++++++++++++++++++++++++++++++++++ sapi/fpm/tests/009.phpt | 54 ++++++++++++++++++++++++++ sapi/fpm/tests/010.phpt | 85 +++++++++++++++++++++++++++++++++++++++++ sapi/fpm/tests/011.phpt | 54 ++++++++++++++++++++++++++ 9 files changed, 467 insertions(+), 6 deletions(-) create mode 100644 sapi/fpm/tests/005.phpt create mode 100644 sapi/fpm/tests/006.phpt create mode 100644 sapi/fpm/tests/007.phpt create mode 100644 sapi/fpm/tests/008.phpt create mode 100644 sapi/fpm/tests/009.phpt create mode 100644 sapi/fpm/tests/010.phpt create mode 100644 sapi/fpm/tests/011.phpt diff --git a/sapi/fpm/tests/002.phpt b/sapi/fpm/tests/002.phpt index ce878661eaf..2ef6cedc385 100644 --- a/sapi/fpm/tests/002.phpt +++ b/sapi/fpm/tests/002.phpt @@ -8,13 +8,12 @@ FPM: Startup and connect include "include.inc"; $logfile = dirname(__FILE__).'/php-fpm.log.tmp'; -$port = 9000+PHP_INT_SIZE; $cfg = << +--FILE-- + +--EXPECTF-- +[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d +[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections +IPv4 ok +IPv6 error +--CLEAN-- + diff --git a/sapi/fpm/tests/006.phpt b/sapi/fpm/tests/006.phpt new file mode 100644 index 00000000000..d8b47ee5338 --- /dev/null +++ b/sapi/fpm/tests/006.phpt @@ -0,0 +1,58 @@ +--TEST-- +FPM: Test IPv6 allowed clients (bug #68428) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d +[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections +IPv4 error +IPv6 ok +--CLEAN-- + diff --git a/sapi/fpm/tests/007.phpt b/sapi/fpm/tests/007.phpt new file mode 100644 index 00000000000..18893819e21 --- /dev/null +++ b/sapi/fpm/tests/007.phpt @@ -0,0 +1,69 @@ +--TEST-- +FPM: Test IPv6 all addresses and access_log (bug #68421) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d +[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections +int(%d) +IPv4 ok +int(%d) +IPv6 ok +127.0.0.1 %s "GET /ping" 200 +::1 %s "GET /ping" 200 +--CLEAN-- + diff --git a/sapi/fpm/tests/008.phpt b/sapi/fpm/tests/008.phpt new file mode 100644 index 00000000000..aaa773093cb --- /dev/null +++ b/sapi/fpm/tests/008.phpt @@ -0,0 +1,85 @@ +--TEST-- +FPM: Test multi pool (dynamic + ondemand + static) (bug #68423) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d +[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections +int(%d) +Dynamic ok +int(%d) +OnDemand ok +int(%d) +Static ok +--CLEAN-- + diff --git a/sapi/fpm/tests/009.phpt b/sapi/fpm/tests/009.phpt new file mode 100644 index 00000000000..836fb193236 --- /dev/null +++ b/sapi/fpm/tests/009.phpt @@ -0,0 +1,54 @@ +--TEST-- +FPM: Test Unix Domain Socket +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d +[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections +int(%d) +UDS ok +--CLEAN-- + diff --git a/sapi/fpm/tests/010.phpt b/sapi/fpm/tests/010.phpt new file mode 100644 index 00000000000..dc8d5bb949f --- /dev/null +++ b/sapi/fpm/tests/010.phpt @@ -0,0 +1,85 @@ +--TEST-- +FPM: Test status page +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d +[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections +X-Powered-By: PHP/%s +Expires: %s +Cache-Control: %s +Content-type: text/plain%s + +pool: unconfined +process manager: dynamic +start time: %s +start since: %d +accepted conn: 1 +listen queue: 0 +max listen queue: 0 +listen queue len: %d +idle processes: 1 +active processes: 1 +total processes: 2 +max active processes: 1 +max children reached: 0 +slow requests: 0 + +bool(true) +bool(true) +bool(true) +IPv4 ok +--CLEAN-- + diff --git a/sapi/fpm/tests/011.phpt b/sapi/fpm/tests/011.phpt new file mode 100644 index 00000000000..ddcf67f6d3a --- /dev/null +++ b/sapi/fpm/tests/011.phpt @@ -0,0 +1,54 @@ +--TEST-- +FPM: Test IPv4 all addresses (bug #68420) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d +[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections +int(%d) +IPv4 ok +--CLEAN-- + From 51394dff3f8d55fd40823e1841a97e631f4dfec5 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 18 Nov 2014 11:08:49 +0100 Subject: [PATCH 383/398] Add test for bug #68442 Add another helper function fpm_display_log Restore change from c996a989 badly reverted in 8c0cc49 --- sapi/fpm/tests/002.phpt | 5 ++- sapi/fpm/tests/003.phpt | 5 ++- sapi/fpm/tests/012.phpt | 79 ++++++++++++++++++++++++++++++++++++++ sapi/fpm/tests/include.inc | 10 +++++ 4 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 sapi/fpm/tests/012.phpt diff --git a/sapi/fpm/tests/002.phpt b/sapi/fpm/tests/002.phpt index 2ef6cedc385..ce878661eaf 100644 --- a/sapi/fpm/tests/002.phpt +++ b/sapi/fpm/tests/002.phpt @@ -8,12 +8,13 @@ FPM: Startup and connect include "include.inc"; $logfile = dirname(__FILE__).'/php-fpm.log.tmp'; +$port = 9000+PHP_INT_SIZE; $cfg = << +--FILE-- + +--EXPECTF-- +[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d +[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections +int(%d) +IPv4 ok +[%d-%s-%d %d:%d:%d] NOTICE: Reloading in progress ... +[%d-%s-%d %d:%d:%d] NOTICE: reloading: %s +[%d-%s-%d %d:%d:%d] NOTICE: using inherited socket fd=%d, "127.0.0.1:%d" +[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d +[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections +int(%d) +IPv4 ok +--CLEAN-- + diff --git a/sapi/fpm/tests/include.inc b/sapi/fpm/tests/include.inc index 5d01ae693da..b195fad5073 100644 --- a/sapi/fpm/tests/include.inc +++ b/sapi/fpm/tests/include.inc @@ -76,6 +76,16 @@ function run_fpm_till($needle, $config, $max = 10) /* {{{ */ } /* }}} */ +function fpm_display_log($tail, $n=1, $ignore='systemd') { + while ($n) { + $a = fgets($tail); + if (empty($ignore) || !strpos($a, $ignore)) { + echo $a; + $n--; + } + } +} + function run_request($host, $port, $uri='/ping', $query='') { require_once 'fcgi.inc'; $client = new Adoy\FastCGI\Client($host, $port); From e20a727430713cc4ab81bc8faad64d616837c787 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 18 Nov 2014 14:37:36 +0300 Subject: [PATCH 384/398] SEND_VAR_NO_REF optimization --- Zend/zend_compile.c | 7 +++- Zend/zend_vm_def.h | 19 ++++------- Zend/zend_vm_execute.h | 38 ++++++++------------- ext/opcache/Optimizer/optimize_func_calls.c | 2 -- ext/opcache/Optimizer/zend_optimizer.c | 8 +++++ 5 files changed, 35 insertions(+), 39 deletions(-) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index c3a572a04d5..d15b85fc0ba 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -2478,7 +2478,12 @@ uint32_t zend_compile_args(zend_ast *ast, zend_function *fbc TSRMLS_DC) /* {{{ * if (fbc) { flags |= ZEND_ARG_COMPILE_TIME_BOUND; } - opline->extended_value = flags; + if ((flags & ZEND_ARG_COMPILE_TIME_BOUND) && !(flags & ZEND_ARG_SEND_BY_REF)) { + opline->opcode = ZEND_SEND_VAR; + opline->extended_value = ZEND_ARG_COMPILE_TIME_BOUND; + } else { + opline->extended_value = flags; + } } else if (fbc) { opline->extended_value = ZEND_ARG_COMPILE_TIME_BOUND; } diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 7ea7929a696..f0ebac44efe 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -3062,11 +3062,8 @@ ZEND_VM_HANDLER(106, ZEND_SEND_VAR_NO_REF, VAR|CV, ANY) zval *varptr, *arg; SAVE_OPLINE(); - if (opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) { /* Had function_ptr at compile_time */ - if (!(opline->extended_value & ZEND_ARG_SEND_BY_REF)) { - ZEND_VM_DISPATCH_TO_HANDLER(ZEND_SEND_VAR); - } - } else { + + if (!(opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND)) { if (!ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) { ZEND_VM_DISPATCH_TO_HANDLER(ZEND_SEND_VAR); } @@ -3081,20 +3078,18 @@ ZEND_VM_HANDLER(106, ZEND_SEND_VAR_NO_REF, VAR|CV, ANY) if (OP1_TYPE == IS_CV) { Z_ADDREF_P(varptr); } - arg = ZEND_CALL_ARG(EX(call), opline->op2.num); - EX(call)->num_args = opline->op2.num; - ZVAL_COPY_VALUE(arg, varptr); } else { if ((opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) ? !(opline->extended_value & ZEND_ARG_SEND_SILENT) : !ARG_MAY_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) { zend_error(E_STRICT, "Only variables should be passed by reference"); } - arg = ZEND_CALL_ARG(EX(call), opline->op2.num); - EX(call)->num_args = opline->op2.num; - ZVAL_COPY(arg, varptr); - FREE_OP1_IF_VAR(); } + + arg = ZEND_CALL_ARG(EX(call), opline->op2.num); + EX(call)->num_args = opline->op2.num; + ZVAL_COPY_VALUE(arg, varptr); + CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 6680da3458e..fc563b40a82 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -16482,11 +16482,8 @@ static int ZEND_FASTCALL ZEND_SEND_VAR_NO_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HAND zval *varptr, *arg; SAVE_OPLINE(); - if (opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) { /* Had function_ptr at compile_time */ - if (!(opline->extended_value & ZEND_ARG_SEND_BY_REF)) { - return ZEND_SEND_VAR_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); - } - } else { + + if (!(opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND)) { if (!ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) { return ZEND_SEND_VAR_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } @@ -16501,20 +16498,18 @@ static int ZEND_FASTCALL ZEND_SEND_VAR_NO_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HAND if (IS_VAR == IS_CV) { Z_ADDREF_P(varptr); } - arg = ZEND_CALL_ARG(EX(call), opline->op2.num); - EX(call)->num_args = opline->op2.num; - ZVAL_COPY_VALUE(arg, varptr); } else { if ((opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) ? !(opline->extended_value & ZEND_ARG_SEND_SILENT) : !ARG_MAY_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) { zend_error(E_STRICT, "Only variables should be passed by reference"); } - arg = ZEND_CALL_ARG(EX(call), opline->op2.num); - EX(call)->num_args = opline->op2.num; - ZVAL_COPY(arg, varptr); - zval_ptr_dtor_nogc(free_op1); } + + arg = ZEND_CALL_ARG(EX(call), opline->op2.num); + EX(call)->num_args = opline->op2.num; + ZVAL_COPY_VALUE(arg, varptr); + CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -34276,11 +34271,8 @@ static int ZEND_FASTCALL ZEND_SEND_VAR_NO_REF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDL zval *varptr, *arg; SAVE_OPLINE(); - if (opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) { /* Had function_ptr at compile_time */ - if (!(opline->extended_value & ZEND_ARG_SEND_BY_REF)) { - return ZEND_SEND_VAR_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); - } - } else { + + if (!(opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND)) { if (!ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) { return ZEND_SEND_VAR_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } @@ -34295,20 +34287,18 @@ static int ZEND_FASTCALL ZEND_SEND_VAR_NO_REF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDL if (IS_CV == IS_CV) { Z_ADDREF_P(varptr); } - arg = ZEND_CALL_ARG(EX(call), opline->op2.num); - EX(call)->num_args = opline->op2.num; - ZVAL_COPY_VALUE(arg, varptr); } else { if ((opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) ? !(opline->extended_value & ZEND_ARG_SEND_SILENT) : !ARG_MAY_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) { zend_error(E_STRICT, "Only variables should be passed by reference"); } - arg = ZEND_CALL_ARG(EX(call), opline->op2.num); - EX(call)->num_args = opline->op2.num; - ZVAL_COPY(arg, varptr); - } + + arg = ZEND_CALL_ARG(EX(call), opline->op2.num); + EX(call)->num_args = opline->op2.num; + ZVAL_COPY_VALUE(arg, varptr); + CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } diff --git a/ext/opcache/Optimizer/optimize_func_calls.c b/ext/opcache/Optimizer/optimize_func_calls.c index aa62a4542dd..9031a38f56b 100644 --- a/ext/opcache/Optimizer/optimize_func_calls.c +++ b/ext/opcache/Optimizer/optimize_func_calls.c @@ -143,8 +143,6 @@ void optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx TSRMLS if (!(opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) && call_stack[call - 1].func) { if (ARG_SHOULD_BE_SENT_BY_REF(call_stack[call - 1].func, opline->op2.num)) { opline->extended_value |= ZEND_ARG_COMPILE_TIME_BOUND | ZEND_ARG_SEND_BY_REF; - } else if (opline->extended_value) { - opline->extended_value |= ZEND_ARG_COMPILE_TIME_BOUND; } else { opline->opcode = ZEND_SEND_VAR; opline->extended_value = 0; diff --git a/ext/opcache/Optimizer/zend_optimizer.c b/ext/opcache/Optimizer/zend_optimizer.c index 1a6d0b675af..589028368f1 100644 --- a/ext/opcache/Optimizer/zend_optimizer.c +++ b/ext/opcache/Optimizer/zend_optimizer.c @@ -283,6 +283,14 @@ int zend_optimizer_replace_by_const(zend_op_array *op_array, case ZEND_ASSIGN_DIM: case ZEND_SEPARATE: return 0; + case ZEND_SEND_VAR: + opline->extended_value = 0; + opline->opcode = ZEND_SEND_VAL; + break; + case ZEND_SEND_VAR_EX: + opline->extended_value = 0; + opline->opcode = ZEND_SEND_VAL_EX; + break; case ZEND_SEND_VAR_NO_REF: if (opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) { if (opline->extended_value & ZEND_ARG_SEND_BY_REF) { From ec26d7a80f1d486d79d6319f891bd474bad3710d Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 18 Nov 2014 13:11:53 +0100 Subject: [PATCH 385/398] simplify fpm tests --- sapi/fpm/tests/002.phpt | 9 +++------ sapi/fpm/tests/003.phpt | 9 +++------ sapi/fpm/tests/004.phpt | 9 +++------ sapi/fpm/tests/005.phpt | 3 +-- sapi/fpm/tests/006.phpt | 3 +-- sapi/fpm/tests/007.phpt | 3 +-- sapi/fpm/tests/008.phpt | 3 +-- sapi/fpm/tests/009.phpt | 3 +-- sapi/fpm/tests/010.phpt | 3 +-- sapi/fpm/tests/011.phpt | 3 +-- 10 files changed, 16 insertions(+), 32 deletions(-) diff --git a/sapi/fpm/tests/002.phpt b/sapi/fpm/tests/002.phpt index ce878661eaf..89e431849ab 100644 --- a/sapi/fpm/tests/002.phpt +++ b/sapi/fpm/tests/002.phpt @@ -24,8 +24,7 @@ EOT; $fpm = run_fpm($cfg, $tail); if (is_resource($fpm)) { - var_dump(fgets($tail)); - var_dump(fgets($tail)); + fpm_display_log($tail, 2); $i = 0; while (($i++ < 30) && !($fp = @fsockopen('127.0.0.1', $port))) { usleep(10000); @@ -42,10 +41,8 @@ if (is_resource($fpm)) { ?> --EXPECTF-- -string(%d) "[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d -" -string(%d) "[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections -" +[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d +[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections Done --CLEAN-- --EXPECTF-- -string(%d) "[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d -" -string(%d) "[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections -" +[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d +[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections Done --CLEAN-- --EXPECTF-- -string(%d) "[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d -" -string(%d) "[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections -" +[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d +[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections Done IPv4 Done IPv6 --CLEAN-- diff --git a/sapi/fpm/tests/005.phpt b/sapi/fpm/tests/005.phpt index 992b01f08e8..c565c2a9ebd 100644 --- a/sapi/fpm/tests/005.phpt +++ b/sapi/fpm/tests/005.phpt @@ -25,8 +25,7 @@ EOT; $fpm = run_fpm($cfg, $tail); if (is_resource($fpm)) { - echo fgets($tail); - echo fgets($tail); + fpm_display_log($tail, 2); try { run_request('127.0.0.1', $port); echo "IPv4 ok\n"; diff --git a/sapi/fpm/tests/006.phpt b/sapi/fpm/tests/006.phpt index d8b47ee5338..a12ca253d21 100644 --- a/sapi/fpm/tests/006.phpt +++ b/sapi/fpm/tests/006.phpt @@ -25,8 +25,7 @@ EOT; $fpm = run_fpm($cfg, $tail); if (is_resource($fpm)) { - echo fgets($tail); - echo fgets($tail); + fpm_display_log($tail, 2); try { run_request('127.0.0.1', $port); echo "IPv4 ok\n"; diff --git a/sapi/fpm/tests/007.phpt b/sapi/fpm/tests/007.phpt index 18893819e21..0d817907cf0 100644 --- a/sapi/fpm/tests/007.phpt +++ b/sapi/fpm/tests/007.phpt @@ -28,8 +28,7 @@ EOT; $fpm = run_fpm($cfg, $tail); if (is_resource($fpm)) { - echo fgets($tail); - echo fgets($tail); + fpm_display_log($tail, 2); try { var_dump(strpos(run_request('127.0.0.1', $port), 'pong')); echo "IPv4 ok\n"; diff --git a/sapi/fpm/tests/008.phpt b/sapi/fpm/tests/008.phpt index aaa773093cb..60f1ea6ebda 100644 --- a/sapi/fpm/tests/008.phpt +++ b/sapi/fpm/tests/008.phpt @@ -41,8 +41,7 @@ EOT; $fpm = run_fpm($cfg, $tail); if (is_resource($fpm)) { - echo fgets($tail); - echo fgets($tail); + fpm_display_log($tail, 2); try { var_dump(strpos(run_request('127.0.0.1', $port1), 'pong-dynamic')); echo "Dynamic ok\n"; diff --git a/sapi/fpm/tests/009.phpt b/sapi/fpm/tests/009.phpt index 836fb193236..34cdffcf833 100644 --- a/sapi/fpm/tests/009.phpt +++ b/sapi/fpm/tests/009.phpt @@ -26,8 +26,7 @@ EOT; $fpm = run_fpm($cfg, $tail); if (is_resource($fpm)) { - echo fgets($tail); - echo fgets($tail); + fpm_display_log($tail, 2); try { var_dump(strpos(run_request('unix://'.$socket, -1), 'pong')); echo "UDS ok\n"; diff --git a/sapi/fpm/tests/010.phpt b/sapi/fpm/tests/010.phpt index dc8d5bb949f..37c778db5be 100644 --- a/sapi/fpm/tests/010.phpt +++ b/sapi/fpm/tests/010.phpt @@ -25,8 +25,7 @@ EOT; $fpm = run_fpm($cfg, $tail); if (is_resource($fpm)) { - echo fgets($tail); - echo fgets($tail); + fpm_display_log($tail, 2); try { echo run_request('127.0.0.1', $port, '/status'); diff --git a/sapi/fpm/tests/011.phpt b/sapi/fpm/tests/011.phpt index ddcf67f6d3a..0b849f873ba 100644 --- a/sapi/fpm/tests/011.phpt +++ b/sapi/fpm/tests/011.phpt @@ -26,8 +26,7 @@ EOT; $fpm = run_fpm($cfg, $tail); if (is_resource($fpm)) { - echo fgets($tail); - echo fgets($tail); + fpm_display_log($tail, 2); try { var_dump(strpos(run_request('127.0.0.1', $port), 'pong')); echo "IPv4 ok\n"; From 6b3b4fc94497f8e468821e1a3108916cc83c15cf Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sat, 15 Nov 2014 13:12:25 +0100 Subject: [PATCH 386/398] joined identical conditional blocks --- Zend/zend_hash.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index 5577194b0c7..24be94f0d98 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -1697,8 +1697,7 @@ ZEND_API int zend_hash_sort(HashTable *ht, sort_func_t sort_func, p->key = NULL; } } - } - if (renumber) { + ht->nNextFreeElement = i; } if (ht->u.flags & HASH_FLAG_PACKED) { From 544a2c479254d104bb97641c819d733bd08ef968 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 18 Nov 2014 10:50:56 +0100 Subject: [PATCH 387/398] "extern" shouldn't be used for definitions --- sapi/embed/php_embed.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sapi/embed/php_embed.c b/sapi/embed/php_embed.c index e0df6661083..8bfaf9f52d9 100644 --- a/sapi/embed/php_embed.c +++ b/sapi/embed/php_embed.c @@ -108,7 +108,7 @@ static int php_embed_startup(sapi_module_struct *sapi_module) return SUCCESS; } -extern EMBED_SAPI_API sapi_module_struct php_embed_module = { +EMBED_SAPI_API sapi_module_struct php_embed_module = { "embed", /* name */ "PHP Embedded Library", /* pretty name */ From 7c5ae9a1cf3e65afadb4ba3cf50a0690e7d4d27d Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 18 Nov 2014 11:03:54 +0100 Subject: [PATCH 388/398] fix unsigned check --- sapi/apache2handler/php_functions.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sapi/apache2handler/php_functions.c b/sapi/apache2handler/php_functions.c index d9ae4d97eac..f32c881e057 100644 --- a/sapi/apache2handler/php_functions.c +++ b/sapi/apache2handler/php_functions.c @@ -388,8 +388,12 @@ PHP_MINFO_FUNCTION(apache) } smart_str_appendc(&tmp1, ' '); } - if (tmp1.s && (tmp1.s->len - 1) >= 0) { - tmp1.s->val[tmp1.s->len - 1] = '\0'; + if (tmp1.s) { + if (tmp1.s->len > 0) { + tmp1.s->val[tmp1.s->len - 1] = '\0'; + } else { + tmp1.s->val[0] = '\0'; + } } php_info_print_table_start(); From fb6c3d3cf54b40caa8860d1f8d5577c26d4a6e89 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 18 Nov 2014 11:49:06 +0100 Subject: [PATCH 389/398] fix datatype mismatches --- Zend/zend_virtual_cwd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Zend/zend_virtual_cwd.c b/Zend/zend_virtual_cwd.c index f8b42b1596e..509b33e369d 100644 --- a/Zend/zend_virtual_cwd.c +++ b/Zend/zend_virtual_cwd.c @@ -347,7 +347,7 @@ CWD_API int php_sys_stat_ex(const char *path, zend_stat_t *buf, int lstat) /* {{ /* File is a reparse point. Get the target */ HANDLE hLink = NULL; REPARSE_DATA_BUFFER * pbuffer; - unsigned int retlength = 0; + DWORD retlength = 0; hLink = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT|FILE_FLAG_BACKUP_SEMANTICS, NULL); if(hLink == INVALID_HANDLE_VALUE) { @@ -898,7 +898,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i /* File is a reparse point. Get the target */ HANDLE hLink = NULL; REPARSE_DATA_BUFFER * pbuffer; - unsigned int retlength = 0; + DWORD retlength = 0; int bufindex = 0, isabsolute = 0; wchar_t * reparsetarget; BOOL isVolume = FALSE; From 2a1bfe6f0c652db3e7b190fbb9fa42a1e0b9c299 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 18 Nov 2014 11:53:33 +0100 Subject: [PATCH 390/398] add missing type specifier --- main/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/main.c b/main/main.c index 828831545e4..5b969a930c5 100644 --- a/main/main.c +++ b/main/main.c @@ -130,7 +130,7 @@ PHPAPI int core_globals_id; #ifdef PHP_WIN32 #include "win32_internal_function_disabled.h" -static php_win32_disable_functions(TSRMLS_D) +static int php_win32_disable_functions(TSRMLS_D) { int i; From 7e8e7ff634ade8d58711b9cbb28f9180c534ab77 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 18 Nov 2014 12:11:25 +0100 Subject: [PATCH 391/398] fix datatype mismatches --- main/snprintf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/snprintf.c b/main/snprintf.c index 826880f62ab..0b9182b6145 100644 --- a/main/snprintf.c +++ b/main/snprintf.c @@ -1241,7 +1241,7 @@ static void strx_printv(int *ccp, char *buf, size_t len, const char *format, va_ PHPAPI int ap_php_slprintf(char *buf, size_t len, const char *format,...) /* {{{ */ { - unsigned int cc; + int cc; va_list ap; va_start(ap, format); @@ -1257,7 +1257,7 @@ PHPAPI int ap_php_slprintf(char *buf, size_t len, const char *format,...) /* {{{ PHPAPI int ap_php_vslprintf(char *buf, size_t len, const char *format, va_list ap) /* {{{ */ { - unsigned int cc; + int cc; strx_printv(&cc, buf, len, format, ap); if (cc >= len) { From f8f86a44ef108e7fcd7e8bc810e7c8ee3dd684a2 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 18 Nov 2014 12:34:45 +0100 Subject: [PATCH 392/398] return after the warning, to fix uninitialized salt usage --- ext/standard/password.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/standard/password.c b/ext/standard/password.c index cd2170b036a..4f211dd35f3 100644 --- a/ext/standard/password.c +++ b/ext/standard/password.c @@ -384,6 +384,7 @@ PHP_FUNCTION(password_hash) efree(hash_format); efree(buffer); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Supplied salt is too long"); + RETURN_NULL(); } else if (buffer_len < required_salt_len) { efree(hash_format); efree(buffer); From 075fc1ff1a37a096438e7cbffe7f8e4cca98c111 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 18 Nov 2014 13:13:23 +0100 Subject: [PATCH 393/398] fix some datatype mismatches --- ext/wddx/php_wddx_api.h | 2 +- ext/wddx/wddx.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ext/wddx/php_wddx_api.h b/ext/wddx/php_wddx_api.h index 5c47109ee3c..edbd013342e 100644 --- a/ext/wddx/php_wddx_api.h +++ b/ext/wddx/php_wddx_api.h @@ -61,7 +61,7 @@ void php_wddx_packet_start(wddx_packet *packet, char *comment, size_t comment void php_wddx_packet_end(wddx_packet *packet); void php_wddx_serialize_var(wddx_packet *packet, zval *var, zend_string *name TSRMLS_DC); -int php_wddx_deserialize_ex(char *, int, zval *return_value); +int php_wddx_deserialize_ex(const char *, size_t, zval *return_value); #define php_wddx_gather(packet) estrndup(packet->c, packet->len) #endif /* PHP_WDDX_API_H */ diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c index 705babd8858..43deb15afdc 100644 --- a/ext/wddx/wddx.c +++ b/ext/wddx/wddx.c @@ -1046,7 +1046,7 @@ static void php_wddx_process_data(void *user_data, const XML_Char *s, int len) /* {{{ php_wddx_deserialize_ex */ -int php_wddx_deserialize_ex(char *value, int vallen, zval *return_value) +int php_wddx_deserialize_ex(const char *value, size_t vallen, zval *return_value) { wddx_stack stack; XML_Parser parser; @@ -1060,7 +1060,8 @@ int php_wddx_deserialize_ex(char *value, int vallen, zval *return_value) XML_SetElementHandler(parser, php_wddx_push_element, php_wddx_pop_element); XML_SetCharacterDataHandler(parser, php_wddx_process_data); - XML_Parse(parser, value, vallen, 1); + /* XXX value should be parsed in the loop to exhaust size_t */ + XML_Parse(parser, value, (int)vallen, 1); XML_ParserFree(parser); From 376a366f0cce0c2bea36e5e06d8710675957c626 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 18 Nov 2014 13:17:43 +0100 Subject: [PATCH 394/398] move to size_t where zend_string is used internally --- ext/standard/incomplete_class.c | 2 +- ext/standard/php_incomplete_class.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/standard/incomplete_class.c b/ext/standard/incomplete_class.c index 011407da29b..bb1b9c5a6a3 100644 --- a/ext/standard/incomplete_class.c +++ b/ext/standard/incomplete_class.c @@ -150,7 +150,7 @@ PHPAPI zend_string *php_lookup_class_name(zval *object) /* {{{ php_store_class_name */ -PHPAPI void php_store_class_name(zval *object, const char *name, uint32_t len) +PHPAPI void php_store_class_name(zval *object, const char *name, size_t len) { zval val; TSRMLS_FETCH(); diff --git a/ext/standard/php_incomplete_class.h b/ext/standard/php_incomplete_class.h index 177e960765c..fa2747f3bfd 100644 --- a/ext/standard/php_incomplete_class.h +++ b/ext/standard/php_incomplete_class.h @@ -54,7 +54,7 @@ extern "C" { PHPAPI zend_class_entry *php_create_incomplete_class(TSRMLS_D); PHPAPI zend_string *php_lookup_class_name(zval *object); -PHPAPI void php_store_class_name(zval *object, const char *name, uint32_t len); +PHPAPI void php_store_class_name(zval *object, const char *name, size_t len); #ifdef __cplusplus }; From 5400f92c751a78452a4cf74b7b25e30b2508bf56 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 18 Nov 2014 15:38:35 +0100 Subject: [PATCH 395/398] proper dllexport --- ext/standard/php_fopen_wrapper.c | 2 +- ext/standard/php_fopen_wrappers.h | 4 ++-- main/streams/plain_wrapper.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/standard/php_fopen_wrapper.c b/ext/standard/php_fopen_wrapper.c index 1989a2eabc8..8026b08d451 100644 --- a/ext/standard/php_fopen_wrapper.c +++ b/ext/standard/php_fopen_wrapper.c @@ -418,7 +418,7 @@ static php_stream_wrapper_ops php_stdio_wops = { NULL /* rmdir */ }; -php_stream_wrapper php_stream_php_wrapper = { +PHPAPI php_stream_wrapper php_stream_php_wrapper = { &php_stdio_wops, NULL, 0, /* is_url */ diff --git a/ext/standard/php_fopen_wrappers.h b/ext/standard/php_fopen_wrappers.h index 084efc291c8..6d6a5bde27d 100644 --- a/ext/standard/php_fopen_wrappers.h +++ b/ext/standard/php_fopen_wrappers.h @@ -27,7 +27,7 @@ php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, const char *pa php_stream *php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); extern PHPAPI php_stream_wrapper php_stream_http_wrapper; extern PHPAPI php_stream_wrapper php_stream_ftp_wrapper; -extern php_stream_wrapper php_stream_php_wrapper; -extern php_stream_wrapper php_plain_files_wrapper; +extern PHPAPI php_stream_wrapper php_stream_php_wrapper; +extern PHPAPI php_stream_wrapper php_plain_files_wrapper; #endif diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 1aa01f270d5..8590647818f 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -1399,7 +1399,7 @@ static php_stream_wrapper_ops php_plain_files_wrapper_ops = { php_plain_files_metadata }; -php_stream_wrapper php_plain_files_wrapper = { +PHPAPI php_stream_wrapper php_plain_files_wrapper = { &php_plain_files_wrapper_ops, NULL, 0 From 9a43410871c76f9b3e712295ff49fa1f832ab17e Mon Sep 17 00:00:00 2001 From: David Zuelke Date: Sat, 8 Nov 2014 17:22:54 -0500 Subject: [PATCH 396/398] Fixed bug #68381 Set FPM log level earlier during init MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The log level will be ignored throughout log events in fpm_unix_init_main, until the very end when zlog_set_level is finally called. In particular, fpm_unix_conf_wp may throw notices like this: > [08-Nov-2014 17:13:36] NOTICE: [pool www] 'user' directive is ignored when… Which will still appear even if log_level in php-fpm.conf is set to warning+ --- sapi/fpm/fpm/fpm_unix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sapi/fpm/fpm/fpm_unix.c b/sapi/fpm/fpm/fpm_unix.c index 68978ee75d1..c29e28f8867 100644 --- a/sapi/fpm/fpm/fpm_unix.c +++ b/sapi/fpm/fpm/fpm_unix.c @@ -266,6 +266,8 @@ int fpm_unix_init_main() /* {{{ */ struct fpm_worker_pool_s *wp; int is_root = !geteuid(); + zlog_set_level(fpm_globals.log_level); + if (fpm_global_config.rlimit_files) { struct rlimit r; @@ -396,7 +398,6 @@ int fpm_unix_init_main() /* {{{ */ } } - zlog_set_level(fpm_globals.log_level); return 0; } /* }}} */ From f164df0b7b014674c3c8e0a769d6892a725c6094 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 18 Nov 2014 17:44:53 +0100 Subject: [PATCH 397/398] add test for bug #68381 --- sapi/fpm/tests/013.phpt | 54 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 sapi/fpm/tests/013.phpt diff --git a/sapi/fpm/tests/013.phpt b/sapi/fpm/tests/013.phpt new file mode 100644 index 00000000000..8d6a9d1d856 --- /dev/null +++ b/sapi/fpm/tests/013.phpt @@ -0,0 +1,54 @@ +--TEST-- +FPM: Test for log_level in fpm_unix_init_main #68381 +--SKIPIF-- + +--FILE-- + +Done +--EXPECTF-- +Started +Done +--CLEAN-- + \ No newline at end of file From c40e665ecd32806c2b01e601867a788dd324dc1f Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 18 Nov 2014 17:45:12 +0100 Subject: [PATCH 398/398] NEWS --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 620940d5094..53f3dfabe4e 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,8 @@ PHP NEWS . Fixed bug #68421 (access.format='%R' doesn't log ipv6 address). (Remi) . Fixed bug #68423 (PHP-FPM will no longer load all pools). (Remi) . Fixed bug #68428 (listen.allowed_clients is IPv4 only). (Remi) + . Fixed bug #68381 (fpm_unix_init_main ignores log_level). + (David Zuelke, Remi) GMP: . Fixed bug #68419 (build error with gmp 4.1). (Remi)