Projects
home:rottame:vhosts-ng:php8-extensions
php8-xdebug
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 4
View file
php8-xdebug.changes
Changed
@@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Fri May 31 14:36:41 UTC 2024 - Angelo Grossini <angelo@intercom.it> + +- update to 3.3.2 + +------------------------------------------------------------------- Wed Aug 16 12:46:25 UTC 2023 - Angelo Grossini <rottame@intercom.it> - vhng versioning
View file
php8-xdebug.spec
Changed
@@ -19,7 +19,7 @@ %define pkg_name xdebug %define pkg_version %{version} Name: php8-%{pkg_name} -Version: 3.2.0 +Version: 3.3.2 Release: 0 Summary: Extended PHP debugger License: PHP-3.0
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/CONTRIBUTING.rst
Deleted
@@ -1,108 +0,0 @@ -Contributing -============ - -Xdebug is hosted on Github. The source code can be browsed there and can be -checked out with:: - - git clone git://github.com/xdebug/xdebug.git - -If you think you want to fix a bug or work on a new feature, then you need to -follow the instructions below. Please reach out first to discuss your -suggested changes as well. - -Initial Set-up --------------- - -- Fork Xdebug on GitHub. -- Make sure you have configured your Author Name and Author Email with GIT. - Xdebug doesn't accept contributions from accounts with unnatural names. -- Clone the repository:: - - git clone git@github.com:{your username}/xdebug.git - -- Change into the ``xdebug`` repository:: - - cd xdebug - -- Add the original repository as ``upstream`` remote:: - - git remote add upstream git://github.com/xdebug/xdebug.git - git fetch upstream - -- Add a tracking branch for Xdebug 3.1:: - - git checkout --track origin/xdebug_3_1 - -Branches --------- - -There are two branches in operation: - -``master`` - This is were all new feature Pull Requests should be targeted at -``xdebug_3_1`` - This is were all bug fix Pull Requests should be targeted at. The - maintainer will add them to ``master`` too when merging the Pull Request. - -Working on a Pull Request -------------------------- - -- Make sure that your ``master`` and ``xdebug_3_1`` branches are up to date - with the ``upstream`` repository. -- Create an issue in the `issue tracker <https://bugs.xdebug.org>`_ (if none - exists yet). -- Switch to the right target branch (``master`` for features, ``xdebug_3_1`` - for bug fixes). -- Create a feature branch:: - - git checkout -b issue{issue number}-{description} - - For example:: - - git checkout -b issue1893-crash-with-fiber - -- For a bug fix, write one or more test cases to verify that the problem - currently exists, and also to define what the output should be. Xdebug uses - PHP's `phpt tests <https://qa.php.net/write-test.php>`_. The ``README.rst`` - file contains information on how to run the tests. - - Each of Xdebug's modes has a specific directory where to place tests. For - example, for code coverage that is ``tests/coverage``. Test case names - should follow the following pattern:: - - tests/{feature-group}bug0{issue-number}.phpt - - If you need more than one test, append ``-001`` after the issue number. - - Pull Requests without tests won't be accepted. - -- Fix and/or write the code. - -- Before you submit a PR, make sure each commit is a single logical unit. The - main commit that implements the issue, should have as commit message ``Fixed - issue #1893: `` followed by the Summary of the issue in the issue tracker. The - message should state what the change was about. For example:: - - Fixed issue #1893: Crash with ext-fiber with xdebug.mode=coverage - -- Before you submit a PR, make sure to rebase first on the branch that you - will be targeting, for example to rebase against the current bug fix - branch:: - - git fetch upstream && git rebase upstream/xdebug_3_1 - -- Push your changes to your remote repository:: - - git push origin {branch-name} - - For example:: - - git push origin issue1893-crash-with-fiber - -- Once you're satisfied, generate a pull request. Make sure that the title is - in one line, it's fine if it's a few characters larger than what GitHub - likes. Do not let the title spill over into the description with ``...```. - - In the description, explain what you changed, and why, and how your solution - is the right one. Feel free to include questions, and pointers to specific - things that need close review.
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/LICENSE
Deleted
@@ -1,60 +0,0 @@ --------------------------------------------------------------------- - The Xdebug License, version 1.02 - (Based on "The PHP License", version 3.0) - Copyright (c) 2003-2018 Derick Rethans. All rights reserved. --------------------------------------------------------------------- - -Redistribution and use in source and binary forms, with or without -modification, is permitted provided that the following conditions -are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - 3. The name "Xdebug" must not be used to endorse or promote products - derived from this software without prior written permission. For - written permission, please contact derick@xdebug.org. - - 4. Products derived from this software may not be called "Xdebug", nor - may "Xdebug" appear in their name, without prior written permission - from derick@xdebug.org. - - 5. Derick Rethans may publish revised and/or new versions of the - license from time to time. Each version will be given a - distinguishing version number. Once covered code has been - published under a particular version of the license, you may - always continue to use it under the terms of that version. You - may also choose to use such covered code under the terms of any - subsequent version of the license published by Derick Rethans. No - one other than Derick Rethans has the right to modify the terms - applicable to covered code created under this License. - - 6. Redistributions of any form whatsoever must retain the following - acknowledgment: "This product includes Xdebug, freely available - from <https://xdebug.org/>". - -THIS SOFTWARE IS PROVIDED BY DERICK RETHANS ``AS IS'' AND ANY -EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP DEVELOPMENT TEAM OR -ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - --------------------------------------------------------------------- - -This software consists of voluntary contributions made by some -individuals on behalf of Derick Rethans. - -Derick Rethans can be contacted via e-mail at derick@xdebug.org. - -For more information Xdebug, please see <https://xdebug.org>.
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/config.m4
Deleted
@@ -1,133 +0,0 @@ -dnl config.m4 for extension Xdebug - -PHP_ARG_ENABLE(xdebug, whether to enable Xdebug support, - --enable-xdebug Enable Xdebug support) - -PHP_ARG_ENABLE(xdebug-dev, whether to enable Xdebug developer build flags, - --enable-xdebug-dev Xdebug: Enable developer flags,, no) - -PHP_ARG_WITH(xdebug-compression, whether to compress profiler files (requires zlib), - --without-xdebug-compression Xdebug: Disable compression through zlib,yes,no) - -m4_include(m4/pkg.m4) -m4_include(m4/clocks.m4) - -if test "$PHP_XDEBUG" != "no"; then - AC_MSG_CHECKING(Check for supported PHP versions) - PHP_XDEBUG_FOUND_VERSION=`${PHP_CONFIG} --version` - PHP_XDEBUG_FOUND_VERNUM=`echo "${PHP_XDEBUG_FOUND_VERSION}" | $AWK 'BEGIN { FS = "."; } { printf "%d", ($1 * 100 + $2) * 100 + $3;}'` - if test "$PHP_XDEBUG_FOUND_VERNUM" -lt "80000"; then - AC_MSG_ERROR(not supported. Need a PHP version >= 8.0.0 and < 8.3.0 (found $PHP_XDEBUG_FOUND_VERSION)) - else - if test "$PHP_XDEBUG_FOUND_VERNUM" -ge "80300"; then - AC_MSG_ERROR(not supported. Need a PHP version >= 8.0.0 and < 8.3.0 (found $PHP_XDEBUG_FOUND_VERSION)) - else - AC_MSG_RESULT(supported ($PHP_XDEBUG_FOUND_VERSION)) - fi - fi - - AC_DEFINE(HAVE_XDEBUG,1, ) - - old_CPPFLAGS=$CPPFLAGS - CPPFLAGS="$INCLUDES $CPPFLAGS" - - AC_XDEBUG_CLOCK - - AC_CHECK_HEADERS(netinet/in.h poll.h sys/poll.h) - case $host_os in - linux*) - AC_CHECK_HEADERS(linux/rtnetlink.h, , - case $host_os in - linux-musl*) - AC_MSG_ERROR(rtnetlink.h is required, install the linux-headers package: apk add --update linux-headers) - esac - AC_MSG_ERROR(rtnetlink.h is required, please make sure it is available by installing the correct package) - ) - esac - - PHP_CHECK_FUNC(res_ninit, resolv) - PHP_CHECK_FUNC(res_nclose, resolv) - - PHP_CHECK_LIBRARY(m, cos, PHP_ADD_LIBRARY(m,, XDEBUG_SHARED_LIBADD) ) - - if test "$PHP_XDEBUG_COMPRESSION" != "no"; then - PKG_CHECK_MODULES(ZLIB, zlib >= 1.2.9, - PHP_EVAL_LIBLINE($ZLIB_LIBS, XDEBUG_SHARED_LIBADD) - PHP_EVAL_INCLINE($ZLIB_CFLAGS) - - AC_DEFINE(HAVE_XDEBUG_ZLIB,1, ) - , ) - fi - - CPPFLAGS=$old_CPPFLAGS - - if test "$PHP_XDEBUG_DEV" = "yes"; then - AX_CHECK_COMPILE_FLAG(-Wbool-conversion, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wbool-conversion") - AX_CHECK_COMPILE_FLAG(-Wdeclaration-after-statement, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wdeclaration-after-statement") - AX_CHECK_COMPILE_FLAG(-Wdiscarded-qualifiers, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wdiscarded-qualifiers") - AX_CHECK_COMPILE_FLAG(-Wduplicate-enum, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wduplicate-enum") - AX_CHECK_COMPILE_FLAG(-Wempty-body, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wempty-body") - AX_CHECK_COMPILE_FLAG(-Wenum-compare, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wenum-compare") - AX_CHECK_COMPILE_FLAG(-Werror, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Werror") - AX_CHECK_COMPILE_FLAG(-Wextra, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wextra") - AX_CHECK_COMPILE_FLAG(-Wformat-nonliteral, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wformat-nonliteral") - AX_CHECK_COMPILE_FLAG(-Wformat-security, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wformat-security") - AX_CHECK_COMPILE_FLAG(-Wheader-guard, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wheader-guard") - AX_CHECK_COMPILE_FLAG(-Wincompatible-pointer-types-discards-qualifiers, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wincompatible-pointer-types-discards-qualifiers") - AX_CHECK_COMPILE_FLAG(-Wimplicit-fallthrough, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wimplicit-fallthrough") - AX_CHECK_COMPILE_FLAG(-Winit-self, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Winit-self") - AX_CHECK_COMPILE_FLAG(-Wlogical-not-parentheses, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wlogical-not-parentheses") - AX_CHECK_COMPILE_FLAG(-Wlogical-op, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wlogical-op") - AX_CHECK_COMPILE_FLAG(-Wlogical-op-parentheses, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wlogical-op-parentheses") - AX_CHECK_COMPILE_FLAG(-Wloop-analysis, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wloop-analysis") - AX_CHECK_COMPILE_FLAG(-Wmaybe-uninitialized, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wmaybe-uninitialized") - AX_CHECK_COMPILE_FLAG(-Wmissing-format-attribute, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wmissing-format-attribute") - AX_CHECK_COMPILE_FLAG(-Wno-missing-field-initializers, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wno-missing-field-initializers") - AX_CHECK_COMPILE_FLAG(-Wno-sign-compare, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wno-sign-compare") - AX_CHECK_COMPILE_FLAG(-Wno-unused-but-set-variable, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wno-unused-but-set-variable") - AX_CHECK_COMPILE_FLAG(-Wno-unused-parameter, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wno-unused-parameter") - AX_CHECK_COMPILE_FLAG(-Wno-variadic-macros, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wno-variadic-macros") - AX_CHECK_COMPILE_FLAG(-Wparentheses, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wparentheses") - AX_CHECK_COMPILE_FLAG(-Wpointer-bool-conversion, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wpointer-bool-conversion") - AX_CHECK_COMPILE_FLAG(-Wsizeof-array-argument, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wsizeof-array-argument") - AX_CHECK_COMPILE_FLAG(-Wstring-conversion, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wstring-conversion") - AX_CHECK_COMPILE_FLAG(-Wwrite-strings, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wwrite-strings") - AX_CHECK_COMPILE_FLAG(-Wpointer-arith, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wpointer-arith") - AX_CHECK_COMPILE_FLAG(-fdiagnostics-show-option, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fdiagnostics-show-option") - AX_CHECK_COMPILE_FLAG(-fno-exceptions, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fno-exceptions") - AX_CHECK_COMPILE_FLAG(-fno-omit-frame-pointer, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fno-omit-frame-pointer") - AX_CHECK_COMPILE_FLAG(-fno-optimize-sibling-calls, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fno-optimize-sibling-calls") - AX_CHECK_COMPILE_FLAG(-fsanitize-address, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fsanitize-address") - AX_CHECK_COMPILE_FLAG(-fstack-protector, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fstack-protector") - - MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS" - STD_CFLAGS="-g -O0 -Wall" - fi - - PHP_XDEBUG_CFLAGS="$STD_CFLAGS $MAINTAINER_CFLAGS" - - XDEBUG_BASE_SOURCES="src/base/base.c src/base/filter.c" - XDEBUG_LIB_SOURCES="src/lib/usefulstuff.c src/lib/compat.c src/lib/crc32.c src/lib/file.c src/lib/hash.c src/lib/headers.c src/lib/lib.c src/lib/llist.c src/lib/log.c src/lib/set.c src/lib/str.c src/lib/timing.c src/lib/var.c src/lib/var_export_html.c src/lib/var_export_line.c src/lib/var_export_text.c src/lib/var_export_xml.c src/lib/xml.c" - - XDEBUG_COVERAGE_SOURCES="src/coverage/branch_info.c src/coverage/code_coverage.c" - XDEBUG_DEBUGGER_SOURCES="src/debugger/com.c src/debugger/debugger.c src/debugger/handler_dbgp.c src/debugger/handlers.c src/debugger/ip_info.c" - XDEBUG_DEVELOP_SOURCES="src/develop/develop.c src/develop/monitor.c src/develop/php_functions.c src/develop/stack.c src/develop/superglobals.c" - XDEBUG_GCSTATS_SOURCES="src/gcstats/gc_stats.c" - XDEBUG_PROFILER_SOURCES="src/profiler/profiler.c" - XDEBUG_TRACING_SOURCES="src/tracing/trace_computerized.c src/tracing/trace_html.c src/tracing/trace_textual.c src/tracing/tracing.c" - - PHP_NEW_EXTENSION(xdebug, xdebug.c $XDEBUG_BASE_SOURCES $XDEBUG_LIB_SOURCES $XDEBUG_COVERAGE_SOURCES $XDEBUG_DEBUGGER_SOURCES $XDEBUG_DEVELOP_SOURCES $XDEBUG_GCSTATS_SOURCES $XDEBUG_PROFILER_SOURCES $XDEBUG_TRACING_SOURCES, $ext_shared,,$PHP_XDEBUG_CFLAGS,,yes) - PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(xdebug)/src/base) - PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(xdebug)/src/lib) - PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(xdebug)/src/coverage) - PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(xdebug)/src/debugger) - PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(xdebug)/src/develop) - PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(xdebug)/src/gcstats) - PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(xdebug)/src/profiler) - PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(xdebug)/src/tracing) - PHP_SUBST(XDEBUG_SHARED_LIBADD) - PHP_ADD_MAKEFILE_FRAGMENT - - PHP_ADD_INCLUDE($ext_srcdir/src) - PHP_ADD_INCLUDE($ext_builddir/src) -fi
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/config.w32
Deleted
@@ -1,49 +0,0 @@ -// vim:ft=javascript - -ARG_WITH("xdebug", "Xdebug support", "no"); - -ARG_WITH("xdebug-compression", "whether to compress profiler files (requires zlib)", "no"); - -if (PHP_XDEBUG != 'no') { - var XDEBUG_BASE_SOURCES="base.c filter.c" - var XDEBUG_LIB_SOURCES="usefulstuff.c compat.c crc32.c file.c hash.c headers.c lib.c llist.c log.c set.c str.c timing.c var.c var_export_html.c var_export_line.c var_export_text.c var_export_xml.c xml.c" - - var XDEBUG_COVERAGE_SOURCES="branch_info.c code_coverage.c" - var XDEBUG_DEBUGGER_SOURCES="com.c debugger.c handler_dbgp.c handlers.c" - var XDEBUG_DEVELOP_SOURCES="develop.c monitor.c php_functions.c stack.c superglobals.c" - var XDEBUG_GCSTATS_SOURCES="gc_stats.c" - var XDEBUG_PROFILER_SOURCES="profiler.c" - var XDEBUG_TRACING_SOURCES="trace_computerized.c trace_html.c trace_textual.c tracing.c" - - var files = "xdebug.c"; - - if (typeof(ZEND_EXTENSION) == 'undefined') { - EXTENSION('xdebug', files); - } else { - ZEND_EXTENSION('xdebug', files); - } - ADD_FLAG("CFLAGS_XDEBUG", " /I " + configure_module_dirname + " "); - ADD_FLAG("CFLAGS_XDEBUG", " /I " + configure_module_dirname + "/src "); - ADD_SOURCES(configure_module_dirname + "/src/base", XDEBUG_BASE_SOURCES, "xdebug"); - ADD_SOURCES(configure_module_dirname + "/src/lib", XDEBUG_LIB_SOURCES, "xdebug"); - ADD_SOURCES(configure_module_dirname + "/src/coverage", XDEBUG_COVERAGE_SOURCES, "xdebug"); - ADD_SOURCES(configure_module_dirname + "/src/debugger", XDEBUG_DEBUGGER_SOURCES, "xdebug"); - ADD_SOURCES(configure_module_dirname + "/src/develop", XDEBUG_DEVELOP_SOURCES, "xdebug"); - ADD_SOURCES(configure_module_dirname + "/src/gcstats", XDEBUG_GCSTATS_SOURCES, "xdebug"); - ADD_SOURCES(configure_module_dirname + "/src/profiler", XDEBUG_PROFILER_SOURCES, "xdebug"); - ADD_SOURCES(configure_module_dirname + "/src/tracing", XDEBUG_TRACING_SOURCES, "xdebug"); - - // PHP_ZLIB is "yes"/"no" for in-tree builds, but boolean for phpize builds - var XDEBUG_ZLIB = (!MODE_PHPIZE && PHP_ZLIB == "yes") || (MODE_PHPIZE && PHP_ZLIB); - - if (PHP_XDEBUG_COMPRESSION != "no") { - if (((!XDEBUG_ZLIB) && (CHECK_LIB("zlib_a.lib;zlib.lib", "xdebug", PHP_XDEBUG))) || - (PHP_ZLIB_SHARED && CHECK_LIB("zlib.lib", "xdebug", PHP_XDEBUG)) || - (XDEBUG_ZLIB && (!PHP_ZLIB_SHARED)) - ) { - AC_DEFINE('HAVE_XDEBUG_ZLIB', 1); - } - } - - AC_DEFINE("HAVE_XDEBUG", 1, "Xdebug support"); -}
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/php_xdebug.h
Deleted
@@ -1,111 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#ifndef PHP_XDEBUG_H -#define PHP_XDEBUG_H - -#define XDEBUG_NAME "Xdebug" -#define XDEBUG_VERSION "3.2.0" -#define XDEBUG_AUTHOR "Derick Rethans" -#define XDEBUG_COPYRIGHT "Copyright (c) 2002-2022 by Derick Rethans" -#define XDEBUG_COPYRIGHT_SHORT "Copyright (c) 2002-2022" -#define XDEBUG_URL "https://xdebug.org" -#define XDEBUG_URL_FAQ "https://xdebug.org/docs/faq#api" - -#include "lib/php-header.h" - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "base/base_globals.h" -#include "coverage/branch_info.h" -#include "coverage/code_coverage.h" -#include "debugger/debugger.h" -#include "develop/develop.h" -#include "lib/lib.h" -#include "gcstats/gc_stats.h" -#include "profiler/profiler.h" -#include "tracing/tracing.h" -#include "lib/compat.h" -#include "lib/hash.h" -#include "lib/llist.h" -#include "lib/vector.h" -#include "lib/timing.h" - -extern zend_module_entry xdebug_module_entry; -#define phpext_xdebug_ptr &xdebug_module_entry - -#define OUTPUT_NOT_CHECKED -1 -#define OUTPUT_IS_TTY 1 -#define OUTPUT_NOT_TTY 0 - -#ifdef PHP_WIN32 -#define PHP_XDEBUG_API __declspec(dllexport) -#else -#define PHP_XDEBUG_API -#endif - -#ifdef ZTS -#include "TSRM.h" -#endif - -#include "main/SAPI.h" - -#define XDEBUG_ALLOWED_HALT_LEVELS (E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE ) - -PHP_MINIT_FUNCTION(xdebug); -PHP_MSHUTDOWN_FUNCTION(xdebug); -PHP_RINIT_FUNCTION(xdebug); -PHP_RSHUTDOWN_FUNCTION(xdebug); -PHP_MINFO_FUNCTION(xdebug); -ZEND_MODULE_POST_ZEND_DEACTIVATE_D(xdebug); - -int xdebug_is_output_tty(); - -ZEND_BEGIN_MODULE_GLOBALS(xdebug) - struct { - xdebug_base_globals_t base; - xdebug_coverage_globals_t coverage; - xdebug_debugger_globals_t debugger; - xdebug_develop_globals_t develop; - xdebug_gc_stats_globals_t gc_stats; - xdebug_library_globals_t library; - xdebug_profiler_globals_t profiler; - xdebug_tracing_globals_t tracing; - } globals; - struct { - xdebug_base_settings_t base; - xdebug_coverage_settings_t coverage; - xdebug_debugger_settings_t debugger; - xdebug_develop_settings_t develop; - xdebug_gc_stats_settings_t gc_stats; - xdebug_library_settings_t library; - xdebug_profiler_settings_t profiler; - xdebug_tracing_settings_t tracing; - } settings; -ZEND_END_MODULE_GLOBALS(xdebug) - -#ifdef ZTS -#define XG(v) TSRMG(xdebug_globals_id, zend_xdebug_globals *, v) -#else -#define XG(v) (xdebug_globals.v) -#endif - -#define XG_BASE(v) (XG(globals.base.v)) -#define XINI_BASE(v) (XG(settings.base.v)) - -#endif
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/php_xdebug_arginfo.h
Deleted
@@ -1,208 +0,0 @@ -/* This is a generated file, edit the .stub.php file instead. - * Stub hash: e2f05d239588b29ea35befb55344d8df126d8c12 */ - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_xdebug_break, 0, 0, _IS_BOOL, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_xdebug_call_class, 0, 0, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, depth, IS_LONG, 0, "2") -ZEND_END_ARG_INFO() - -#define arginfo_xdebug_call_file arginfo_xdebug_call_class - -#define arginfo_xdebug_call_function arginfo_xdebug_call_class - -#define arginfo_xdebug_call_line arginfo_xdebug_call_class - -#define arginfo_xdebug_code_coverage_started arginfo_xdebug_break - -#define arginfo_xdebug_connect_to_client arginfo_xdebug_break - -ZEND_BEGIN_ARG_INFO_EX(arginfo_xdebug_debug_zval, 0, 0, 0) - ZEND_ARG_VARIADIC_TYPE_INFO(0, varname, IS_STRING, 0) -ZEND_END_ARG_INFO() - -#define arginfo_xdebug_debug_zval_stdout arginfo_xdebug_debug_zval - -ZEND_BEGIN_ARG_INFO_EX(arginfo_xdebug_dump_superglobals, 0, 0, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_xdebug_get_code_coverage, 0, 0, IS_ARRAY, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_xdebug_get_collected_errors, 0, 0, IS_ARRAY, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, emptyList, _IS_BOOL, 0, "false") -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_xdebug_get_function_count, 0, 0, IS_LONG, 0) -ZEND_END_ARG_INFO() - -#define arginfo_xdebug_get_function_stack arginfo_xdebug_get_code_coverage - -#define arginfo_xdebug_get_gc_run_count arginfo_xdebug_get_function_count - -#define arginfo_xdebug_get_gc_total_collected_roots arginfo_xdebug_get_function_count - -#define arginfo_xdebug_get_gcstats_filename arginfo_xdebug_dump_superglobals - -#define arginfo_xdebug_get_headers arginfo_xdebug_get_code_coverage - -#define arginfo_xdebug_get_monitored_functions arginfo_xdebug_get_code_coverage - -#define arginfo_xdebug_get_profiler_filename arginfo_xdebug_dump_superglobals - -#define arginfo_xdebug_get_stack_depth arginfo_xdebug_get_function_count - -#define arginfo_xdebug_get_tracefile_name arginfo_xdebug_dump_superglobals - -ZEND_BEGIN_ARG_INFO_EX(arginfo_xdebug_info, 0, 0, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, category, IS_STRING, 0, "null") -ZEND_END_ARG_INFO() - -#define arginfo_xdebug_is_debugger_active arginfo_xdebug_break - -#define arginfo_xdebug_memory_usage arginfo_xdebug_get_function_count - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_xdebug_notify, 0, 1, _IS_BOOL, 0) - ZEND_ARG_TYPE_INFO(0, data, IS_MIXED, 0) -ZEND_END_ARG_INFO() - -#define arginfo_xdebug_peak_memory_usage arginfo_xdebug_get_function_count - -ZEND_BEGIN_ARG_INFO_EX(arginfo_xdebug_print_function_stack, 0, 0, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, message, IS_STRING, 0, "\"user triggered\"") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "0") -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_xdebug_set_filter, 0, 0, 3) - ZEND_ARG_TYPE_INFO(0, group, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, listType, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, configuration, IS_ARRAY, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_xdebug_start_code_coverage, 0, 0, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "0") -ZEND_END_ARG_INFO() - -#define arginfo_xdebug_start_error_collection arginfo_xdebug_dump_superglobals - -ZEND_BEGIN_ARG_INFO_EX(arginfo_xdebug_start_function_monitor, 0, 0, 1) - ZEND_ARG_TYPE_INFO(0, listOfFunctionsToMonitor, IS_ARRAY, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_xdebug_start_gcstats, 0, 0, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, gcstatsFile, IS_STRING, 1, "null") -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_xdebug_start_trace, 0, 0, IS_STRING, 1) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, traceFile, IS_STRING, 1, "null") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "0") -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_xdebug_stop_code_coverage, 0, 0, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, cleanUp, _IS_BOOL, 0, "true") -ZEND_END_ARG_INFO() - -#define arginfo_xdebug_stop_error_collection arginfo_xdebug_dump_superglobals - -#define arginfo_xdebug_stop_function_monitor arginfo_xdebug_dump_superglobals - -#define arginfo_xdebug_stop_gcstats arginfo_xdebug_dump_superglobals - -#define arginfo_xdebug_stop_trace arginfo_xdebug_dump_superglobals - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_xdebug_time_index, 0, 0, IS_DOUBLE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_xdebug_var_dump, 0, 0, 0) - ZEND_ARG_VARIADIC_TYPE_INFO(0, variable, IS_MIXED, 0) -ZEND_END_ARG_INFO() - - -ZEND_FUNCTION(xdebug_break); -ZEND_FUNCTION(xdebug_call_class); -ZEND_FUNCTION(xdebug_call_file); -ZEND_FUNCTION(xdebug_call_function); -ZEND_FUNCTION(xdebug_call_line); -ZEND_FUNCTION(xdebug_code_coverage_started); -ZEND_FUNCTION(xdebug_connect_to_client); -ZEND_FUNCTION(xdebug_debug_zval); -ZEND_FUNCTION(xdebug_debug_zval_stdout); -ZEND_FUNCTION(xdebug_dump_superglobals); -ZEND_FUNCTION(xdebug_get_code_coverage); -ZEND_FUNCTION(xdebug_get_collected_errors); -ZEND_FUNCTION(xdebug_get_function_count); -ZEND_FUNCTION(xdebug_get_function_stack); -ZEND_FUNCTION(xdebug_get_gc_run_count); -ZEND_FUNCTION(xdebug_get_gc_total_collected_roots); -ZEND_FUNCTION(xdebug_get_gcstats_filename); -ZEND_FUNCTION(xdebug_get_headers); -ZEND_FUNCTION(xdebug_get_monitored_functions); -ZEND_FUNCTION(xdebug_get_profiler_filename); -ZEND_FUNCTION(xdebug_get_stack_depth); -ZEND_FUNCTION(xdebug_get_tracefile_name); -ZEND_FUNCTION(xdebug_info); -ZEND_FUNCTION(xdebug_is_debugger_active); -ZEND_FUNCTION(xdebug_memory_usage); -ZEND_FUNCTION(xdebug_notify); -ZEND_FUNCTION(xdebug_peak_memory_usage); -ZEND_FUNCTION(xdebug_print_function_stack); -ZEND_FUNCTION(xdebug_set_filter); -ZEND_FUNCTION(xdebug_start_code_coverage); -ZEND_FUNCTION(xdebug_start_error_collection); -ZEND_FUNCTION(xdebug_start_function_monitor); -ZEND_FUNCTION(xdebug_start_gcstats); -ZEND_FUNCTION(xdebug_start_trace); -ZEND_FUNCTION(xdebug_stop_code_coverage); -ZEND_FUNCTION(xdebug_stop_error_collection); -ZEND_FUNCTION(xdebug_stop_function_monitor); -ZEND_FUNCTION(xdebug_stop_gcstats); -ZEND_FUNCTION(xdebug_stop_trace); -ZEND_FUNCTION(xdebug_time_index); -ZEND_FUNCTION(xdebug_var_dump); - - -static const zend_function_entry ext_functions = { - ZEND_FE(xdebug_break, arginfo_xdebug_break) - ZEND_FE(xdebug_call_class, arginfo_xdebug_call_class) - ZEND_FE(xdebug_call_file, arginfo_xdebug_call_file) - ZEND_FE(xdebug_call_function, arginfo_xdebug_call_function) - ZEND_FE(xdebug_call_line, arginfo_xdebug_call_line) - ZEND_FE(xdebug_code_coverage_started, arginfo_xdebug_code_coverage_started) - ZEND_FE(xdebug_connect_to_client, arginfo_xdebug_connect_to_client) - ZEND_FE(xdebug_debug_zval, arginfo_xdebug_debug_zval) - ZEND_FE(xdebug_debug_zval_stdout, arginfo_xdebug_debug_zval_stdout) - ZEND_FE(xdebug_dump_superglobals, arginfo_xdebug_dump_superglobals) - ZEND_FE(xdebug_get_code_coverage, arginfo_xdebug_get_code_coverage) - ZEND_FE(xdebug_get_collected_errors, arginfo_xdebug_get_collected_errors) - ZEND_FE(xdebug_get_function_count, arginfo_xdebug_get_function_count) - ZEND_FE(xdebug_get_function_stack, arginfo_xdebug_get_function_stack) - ZEND_FE(xdebug_get_gc_run_count, arginfo_xdebug_get_gc_run_count) - ZEND_FE(xdebug_get_gc_total_collected_roots, arginfo_xdebug_get_gc_total_collected_roots) - ZEND_FE(xdebug_get_gcstats_filename, arginfo_xdebug_get_gcstats_filename) - ZEND_FE(xdebug_get_headers, arginfo_xdebug_get_headers) - ZEND_FE(xdebug_get_monitored_functions, arginfo_xdebug_get_monitored_functions) - ZEND_FE(xdebug_get_profiler_filename, arginfo_xdebug_get_profiler_filename) - ZEND_FE(xdebug_get_stack_depth, arginfo_xdebug_get_stack_depth) - ZEND_FE(xdebug_get_tracefile_name, arginfo_xdebug_get_tracefile_name) - ZEND_FE(xdebug_info, arginfo_xdebug_info) - ZEND_FE(xdebug_is_debugger_active, arginfo_xdebug_is_debugger_active) - ZEND_FE(xdebug_memory_usage, arginfo_xdebug_memory_usage) - ZEND_FE(xdebug_notify, arginfo_xdebug_notify) - ZEND_FE(xdebug_peak_memory_usage, arginfo_xdebug_peak_memory_usage) - ZEND_FE(xdebug_print_function_stack, arginfo_xdebug_print_function_stack) - ZEND_FE(xdebug_set_filter, arginfo_xdebug_set_filter) - ZEND_FE(xdebug_start_code_coverage, arginfo_xdebug_start_code_coverage) - ZEND_FE(xdebug_start_error_collection, arginfo_xdebug_start_error_collection) - ZEND_FE(xdebug_start_function_monitor, arginfo_xdebug_start_function_monitor) - ZEND_FE(xdebug_start_gcstats, arginfo_xdebug_start_gcstats) - ZEND_FE(xdebug_start_trace, arginfo_xdebug_start_trace)
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/run-xdebug-tests.php
Deleted
@@ -1,4041 +0,0 @@ -#!/usr/bin/env php -<?php -/* - +----------------------------------------------------------------------+ - | Copyright (c) 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: | - | https://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: Ilia Alshanetsky <iliaa@php.net> | - | Preston L. Bannister <pbannister@php.net> | - | Marcus Boerger <helly@php.net> | - | Derick Rethans <derick@php.net> | - | Sander Roobol <sander@php.net> | - | Andrea Faulds <ajf@ajf.me> | - | (based on version by: Stig Bakken <ssb@php.net>) | - | (based on the PHP 3 test framework by Rasmus Lerdorf) | - +----------------------------------------------------------------------+ - */ - -/* $Id: ff8fc1a09b14846e2a5daa9b51cc2b6e97f3ac3c $ */ - -/* Temporary variables while this file is being refactored. */ -/** @var ?JUnit */ -$junit = null; - -/* End temporary variables. */ - -/* Let there be no top-level code beyond this point: - * Only functions and classes, thanks! - * - * Minimum required PHP version: 7.4.0 - */ - -function show_usage(): void -{ - echo <<<HELP -Synopsis: - php run-tests.php options files directories - -Options: - -j<workers> Run up to <workers> simultaneous testing processes in parallel for - quicker testing on systems with multiple logical processors. - Note that this is experimental feature. - - -l <file> Read the testfiles to be executed from <file>. After the test - has finished all failed tests are written to the same <file>. - If the list is empty and no further test is specified then - all tests are executed (same as: -r <file> -w <file>). - - -r <file> Read the testfiles to be executed from <file>. - - -w <file> Write a list of all failed tests to <file>. - - -a <file> Same as -w but append rather then truncating <file>. - - -W <file> Write a list of all tests and their result status to <file>. - - -c <file> Look for php.ini in directory <file> or use <file> as ini. - - -n Pass -n option to the php binary (Do not use a php.ini). - - -d foo=bar Pass -d option to the php binary (Define INI entry foo - with value 'bar'). - - -g Comma separated list of groups to show during test run - (possible values: PASS, FAIL, XFAIL, XLEAK, SKIP, BORK, WARN, LEAK, REDIRECT). - - -m Test for memory leaks with Valgrind (equivalent to -M memcheck). - - -M <tool> Test for errors with Valgrind tool. - - -p <php> Specify PHP executable to run. - - -P Use PHP_BINARY as PHP executable to run (default). - - -q Quiet, no user interaction (same as environment NO_INTERACTION). - - -s <file> Write output to <file>. - - -x Sets 'SKIP_SLOW_TESTS' environmental variable. - - --offline Sets 'SKIP_ONLINE_TESTS' environmental variable. - - --verbose - -v Verbose mode. - - --help - -h This Help. - - --temp-source <sdir> --temp-target <tdir> --temp-urlbase <url> - Write temporary files to <tdir> by replacing <sdir> from the - filenames to generate with <tdir>. In general you want to make - <sdir> the path to your source files and <tdir> some patch in - your web page hierarchy with <url> pointing to <tdir>. - - --keep-all|php|skip|after|clean - Do not delete 'all' files, 'php' test file, 'skip', 'after', - or 'clean' file. - - --set-timeout <n> - Set timeout for individual tests, where <n> is the number of - seconds. The default value is 60 seconds, or 300 seconds when - testing for memory leaks. - - --context <n> - Sets the number of lines of surrounding context to print for diffs. - The default value is 3. - - --show-all|php|skip|clean|after|exp|diff|out|mem - Show 'all' files, 'php' test file, 'skip', 'after', or 'clean' file. - You can also use this to show the output 'out', the expected result - 'exp', the difference between them 'diff' or the valgrind log - 'mem'. The result types get written independent of the log format, - however 'diff' only exists when a test fails. - - --show-slow <n> - Show all tests that took longer than <n> milliseconds to run. - - --no-clean Do not execute clean section if any. - - --color - --no-color Do/Don't colorize the result type in the test result. - - --repeat n - Run the tests multiple times in the same process and check the - output of the last execution (CLI SAPI only). - - --bless Bless failed tests using scripts/dev/bless_tests.php. - -HELP; -} - -/** - * One function to rule them all, one function to find them, one function to - * bring them all and in the darkness bind them. - * This is the entry point and exit point überfunction. It contains all the - * code that was previously found at the top level. It could and should be - * refactored to be smaller and more manageable. - */ -function main(): void -{ - /* This list was derived in a naïve mechanical fashion. If a member - * looks like it doesn't belong, it probably doesn't; cull at will. - */ - global $DETAILED, $PHP_FAILED_TESTS, $SHOW_ONLY_GROUPS, $argc, $argv, $cfg, - $cfgfiles, $cfgtypes, $conf_passed, $end_time, $environment, - $exts_skipped, $exts_tested, $exts_to_test, $failed_tests_file, - $ignored_by_ext, $ini_overwrites, $is_switch, $colorize, - $log_format, $matches, $no_clean, $no_file_cache, - $optionals, $pass_option_n, $pass_options, - $pattern_match, $php, $php_cgi, $phpdbg, $preload, $redir_tests, - $repeat, $result_tests_file, $slow_min_ms, $start_time, $switch, - $temp_source, $temp_target, $test_cnt, $test_dirs, - $test_files, $test_idx, $test_list, $test_results, $testfile, - $user_tests, $valgrind, $sum_results, $shuffle, $file_cache, $num_repeats, - $bless; - // Parallel testing - global $workers, $workerID; - global $context_line_count; - - // Temporary for the duration of refactoring - /** @var JUnit */ - global $junit; - - define('IS_WINDOWS', substr(PHP_OS, 0, 3) == "WIN"); - - $workerID = 0; - if (getenv("TEST_PHP_WORKER")) { - $workerID = intval(getenv("TEST_PHP_WORKER")); - run_worker(); - return; - } - - define('INIT_DIR', getcwd()); - - // Change into the PHP source directory. - if (getenv('TEST_PHP_SRCDIR')) { - @chdir(getenv('TEST_PHP_SRCDIR')); - } - - define('TEST_PHP_SRCDIR', getcwd()); - - check_proc_open_function_exists(); - - // If timezone is not set, use UTC. - if (ini_get('date.timezone') == '') { - date_default_timezone_set('UTC'); - } - - // Delete some security related environment variables - putenv('SSH_CLIENT=deleted'); - putenv('SSH_AUTH_SOCK=deleted'); - putenv('SSH_TTY=deleted');
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/base/base.c
Deleted
@@ -1,1530 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#include "lib/php-header.h" -#include "TSRM.h" -#include "php_globals.h" -#include "zend_closures.h" -#include "zend_exceptions.h" -#if PHP_VERSION_ID >= 80200 -# include "zend_attributes.h" -#endif - -#include "zend_interfaces.h" - -#if PHP_VERSION_ID >= 80100 -# include "base_private.h" -# include "Zend/zend_fibers.h" -# include "Zend/zend_observer.h" -#endif - -#include "php_xdebug.h" -#include "php_xdebug_arginfo.h" - -#include "base.h" -#include "filter.h" -#include "develop/develop.h" -#include "develop/stack.h" -#include "gcstats/gc_stats.h" -#include "lib/lib_private.h" -#include "lib/log.h" -#include "lib/var_export_line.h" -#include "lib/var.h" -#include "profiler/profiler.h" - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - -#if PHP_VERSION_ID >= 80100 -void (*xdebug_old_error_cb)(int type, zend_string *error_filename, const uint32_t error_lineno, zend_string *message); -void (*xdebug_new_error_cb)(int type, zend_string *error_filename, const uint32_t error_lineno, zend_string *message); -static void xdebug_error_cb(int orig_type, zend_string *error_filename, const uint32_t error_lineno, zend_string *message); -#else -void (*xdebug_old_error_cb)(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message); -void (*xdebug_new_error_cb)(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message); -static void xdebug_error_cb(int orig_type, const char *error_filename, const uint32_t error_lineno, zend_string *message); -#endif - -/* execution redirection functions */ -zend_op_array* (*old_compile_file)(zend_file_handle* file_handle, int type); -static void (*xdebug_old_execute_ex)(zend_execute_data *execute_data); -static void (*xdebug_old_execute_internal)(zend_execute_data *current_execute_data, zval *return_value); - -/* error_cb and execption hook overrides */ -void xdebug_base_use_original_error_cb(void); -void xdebug_base_use_xdebug_error_cb(void); -void xdebug_base_use_xdebug_throw_exception_hook(void); - -/* Forward declarations for function overides */ -PHP_FUNCTION(xdebug_set_time_limit); -PHP_FUNCTION(xdebug_error_reporting); -PHP_FUNCTION(xdebug_pcntl_exec); -PHP_FUNCTION(xdebug_pcntl_fork); - - -/* {{{ zend_op_array xdebug_compile_file (file_handle, type) - * This function provides a hook for the execution of bananas */ -static zend_op_array *xdebug_compile_file(zend_file_handle *file_handle, int type) -{ - zend_op_array *op_array; - - op_array = old_compile_file(file_handle, type); - - if (!op_array) { - return NULL; - } - - xdebug_coverage_compile_file(op_array); - xdebug_debugger_compile_file(op_array); - - return op_array; -} -/* }}} */ - -/* I don't like this API, but the function_stack_entry does not keep this as a - * pointer, and hence we need two APIs for freeing :-S */ -void xdebug_func_dtor_by_ref(xdebug_func *elem) -{ - if (elem->function) { - xdfree(elem->function); - } - if (elem->object_class) { - zend_string_release(elem->object_class); - } - if (elem->scope_class) { - zend_string_release(elem->scope_class); - } -} - -void xdebug_func_dtor(xdebug_func *elem) -{ - xdebug_func_dtor_by_ref(elem); - xdfree(elem); -} - -static void function_stack_entry_dtor(void *elem) -{ - unsigned int i; - function_stack_entry *e = elem; - - xdebug_func_dtor_by_ref(&e->function); - - if (e->filename) { - zend_string_release(e->filename); - } - - if (e->var) { - for (i = 0; i < e->varc; i++) { - if (e->vari.name) { - zend_string_release(e->vari.name); - } - zval_ptr_dtor(&(e->vari.data)); - } - xdfree(e->var); - } - - if (e->include_filename) { - zend_string_release(e->include_filename); - } - - if (e->declared_vars) { - xdebug_llist_destroy(e->declared_vars, NULL); - e->declared_vars = NULL; - } - - if (e->profile.call_list) { - xdebug_llist_destroy(e->profile.call_list, NULL); - e->profile.call_list = NULL; - } -} - -int xdebug_include_or_eval_handler(XDEBUG_OPCODE_HANDLER_ARGS) -{ - const zend_op *opline = execute_data->opline; - zval *inc_filename; - zval tmp_inc_filename; - int is_var; - - if (opline->extended_value != ZEND_EVAL) { - return xdebug_call_original_opcode_handler_if_set(opline->opcode, XDEBUG_OPCODE_HANDLER_ARGS_PASSTHRU); - } - - inc_filename = xdebug_get_zval(execute_data, opline->op1_type, &opline->op1, &is_var); - - /* If there is no inc_filename, we're just bailing out instead */ - if (!inc_filename) { - return xdebug_call_original_opcode_handler_if_set(opline->opcode, XDEBUG_OPCODE_HANDLER_ARGS_PASSTHRU); - } - - if (Z_TYPE_P(inc_filename) != IS_STRING) { - tmp_inc_filename = *inc_filename; - zval_copy_ctor(&tmp_inc_filename); - convert_to_string(&tmp_inc_filename); - inc_filename = &tmp_inc_filename; - } - - /* Now let's store this info */ - if (XG_BASE(last_eval_statement)) { - zend_string_release(XG_BASE(last_eval_statement)); - } - XG_BASE(last_eval_statement) = zend_string_init(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename), 0); - - if (inc_filename == &tmp_inc_filename) { - zval_dtor(&tmp_inc_filename); - } - - return xdebug_call_original_opcode_handler_if_set(opline->opcode, XDEBUG_OPCODE_HANDLER_ARGS_PASSTHRU); -} - -static int find_line_number_for_current_execute_point(zend_execute_data *edata) -{ - zend_execute_data *ptr = edata; - - while (ptr && (!ptr->func || !ZEND_USER_CODE(ptr->func->type))) { - ptr = ptr->prev_execute_data; - } - - if (ptr && ptr->opline) {
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/base/base_globals.h
Deleted
@@ -1,88 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#ifndef __XDEBUG_BASE_GLOBALS_H__ -#define __XDEBUG_BASE_GLOBALS_H__ - -#include "lib/hash.h" -#include "lib/llist.h" -#include "lib/vector.h" - - -#if PHP_WIN32 -typedef void (WINAPI *WIN_PRECISE_TIME_FUNC)(LPFILETIME); -#endif - -typedef struct _xdebug_nanotime_context { - uint64_t start_abs; - uint64_t last_abs; -#if PHP_WIN32 | HAVE_XDEBUG_CLOCK_GETTIME | HAVE_XDEBUG_CLOCK_GETTIME_NSEC_NP - uint64_t start_rel; - uint64_t last_rel; - int use_rel_time; -#endif -#if PHP_WIN32 - WIN_PRECISE_TIME_FUNC win_precise_time_func; - uint64_t win_freq; -#endif -} xdebug_nanotime_context; - - -typedef struct _xdebug_base_globals_t { - xdebug_vector *stack; -#if PHP_VERSION_ID >= 80100 - xdebug_hash *fiber_stacks; -#endif - xdebug_nanotime_context nanotime_context; - uint64_t start_nanotime; - unsigned int prev_memory; - zif_handler orig_set_time_limit_func; - zif_handler orig_error_reporting_func; - zif_handler orig_pcntl_exec_func; - zif_handler orig_pcntl_fork_func; - int output_is_tty; - zend_bool in_debug_info; - zend_long error_reporting_override; - zend_bool error_reporting_overridden; - unsigned int function_count; - zend_string *last_eval_statement; - char *last_exception_trace; - - /* in-execution checking */ - zend_bool in_execution; - zend_bool in_var_serialisation; - - /* Systemd Private Temp */ - char *private_tmp; - - /* filters */ - zend_long filter_type_code_coverage; - zend_long filter_type_stack; - zend_long filter_type_tracing; - xdebug_llist *filters_code_coverage; - xdebug_llist *filters_stack; - xdebug_llist *filters_tracing; - - /* PHP versions */ - const char *php_version_compile_time; - const char *php_version_run_time; -} xdebug_base_globals_t; - -typedef struct _xdebug_base_settings_t { - zend_long max_nesting_level; -} xdebug_base_settings_t; - -#endif // __XDEBUG_BASE_GLOBALS_H__
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/base/filter.c
Deleted
@@ -1,269 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2021 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ -#include "php_xdebug.h" - -#include "filter.h" - -#include "lib/lib.h" -#include "lib/log.h" - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - -int xdebug_is_stack_frame_filtered(int filter_type, function_stack_entry *fse) -{ - switch (filter_type) { - case XDEBUG_FILTER_CODE_COVERAGE: - return fse->filtered_code_coverage; - - case XDEBUG_FILTER_STACK: - return fse->filtered_stack; - - case XDEBUG_FILTER_TRACING: - return fse->filtered_tracing; - } - - return 0; -} - -int xdebug_is_top_stack_frame_filtered(int filter_type) -{ - function_stack_entry *fse; - fse = XDEBUG_VECTOR_TAIL(XG_BASE(stack)); - return xdebug_is_stack_frame_filtered(filter_type, fse); -} - -void xdebug_filter_register_constants(INIT_FUNC_ARGS) -{ - REGISTER_LONG_CONSTANT("XDEBUG_FILTER_CODE_COVERAGE", XDEBUG_FILTER_CODE_COVERAGE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XDEBUG_FILTER_STACK", XDEBUG_FILTER_STACK, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XDEBUG_FILTER_TRACING", XDEBUG_FILTER_TRACING, CONST_CS | CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("XDEBUG_FILTER_NONE", XDEBUG_FILTER_NONE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XDEBUG_PATH_INCLUDE", XDEBUG_PATH_INCLUDE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XDEBUG_PATH_EXCLUDE", XDEBUG_PATH_EXCLUDE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XDEBUG_NAMESPACE_INCLUDE", XDEBUG_NAMESPACE_INCLUDE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XDEBUG_NAMESPACE_EXCLUDE", XDEBUG_NAMESPACE_EXCLUDE, CONST_CS | CONST_PERSISTENT); -} - -static int xdebug_filter_match_path_include(function_stack_entry *fse, unsigned char *filtered_flag, char *filter) -{ - if (fse->filename && strncasecmp(filter, ZSTR_VAL(fse->filename), strlen(filter)) == 0) { - *filtered_flag = 0; - return 1; - } - return 0; -} - -static int xdebug_filter_match_path_exclude(function_stack_entry *fse, unsigned char *filtered_flag, char *filter) -{ - if (fse->filename && strncasecmp(filter, ZSTR_VAL(fse->filename), strlen(filter)) == 0) { - *filtered_flag = 1; - return 1; - } - return 0; -} - -static int xdebug_filter_match_namespace_include(function_stack_entry *fse, unsigned char *filtered_flag, char *filter) -{ - if (!fse->function.object_class && filter0 == '\0') { - *filtered_flag = 0; - return 1; - } - if (fse->function.object_class && filter0 != '\0' && strncasecmp(filter, ZSTR_VAL(fse->function.object_class), strlen(filter)) == 0) { - *filtered_flag = 0; - return 1; - } - return 0; -} - -static int xdebug_filter_match_namespace_exclude(function_stack_entry *fse, unsigned char *filtered_flag, char *filter) -{ - if (!fse->function.object_class && filter0 == '\0') { - *filtered_flag = 1; - return 1; - } - if (fse->function.object_class && filter0 != '\0' && strncasecmp(filter, ZSTR_VAL(fse->function.object_class), strlen(filter)) == 0) { - *filtered_flag = 1; - return 1; - } - return 0; -} - - -void xdebug_filter_run_internal(function_stack_entry *fse, int group, unsigned char *filtered_flag, int type, xdebug_llist *filters) -{ - xdebug_llist_element *le; - unsigned int k; - function_stack_entry tmp_fse; - int (*filter_to_run)(function_stack_entry *fse, unsigned char *filtered_flag, char *filter); - - le = XDEBUG_LLIST_HEAD(filters); - - switch (type) { - case XDEBUG_PATH_INCLUDE: - *filtered_flag = 1; - if (group == XDEBUG_FILTER_CODE_COVERAGE && fse->function.type & XFUNC_INCLUDES) { - tmp_fse.filename = fse->include_filename; - fse = &tmp_fse; - } - - filter_to_run = xdebug_filter_match_path_include; - break; - - case XDEBUG_PATH_EXCLUDE: - *filtered_flag = 0; - if (group == XDEBUG_FILTER_CODE_COVERAGE && fse->function.type & XFUNC_INCLUDES) { - tmp_fse.filename = fse->include_filename; - fse = &tmp_fse; - } - - filter_to_run = xdebug_filter_match_path_exclude; - break; - - case XDEBUG_NAMESPACE_INCLUDE: - *filtered_flag = 1; - filter_to_run = xdebug_filter_match_namespace_include; - break; - - case XDEBUG_NAMESPACE_EXCLUDE: - *filtered_flag = 0; - filter_to_run = xdebug_filter_match_namespace_exclude; - break; - - default: - /* Logically can't happen, but compilers can't detect that */ - return; - } - - for (k = 0; k < filters->size; k++, le = XDEBUG_LLIST_NEXT(le)) { - char *filter = XDEBUG_LLIST_VALP(le); - - /* If the filter matched once, we're done */ - if (filter_to_run(fse, filtered_flag, filter)) { - break; - } - } -} - -void xdebug_filter_run(function_stack_entry *fse) -{ - fse->filtered_stack = 0; - fse->filtered_tracing = 0; - - if (XG_BASE(filter_type_stack) != XDEBUG_FILTER_NONE) { - xdebug_filter_run_internal(fse, XDEBUG_FILTER_STACK, &fse->filtered_stack, XG_BASE(filter_type_stack), XG_BASE(filters_stack)); - } - if (XG_BASE(filter_type_tracing) != XDEBUG_FILTER_NONE) { - xdebug_filter_run_internal(fse, XDEBUG_FILTER_TRACING, &fse->filtered_tracing, XG_BASE(filter_type_tracing), XG_BASE(filters_tracing)); - } -} - -/* {{{ proto void xdebug_set_filter(int group, int type, array filters) - This function configures filters for tracing and code coverage */ -PHP_FUNCTION(xdebug_set_filter) -{ - zend_long filter_group; - zend_long filter_type; - xdebug_llist **filter_list; - zval *filters, *item; - - if (zend_parse_parameters(ZEND_NUM_ARGS(), "lla", &filter_group, &filter_type, &filters) == FAILURE) { - return; - } - - switch (filter_group) { - case XDEBUG_FILTER_CODE_COVERAGE: - if (!XDEBUG_MODE_IS(XDEBUG_MODE_COVERAGE)) { - xdebug_log_ex(XLOG_CHAN_BASE, XLOG_WARN, "COV-FILTER", "Can not set a filter for code coverage, because Xdebug mode does not include 'coverage'"); - return; - } - - filter_list = &XG_BASE(filters_code_coverage); - XG_BASE(filter_type_code_coverage) = XDEBUG_FILTER_NONE; - if (filter_type == XDEBUG_NAMESPACE_INCLUDE || filter_type == XDEBUG_NAMESPACE_EXCLUDE) { - php_error(E_WARNING, "The code coverage filter (XDEBUG_FILTER_CODE_COVERAGE) only supports the XDEBUG_PATH_INCLUDE, XDEBUG_PATH_EXCLUDE, and XDEBUG_FILTER_NONE filter types"); - return; - }
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/coverage/code_coverage.c
Deleted
@@ -1,1186 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2021 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#include "php_xdebug.h" -#include "zend_extensions.h" - -#include "branch_info.h" -#include "code_coverage_private.h" - -#include "base/base.h" -#include "base/filter.h" -#include "lib/compat.h" -#include "lib/set.h" -#include "lib/var.h" -#include "tracing/tracing.h" - -/* True globals */ -int zend_xdebug_filter_offset = -1; -int zend_xdebug_cc_run_offset = -1; - -extern ZEND_DECLARE_MODULE_GLOBALS(xdebug); - -static void xdebug_coverage_line_dtor(void *data) -{ - xdebug_coverage_line *line = (xdebug_coverage_line *) data; - - xdfree(line); -} - -xdebug_coverage_file *xdebug_coverage_file_ctor(zend_string *filename) -{ - xdebug_coverage_file *file; - - file = xdmalloc(sizeof(xdebug_coverage_file)); - file->name = zend_string_copy(filename); - file->lines = xdebug_hash_alloc(128, xdebug_coverage_line_dtor); - file->functions = xdebug_hash_alloc(128, xdebug_coverage_function_dtor); - file->has_branch_info = 0; - - return file; -} - -static void xdebug_coverage_file_dtor(void *data) -{ - xdebug_coverage_file *file = (xdebug_coverage_file *) data; - - xdebug_hash_destroy(file->lines); - xdebug_hash_destroy(file->functions); - zend_string_release(file->name); - xdfree(file); -} - -xdebug_coverage_function *xdebug_coverage_function_ctor(char *function_name) -{ - xdebug_coverage_function *function; - - function = xdmalloc(sizeof(xdebug_coverage_function)); - function->name = xdstrdup(function_name); - function->branch_info = NULL; - - return function; -} - -void xdebug_coverage_function_dtor(void *data) -{ - xdebug_coverage_function *function = (xdebug_coverage_function *) data; - - if (function->branch_info) { - xdebug_branch_info_free(function->branch_info); - } - xdfree(function->name); - xdfree(function); -} - -static void xdebug_func_format(char *buffer, size_t buffer_size, xdebug_func *func) -{ - if (func->type == XFUNC_NORMAL) { - int len = strlen(func->function); - - if (len + 1 > buffer_size) { - goto error; - } - memcpy(buffer, func->function, len); - bufferlen = '\0'; - return; - } - - if (func->type == XFUNC_MEMBER) { - int func_len = strlen(func->function); - int len = ZSTR_LEN(func->object_class) + 2 + func_len; - - if (len + 1 > buffer_size) { - goto error; - } - memcpy(buffer, ZSTR_VAL(func->object_class), ZSTR_LEN(func->object_class)); - memcpy(buffer + ZSTR_LEN(func->object_class), "->", 2); - memcpy(buffer + ZSTR_LEN(func->object_class) + 2, func->function, func_len); - bufferlen = '\0'; - return; - } - -error: - memcpy(buffer, "?", 1); - buffer1 = '\0'; -} - -static void xdebug_build_fname_from_oparray(xdebug_func *tmp, zend_op_array *opa) -{ - int wrapped = 0; - - memset(tmp, 0, sizeof(xdebug_func)); - - if (opa->function_name) { - if (opa->fn_flags & ZEND_ACC_CLOSURE) { - tmp->function = xdebug_wrap_closure_location_around_function_name(opa, STR_NAME_VAL(opa->function_name)); - wrapped = 1; - } else if ( - opa->fn_flags & ZEND_ACC_TRAIT_CLONE - || (opa->scope && opa->scope->ce_flags & ZEND_ACC_TRAIT) - ) { - tmp->function = xdebug_wrap_location_around_function_name("trait-method", opa, STR_NAME_VAL(opa->function_name)); - wrapped = 1; - } else { - tmp->function = xdstrdup(STR_NAME_VAL(opa->function_name)); - } - } else { - tmp->function = xdstrdup("{main}"); - tmp->type = XFUNC_MAIN; - } - - if (opa->scope && !wrapped) { - tmp->type = XFUNC_MEMBER; - tmp->object_class = zend_string_copy(opa->scope->name); - } else { - tmp->type = XFUNC_NORMAL; - } -} - -static void xdebug_print_opcode_info(zend_execute_data *execute_data, const zend_op *cur_opcode) -{ - zend_op_array *op_array = &execute_data->func->op_array; - xdebug_func func_info; - char function_name1024; - long opnr = execute_data->opline - execute_data->func->op_array.opcodes; - - xdebug_build_fname_from_oparray(&func_info, op_array); - xdebug_func_format(function_name, sizeof(function_name), &func_info); - if (func_info.object_class) { - zend_string_release(func_info.object_class); - } - if (func_info.scope_class) { - zend_string_release(func_info.scope_class); - } - if (func_info.function) { - xdfree(func_info.function); - } - - xdebug_branch_info_mark_reached(op_array->filename, function_name, op_array, opnr); -} - -static int xdebug_check_branch_entry_handler(XDEBUG_OPCODE_HANDLER_ARGS) -{ - zend_op_array *op_array = &execute_data->func->op_array; - const zend_op *cur_opcode = execute_data->opline; - - if (!op_array->reservedXG_COV(code_coverage_filter_offset) && XG_COV(code_coverage_active)) { - xdebug_print_opcode_info(execute_data, cur_opcode); - } - - return xdebug_call_original_opcode_handler_if_set(cur_opcode->opcode, XDEBUG_OPCODE_HANDLER_ARGS_PASSTHRU); -} - -static void xdebug_count_line(zend_string *filename, int lineno, int executable, int deadcode) -{ - xdebug_coverage_file *file; - xdebug_coverage_line *line; - - if (XG_COV(previous_filename) && zend_string_equals(XG_COV(previous_filename), filename)) { - file = XG_COV(previous_file); - } else { - /* Check if the file already exists in the hash */ - if (!xdebug_hash_find(XG_COV(code_coverage_info), ZSTR_VAL(filename), ZSTR_LEN(filename), (void *) &file)) { - /* The file does not exist, so we add it to the hash */ - file = xdebug_coverage_file_ctor(filename); - - xdebug_hash_add(XG_COV(code_coverage_info), ZSTR_VAL(filename), ZSTR_LEN(filename), file);
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/debugger/com.c
Deleted
@@ -1,768 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ -#include "php_xdebug.h" -#include <string.h> -#include <sys/types.h> -#include <errno.h> -#include <stdio.h> -#include <fcntl.h> -#ifndef PHP_WIN32 -# if HAVE_POLL_H -# include <poll.h> -# elif HAVE_SYS_POLL_H -# include <sys/poll.h> -# endif -# include <unistd.h> -# include <sys/socket.h> -# include <sys/un.h> -# include <netinet/tcp.h> -# if HAVE_NETINET_IN_H -# include <netinet/in.h> -# endif -# include <netdb.h> -#else -# include <process.h> -# include <direct.h> -# include "win32/time.h" -# undef UNICODE -# include <winsock2.h> -# include <ws2tcpip.h> -# include <mstcpip.h> -# pragma comment (lib, "Ws2_32.lib") -# define PATH_MAX MAX_PATH -# define poll WSAPoll -#endif - -#include "com.h" - -#include "debugger_private.h" -#include "handler_dbgp.h" -#include "ip_info.h" -#include "lib/crc32.h" -#include "lib/log.h" - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - -#if !WIN32 && !WINNT -static int xdebug_create_socket_unix(const char *path) -{ - struct sockaddr_un sa; - int sockfd; - - if ((sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) == SOCK_ERR) { - xdebug_log_ex(XLOG_CHAN_DEBUG, XLOG_WARN, "UNIX", "Creating socket for 'unix://%s', socket: %s.", path, strerror(errno)); - return SOCK_ERR; - } - - sa.sun_family = AF_UNIX; - strncpy(sa.sun_path, path, sizeof(sa.sun_path) - 1); - if (connect(sockfd, (struct sockaddr*)&sa, sizeof(sa)) < 0) { - xdebug_log_ex(XLOG_CHAN_DEBUG, XLOG_WARN, "UNIX", "Creating socket for 'unix://%s', connect: %s.", path, strerror(errno)); - SCLOSE(sockfd); - return (errno == EACCES) ? SOCK_ACCESS_ERR : SOCK_ERR; - } - - /* Prevent the socket from being inherited by exec'd children */ - if (fcntl(sockfd, F_SETFD, FD_CLOEXEC) < 0) { - xdebug_log_ex(XLOG_CHAN_DEBUG, XLOG_WARN, "UNIX", "Creating socket for 'unix://%s', fcntl(FD_CLOEXEC): %s.", path, strerror(errno)); - } - - return sockfd; -} -#endif - -#if !WIN32 && !WINNT - -/* For OSX and FreeBSD */ -# if !defined(SOL_TCP) && defined(IPPROTO_TCP) -# define SOL_TCP IPPROTO_TCP -# endif -# if !defined(TCP_KEEPIDLE) && defined(TCP_KEEPALIVE) -# define TCP_KEEPIDLE TCP_KEEPALIVE -# endif - -void set_keepalive_options(int fd) -{ - int optval = 1; - int optlen = sizeof(optval); - int ret; - - ret = setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &optval, optlen); - if (ret) { - xdebug_log_ex(XLOG_CHAN_DEBUG, XLOG_WARN, "KEEPALIVE", "Could not set SO_KEEPALIVE: %s.", strerror(errno)); - return; - } - -# if defined(TCP_KEEPIDLE) - optval = 600; - ret = setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, &optval, optlen); - if (ret) { - xdebug_log_ex(XLOG_CHAN_DEBUG, XLOG_WARN, "KEEPALIVE", "Could not set TCP_KEEPIDLE to %d: %s.", optval, strerror(errno)); - return; - } -# endif - -# if defined(TCP_KEEPCNT) - optval = 20; - ret = setsockopt(fd, SOL_TCP, TCP_KEEPCNT, &optval, optlen); - if (ret) { - xdebug_log_ex(XLOG_CHAN_DEBUG, XLOG_WARN, "KEEPALIVE", "Could not set TCP_KEEPCNT to %d: %s.", optval, strerror(errno)); - return; - } -# endif - -# if defined(TCP_KEEPINTVL) - optval = 60; - ret = setsockopt(fd, SOL_TCP, TCP_KEEPINTVL, &optval, optlen); - if (ret) { - xdebug_log_ex(XLOG_CHAN_DEBUG, XLOG_WARN, "KEEPALIVE", "Could not set TCP_KEEPINTVL to %d: %s.", optval, strerror(errno)); - return; - } -# endif -} -#endif // !WIN32 && !WINNT - -static char* resolve_pseudo_hosts(const char *requested_hostname) -{ -#if __linux__ - /* Does it start with 'xdebug://' ? */ - if (strncmp(requested_hostname, "xdebug://", strlen("xdebug://")) != 0) { - return NULL; - } - - /* Check for 'gateway' pseudo host */ - if (strcmp(requested_hostname, "xdebug://gateway") == 0) { -#if XDEBUG_GATEWAY_SUPPORT - char *gateway = xdebug_get_gateway_ip(); - - if (!gateway) { - xdebug_log_ex(XLOG_CHAN_DEBUG, XLOG_WARN, "GATEWAY", "Could not find network gateway to use for 'gateway' pseudo-host."); - return NULL; - } - - xdebug_log(XLOG_CHAN_DEBUG, XLOG_INFO, "Found 'gateway' pseudo-host, with IP address '%s'.", gateway); - return gateway; -#else - xdebug_log_ex(XLOG_CHAN_DEBUG, XLOG_WARN, "PSEUDO-GW-NO-SUPPORT", "Pseudo-host: '%s' is not supported on this host.", requested_hostname + strlen("xdebug://")); - return NULL; -# endif - } - - /* Check for 'nameserver' pseudo host */ - if (strcmp(requested_hostname, "xdebug://nameserver") == 0) { -#if XDEBUG_NAMESERVER_SUPPORT - char *gateway = xdebug_get_private_nameserver(); - - if (!gateway) { - xdebug_log_ex(XLOG_CHAN_DEBUG, XLOG_WARN, "NAMESERVER", "Could not find a private network nameserver for 'nameserver' pseudo-host."); - return NULL; - } - - xdebug_log(XLOG_CHAN_DEBUG, XLOG_INFO, "Found 'nameserver' pseudo-host, with IP address '%s'.", gateway); - return gateway; -# else - xdebug_log_ex(XLOG_CHAN_DEBUG, XLOG_WARN, "PSEUDO-NS-NO-SUPPORT", "Pseudo-host: '%s' is not supported on this host.", requested_hostname + strlen("xdebug://")); - return NULL; -# endif - } - - xdebug_log_ex(XLOG_CHAN_DEBUG, XLOG_WARN, "PSEUDO-UNKNOWN", "Unknown pseudo-host: '%s', only 'gateway' or 'nameserver' are supported.", requested_hostname + strlen("xdebug://")); -#endif - - return NULL; -} - -static int xdebug_create_socket(const char *hostname, int dport, int timeout) -{ - struct addrinfo hints; - struct addrinfo *remote; - struct addrinfo *ptr; - int status; - int sockfd = 0; - int sockerror; - char sport10; - int actually_connected; - struct sockaddr_in6 sa; - socklen_t size = sizeof(sa);
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/debugger/com.h
Deleted
@@ -1,68 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2020 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#ifndef __HAVE_XDEBUG_COM_H__ -#define __HAVE_XDEBUG_COM_H__ - -#include "handlers.h" - -#if WIN32|WINNT -# define SOCK_ERR INVALID_SOCKET -# define SOCK_CONN_ERR SOCKET_ERROR -# define SOCK_RECV_ERR SOCKET_ERROR -#else -# define SOCK_ERR -1 -# define SOCK_CONN_ERR -1 -# define SOCK_RECV_ERR -1 -#endif -#define SOCK_TIMEOUT_ERR -2 -#define SOCK_ACCESS_ERR -3 - -#if WIN32|WINNT -#define SCLOSE(a) closesocket(a) -#define SSENDL(a,b,c) send(a,b,c,0) -#define SSEND(a,b) send(a,b,strlen(b),0) -#define SREAD(a,b,c) recv(a,b,c,0) -#else -#define SCLOSE(a) close(a) -#define SSENDL(a,b,c) write(a,b,c) -#define SSEND(a,b) write(a,b,strlen(b)) -#define SREAD(a,b,c) read(a,b,c) -#endif - - -#define SENDMSG(socket, str) { \ - char *message_buffer; \ - \ - message_buffer = str; \ - SSEND(socket, message_buffer); \ - xdfree(message_buffer); \ -} - -void xdebug_close_socket(int socket); - -/* Remote connection activation and house keeping */ -int xdebug_is_debug_connection_active(void); -void xdebug_abort_debugger(void); -void xdebug_restart_debugger(void); -void xdebug_mark_debug_connection_active(void); -void xdebug_mark_debug_connection_not_active(void); -void xdebug_mark_debug_connection_pending(void); -void xdebug_debug_init_if_requested_at_startup(void); -void xdebug_debug_init_if_requested_on_error(void); -void xdebug_debug_init_if_requested_on_xdebug_break(void); - -#endif
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/debugger/debugger.c
Deleted
@@ -1,968 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#include "php_xdebug.h" - -#include "ext/standard/info.h" -#include "zend_exceptions.h" - -#include "debugger_private.h" -#include "lib/log.h" -#include "lib/var.h" - -extern ZEND_DECLARE_MODULE_GLOBALS(xdebug); - -static size_t (*xdebug_orig_ub_write)(const char *string, size_t len); -static size_t xdebug_ub_write(const char *string, size_t length); - -static void xdebug_line_list_dtor(xdebug_lines_list *line_list); - -void xdebug_init_debugger_globals(xdebug_debugger_globals_t *xg) -{ - xg->breakpoint_count = 0; - xg->ide_key = NULL; - xg->stdout_mode = 0; - xg->no_exec = 0; - xg->context.program_name = NULL; - xg->context.list.last_filename = NULL; - xg->context.list.last_line = 0; - xg->context.do_break = 0; - xg->context.pending_breakpoint = NULL; - xg->context.do_step = 0; - xg->context.do_next = 0; - xg->context.do_finish = 0; - xg->context.do_connect_to_client = 0; - - xg->remote_connection_enabled = 0; - xg->remote_connection_pid = 0; - xg->breakpoints_allowed = 0; - xg->suppress_return_value_step = 0; - - /* Capturing output */ - if (sapi_module.ub_write != xdebug_ub_write) { - xdebug_orig_ub_write = sapi_module.ub_write; - sapi_module.ub_write = xdebug_ub_write; - } - - /* Statistics and diagnostics */ - xg->context.connected_hostname = NULL; - xg->context.connected_port = 0; - xg->context.detached_message = NULL; -} - -static char *xdebug_debugger_get_ide_key(void) -{ - char *ide_key; - - ide_key = XINI_DBG(ide_key_setting); - if (ide_key && *ide_key) { - return ide_key; - } - - ide_key = getenv("DBGP_IDEKEY"); - if (ide_key && *ide_key) { - return ide_key; - } - - return NULL; -} - -void xdebug_debugger_reset_ide_key(char *envval) -{ - if (XG_DBG(ide_key)) { - xdfree(XG_DBG(ide_key)); - } - XG_DBG(ide_key) = xdstrdup(envval); -} - -int xdebug_debugger_bailout_if_no_exec_requested(void) -{ - /* We need to do this first before the executable clauses are called */ - if (XG_DBG(no_exec) == 1) { - php_printf("DEBUG SESSION ENDED"); - return 1; - } - return 0; -} - -static void register_compiled_variables(void) -{ - function_stack_entry *loop_fse = XDEBUG_VECTOR_TAIL(XG_BASE(stack)); - int i; - - for (i = 0; i < XDEBUG_VECTOR_COUNT(XG_BASE(stack)); i++, loop_fse--) { - if (loop_fse->declared_vars) { - continue; - } - - if (loop_fse->user_defined == XDEBUG_BUILT_IN) { - continue; - } - - xdebug_lib_register_compiled_variables(loop_fse, loop_fse->op_array); - } -} - - -void xdebug_debugger_set_program_name(zend_string *filename) -{ - if (!XG_DBG(context).program_name) { - XG_DBG(context).program_name = zend_string_copy(filename); - } -} - -/* Remote debugger helper functions */ -static int xdebug_handle_hit_value(xdebug_brk_info *brk_info) -{ - /* If this is a temporary breakpoint, disable the breakpoint */ - if (brk_info->temporary) { - brk_info->disabled = 1; - } - - /* Increase hit counter */ - brk_info->hit_count++; - - /* If the hit_value is 0, the condition check is disabled */ - if (!brk_info->hit_value) { - return 1; - } - - switch (brk_info->hit_condition) { - case XDEBUG_HIT_GREATER_EQUAL: - if (brk_info->hit_count >= brk_info->hit_value) { - return 1; - } - break; - case XDEBUG_HIT_EQUAL: - if (brk_info->hit_count == brk_info->hit_value) { - return 1; - } - break; - case XDEBUG_HIT_MOD: - if (brk_info->hit_count % brk_info->hit_value == 0) { - return 1; - } - break; - case XDEBUG_HIT_DISABLED: - return 1; - break; - } - return 0; -} - -int xdebug_do_eval(char *eval_string, zval *ret_zval) -{ - volatile int res = 1; - zend_execute_data *original_execute_data = EG(current_execute_data); - int original_no_extensions = EG(no_extensions); - zend_object *original_exception = EG(exception); - JMP_BUF *original_bailout = EG(bailout); - - /* Remember error reporting level and track errors */ - XG_BASE(error_reporting_override) = EG(error_reporting); - XG_BASE(error_reporting_overridden) = 1; - EG(error_reporting) = 0; - - XG_DBG(context).inhibit_notifications = 1; - XG_DBG(breakpoints_allowed) = 0; - - /* Reset exception in case we're triggered while being in xdebug_throw_exception_hook */ - EG(exception) = NULL; - - /* Do evaluation */ - zend_first_try { - res = (zend_eval_string(eval_string, ret_zval, (char*) "xdebug://debug-eval") == SUCCESS); - } zend_end_try(); - - /* FIXME: Bubble up exception message to DBGp return packet */ - if (EG(exception)) { - if (!res) { - zend_clear_exception(); - } - res = 0; - } - - /* Clean up */ - EG(error_reporting) = XG_BASE(error_reporting_override);
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/debugger/debugger.h
Deleted
@@ -1,95 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#ifndef __XDEBUG_DEBUGGER_H__ -#define __XDEBUG_DEBUGGER_H__ - -#include "com.h" - -typedef struct _xdebug_debugger_globals_t { - int status; - int reason; - const char *lastcmd; - char *lasttransid; - zval *current_return_value; - - zend_bool remote_connection_enabled; - zend_ulong remote_connection_pid; - zend_bool breakpoints_allowed; - zend_bool suppress_return_value_step; - zend_bool detached; - xdebug_con context; - unsigned int breakpoint_count; - unsigned int no_exec; - char *ide_key; /* As Xdebug uses it, from environment, USER, USERNAME or empty */ - - /* breakpoint resolving */ - size_t function_count; - size_t class_count; - xdebug_hash *breakable_lines_map; - - /* output redirection */ - int stdout_mode; -} xdebug_debugger_globals_t; - -typedef struct _xdebug_debugger_settings_t { - /* Cloud */ - char *cloud_id; - char *cloud_shared_key; - - /* Step Debugger */ - zend_long client_port; /* 9000 */ - char *client_host; /* localhost */ - zend_bool discover_client_host; /* (try to) connect back to the HTTP requestor */ - char *client_discovery_header; /* User configured header to check for forwarded IP address */ - zend_long connect_timeout_ms; /* Timeout in MS for remote connections */ - - char *ide_key_setting; /* Set through php.ini and friends */ -} xdebug_debugger_settings_t; - -PHP_INI_MH(OnUpdateDebugMode); - -void xdebug_init_debugger_globals(xdebug_debugger_globals_t *xg); - -#define XDEBUG_RETURN_VALUE_VAR_NAME "__RETURN_VALUE" - -void xdebug_debugger_reset_ide_key(char *envval); -int xdebug_debugger_bailout_if_no_exec_requested(void); -void xdebug_debugger_set_program_name(zend_string *filename); -void xdebug_debugger_register_eval(function_stack_entry *fse); -void xdebug_debugger_restart_if_pid_changed(void); - -xdebug_set *xdebug_debugger_get_breakable_lines_from_oparray(zend_op_array *opa); -int xdebug_do_eval(char *eval_string, zval *ret_zval); - -void xdebug_debugger_statement_call(zend_string *filename, int lineno); -void xdebug_debugger_throw_exception_hook(zend_object *exception, zval *file, zval *line, zval *code, char *code_str, zval *message); -void xdebug_debugger_error_cb(zend_string *error_filename, int error_lineno, int type, char *error_type_str, char *buffer); -void xdebug_debugger_handle_breakpoints(function_stack_entry *fse, int breakpoint_type, zval *return_value); - -void xdebug_debugger_zend_startup(void); -void xdebug_debugger_zend_shutdown(void); -void xdebug_debugger_minit(void); -void xdebug_debugger_minfo(void); -void xdebug_debugger_rinit(void); -void xdebug_debugger_post_deactivate(void); - -void xdebug_debugger_compile_file(zend_op_array *op_array); - -PHP_FUNCTION(xdebug_break); - - -#endif
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/debugger/handler_dbgp.c
Deleted
@@ -1,3159 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#include <sys/types.h> - -#ifndef PHP_WIN32 -#include <unistd.h> -#endif - -#include "lib/php-header.h" -#include "SAPI.h" - -#include "ext/standard/php_string.h" -#include "ext/standard/url.h" -#include "main/php_version.h" -#include "main/php_network.h" -#include "ext/standard/base64.h" -#include "TSRM.h" - -#include "php_globals.h" -#include "php_xdebug.h" - -#include "com.h" -#include "handler_dbgp.h" -#include "debugger_private.h" - -#include "coverage/code_coverage.h" -#include "develop/stack.h" -#include "lib/compat.h" -#include "lib/hash.h" -#include "lib/llist.h" -#include "lib/log.h" -#include "lib/mm.h" -#include "lib/var_export_xml.h" -#include "lib/vector.h" -#include "lib/xml.h" - -#ifdef PHP_WIN32 -#include "win32/time.h" -#include <process.h> -#endif -#include <fcntl.h> - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - -xdebug_remote_handler xdebug_handler_dbgp = { - xdebug_dbgp_init, - xdebug_dbgp_deinit, - xdebug_dbgp_error, - xdebug_dbgp_break_on_line, - xdebug_dbgp_breakpoint, - xdebug_dbgp_resolve_breakpoints, - xdebug_dbgp_stream_output, - xdebug_dbgp_notification, - xdebug_dbgp_user_notify, - xdebug_dbgp_register_eval_id, -}; - -static char *create_eval_key_id(int id); -static void line_breakpoint_resolve_helper(xdebug_con *context, xdebug_lines_list *lines_list, xdebug_brk_info *brk_info); - -/***************************************************************************** -** Constants and strings for statii and reasons -*/ - -/* Status structure */ -#define DBGP_STATUS_STARTING 1 -#define DBGP_STATUS_STOPPING 2 -#define DBGP_STATUS_STOPPED 3 -#define DBGP_STATUS_RUNNING 4 -#define DBGP_STATUS_BREAK 5 -#define DBGP_STATUS_DETACHED 6 - -const char *xdebug_dbgp_status_strings7 = - {"", "starting", "stopping", "stopped", "running", "break", "detached"}; - -#define DBGP_REASON_OK 0 -#define DBGP_REASON_ERROR 1 -#define DBGP_REASON_ABORTED 2 -#define DBGP_REASON_EXCEPTION 3 - -const char *xdebug_dbgp_reason_strings4 = - {"ok", "error", "aborted", "exception"}; - -typedef struct { - int code; - const char *message; -} xdebug_error_entry; - -xdebug_error_entry xdebug_error_codes24 = { - { 0, "no error" }, - { 1, "parse error in command" }, - { 2, "duplicate arguments in command" }, - { 3, "invalid or missing options" }, - { 4, "unimplemented command" }, - { 5, "command is not available" }, - { 100, "can not open file" }, - { 101, "stream redirect failed" }, - { 200, "breakpoint could not be set" }, - { 201, "breakpoint type is not supported" }, - { 202, "invalid breakpoint line" }, - { 203, "no code on breakpoint line" }, - { 204, "invalid breakpoint state" }, - { 205, "no such breakpoint" }, - { 206, "error evaluating code" }, - { 207, "invalid expression" }, - { 300, "can not get property" }, - { 301, "stack depth invalid" }, - { 302, "context invalid" }, - { 800, "profiler not started" }, - { 900, "encoding not supported" }, - { 998, "an internal exception in the debugger" }, - { 999, "unknown error" }, - { -1, NULL } -}; - -#define XDEBUG_STR_SWITCH_DECL char *__switch_variable -#define XDEBUG_STR_SWITCH(s) __switch_variable = (s); -#define XDEBUG_STR_CASE(s) if (strcmp(__switch_variable, s) == 0) { -#define XDEBUG_STR_CASE_END } else -#define XDEBUG_STR_CASE_DEFAULT { -#define XDEBUG_STR_CASE_DEFAULT_END } - -#define XDEBUG_TYPES_COUNT 8 -const char *xdebug_dbgp_typemapXDEBUG_TYPES_COUNT3 = { - /* common, lang, schema */ - {"bool", "bool", "xsd:boolean"}, - {"int", "int", "xsd:decimal"}, - {"float", "float", "xsd:double"}, - {"string", "string", "xsd:string"}, - {"null", "null", NULL}, - {"hash", "array", NULL}, - {"object", "object", NULL}, - {"resource", "resource", NULL} -}; - - -typedef struct { - int value; - const char *name; -} xdebug_breakpoint_entry; - -#define XDEBUG_BREAKPOINT_TYPES_COUNT 6 -xdebug_breakpoint_entry xdebug_breakpoint_typesXDEBUG_BREAKPOINT_TYPES_COUNT = { - { XDEBUG_BREAKPOINT_TYPE_LINE, "line" }, - { XDEBUG_BREAKPOINT_TYPE_CONDITIONAL, "conditional" }, - { XDEBUG_BREAKPOINT_TYPE_CALL, "call" }, - { XDEBUG_BREAKPOINT_TYPE_RETURN, "return" }, - { XDEBUG_BREAKPOINT_TYPE_EXCEPTION, "exception" }, - { XDEBUG_BREAKPOINT_TYPE_WATCH, "watch" } -}; - -#define XDEBUG_DBGP_SCAN_RANGE 5 - -/***************************************************************************** -** Prototypes for debug command handlers -*/ - -/* DBGP_FUNC(break); */ -DBGP_FUNC(breakpoint_get); -DBGP_FUNC(breakpoint_list); -DBGP_FUNC(breakpoint_remove); -DBGP_FUNC(breakpoint_set); -DBGP_FUNC(breakpoint_update); - -DBGP_FUNC(context_get); -DBGP_FUNC(context_names); - -DBGP_FUNC(eval); -DBGP_FUNC(feature_get); -DBGP_FUNC(feature_set); - -DBGP_FUNC(typemap_get); -DBGP_FUNC(property_get); -DBGP_FUNC(property_set); -DBGP_FUNC(property_value); - -DBGP_FUNC(source); -DBGP_FUNC(stack_depth); -DBGP_FUNC(stack_get); -DBGP_FUNC(status); - -DBGP_FUNC(stderr); -DBGP_FUNC(stdout); - -DBGP_FUNC(stop);
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/debugger/handler_dbgp.h
Deleted
@@ -1,112 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#ifndef __HAVE_XDEBUG_HANDLER_DBGP_H__ -#define __HAVE_XDEBUG_HANDLER_DBGP_H__ - -#include <string.h> -#include "handlers.h" -#include "lib/xml.h" - -#define DBGP_VERSION "1.0" - -typedef struct xdebug_dbgp_result { - int status; - int reason; - int code; -} xdebug_dbgp_result; - -#define ADD_REASON_MESSAGE(c) { \ - xdebug_xml_node *message = xdebug_xml_node_init("message"); \ - xdebug_error_entry *error_entry = &xdebug_error_codes0; \ - \ - while (error_entry->message) { \ - if ((c) == error_entry->code) { \ - xdebug_xml_add_text(message, xdstrdup(error_entry->message)); \ - xdebug_xml_add_child(error, message); \ - } \ - error_entry++; \ - } \ -} - -#define RETURN_RESULT(s, r, c) { \ - xdebug_xml_node *error = xdebug_xml_node_init("error"); \ - xdebug_xml_node *message = xdebug_xml_node_init("message"); \ - xdebug_error_entry *error_entry = &xdebug_error_codes0; \ - \ - xdebug_xml_add_attribute(*retval, "status", xdebug_dbgp_status_strings(s)); \ - xdebug_xml_add_attribute(*retval, "reason", xdebug_dbgp_reason_strings(r)); \ - xdebug_xml_add_attribute_ex(error, "code", xdebug_sprintf("%u", (c)), 0, 1); \ - \ - while (error_entry->message) { \ - if ((c) == error_entry->code) { \ - xdebug_xml_add_text(message, xdstrdup(error_entry->message)); \ - xdebug_xml_add_child(error, message); \ - } \ - error_entry++; \ - } \ - xdebug_xml_add_child(*retval, error); \ - return; \ -} - -/* Argument structure */ -typedef struct xdebug_dbgp_arg { - xdebug_str *value27; /* one extra for - */ -} xdebug_dbgp_arg; - -#define DBGP_FUNC_PARAMETERS xdebug_xml_node **retval, xdebug_con *context, xdebug_dbgp_arg *args -#define DBGP_FUNC_PASS_PARAMETERS retval, context, args -#define DBGP_FUNC(name) static void xdebug_dbgp_handle_##name(DBGP_FUNC_PARAMETERS) -#define DBGP_FUNC_ENTRY(name,flags) { #name, xdebug_dbgp_handle_##name, 0, flags }, -#define DBGP_CONT_FUNC_ENTRY(name,flags) { #name, xdebug_dbgp_handle_##name, 1, flags }, -#define DBGP_STOP_FUNC_ENTRY(name,flags) { #name, xdebug_dbgp_handle_##name, 2, flags }, - -#define XDEBUG_DBGP_NONE 1 << 0 -#define XDEBUG_DBGP_POST_MORTEM 1 << 1 /* command is valid in 'stopping' (post mortem) state */ - -typedef struct xdebug_dbgp_cmd { - const char *name; - void (*handler)(DBGP_FUNC_PARAMETERS); - int cont; - int flags; -} xdebug_dbgp_cmd; - -typedef struct xdebug_dbgp_resolve_context { - xdebug_con *context; - zend_string *filename; - xdebug_lines_list *lines_list; -} xdebug_dbgp_resolve_context; - -#define CMD_OPTION_SET(opt) (!!(opt == '-' ? args->value26 : args->value(opt) - 'a')) -#define CMD_OPTION_CHAR(opt) (opt == '-' ? args->value26->d : args->value(opt) - 'a'->d) -#define CMD_OPTION_LEN(opt) (opt == '-' ? args->value26->l : args->value(opt) - 'a'->l) -#define CMD_OPTION_XDEBUG_STR(opt) (opt == '-' ? args->value26 : args->value(opt) - 'a') - -int xdebug_dbgp_init(xdebug_con *context, int mode); -int xdebug_dbgp_deinit(xdebug_con *context); -int xdebug_dbgp_error(xdebug_con *context, int type, char *exception_type, char *message, const char *location, const unsigned int line, xdebug_vector *stack); -int xdebug_dbgp_break_on_line(xdebug_con *context, xdebug_brk_info *brk, zend_string *filename, int lineno); -int xdebug_dbgp_breakpoint(xdebug_con *context, xdebug_vector *stack, zend_string *filename, long lineno, int type, char *exception, char *code, const char *message, xdebug_brk_info *brk_info, zval *return_value); -int xdebug_dbgp_resolve_breakpoints(xdebug_con *context, zend_string *filename); -int xdebug_dbgp_stream_output(const char *string, unsigned int length); -int xdebug_dbgp_notification(xdebug_con *context, zend_string *filename, long lineno, int type, char *type_string, char *message); -int xdebug_dbgp_user_notify(xdebug_con *context, zend_string *filename, long lineno, zval *data); -void XDEBUG_ATTRIBUTE_FORMAT(printf, 2, 3) xdebug_dbgp_log(int log_level, const char *fmt, ...); -int xdebug_dbgp_register_eval_id(xdebug_con *context, function_stack_entry *fse); - -extern xdebug_remote_handler xdebug_handler_dbgp; - -#endif
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/debugger/handlers.h
Deleted
@@ -1,168 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#ifndef __HAVE_XDEBUG_HANDLERS_H__ -#define __HAVE_XDEBUG_HANDLERS_H__ - -#include "php_xdebug.h" -#include "lib/compat.h" -#include "lib/llist.h" -#include "lib/hash.h" -#include "lib/lib.h" -#include "lib/usefulstuff.h" -#include "lib/vector.h" -#include "debugger_private.h" - -typedef struct _xdebug_brk_admin xdebug_brk_admin; -typedef struct _xdebug_brk_info xdebug_brk_info; -typedef struct _xdebug_brk_span xdebug_brk_span; -typedef struct _xdebug_eval_info xdebug_eval_info; -typedef struct _xdebug_con xdebug_con; -typedef struct _xdebug_debug_list xdebug_debug_list; -typedef struct _xdebug_remote_handler xdebug_remote_handler; -typedef struct _xdebug_remote_handler_info xdebug_remote_handler_info; - -struct _xdebug_debug_list { - zend_string *last_filename; - int last_line; -}; - -#define XDEBUG_BREAKPOINT_TYPE_LINE 0x01 -#define XDEBUG_BREAKPOINT_TYPE_CONDITIONAL 0x02 -#define XDEBUG_BREAKPOINT_TYPE_CALL 0x04 -#define XDEBUG_BREAKPOINT_TYPE_RETURN 0x08 -#define XDEBUG_BREAKPOINT_TYPE_EXCEPTION 0x10 -#define XDEBUG_BREAKPOINT_TYPE_WATCH 0x20 -#define XDEBUG_BREAKPOINT_TYPES_MASK 0x3F - -#define XDEBUG_BREAKPOINT_TYPE_EXTERNAL 0x40 // user-defined PHP function - -#define XDEBUG_BREAKPOINT_TYPE_NAME(v) (xdebug_breakpoint_types(int)(log2(v))).name - -struct _xdebug_brk_admin { - int id; - int type; - char *key; -}; - -#define XDEBUG_NORMAL 0x01 -#define XDEBUG_CLOUD 0x02 -#define XDEBUG_CLOUD_FROM_TRIGGER_VALUE 0x03 - -struct _xdebug_con { - int socket; - int host_type; /* XDEBUG_NORMAL, XDEBUG_CLOUD, XDEBUG_CLOUD_FROM_TRIGGER_VALUE */ - void *options; - xdebug_remote_handler *handler; - fd_buf *buffer; - zend_string *program_name; - xdebug_hash *breakpoint_list; - xdebug_hash *function_breakpoints; - xdebug_hash *eval_id_lookup; - int eval_id_sequence; - xdebug_llist *line_breakpoints; - xdebug_hash *exception_breakpoints; - xdebug_debug_list list; - int do_break; - xdebug_brk_info *pending_breakpoint; - - int do_step; - int do_next; - int next_level; - int do_finish; - int do_connect_to_client; - int finish_level; - int finish_func_nr; - - int send_notifications; - int inhibit_notifications; - - int resolved_breakpoints; - int breakpoint_details; - int breakpoint_include_return_value; - - /* Statistics and diagnostics */ - char *connected_hostname; - int connected_port; - char *detached_message; -}; - -#define XDEBUG_BRK_UNRESOLVED 0 -#define XDEBUG_BRK_RESOLVED 1 - -#define XDEBUG_HIT_DISABLED 0 -#define XDEBUG_HIT_GREATER_EQUAL 1 -#define XDEBUG_HIT_EQUAL 2 -#define XDEBUG_HIT_MOD 3 - -#define XDEBUG_RESOLVED_SPAN_MAX 2147483647 - -struct _xdebug_brk_info { - int id; - int brk_type; - int resolved; - char *classname; - char *functionname; - char *exceptionname; - int function_break_type; /* XDEBUG_BRK_FUNC_* */ - zend_string *filename; - int original_lineno; /* line number that was set through breakpoint_set */ - int resolved_lineno; /* line number after resolving, initialised with 'original_lineno' */ - char *condition; - int disabled; - int temporary; - int hit_count; - int hit_value; - int hit_condition; -}; - -struct _xdebug_eval_info { - int id; - int refcount; - zend_string *contents; -}; - -struct _xdebug_remote_handler { - /* Init / deinit */ - int (*remote_init)(xdebug_con *h, int mode); - int (*remote_deinit)(xdebug_con *h); - - /* Stack messages */ - int (*remote_error)(xdebug_con *h, int type, char *exception_type, char *message, const char *location, const unsigned int line, xdebug_vector *stack); - - /* Breakpoints */ - int (*break_on_line)(xdebug_con *h, xdebug_brk_info *brk, zend_string *filename, int lineno); - int (*remote_breakpoint)(xdebug_con *h, xdebug_vector *stack, zend_string *filename, long lineno, int type, char *exception, char *code, const char *message, xdebug_brk_info *brk_info, zval *return_value); - int (*resolve_breakpoints)(xdebug_con *h, zend_string *opa); - - /* Output redirection */ - int (*remote_stream_output)(const char *string, unsigned int length); - - /* Notifications & Logging */ - int (*remote_notification)(xdebug_con *h, zend_string *file, long lineno, int type, char *type_string, char *message); - int (*user_notification)(xdebug_con *h, zend_string *filename, long lineno, zval *data); - - /* Eval ID registration and removal */ - int (*register_eval_id)(xdebug_con *h, function_stack_entry *fse); -}; - -xdebug_brk_info *xdebug_brk_info_ctor(void); -void xdebug_brk_info_dtor(xdebug_brk_info *brk); -void xdebug_llist_brk_dtor(void *dummy, xdebug_brk_info *brk); -void xdebug_hash_brk_dtor(xdebug_brk_info *brk); -void xdebug_hash_eval_info_dtor(xdebug_eval_info *ei); - -#endif
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/debugger/ip_info.c
Deleted
@@ -1,289 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ -#ifdef __linux__ - -#include "php_xdebug.h" - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <errno.h> -#include <linux/rtnetlink.h> -#include <arpa/inet.h> -#include <net/if.h> -#include <netinet/in.h> -#include <arpa/nameser.h> -#include <resolv.h> - -#include "ip_info.h" - -#if XDEBUG_GATEWAY_SUPPORT - -#define BUFFER_SIZE 4096 - -static char *convert_to_quad(int domain, void *buf) -{ - char *ip = xdcalloc(1, INET6_ADDRSTRLEN + 1); - - inet_ntop(domain, buf, ip, INET6_ADDRSTRLEN); - - return ip; -} - -static int get_ip(int fd, struct sockaddr_nl *sa, int domain) -{ - char bufBUFFER_SIZE; - struct nlmsghdr *nl; - struct ifaddrmsg *ifa; - struct iovec iov = { 0 }; - struct msghdr msg = { 0 }; - int r; - - memset(buf, 0, BUFFER_SIZE); - - /* Assemble the message according to the netlink protocol */ - nl = (struct nlmsghdr*)buf; - nl->nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg)); - nl->nlmsg_type = RTM_GETADDR; - nl->nlmsg_flags = NLM_F_REQUEST | NLM_F_ROOT; - - ifa = (struct ifaddrmsg*)NLMSG_DATA(nl); - ifa->ifa_family = domain; // We only get IPv4 address here - - /* Prepare struct msghdr for sending */ - iov.iov_base = nl; - iov.iov_len = nl->nlmsg_len; - msg.msg_name = sa; - msg.msg_namelen = sizeof(*sa); - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - msg.msg_control = NULL; - msg.msg_controllen = 0; - msg.msg_flags = 0; - - /* Send netlink message to kernel */ - r = sendmsg(fd, &msg, 0); - return (r < 0) ? -1 : 0; -} - -static int get_msg(int fd, struct sockaddr_nl *sa, void *buf, size_t len) -{ - struct iovec iov; - struct msghdr msg; - - iov.iov_base = buf; - iov.iov_len = len; - - memset(&msg, 0, sizeof(msg)); - msg.msg_name = sa; - msg.msg_namelen = sizeof(*sa); - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - - return recvmsg(fd, &msg, 0); -} - -static char *parse_ifa_msg(struct ifaddrmsg *ifa, void *buf, size_t len, const char *wanted_iface) -{ - char ifnameIF_NAMESIZE; - struct rtattr *rta = NULL; - int fa = ifa->ifa_family; - - if_indextoname(ifa->ifa_index, ifname); - - if (strcmp(ifname, wanted_iface) != 0) { - return NULL; - } - - for (rta = (struct rtattr*)buf; RTA_OK(rta, len); rta = RTA_NEXT(rta, len)) { - if (rta->rta_type == IFA_ADDRESS) { - return convert_to_quad(fa, RTA_DATA(rta)); - } - } - - return NULL; -} - -static uint32_t parse_nl_msg(void *buf, size_t len, const char *iface, char **if_address) -{ - struct nlmsghdr *nl = NULL; - uint32_t nlmsg_type = NLMSG_ERROR; - - for ( - nl = (struct nlmsghdr*)buf; - NLMSG_OK(nl, (uint32_t)len) && nl->nlmsg_type != NLMSG_DONE; - nl = NLMSG_NEXT(nl, len) - ) { - nlmsg_type = nl->nlmsg_type; - - if (nl->nlmsg_type == NLMSG_ERROR) { - return -1; - } - - if (nl->nlmsg_type == RTM_NEWADDR) { - struct ifaddrmsg *ifa; - ifa = (struct ifaddrmsg*)NLMSG_DATA(nl); - - if (*if_address == NULL) { - *if_address = parse_ifa_msg(ifa, IFA_RTA(ifa), IFA_PAYLOAD(nl), iface); - if (*if_address) { - return NLMSG_DONE; - } - } - continue; - } - } - return nlmsg_type; -} - -char *xdebug_get_ip_for_interface(const char *iface) -{ - char bufBUFFER_SIZE; - int fd = 0, len = 0; - char *if_address = NULL; - uint32_t nl_msg_type = NLMSG_DONE; - struct sockaddr_nl sa; - - /* Create a socket with the AF_NETLINK domain */ - fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); - if (fd < 0) { - return NULL; - } - - memset(&sa, 0, sizeof(sa)); - sa.nl_family = AF_NETLINK; - - len = get_ip(fd, &sa, AF_INET); // For IPv6: use AF_INET6 instead - if (len < 0) { - return NULL; - } - - do { - len = get_msg(fd, &sa, buf, BUFFER_SIZE); - if (len < 0) { - return NULL; - } - - nl_msg_type = parse_nl_msg(buf, len, iface, &if_address); - } while (nl_msg_type != NLMSG_DONE && nl_msg_type != NLMSG_ERROR); - - return if_address; -} - -/***/ - -static int get_gateway_and_iface(in_addr_t *addr, char *interface) -{ - long destination, gateway; - char ifaceIF_NAMESIZE; - char bufBUFFER_SIZE; - FILE *file; - - memset(iface, 0, sizeof(iface)); - memset(buf, 0, sizeof(buf)); - - file = fopen("/proc/net/route", "r"); - if (!file) {
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/develop/develop.c
Deleted
@@ -1,137 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ -#include "lib/php-header.h" -#include "zend_exceptions.h" - -#include "php_xdebug.h" -#include "monitor.h" -#include "stack.h" -#include "superglobals.h" - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - -static int xdebug_silence_handler(XDEBUG_OPCODE_HANDLER_ARGS); - -static void xdebug_develop_overloaded_functions_setup(void) -{ - zend_function *orig; - - /* Override var_dump with our own function */ - orig = zend_hash_str_find_ptr(EG(function_table), "var_dump", sizeof("var_dump") - 1); - XG_DEV(orig_var_dump_func) = orig->internal_function.handler; - orig->internal_function.handler = zif_xdebug_var_dump; -} - -static void xdebug_develop_overloaded_functions_restore(void) -{ - zend_function *orig; - - orig = zend_hash_str_find_ptr(EG(function_table), "var_dump", sizeof("var_dump") - 1); - orig->internal_function.handler = XG_DEV(orig_var_dump_func); -} - - -void xdebug_init_develop_globals(xdebug_develop_globals_t *xg) -{ - xg->do_monitor_functions = 0; - - xg->in_at = 0; /* scream */ - - xdebug_llist_init(&xg->server, xdebug_superglobals_dump_dtor); - xdebug_llist_init(&xg->get, xdebug_superglobals_dump_dtor); - xdebug_llist_init(&xg->post, xdebug_superglobals_dump_dtor); - xdebug_llist_init(&xg->cookie, xdebug_superglobals_dump_dtor); - xdebug_llist_init(&xg->files, xdebug_superglobals_dump_dtor); - xdebug_llist_init(&xg->env, xdebug_superglobals_dump_dtor); - xdebug_llist_init(&xg->request, xdebug_superglobals_dump_dtor); - xdebug_llist_init(&xg->session, xdebug_superglobals_dump_dtor); -} - -void xdebug_deinit_develop_globals(xdebug_develop_globals_t *xg) -{ - xdebug_llist_empty(&xg->server, NULL); - xdebug_llist_empty(&xg->get, NULL); - xdebug_llist_empty(&xg->post, NULL); - xdebug_llist_empty(&xg->cookie, NULL); - xdebug_llist_empty(&xg->files, NULL); - xdebug_llist_empty(&xg->env, NULL); - xdebug_llist_empty(&xg->request, NULL); - xdebug_llist_empty(&xg->session, NULL); -} - -void xdebug_develop_minit(INIT_FUNC_ARGS) -{ - /* Overload opcodes for 'scream' */ - xdebug_set_opcode_handler(ZEND_BEGIN_SILENCE, xdebug_silence_handler); - xdebug_set_opcode_handler(ZEND_END_SILENCE, xdebug_silence_handler); - - REGISTER_LONG_CONSTANT("XDEBUG_STACK_NO_DESC", XDEBUG_STACK_NO_DESC, CONST_CS | CONST_PERSISTENT); -} - -void xdebug_develop_mshutdown() -{ -} - -void xdebug_develop_rinit() -{ - XG_DEV(collected_errors) = xdebug_llist_alloc(xdebug_llist_string_dtor); - - /* Function monitoring */ - XG_DEV(do_monitor_functions) = 0; - XG_DEV(functions_to_monitor) = NULL; - XG_DEV(monitored_functions_found) = xdebug_llist_alloc(xdebug_monitored_function_dtor); - - xdebug_develop_overloaded_functions_setup(); -} - -void xdebug_develop_post_deactivate() -{ - xdebug_llist_destroy(XG_DEV(collected_errors), NULL); - XG_DEV(collected_errors) = NULL; - - xdebug_llist_destroy(XG_DEV(monitored_functions_found), NULL); - XG_DEV(monitored_functions_found) = NULL; - - if (XG_DEV(functions_to_monitor)) { - xdebug_hash_destroy(XG_DEV(functions_to_monitor)); - XG_DEV(functions_to_monitor) = NULL; - } - - xdebug_develop_overloaded_functions_restore(); -} - - -static int xdebug_silence_handler(XDEBUG_OPCODE_HANDLER_ARGS) -{ - zend_op_array *op_array = &execute_data->func->op_array; - const zend_op *cur_opcode = execute_data->opline; - - if (XDEBUG_MODE_IS(XDEBUG_MODE_COVERAGE)) { - xdebug_coverage_record_if_active(execute_data, op_array); - } - - if (XINI_DEV(do_scream)) { - execute_data->opline++; - if (cur_opcode->opcode == ZEND_BEGIN_SILENCE) { - XG_DEV(in_at) = 1; - } else { - XG_DEV(in_at) = 0; - } - return ZEND_USER_OPCODE_CONTINUE; - } - - return xdebug_call_original_opcode_handler_if_set(cur_opcode->opcode, XDEBUG_OPCODE_HANDLER_ARGS_PASSTHRU); -}
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/develop/develop.h
Deleted
@@ -1,78 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2020 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#ifndef __XDEBUG_DEVELOP_H__ -#define __XDEBUG_DEVELOP_H__ - -typedef struct _xdebug_develop_globals_t { - /* used for function monitoring */ - zend_bool do_monitor_functions; - xdebug_hash *functions_to_monitor; - xdebug_llist *monitored_functions_found; /* List of functions found */ - - /* superglobals */ - xdebug_llist server; - xdebug_llist get; - xdebug_llist post; - xdebug_llist cookie; - xdebug_llist files; - xdebug_llist env; - xdebug_llist request; - xdebug_llist session; - - /* used for collection errors */ - xdebug_llist *collected_errors; - - /* scream */ - zend_bool in_at; - - /* overloaded var_dump */ - zif_handler orig_var_dump_func; -} xdebug_develop_globals_t; - -typedef struct _xdebug_develop_settings_t { - - zend_long max_stack_frames; - zend_bool show_ex_trace; - zend_bool show_error_trace; - zend_bool show_local_vars; - zend_bool force_display_errors; - zend_long force_error_reporting; - zend_long halt_level; - - zend_long cli_color; - - /* superglobals */ - zend_bool dump_globals; - zend_bool dump_once; - zend_bool dump_undefined; - - /* scream */ - zend_bool do_scream; -} xdebug_develop_settings_t; - -void xdebug_init_develop_globals(xdebug_develop_globals_t *xg); -void xdebug_deinit_develop_globals(xdebug_develop_globals_t *xg); - -void xdebug_develop_minit(); -void xdebug_develop_mshutdown(); -void xdebug_develop_rinit(); -void xdebug_develop_post_deactivate(); - -void xdebug_develop_throw_exception_hook(zend_object *exception, zval *file, zval *line, zval *code, char *code_str, zval *message); -void xdebug_monitor_handler(function_stack_entry *fse); - -#endif
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/develop/monitor.c
Deleted
@@ -1,173 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#include "lib/php-header.h" -#include "php_xdebug.h" - -#include "develop_private.h" -#include "monitor.h" - -#include "lib/compat.h" -#include "lib/hash.h" -#include "lib/var.h" - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - -static void init_function_monitor_hash(xdebug_hash *internal, HashTable *functions_to_monitor) -{ - zval *val; - - ZEND_HASH_FOREACH_VAL(functions_to_monitor, val) { - if (Z_TYPE_P(val) == IS_STRING) { - xdebug_hash_add(internal, Z_STRVAL_P(val), Z_STRLEN_P(val), xdstrdup(Z_STRVAL_P(val))); - } - } ZEND_HASH_FOREACH_END(); -} - -static void xdebug_hash_function_monitor_dtor(char *function) -{ - xdfree(function); -} - -static xdebug_monitored_function_entry *xdebug_monitored_function_init(char *func_name, zend_string *filename, int lineno) -{ - xdebug_monitored_function_entry *tmp = xdmalloc(sizeof(xdebug_monitored_function_entry)); - - tmp->func_name = xdstrdup(func_name); - tmp->filename = zend_string_copy(filename); - tmp->lineno = lineno; - - return tmp; -} - -void xdebug_monitored_function_dtor(void *dummy, void *elem) -{ - xdebug_monitored_function_entry *mfe = (xdebug_monitored_function_entry*) elem; - - xdfree(mfe->func_name); - zend_string_release(mfe->filename); - xdfree(mfe); -} - -void xdebug_function_monitor_record(char *func_name, zend_string *filename, int lineno) -{ - xdebug_monitored_function_entry *record; - - record = xdebug_monitored_function_init(func_name, filename, lineno); - xdebug_llist_insert_next(XG_DEV(monitored_functions_found), XDEBUG_LLIST_TAIL(XG_DEV(monitored_functions_found)), record); -} - -void xdebug_monitor_handler(function_stack_entry *fse) -{ - char *func_name = NULL; - int func_name_len = 0; - void *dummy = NULL; - - if (!XG_DEV(do_monitor_functions)) { - return; - } - - func_name = xdebug_show_fname(fse->function, XDEBUG_SHOW_FNAME_DEFAULT); - func_name_len = strlen(func_name); - - if (xdebug_hash_find(XG_DEV(functions_to_monitor), func_name, func_name_len, (void *) &dummy)) { - xdebug_function_monitor_record(func_name, fse->filename, fse->lineno); - } - - xdfree(func_name); -} - -PHP_FUNCTION(xdebug_start_function_monitor) -{ - HashTable *functions_to_monitor; - - if (!XDEBUG_MODE_IS(XDEBUG_MODE_DEVELOP)) { - php_error(E_WARNING, "Function must be enabled in php.ini by setting 'xdebug.mode' to 'develop'"); - return; - } - - if (zend_parse_parameters(ZEND_NUM_ARGS(), "H", &functions_to_monitor) == FAILURE) { - return; - } - - if (XG_DEV(do_monitor_functions) == 1) { - php_error(E_NOTICE, "Function monitoring was already started"); - } - - /* Clean and store list of functions to monitor */ - if (XG_DEV(functions_to_monitor)) { - xdebug_hash_destroy(XG_DEV(functions_to_monitor)); - } - - /* We add "1" here so that we don't alloc a 0-slot hash table */ - XG_DEV(functions_to_monitor) = xdebug_hash_alloc(zend_hash_num_elements(functions_to_monitor) + 1, (xdebug_hash_dtor_t) xdebug_hash_function_monitor_dtor); - init_function_monitor_hash(XG_DEV(functions_to_monitor), functions_to_monitor); - - XG_DEV(do_monitor_functions) = 1; -} - -PHP_FUNCTION(xdebug_stop_function_monitor) -{ - if (!XDEBUG_MODE_IS(XDEBUG_MODE_DEVELOP)) { - php_error(E_WARNING, "Function must be enabled in php.ini by setting 'xdebug.mode' to 'develop'"); - return; - } - - if (XG_DEV(do_monitor_functions) == 0) { - php_error(E_NOTICE, "Function monitoring was not started"); - } - XG_DEV(do_monitor_functions) = 0; -} - -PHP_FUNCTION(xdebug_get_monitored_functions) -{ - xdebug_llist_element *le; - zend_bool clear = 0; - xdebug_monitored_function_entry *mfe; - - if (!XDEBUG_MODE_IS(XDEBUG_MODE_DEVELOP)) { - php_error(E_WARNING, "Function must be enabled in php.ini by setting 'xdebug.mode' to 'develop'"); - array_init(return_value); - return; - } - - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &clear) == FAILURE) { - return; - } - - array_init(return_value); - for (le = XDEBUG_LLIST_HEAD(XG_DEV(monitored_functions_found)); le != NULL; le = XDEBUG_LLIST_NEXT(le)) { - zval *entry; - - mfe = XDEBUG_LLIST_VALP(le); - - XDEBUG_MAKE_STD_ZVAL(entry); - array_init(entry); - - add_assoc_string_ex(entry, "function", HASH_KEY_SIZEOF("function"), mfe->func_name); - add_assoc_string_ex(entry, "filename", HASH_KEY_SIZEOF("filename"), ZSTR_VAL(mfe->filename)); - add_assoc_long(entry, "lineno", mfe->lineno); - - add_next_index_zval(return_value, entry); - efree(entry); - } - - if (clear) { - xdebug_llist_destroy(XG_DEV(monitored_functions_found), NULL); - XG_DEV(monitored_functions_found) = xdebug_llist_alloc(xdebug_monitored_function_dtor); - } -} -/* }}} */
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/develop/php_functions.c
Deleted
@@ -1,383 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#include "lib/php-header.h" -#include "php_xdebug.h" - -#include "develop_private.h" -#include "stack.h" - -#include "lib/lib_private.h" -#include "lib/var_export_html.h" -#include "lib/var_export_line.h" -#include "lib/var_export_text.h" - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - -#define MODE_MUST_BE(m,n) \ - if (!XDEBUG_MODE_IS((m))) { \ - php_error(E_WARNING, "Function must be enabled in php.ini by setting 'xdebug.mode' to '%s'", (n)); \ - return; \ - } - -/* {{{ proto void xdebug_var_dump(mixed var , ... ) - Outputs a fancy string representation of a variable */ -PHP_FUNCTION(xdebug_var_dump) -{ - zval *args; - int argc; - int i; - xdebug_str *val; - - argc = ZEND_NUM_ARGS(); - - args = safe_emalloc(argc, sizeof(zval), 0); - if (ZEND_NUM_ARGS() == 0 || zend_get_parameters_array_ex(argc, args) == FAILURE) { - efree(args); - WRONG_PARAM_COUNT; - } - - for (i = 0; i < argc; i++) { - if (PG(html_errors)) { - val = xdebug_get_zval_value_html(NULL, (zval*) &argsi, 0, NULL); - PHPWRITE(val->d, val->l); - xdebug_str_free(val); - } - else if ((XINI_DEV(cli_color) == 1 && xdebug_is_output_tty()) || (XINI_DEV(cli_color) == 2)) { - val = xdebug_get_zval_value_ansi((zval*) &argsi, 0, NULL); - PHPWRITE(val->d, val->l); - xdebug_str_free(val); - } - else { - val = xdebug_get_zval_value_text((zval*) &argsi, 0, NULL); - PHPWRITE(val->d, val->l); - xdebug_str_free(val); - } - } - - efree(args); -} -/* }}} */ - -/* {{{ proto void xdebug_debug_zval(mixed var , ... ) - Outputs a fancy string representation of a variable */ -PHP_FUNCTION(xdebug_debug_zval) -{ - zval *args; - int argc; - int i; - xdebug_str *val; - - argc = ZEND_NUM_ARGS(); - - args = safe_emalloc(argc, sizeof(zval), 0); - if (ZEND_NUM_ARGS() == 0 || zend_get_parameters_array_ex(argc, args) == FAILURE) { - efree(args); - WRONG_PARAM_COUNT; - } - - if (!(ZEND_CALL_INFO(EG(current_execute_data)->prev_execute_data) & ZEND_CALL_HAS_SYMBOL_TABLE)) { - zend_rebuild_symbol_table(); - } - - for (i = 0; i < argc; i++) { - if (Z_TYPE(argsi) == IS_STRING) { - zval debugzval; - xdebug_str *tmp_name; - - xdebug_lib_set_active_symbol_table(EG(current_execute_data)->prev_execute_data->symbol_table); - xdebug_lib_set_active_data(EG(current_execute_data)->prev_execute_data); - - tmp_name = xdebug_str_create(Z_STRVAL(argsi), Z_STRLEN(argsi)); - xdebug_get_php_symbol(&debugzval, tmp_name); - xdebug_str_free(tmp_name); - - /* Reduce refcount for dumping */ - Z_TRY_DELREF(debugzval); - - php_printf("%s: ", Z_STRVAL(argsi)); - if (Z_TYPE(debugzval) != IS_UNDEF) { - if (PG(html_errors)) { - val = xdebug_get_zval_value_html(NULL, &debugzval, 1, NULL); - PHPWRITE(val->d, val->l); - } - else if ((XINI_DEV(cli_color) == 1 && xdebug_is_output_tty()) || (XINI_DEV(cli_color) == 2)) { - val = xdebug_get_zval_value_ansi(&debugzval, 1, NULL); - PHPWRITE(val->d, val->l); - } - else { - val = xdebug_get_zval_value_line(&debugzval, 1, NULL); - PHPWRITE(val->d, val->l); - } - xdebug_str_free(val); - PHPWRITE("\n", 1); - } else { - PHPWRITE("no such symbol\n", 15); - } - - /* Restore original refcount */ - Z_TRY_ADDREF(debugzval); - zval_ptr_dtor_nogc(&debugzval); - } - } - - efree(args); -} -/* }}} */ - -/* {{{ proto void xdebug_debug_zval_stdout(mixed var , ... ) - Outputs a fancy string representation of a variable */ -PHP_FUNCTION(xdebug_debug_zval_stdout) -{ - zval *args; - int argc; - int i; - - argc = ZEND_NUM_ARGS(); - - args = safe_emalloc(argc, sizeof(zval), 0); - if (ZEND_NUM_ARGS() == 0 || zend_get_parameters_array_ex(argc, args) == FAILURE) { - efree(args); - WRONG_PARAM_COUNT; - } - - if (!(ZEND_CALL_INFO(EG(current_execute_data)->prev_execute_data) & ZEND_CALL_HAS_SYMBOL_TABLE)) { - zend_rebuild_symbol_table(); - } - - for (i = 0; i < argc; i++) { - if (Z_TYPE(argsi) == IS_STRING) { - zval debugzval; - xdebug_str *tmp_name; - xdebug_str *val; - - xdebug_lib_set_active_symbol_table(EG(current_execute_data)->prev_execute_data->symbol_table); - xdebug_lib_set_active_data(EG(current_execute_data)->prev_execute_data); - - tmp_name = xdebug_str_create(Z_STRVAL(argsi), Z_STRLEN(argsi)); - xdebug_get_php_symbol(&debugzval, tmp_name); - xdebug_str_free(tmp_name); - - /* Reduce refcount for dumping */ - Z_TRY_DELREF(debugzval); - - printf("%s: ", Z_STRVAL(argsi)); - if (Z_TYPE(debugzval) != IS_UNDEF) { - val = xdebug_get_zval_value_line(&debugzval, 1, NULL); - printf("%s(%zd)", val->d, val->l); - xdebug_str_free(val); - printf("\n"); - } else { - printf("no such symbol\n\n"); - } - - /* Restore original refcount */ - Z_TRY_ADDREF(debugzval); - zval_ptr_dtor_nogc(&debugzval); - } - } - - efree(args); -} -/* }}} */ - -PHP_FUNCTION(xdebug_start_error_collection) -{ - MODE_MUST_BE(XDEBUG_MODE_DEVELOP, "develop");
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/develop/stack.c
Deleted
@@ -1,1005 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2021 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ -#include "php_xdebug.h" - -#include "main/php_ini.h" - -#include "ext/standard/html.h" -#include "ext/standard/php_smart_string.h" -#include "zend_exceptions.h" -#include "zend_generators.h" - -#include "monitor.h" -#include "stack.h" -#include "superglobals.h" - -#include "base/filter.h" -#include "coverage/code_coverage.h" -#include "lib/compat.h" -#include "lib/lib_private.h" -#include "lib/str.h" -#include "lib/var_export_html.h" -#include "lib/var_export_line.h" -#include "profiler/profiler.h" - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - -static const char* text_formats11 = { - "\n", - "%s: %s in %s on line %d\n", - "\nCall Stack:\n", - "%10.4F %10ld %3d. %s(", - "'%s'", - ") %s:%d\n", - "\n\nVariables in local scope (#%d):\n", - "\n", - " $%s = %s\n", - " $%s = *uninitialized*\n", - "SCREAM: Error suppression ignored for\n" -}; - -static const char* ansi_formats11 = { - "\n", - "1m31m%s0m: %s22m in 31m%s0m on line 32m%d0m22m\n", - "\n1mCall Stack:22m\n", - "%10.4F %10ld %3d. %s(", - "'%s'", - ") %s:%d\n", - "\n\nVariables in local scope (#%d):\n", - "\n", - " $%s = %s\n", - " $%s = *uninitialized*\n", - "1m31mSCREAM0m: Error suppression ignored for\n" -}; - -static const char* html_formats13 = { - "<br />\n<font size='1'><table class='xdebug-error xe-%s%s' dir='ltr' border='1' cellspacing='0' cellpadding='1'>\n", - "<tr><th align='left' bgcolor='#f57900' colspan=\"5\"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> %s: %s in %s on line <i>%d</i></th></tr>\n", - "<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>\n<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>\n", - "<tr><td bgcolor='#eeeeec' align='center'>%d</td><td bgcolor='#eeeeec' align='center'>%.4F</td><td bgcolor='#eeeeec' align='right'>%ld</td><td bgcolor='#eeeeec'>%s( ", - "<font color='#00bb00'>'%s'</font>", - " )</td><td title='%s' bgcolor='#eeeeec'>%s<b>:</b>%d</td></tr>\n", - "<tr><th align='left' colspan='5' bgcolor='#e9b96e'>Variables in local scope (#%d)</th></tr>\n", - "</table></font>\n", - "<tr><td colspan='2' align='right' bgcolor='#eeeeec' valign='top'><pre>$%s =</pre></td><td colspan='3' bgcolor='#eeeeec'>%s</td></tr>\n", - "<tr><td colspan='2' align='right' bgcolor='#eeeeec' valign='top'><pre>$%s =</pre></td><td colspan='3' bgcolor='#eeeeec' valign='top'><i>Undefined</i></td></tr>\n", - " )</td><td title='%s' bgcolor='#eeeeec'><a style='color: black' href='%s'>%s<b>:</b>%d</a></td></tr>\n", - "<tr><th align='left' bgcolor='#f57900' colspan=\"5\"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> %s: %s in <a style='color: black' href='%s'>%s</a> on line <i>%d</i></th></tr>\n", - "<tr><th align='left' bgcolor='#f57900' colspan=\"5\"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> SCREAM: Error suppression ignored for</th></tr>\n" -}; - -static const char** select_formats(int html) -{ - if (html) { - return html_formats; - } else if ((XINI_DEV(cli_color) == 1 && xdebug_is_output_tty()) || (XINI_DEV(cli_color) == 2)) { - return ansi_formats; - } else { - return text_formats; - } -} - -void xdebug_log_stack(const char *error_type_str, char *buffer, const char *error_filename, const int error_lineno) -{ - char *tmp_log_message; - int i; - function_stack_entry *fse; - - tmp_log_message = xdebug_sprintf( "PHP %s: %s in %s on line %d", error_type_str, buffer, error_filename, error_lineno); - php_log_err(tmp_log_message); - xdfree(tmp_log_message); - - if (!XG_BASE(stack) || XDEBUG_VECTOR_COUNT(XG_BASE(stack)) < 1) { - return; - } - - fse = XDEBUG_VECTOR_HEAD(XG_BASE(stack)); - - php_log_err((char*) "PHP Stack trace:"); - - for (i = 0; i < XDEBUG_VECTOR_COUNT(XG_BASE(stack)); i++, fse++) - { - int c = 0; /* Comma flag */ - unsigned int j = 0; /* Counter */ - char *tmp_name; - xdebug_str log_buffer = XDEBUG_STR_INITIALIZER; - int variadic_opened = 0; - int sent_variables = fse->varc; - - if (sent_variables > 0 && fse->varsent_variables-1.is_variadic && Z_ISUNDEF(fse->varsent_variables-1.data)) { - sent_variables--; - } - - tmp_name = xdebug_show_fname(fse->function, XDEBUG_SHOW_FNAME_DEFAULT); - xdebug_str_add_fmt(&log_buffer, "PHP %3d. %s(", fse->level, tmp_name); - xdfree(tmp_name); - - /* Printing vars */ - for (j = 0; j < sent_variables; j++) { - xdebug_str *tmp_value; - - if (c) { - xdebug_str_add_literal(&log_buffer, ", "); - } else { - c = 1; - } - - if (fse->varj.is_variadic) { - xdebug_str_add_literal(&log_buffer, "..."); - variadic_opened = 1; - } - - if (fse->varj.name) { - xdebug_str_add_fmt(&log_buffer, "$%s = ", ZSTR_VAL(fse->varj.name)); - } - - if (fse->varj.is_variadic) { - xdebug_str_add_literal(&log_buffer, "variadic("); - c = 0; - continue; - } - - if (!Z_ISUNDEF(fse->varj.data)) { - tmp_value = xdebug_get_zval_value_line(&fse->varj.data, 0, NULL); - xdebug_str_add_str(&log_buffer, tmp_value); - xdebug_str_free(tmp_value); - } else { - xdebug_str_add_literal(&log_buffer, "*uninitialized*"); - } - } - - if (variadic_opened) { - xdebug_str_add_literal(&log_buffer, ")"); - } - - xdebug_str_add_fmt(&log_buffer, ") %s:%d", ZSTR_VAL(fse->filename), fse->lineno); - php_log_err(log_buffer.d); - xdebug_str_destroy(&log_buffer); - } -} - -void xdebug_append_error_head(xdebug_str *str, int html, const char *error_type_str) -{ - const char **formats = select_formats(html); - - if (html) { - xdebug_str_add_fmt(str, formats0, error_type_str, XG_DEV(in_at) ? " xe-scream" : ""); - if (XG_DEV(in_at)) { - xdebug_str_add_const(str, formats12); - } - } else { - xdebug_str_add_const(str, formats0); - if (XG_DEV(in_at)) { - xdebug_str_add_const(str, formats10); - } - } -} - -void xdebug_append_error_description(xdebug_str *str, int html, const char *error_type_str, const char *buffer, const char *error_filename, const int error_lineno) -{ - const char **formats = select_formats(html); - char *escaped; - - if (!html) { - escaped = estrdup(buffer); - } else { - zend_string *tmp;
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/gcstats/gc_stats.c
Deleted
@@ -1,356 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ -#include "lib/php-header.h" -#include "zend_builtin_functions.h" -#include "SAPI.h" -#include "Zend/zend_long.h" - -#include "php_xdebug.h" -#include "gc_stats_private.h" - -#include "base/base.h" -#include "lib/lib.h" -#include "lib/log.h" - -/* Set correct int format to use */ -#define XDEBUG_GCINT_FMT ZEND_LONG_FMT_SPEC - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - -static void xdebug_gc_stats_print_run(xdebug_gc_run *run); -static void xdebug_gc_stats_run_free(xdebug_gc_run *run); -int (*xdebug_old_gc_collect_cycles)(void); - -static int xdebug_gc_collect_cycles(void) -{ - int ret; - uint32_t collected; - xdebug_gc_run *run; - zend_execute_data *execute_data; - long int memory; - uint64_t start; - xdebug_func tmp; - zend_gc_status status; - - if (!XG_GCSTATS(active)) { - return xdebug_old_gc_collect_cycles(); - } - - execute_data = EG(current_execute_data); - - zend_gc_get_status(&status); - collected = status.collected; - start = xdebug_get_nanotime(); - memory = zend_memory_usage(0); - - ret = xdebug_old_gc_collect_cycles(); - - run = xdmalloc(sizeof(xdebug_gc_run)); - run->function_name = NULL; - run->class_name = NULL; - - zend_gc_get_status(&status); - run->collected = status.collected - collected; - run->duration = xdebug_get_nanotime() - start; - run->memory_before = memory; - run->memory_after = zend_memory_usage(0); - - xdebug_build_fname(&tmp, execute_data); - - run->function_name = tmp.function ? xdstrdup(tmp.function) : NULL; - run->class_name = tmp.object_class ? zend_string_copy(tmp.object_class) : NULL; - - xdebug_gc_stats_print_run(run); - - xdebug_gc_stats_run_free(run); - xdebug_func_dtor_by_ref(&tmp); - - return ret; -} - -static void xdebug_gc_stats_run_free(xdebug_gc_run *run) -{ - if (!run) { - return; - } - - if (run->function_name) { - xdfree(run->function_name); - } - if (run->class_name) { - zend_string_release(run->class_name); - } - xdfree(run); -} - -static int xdebug_gc_stats_init(char *requested_filename, zend_string *script_name) -{ - char *filename_to_use = NULL; - char *generated_filename = NULL; - char *output_dir = xdebug_lib_get_output_dir(); /* not duplicated */ - - if (!gc_enabled()) { - xdebug_log_ex(XLOG_CHAN_GCSTATS, XLOG_ERR, "DISABLED", "PHP's Garbage Collection is disabled"); - return FAILURE; - } - - if (requested_filename && strlen(requested_filename)) { - filename_to_use = xdstrdup(requested_filename); - } else { - if (!strlen(XINI_GCSTATS(output_name)) || - xdebug_format_output_filename(&generated_filename, XINI_GCSTATS(output_name), ZSTR_VAL(script_name)) <= 0) - { - return FAILURE; - } - - if (IS_SLASH(output_dirstrlen(output_dir) - 1)) { - filename_to_use = xdebug_sprintf("%s%s", output_dir, generated_filename); - } else { - filename_to_use = xdebug_sprintf("%s%c%s", output_dir, DEFAULT_SLASH, generated_filename); - } - } - - XG_GCSTATS(file) = xdebug_fopen(filename_to_use, "w", NULL, &XG_GCSTATS(filename)); - - if (!XG_GCSTATS(file)) { - xdebug_log_diagnose_permissions(XLOG_CHAN_GCSTATS, output_dir, filename_to_use); - - xdfree(filename_to_use); - if (generated_filename) { - xdfree(generated_filename); - } - - return FAILURE; - } - xdfree(filename_to_use); - - fprintf(XG_GCSTATS(file), "Garbage Collection Report\n"); - fprintf(XG_GCSTATS(file), "version: 1\ncreator: xdebug %s (PHP %s)\n\n", XDEBUG_VERSION, PHP_VERSION); - - fprintf(XG_GCSTATS(file), "Collected | Efficiency%% | Duration | Memory Before | Memory After | Reduction%% | Function\n"); - fprintf(XG_GCSTATS(file), "----------+-------------+----------+---------------+--------------+------------+---------\n"); - - fflush(XG_GCSTATS(file)); - - if (generated_filename) { - xdfree(generated_filename); - } - - return SUCCESS; -} - -static void xdebug_gc_stats_stop() -{ - XG_GCSTATS(active) = 0; - - if (XG_GCSTATS(file)) { - if (!gc_enabled()) { - fprintf(XG_GCSTATS(file), "Garbage Collection Disabled End\n"); - xdebug_log_ex(XLOG_CHAN_GCSTATS, XLOG_ERR, "DISABLED", "PHP's Garbage Collection is disabled at the end of the script"); - } - - fclose(XG_GCSTATS(file)); - XG_GCSTATS(file) = NULL; - } -} - -#define AS_PERCENT(n) ((n)*100.0) -#define ROOTS_AS_PERCENT(n) AS_PERCENT((n) / 10000.0) - -static void xdebug_gc_stats_print_run(xdebug_gc_run *run) -{ - double reduction; - - if (run->memory_before) { - reduction = (1 - (float)run->memory_after / (float)run->memory_before) * 100.0; - } else { - reduction = 0; - } - - if (!XG_GCSTATS(file)) { - return; - } - - if (!run->function_name) { - fprintf(XG_GCSTATS(file), - "%9" XDEBUG_GCINT_FMT " | %9.2f %% | %5.2f ms | %13" XDEBUG_GCINT_FMT " | %12" XDEBUG_GCINT_FMT " | %8.2f %% | -\n", - run->collected, - ROOTS_AS_PERCENT(run->collected), - run->duration / (double)NANOS_IN_MILLISEC, - run->memory_before, - run->memory_after, - reduction - ); - } else if (!run->class_name && run->function_name) { - fprintf(XG_GCSTATS(file), - "%9" XDEBUG_GCINT_FMT " | %9.2f %% | %5.2f ms | %13" XDEBUG_GCINT_FMT " | %12" XDEBUG_GCINT_FMT " | %8.2f %% | %s\n",
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/gcstats/gc_stats_private.h
Deleted
@@ -1,34 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2020 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#ifndef __XDEBUG_GC_STATS_PRIVATE_H__ -#define __XDEBUG_GC_STATS_PRIVATE_H__ - -#include "gc_stats.h" - -typedef struct _xdebug_gc_run { - zend_long collected; - zend_long duration; - zend_long memory_before; - zend_long memory_after; - char *function_name; - zend_string *class_name; -} xdebug_gc_run; - -#define XINI_GCSTATS(v) (XG(settings.gc_stats.v)) -#define XG_GCSTATS(v) (XG(globals.gc_stats.v)) - -#endif
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/lib/compat.h
Deleted
@@ -1,80 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#ifndef __HAVE_XDEBUG_COMPAT_H__ -#define __HAVE_XDEBUG_COMPAT_H__ - -#include "lib/php-header.h" -#include "str.h" - -#include "ext/standard/head.h" -#include "ext/standard/php_var.h" -#define xdebug_php_var_dump php_var_dump - -char *xdebug_str_to_str(char *haystack, size_t length, const char *needle, size_t needle_len, const char *str, size_t str_len, size_t *new_len); - -unsigned char *xdebug_base64_encode(unsigned char *data, size_t data_len, size_t *new_len); -unsigned char *xdebug_base64_decode(unsigned char *data, size_t data_len, size_t *new_len); - -zend_string *xdebug_addslashes(zend_string *str); -void xdebug_stripcslashes(char *string, int *new_len); - -zend_ulong xdebug_get_pid(void); - -void xdebug_setcookie(const char *name, int name_len, char *value, int value_len, time_t expires, const char *path, int path_len, const char *domain, int domain_len, int secure, int url_encode, int httponly); -char *xdebug_get_compiled_variable_name(zend_op_array *op_array, uint32_t var, int *cv_len); - -/* Recursion protection is done differently from PHP 7.3 onwards */ -zend_bool xdebug_zend_hash_is_recursive(HashTable* ht); -zend_bool xdebug_zend_hash_apply_protection_begin(HashTable* ht); -zend_bool xdebug_zend_hash_apply_protection_end(HashTable* ht); - -# define XDEBUG_MAKE_STD_ZVAL(zv) \ - zv = ecalloc(sizeof(zval), 1); - -# define HASH_KEY_SIZEOF(k) (sizeof(k) - 1) -# define HASH_KEY_STRLEN(k) (strlen(k)) -# define HASH_KEY_IS_NUMERIC(k) ((k) == NULL) -# define HASH_APPLY_KEY_VAL(k) (k)->val -# define HASH_APPLY_KEY_LEN(k) (k)->len + 1 - -# define STR_NAME_VAL(k) (k)->val -# define STR_NAME_LEN(k) (k)->len - -# if defined (__GNUC__) -# define XDEBUG_GNUC_CHECK_VERSION(major, minor) \ - ((__GNUC__ > (major)) || \ - ((__GNUC__ == (major)) && (__GNUC_MINOR__ >= (minor)))) -# else -# define XDEBUG_GNUC_CHECK_VERSION(major, minor) 0 -# endif - -# if XDEBUG_GNUC_CHECK_VERSION(7, 0) -# define XDEBUG_BREAK_INTENTIONALLY_MISSING __attribute__ ((fallthrough)); -# else -# define XDEBUG_BREAK_INTENTIONALLY_MISSING -# endif - -# if XDEBUG_GNUC_CHECK_VERSION(2, 7) || __has_attribute(format) -# define XDEBUG_ATTRIBUTE_FORMAT(type, idx, first) __attribute__ ((format(type, idx, first))) -# else -# define XDEBUG_ATTRIBUTE_FORMAT(type, idx, first) -# endif - -#define XDEBUG_OPCODE_HANDLER_ARGS zend_execute_data *execute_data -#define XDEBUG_OPCODE_HANDLER_ARGS_PASSTHRU execute_data - -#endif
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/lib/headers.c
Deleted
@@ -1,106 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2020 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ -#include "php_xdebug.h" - -#include "lib_private.h" - -extern ZEND_DECLARE_MODULE_GLOBALS(xdebug); - -static int xdebug_header_handler(sapi_header_struct *h, sapi_header_op_enum op, sapi_headers_struct *s); -static int (*xdebug_orig_header_handler)(sapi_header_struct *h, sapi_header_op_enum op, sapi_headers_struct *s); - -static void xdebug_header_remove_with_prefix(xdebug_llist *headers, char *prefix, size_t prefix_len) -{ - xdebug_llist_element *le; - char *header; - - for (le = XDEBUG_LLIST_HEAD(XG_LIB(headers)); le != NULL; /* intentionally left blank*/) { - header = XDEBUG_LLIST_VALP(le); - - if ((strlen(header) > prefix_len + 1) && (headerprefix_len == ':') && (strncasecmp(header, prefix, prefix_len) == 0)) { - xdebug_llist_element *current = le; - - le = XDEBUG_LLIST_NEXT(le); - xdebug_llist_remove(headers, current, NULL); - } else { - le = XDEBUG_LLIST_NEXT(le); - } - } -} - -static int xdebug_header_handler(sapi_header_struct *h, sapi_header_op_enum op, sapi_headers_struct *s) -{ - if (XG_LIB(headers)) { - switch (op) { - case SAPI_HEADER_ADD: - xdebug_llist_insert_next(XG_LIB(headers), XDEBUG_LLIST_TAIL(XG_LIB(headers)), xdstrdup(h->header)); - break; - case SAPI_HEADER_REPLACE: { - char *colon_offset = strchr(h->header, ':'); - - if (colon_offset) { - char save = *colon_offset; - - *colon_offset = '\0'; - xdebug_header_remove_with_prefix(XG_LIB(headers), h->header, strlen(h->header)); - *colon_offset = save; - } - - xdebug_llist_insert_next(XG_LIB(headers), XDEBUG_LLIST_TAIL(XG_LIB(headers)), xdstrdup(h->header)); - } break; - case SAPI_HEADER_DELETE_ALL: - xdebug_llist_empty(XG_LIB(headers), NULL); - case SAPI_HEADER_DELETE: - case SAPI_HEADER_SET_STATUS: - break; - } - } - if (xdebug_orig_header_handler) { - return xdebug_orig_header_handler(h, op, s); - } - return SAPI_HEADER_ADD; -} - -void xdebug_lib_zend_startup_overload_sapi_headers(void) -{ - /* Override header handler in SAPI */ - if (xdebug_orig_header_handler != NULL) { - return; - } - - xdebug_orig_header_handler = sapi_module.header_handler; - sapi_module.header_handler = xdebug_header_handler; -} - -void xdebug_lib_zend_shutdown_restore_sapi_headers(void) -{ - /* Restore original header handler in SAPI */ - sapi_module.header_handler = xdebug_orig_header_handler; - xdebug_orig_header_handler = NULL; -} - - -PHP_FUNCTION(xdebug_get_headers) -{ - xdebug_llist_element *le; - char *string; - - array_init(return_value); - for (le = XDEBUG_LLIST_HEAD(XG_LIB(headers)); le != NULL; le = XDEBUG_LLIST_NEXT(le)) { - string = XDEBUG_LLIST_VALP(le); - add_next_index_string(return_value, string); - } -}
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/lib/lib.c
Deleted
@@ -1,767 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#include "php_xdebug.h" - -#include "headers.h" - -#include "lib_private.h" -#include "log.h" - -extern ZEND_DECLARE_MODULE_GLOBALS(xdebug); - -void xdebug_init_library_globals(xdebug_library_globals_t *xg) -{ - xg->headers = NULL; - xg->mode = 0xFFFFFFFF; - xg->mode_from_environment = 0; - - xg->log_file = 0; - - xg->active_execute_data = NULL; - xg->opcode_handlers_set = xdebug_set_create(256); - memset(xg->original_opcode_handlers, 0, sizeof(xg->original_opcode_handlers)); - memset(xg->opcode_multi_handlers, 0, sizeof(xg->opcode_multi_handlers)); - - XINI_LIB(log_level) = 0; - xg->diagnosis_buffer = NULL; -} - - -void xdebug_library_zend_startup(void) -{ - xdebug_lib_zend_startup_overload_sapi_headers(); -} - -void xdebug_library_zend_shutdown(void) -{ - xdebug_lib_zend_shutdown_restore_sapi_headers(); -} - - -void xdebug_library_minit(void) -{ - xdebug_set_opcode_multi_handler(ZEND_ASSIGN); - xdebug_set_opcode_multi_handler(ZEND_ASSIGN_DIM); - xdebug_set_opcode_multi_handler(ZEND_ASSIGN_OBJ); - xdebug_set_opcode_multi_handler(ZEND_ASSIGN_STATIC_PROP); - xdebug_set_opcode_multi_handler(ZEND_QM_ASSIGN); - xdebug_set_opcode_multi_handler(ZEND_INCLUDE_OR_EVAL); -} - -static void xdebug_multi_opcode_handler_dtor(xdebug_multi_opcode_handler_t *ptr) -{ - if (ptr->next) { - xdebug_multi_opcode_handler_dtor(ptr->next); - } - xdfree(ptr); -} - -void xdebug_library_mshutdown(void) -{ - int i; - - /* Restore all opcode handlers that we have set */ - for (i = 0; i < 256; i++) { - if (XG_LIB(opcode_multi_handlers)i != NULL) { - xdebug_multi_opcode_handler_dtor(XG_LIB(opcode_multi_handlers)i); - } - xdebug_unset_opcode_handler(i); - } - - xdebug_set_free(XG_LIB(opcode_handlers_set)); -} - -void xdebug_library_rinit(void) -{ - XG_LIB(diagnosis_buffer) = xdebug_str_new(); - xdebug_open_log(); - - XG_LIB(headers) = xdebug_llist_alloc(xdebug_llist_string_dtor); - - XG_LIB(dumped) = 0; - XG_LIB(do_collect_errors) = 0; -} - -void xdebug_library_post_deactivate(void) -{ - /* Clean up collected headers */ - xdebug_llist_destroy(XG_LIB(headers), NULL); - XG_LIB(headers) = NULL; - - - xdebug_close_log(); - xdebug_str_free(XG_LIB(diagnosis_buffer)); -} - - -void xdebug_disable_opcache_optimizer(void) -{ - zend_string *key = zend_string_init(ZEND_STRL("opcache.optimization_level"), 1); - zend_string *value = zend_string_init(ZEND_STRL("0"), 1); - - zend_alter_ini_entry(key, value, ZEND_INI_SYSTEM, ZEND_INI_STAGE_STARTUP); - - zend_string_release(key); - zend_string_release(value); -} - - -static int xdebug_lib_set_mode_item(const char *mode, int len) -{ - if (strncmp(mode, "off", len) == 0) { - XG_LIB(mode) |= XDEBUG_MODE_OFF; - return 1; - } - if (strncmp(mode, "develop", len) == 0) { - XG_LIB(mode) |= XDEBUG_MODE_DEVELOP; - return 1; - } - if (strncmp(mode, "coverage", len) == 0) { - XG_LIB(mode) |= XDEBUG_MODE_COVERAGE; - return 1; - } - if (strncmp(mode, "debug", len) == 0) { - XG_LIB(mode) |= XDEBUG_MODE_STEP_DEBUG; - return 1; - } - if (strncmp(mode, "gcstats", len) == 0) { - XG_LIB(mode) |= XDEBUG_MODE_GCSTATS; - return 1; - } - if (strncmp(mode, "profile", len) == 0) { - XG_LIB(mode) |= XDEBUG_MODE_PROFILING; - return 1; - } - if (strncmp(mode, "trace", len) == 0) { - XG_LIB(mode) |= XDEBUG_MODE_TRACING; - return 1; - } - - return 0; -} - -static int xdebug_lib_set_mode_from_setting(const char *mode) -{ - const char *mode_ptr = mode; - char *comma = NULL; - int errors = 0; - - XG_LIB(mode) = 0; - - comma = strchr(mode_ptr, ','); - while (comma) { - errors += !xdebug_lib_set_mode_item(mode_ptr, comma - mode_ptr); - mode_ptr = comma + 1; - while (*mode_ptr == ' ') { - mode_ptr++; - } - comma = strchr(mode_ptr, ','); - } - errors += !xdebug_lib_set_mode_item(mode_ptr, strlen(mode_ptr)); - - return !errors; -} - -int xdebug_lib_set_mode(const char *mode) -{ - char *config = getenv("XDEBUG_MODE"); - int result = 0; - - /* XDEBUG_MODE environment variable */ - if (config && strlen(config)) { - result = xdebug_lib_set_mode_from_setting(config); - - if (!result) { - xdebug_log_ex(XLOG_CHAN_CONFIG, XLOG_CRIT, "ENVMODE", "Invalid mode '%s' set for 'XDEBUG_MODE' environment variable, fall back to 'xdebug.mode' configuration setting", config); - } else { - XG_LIB(mode_from_environment) = 1; - return result; - } - } - - /* 'xdebug.mode' configuration setting */ - result = xdebug_lib_set_mode_from_setting(mode); - - if (!result) {
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/lib/lib.h
Deleted
@@ -1,324 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2021 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#ifndef __XDEBUG_LIBRARY_H__ -#define __XDEBUG_LIBRARY_H__ - -#ifdef ZTS -# include "TSRM.h" -#endif - -#include "zend.h" -#include "zend_API.h" -#include "compat.h" - -typedef struct xdebug_var_name { - zend_string *name; - zval data; - int is_variadic; -} xdebug_var_name; - -#define XFUNC_UNKNOWN 0x00 -#define XFUNC_NORMAL 0x01 -#define XFUNC_STATIC_MEMBER 0x02 -#define XFUNC_MEMBER 0x03 - -#define XFUNC_INCLUDES 0x10 -#define XFUNC_EVAL 0x10 -#define XFUNC_INCLUDE 0x11 -#define XFUNC_INCLUDE_ONCE 0x12 -#define XFUNC_REQUIRE 0x13 -#define XFUNC_REQUIRE_ONCE 0x14 -#define XFUNC_MAIN 0x15 -#if PHP_VERSION_ID >= 80100 -# define XFUNC_FIBER 0x16 -#endif - -#define XFUNC_ZEND_PASS 0x20 - -#define XDEBUG_IS_NORMAL_FUNCTION(f) ((f)->type == XFUNC_NORMAL || (f)->type == XFUNC_STATIC_MEMBER || (f)->type == XFUNC_MEMBER) - -#define XDEBUG_REGISTER_LONG_CONSTANT(__c) REGISTER_LONG_CONSTANT(#__c, __c, CONST_CS|CONST_PERSISTENT) - -#define XDEBUG_NONE 0 -#define XDEBUG_JIT 1 -#define XDEBUG_REQ 2 - -#define XDEBUG_BREAK 1 -#define XDEBUG_STEP 2 - -#define XDEBUG_BUILT_IN 0 -#define XDEBUG_USER_DEFINED 1 - -#define XDEBUG_MAX_FUNCTION_LEN 1024 - -#define XDEBUG_TRACE_OPTION_APPEND 1 -#define XDEBUG_TRACE_OPTION_COMPUTERIZED 2 -#define XDEBUG_TRACE_OPTION_HTML 4 -#define XDEBUG_TRACE_OPTION_NAKED_FILENAME 8 - -#define XDEBUG_CC_OPTION_UNUSED 1 -#define XDEBUG_CC_OPTION_DEAD_CODE 2 -#define XDEBUG_CC_OPTION_BRANCH_CHECK 4 - -#define STATUS_STARTING 0 -#define STATUS_STOPPING 1 -#define STATUS_STOPPED 2 -#define STATUS_RUNNING 3 -#define STATUS_BREAK 4 - -#define REASON_OK 0 -#define REASON_ERROR 1 -#define REASON_ABORTED 2 -#define REASON_EXCEPTION 3 - -#define XDEBUG_CMDLOOP_NONBLOCK 0 -#define XDEBUG_CMDLOOP_BLOCK 1 - -#define XDEBUG_CMDLOOP_NONBAIL 0 -#define XDEBUG_CMDLOOP_BAIL 1 - -#define XDEBUG_ERROR_OK 0 -#define XDEBUG_ERROR_PARSE 1 -#define XDEBUG_ERROR_DUP_ARG 2 -#define XDEBUG_ERROR_INVALID_ARGS 3 -#define XDEBUG_ERROR_UNIMPLEMENTED 4 -#define XDEBUG_ERROR_COMMAND_UNAVAILABLE 5 - -#define XDEBUG_ERROR_CANT_OPEN_FILE 100 -#define XDEBUG_ERROR_STREAM_REDIRECT_FAILED 101 /* unused */ - -#define XDEBUG_ERROR_BREAKPOINT_NOT_SET 200 -#define XDEBUG_ERROR_BREAKPOINT_TYPE_NOT_SUPPORTED 201 -#define XDEBUG_ERROR_BREAKPOINT_INVALID 202 -#define XDEBUG_ERROR_BREAKPOINT_NO_CODE 203 -#define XDEBUG_ERROR_BREAKPOINT_INVALID_STATE 204 -#define XDEBUG_ERROR_NO_SUCH_BREAKPOINT 205 -#define XDEBUG_ERROR_EVALUATING_CODE 206 -#define XDEBUG_ERROR_INVALID_EXPRESSION 207 /* unused */ - -#define XDEBUG_ERROR_PROPERTY_NON_EXISTENT 300 -#define XDEBUG_ERROR_PROPERTY_NON_EXISTANT 300 /* compatibility typo */ -#define XDEBUG_ERROR_STACK_DEPTH_INVALID 301 -#define XDEBUG_ERROR_CONTEXT_INVALID 302 /* unused */ - -#define XDEBUG_ERROR_PROFILING_NOT_STARTED 800 - -#define XDEBUG_ERROR_ENCODING_NOT_SUPPORTED 900 - -typedef struct _xdebug_func { - zend_string *object_class; - zend_string *scope_class; - char *function; - int type; - int internal; -} xdebug_func; - -typedef struct xdebug_profile { - uint64_t nanotime; - uint64_t nanotime_mark; - long memory; - long mem_mark; - xdebug_llist *call_list; -} xdebug_profile; - -typedef struct _function_stack_entry { - /* function properties */ - xdebug_func function; - unsigned int function_nr; - unsigned short user_defined:1; - unsigned short level:15; - - /* argument properties */ - unsigned short varc; - xdebug_var_name *var; - zval *return_value; - xdebug_llist *declared_vars; - HashTable *symbol_table; - zend_execute_data *execute_data; - unsigned char is_variadic; - unsigned char arg_done; - - /* filter properties */ - unsigned char filtered_code_coverage; - unsigned char filtered_stack; - unsigned char filtered_tracing; - - /* location properties */ - int lineno; - zend_string *filename; - zend_string *include_filename; - - /* tracing properties */ - signed long memory; - signed long prev_memory; - uint64_t nanotime; - - /* profiling properties */ - xdebug_profile profile; - struct { - int lineno; - zend_string *filename; - char *funcname; - } profiler; - - /* misc properties */ - zend_op_array *op_array; -} function_stack_entry; - -function_stack_entry *xdebug_get_stack_frame(int nr); - - -xdebug_hash* xdebug_declared_var_hash_from_llist(xdebug_llist *list); -int xdebug_trigger_enabled(int setting, const char *var_name, char *var_value); - -typedef struct _xdebug_multi_opcode_handler_t xdebug_multi_opcode_handler_t; - -struct _xdebug_multi_opcode_handler_t -{ - user_opcode_handler_t handler; - xdebug_multi_opcode_handler_t *next; -}; - -typedef struct _xdebug_library_globals_t { - int mode; - int start_with_request; /* One of the XDEBUG_START_WITH_REQUEST_* constants */ - int start_upon_error; /* One of the XDEBUG_START_UPON_ERROR_* constants */
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/lib/log.c
Deleted
@@ -1,934 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#include "php_xdebug.h" -#include "ext/standard/info.h" - -#include "headers.h" - -#include "lib_private.h" -#include "log.h" -#include "var.h" - -char* xdebug_lib_docs_base(void) -{ - char *env = getenv("XDEBUG_DOCS_BASE"); - - if (env) { - return env; - } - - return (char*) "https://xdebug.org/docs/"; -} - -extern ZEND_DECLARE_MODULE_GLOBALS(xdebug); - -const char *xdebug_level_msg_prefix11 = { - "C", "E", "", "W", "", "", "", "I", "", "", "D" -}; -const char *xdebug_log_prefix11 = { - "CRIT:", "ERR: ", "", "WARN: ", "", "", "", "INFO: ", "", "", "DEBUG: " -}; -const char *xdebug_log_prefix_emoji11 = { - "☠", "🛑 ", "", "⚠️ ", "", "", "", "🛈 ", "", "", "• " -}; -const char *xdebug_channel_msg_prefix8 = { - "CFG-", "LOG-", "DBG-", "GC-", "PROF-", "TRACE-", "COV-", "BASE-" -}; -const char *xdebug_channel_name8 = { - "Config ", "Log Files ", "Step Debug ", "GC Stats ", "Profiler ", "Tracing ", "Coverage ", "Base " -}; - -static inline int xdebug_internal_log(int channel, int log_level, const char *message) -{ - zend_ulong pid; - - if (!XG_LIB(log_file)) { - return 0; - } - - pid = xdebug_get_pid(); - - if (!XG_LIB(log_opened_message_sent) && XG_LIB(log_open_timestring)) { - XG_LIB(log_opened_message_sent) = 1; - - fprintf(XG_LIB(log_file), "" ZEND_ULONG_FMT " Log opened at %s\n", pid, XG_LIB(log_open_timestring)); - fflush(XG_LIB(log_file)); - xdfree(XG_LIB(log_open_timestring)); - XG_LIB(log_open_timestring) = NULL; - } - - fprintf( - XG_LIB(log_file), - "" ZEND_ULONG_FMT " %s%s%s\n", - pid, - xdebug_channel_namechannel, - xdebug_log_prefixlog_level, - message - ); - - fflush(XG_LIB(log_file)); - - return 1; -} - -#define TR_START "<tr><td class=\"e\">" -#define TR_END "</td></tr>\n" - -static inline void xdebug_diagnostic_log(int channel, int log_level, const char *error_code, const char *message) -{ - if (!XG_LIB(diagnosis_buffer) || log_level > XLOG_WARN) { - return; - } - - if (sapi_module.phpinfo_as_text) { - xdebug_str_add(XG_LIB(diagnosis_buffer), xdebug_channel_namechannel, 0); - xdebug_str_add(XG_LIB(diagnosis_buffer), xdebug_log_prefixlog_level, 0); - xdebug_str_add(XG_LIB(diagnosis_buffer), message, 0); - } else { - xdebug_str_add_const(XG_LIB(diagnosis_buffer), "<tr><td class=\"i\">"); - xdebug_str_add(XG_LIB(diagnosis_buffer), xdebug_log_prefix_emojilog_level, 0); - xdebug_str_add_const(XG_LIB(diagnosis_buffer), "</td><td class=\"v\">"); - xdebug_str_add(XG_LIB(diagnosis_buffer), xdebug_channel_namechannel, 0); - xdebug_str_add(XG_LIB(diagnosis_buffer), message, 0); - xdebug_str_add_const(XG_LIB(diagnosis_buffer), "</td><td class=\"d\"><a href=\""); - xdebug_str_add(XG_LIB(diagnosis_buffer), xdebug_lib_docs_base(), 0); - xdebug_str_add_const(XG_LIB(diagnosis_buffer), "errors#"); - xdebug_str_add(XG_LIB(diagnosis_buffer), xdebug_channel_msg_prefixchannel, 0); - xdebug_str_add(XG_LIB(diagnosis_buffer), xdebug_level_msg_prefixlog_level, 0); - if (error_code) { - xdebug_str_addc(XG_LIB(diagnosis_buffer), '-'); - xdebug_str_add(XG_LIB(diagnosis_buffer), error_code, 0); - } - xdebug_str_add_const(XG_LIB(diagnosis_buffer), "\">🖹</a></td></tr>"); - } - - xdebug_str_addc(XG_LIB(diagnosis_buffer), '\n'); -} - -static inline void xdebug_php_log(int channel, int log_level, const char *error_code, const char *message) -{ - xdebug_str formatted_message = XDEBUG_STR_INITIALIZER; - - if (log_level > XLOG_ERR) { - return; - } - - xdebug_str_add_const(&formatted_message, "Xdebug: "); - xdebug_str_add(&formatted_message, xdebug_channel_namechannel, 0); - xdebug_str_add(&formatted_message, message, 0); - - if (error_code && log_level == XLOG_CRIT) { - xdebug_str_add_const(&formatted_message, " (See: "); - xdebug_str_add(&formatted_message, xdebug_lib_docs_base(), 0); - xdebug_str_add_const(&formatted_message, "errors#"); - xdebug_str_add(&formatted_message, xdebug_channel_msg_prefixchannel, 0); - xdebug_str_add(&formatted_message, xdebug_level_msg_prefixlog_level, 0); - xdebug_str_addc(&formatted_message, '-'); - xdebug_str_add(&formatted_message, error_code, 0); - xdebug_str_addc(&formatted_message, ')'); - } - - php_log_err(formatted_message.d); - - xdebug_str_destroy(&formatted_message); -} - -void XDEBUG_ATTRIBUTE_FORMAT(printf, 4, 5) xdebug_log_ex(int channel, int log_level, const char *error_code, const char *fmt, ...) -{ - xdebug_str message = XDEBUG_STR_INITIALIZER; - va_list argv; - int logged_to_xdebug_log = 0; - - if (XINI_LIB(log_level) < log_level) { - return; - } - - va_start(argv, fmt); - xdebug_str_add_va_fmt(&message, fmt, argv); - va_end(argv); - - logged_to_xdebug_log = xdebug_internal_log(channel, log_level, message.d); - - xdebug_diagnostic_log(channel, log_level, error_code, message.d); - - if (!logged_to_xdebug_log || XINI_LIB(log_level) == XLOG_CRIT) { - xdebug_php_log(channel, log_level, error_code, message.d); - } - - xdebug_str_destroy(&message); -} - -static void log_filename_not_opened(int channel, const char *directory, const char *filename) -{ - xdebug_str full_filename = XDEBUG_STR_INITIALIZER; - - if (directory) { - xdebug_str_add(&full_filename, directory, 0); - if (!IS_SLASH(directorystrlen(directory) - 1)) { - xdebug_str_addc(&full_filename, DEFAULT_SLASH); - } - } - xdebug_str_add(&full_filename, filename, 0); - - xdebug_log_ex(channel, XLOG_ERR, "OPEN", "File '%s' could not be opened.", full_filename.d); - - xdebug_str_destroy(&full_filename); -} - -void xdebug_log_diagnose_permissions(int channel, const char *directory, const char *filename) -{ -#ifndef WIN32 - struct stat dir_info; -#endif - - log_filename_not_opened(channel, directory, filename); -
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/lib/usefulstuff.c
Deleted
@@ -1,724 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#include <stdlib.h> -#include <string.h> - -#ifndef WIN32 -# include <unistd.h> -# include <sys/types.h> -# include <sys/socket.h> -# include <sys/resource.h> -# include <sys/file.h> -#else -# define PATH_MAX MAX_PATH -# include <winsock2.h> -# include <io.h> -# include <process.h> -#endif - -#include "php_xdebug.h" - -#include "mm.h" -#include "crc32.h" -#include "str.h" - -#include "lib_private.h" -#include "usefulstuff.h" -#include "log.h" - -#include "ext/standard/php_lcg.h" -#include "ext/standard/flock_compat.h" -#include "main/php_ini.h" - -#ifndef NAME_MAX -# ifdef _AIX -# include <unistd.h> -# define NAME_MAX pathconf("/dev/null",_PC_NAME_MAX) -# else -# define NAME_MAX (MAXNAMELEN-1) -# endif -#endif - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - -xdebug_arg *xdebug_arg_ctor(void) -{ - xdebug_arg *tmp = /*(xdebug_arg*)*/ xdmalloc(sizeof(xdebug_arg)); - - tmp->args = NULL; - tmp->c = 0; - - return tmp; -} - -void xdebug_arg_dtor(xdebug_arg *arg) -{ - int i; - - for (i = 0; i < arg->c; i++) { - xdfree(arg->argsi); - } - if (arg->args) { - xdfree(arg->args); - } - xdfree(arg); -} - -xdebug_str* xdebug_join(const char *delim, xdebug_arg *args, int begin, int end) -{ - int i; - xdebug_str *ret = xdebug_str_new(); - - if (begin < 0) { - begin = 0; - } - if (end > args->c - 1) { - end = args->c - 1; - } - for (i = begin; i < end; i++) { - xdebug_str_add(ret, args->argsi, 0); - xdebug_str_add(ret, delim, 0); - } - xdebug_str_add(ret, args->argsend, 0); - return ret; -} - -void xdebug_explode(const char *delim, const char *str, xdebug_arg *args, int limit) -{ - const char *p1, *p2, *endp; - - endp = str + strlen(str); - - p1 = str; - p2 = xdebug_memnstr(str, delim, strlen(delim), endp); - - if (p2 == NULL) { - args->c++; - args->args = (char**) xdrealloc(args->args, sizeof(char*) * args->c); - args->argsargs->c - 1 = (char*) xdmalloc(strlen(str) + 1); - memcpy(args->argsargs->c - 1, p1, strlen(str)); - args->argsargs->c - 1strlen(str) = '\0'; - } else { - do { - args->c++; - args->args = (char**) xdrealloc(args->args, sizeof(char*) * args->c); - args->argsargs->c - 1 = (char*) xdmalloc(p2 - p1 + 1); - memcpy(args->argsargs->c - 1, p1, p2 - p1); - args->argsargs->c - 1p2 - p1 = '\0'; - p1 = p2 + strlen(delim); - } while ((p2 = xdebug_memnstr(p1, delim, strlen(delim), endp)) != NULL && (limit == -1 || --limit > 1)); - - if (p1 <= endp) { - args->c++; - args->args = (char**) xdrealloc(args->args, sizeof(char*) * args->c); - args->argsargs->c - 1 = (char*) xdmalloc(endp - p1 + 1); - memcpy(args->argsargs->c - 1, p1, endp - p1); - args->argsargs->c - 1endp - p1 = '\0'; - } - } -} - -const char* xdebug_memnstr(const char *haystack, const char *needle, int needle_len, const char *end) -{ - const char *p = haystack; - char first = *needle; - - /* let end point to the last character where needle may start */ - end -= needle_len; - - while (p <= end) { - while (*p != first) - if (++p > end) - return NULL; - if (memcmp(p, needle, needle_len) == 0) - return p; - p++; - } - return NULL; -} - -char* xdebug_strrstr(const char* haystack, const char* needle) -{ - char *loc = NULL; - char *found = NULL; - size_t pos = 0; - - while ((found = strstr(haystack + pos, needle)) != 0) { - loc = found; - pos = (found - haystack) + 1; - } - - return loc; -} - -char *xdebug_trim(const char *str) -{ - char *trimmed = NULL, *begin = (char *) str, *end = NULL; - - /* trim leading space */ - while (isspace((unsigned char) *begin)) { - ++begin; - } - - /* All spaces */ - if (*begin == '\0') { - return xdstrdup(""); - } - - /* trim trailing space */ - end = begin + strlen(begin) - 1; - while (end > begin && isspace((unsigned char) *end)) { - --end; - } - end++; - - trimmed = xdmalloc(end - begin + 1); - memcpy(trimmed, begin, (end - begin)); - trimmed(end - begin) = '\0'; - - return trimmed; -} - -/* not all versions of php export this */ -static int xdebug_htoi(char *s) -{ - int value;
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/lib/var.c
Deleted
@@ -1,1153 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#include "lib/php-header.h" -#include "ext/standard/php_string.h" -#include "ext/standard/url.h" -#include "zend.h" -#include "zend_exceptions.h" -#include "zend_extensions.h" -#include "ext/standard/php_smart_string.h" -#include "zend_smart_str.h" -#include "zend_closures.h" - -#include "php_xdebug.h" - -#include "lib/compat.h" -#include "lib/lib_private.h" -#include "lib/mm.h" -#include "lib/var.h" -#include "lib/var_export_html.h" -#include "lib/var_export_line.h" -#include "lib/xml.h" - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - -static inline int object_or_ancestor_is_internal(zval dzval) -{ - zend_class_entry *tmp_ce = Z_OBJCE(dzval); - - do { - if (tmp_ce->type == ZEND_INTERNAL_CLASS) { - return 1; - } - tmp_ce = tmp_ce->parent; - } while (tmp_ce); - - return 0; -} - -typedef struct _xdebug_zend_closure_copy { - zend_object std; - zend_function func; - zval this_ptr; - zend_class_entry *called_scope; - zif_handler orig_internal_handler; -} xdebug_zend_closure_copy; - -static int object_with_missing_closure_variables(zval dzval) -{ - zend_class_entry *tmp_ce = NULL; - xdebug_zend_closure_copy *closure = NULL; - - if (Z_TYPE(dzval) != IS_OBJECT) { - return 0; - } - - tmp_ce = Z_OBJCE(dzval); - if (tmp_ce != zend_ce_closure) { - return 0; - } - - closure = (xdebug_zend_closure_copy *) Z_OBJ(dzval); - - if (closure->func.type == ZEND_USER_FUNCTION && closure->func.op_array.static_variables) { - HashTable *static_variables = ZEND_MAP_PTR_GET(closure->func.op_array.static_variables_ptr); - - if (!static_variables) { - return 1; - } - } - - return 0; -} - -HashTable *xdebug_objdebug_pp(zval **zval_pp, int flags) -{ - zval dzval = **zval_pp; - HashTable *tmp; - - if ( - !XG_BASE(in_debug_info) && - (object_or_ancestor_is_internal(dzval) || (flags & XDEBUG_VAR_OBJDEBUG_USE_DEBUGINFO)) && - !object_with_missing_closure_variables(dzval) && - Z_OBJ_HANDLER(dzval, get_debug_info) && - !EG(exception) - ) { - void *original_trace_context; - zend_object *orig_exception; - - xdebug_tracing_save_trace_context(&original_trace_context); - XG_BASE(in_debug_info) = 1; - orig_exception = EG(exception); - EG(exception) = NULL; - - tmp = zend_get_properties_for(&dzval, ZEND_PROP_PURPOSE_DEBUG); - - XG_BASE(in_debug_info) = 0; - xdebug_tracing_restore_trace_context(original_trace_context); - EG(exception) = orig_exception; - - return tmp; - } else { - return zend_get_properties_for(&dzval, ZEND_PROP_PURPOSE_VAR_EXPORT); - } - return NULL; -} - -char* xdebug_error_type_simple(int type) -{ - switch (type) { - case E_ERROR: - case E_CORE_ERROR: - case E_COMPILE_ERROR: - case E_USER_ERROR: - return xdstrdup("fatal-error"); - break; - case E_RECOVERABLE_ERROR: - return xdstrdup("recoverable-fatal-error"); - break; - case E_WARNING: - case E_CORE_WARNING: - case E_COMPILE_WARNING: - case E_USER_WARNING: - return xdstrdup("warning"); - break; - case E_PARSE: - return xdstrdup("parse-error"); - break; - case E_NOTICE: - case E_USER_NOTICE: - return xdstrdup("notice"); - break; - case E_STRICT: - return xdstrdup("strict-standards"); - break; - case E_DEPRECATED: - case E_USER_DEPRECATED: - return xdstrdup("deprecated"); - break; - case 0: - return xdstrdup("xdebug"); - break; - default: - return xdstrdup("unknown-error"); - break; - } -} - -char* xdebug_error_type(int type) -{ - switch (type) { - case E_ERROR: - case E_CORE_ERROR: - case E_COMPILE_ERROR: - case E_USER_ERROR: - return xdstrdup("Fatal error"); - break; - case E_RECOVERABLE_ERROR: - return xdstrdup("Recoverable fatal error"); - break; - case E_WARNING: - case E_CORE_WARNING: - case E_COMPILE_WARNING: - case E_USER_WARNING: - return xdstrdup("Warning"); - break; - case E_PARSE: - return xdstrdup("Parse error"); - break; - case E_NOTICE: - case E_USER_NOTICE: - return xdstrdup("Notice"); - break; - case E_STRICT: - return xdstrdup("Strict standards"); - break; - case E_DEPRECATED: - case E_USER_DEPRECATED: - return xdstrdup("Deprecated"); - break; - case 0: - return xdstrdup("Xdebug"); - break; - default: - return xdstrdup("Unknown error"); - break;
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/lib/var.h
Deleted
@@ -1,89 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#include "lib/php-header.h" -#include "php_xdebug.h" - -#include "lib/compat.h" -#include "lib/lib.h" -#include "lib/str.h" -#include "lib/xml.h" - -#ifndef __HAVE_XDEBUG_VAR_H__ -#define __HAVE_XDEBUG_VAR_H__ - -/* Set correct int format to use */ -#include "Zend/zend_long.h" -#if SIZEOF_ZEND_LONG == 4 -# define XDEBUG_INT_FMT "%ld" -#else -# define XDEBUG_INT_FMT "%lld" -#endif - -typedef struct -{ - int page; /* The number of the page to retrieve */ - int current_element_nr; - int start_element_nr; - int end_element_nr; -} xdebug_var_runtime_page; - -typedef struct xdebug_var_export_options { - int max_children; - int max_data; - int max_depth; - int show_hidden; - int extended_properties; /* Whether the feature is enabled */ - int encode_as_extended_property; /* Whether the current node's elements need to be encoded */ - int show_location; - xdebug_var_runtime_page *runtime; - int no_decoration; -} xdebug_var_export_options; - -#define XDEBUG_VAR_TYPE_NORMAL 0x00 -#define XDEBUG_VAR_TYPE_STATIC 0x01 -#define XDEBUG_VAR_TYPE_CONSTANT 0x02 - -void xdebug_get_php_symbol(zval *retval, xdebug_str* name); - -xdebug_var_export_options* xdebug_var_export_options_from_ini(void); -xdebug_var_export_options* xdebug_var_get_nolimit_options(void); - -xdebug_str* xdebug_get_property_type(zval* object, zval *val); -xdebug_str* xdebug_get_property_info(char *mangled_property, int mangled_len, const char **modifier, char **class_name); - -#define XDEBUG_VAR_OBJDEBUG_DEFAULT 0x00 -#define XDEBUG_VAR_OBJDEBUG_USE_DEBUGINFO 0x01 -HashTable *xdebug_objdebug_pp(zval **zval_pp, int flags); - - -#define XDEBUG_VAR_ATTR_TEXT 0 -#define XDEBUG_VAR_ATTR_HTML 1 -void xdebug_add_variable_attributes(xdebug_str *str, zval *struc, zend_bool fancy); - - -char* xdebug_xmlize(char *s_string, size_t len, size_t *newlen); -char* xdebug_error_type_simple(int type); -char* xdebug_error_type(int type); -zval *xdebug_get_zval(zend_execute_data *zdata, int node_type, const znode_op *node, int *is_var); -zval *xdebug_get_zval_with_opline(zend_execute_data *zdata, const zend_op *opline, int node_type, const znode_op *node, int *is_var); - -#define XDEBUG_SHOW_FNAME_DEFAULT 0 -#define XDEBUG_SHOW_FNAME_ALLOW_HTML 1<<1 -#define XDEBUG_SHOW_FNAME_IGNORE_SCOPE 1<<2 -char* xdebug_show_fname(xdebug_func t, int flags); - -#endif
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/lib/var_export_html.c
Deleted
@@ -1,462 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2021 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#include "var_export_html.h" -#include "lib_private.h" -#include "Zend/zend_closures.h" -#if PHP_VERSION_ID >= 80100 -# include "zend_enum.h" -#endif - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - -/***************************************************************************** -** Fancy variable printing routines -*/ - -#define COLOR_POINTER "#888a85" -#define COLOR_BOOL "#75507b" -#define COLOR_LONG "#4e9a06" -#define COLOR_NULL "#3465a4" -#define COLOR_DOUBLE "#f57900" -#define COLOR_STRING "#cc0000" -#define COLOR_EMPTY "#888a85" -#define COLOR_ARRAY "#ce5c00" -#define COLOR_OBJECT "#8f5902" -#define COLOR_RESOURCE "#2e3436" - -static int xdebug_array_element_export_html(zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, xdebug_str *str, int debug_zval, xdebug_var_export_options *options) -{ - zval **zv = &zv_nptr; - size_t newlen; - char *tmp_str; - - if (options->runtimelevel.current_element_nr >= options->runtimelevel.start_element_nr && - options->runtimelevel.current_element_nr < options->runtimelevel.end_element_nr) - { - xdebug_str_add_fmt(str, "%*s", (level * 4) - 2, ""); - - if (HASH_KEY_IS_NUMERIC(hash_key)) { /* numeric key */ - xdebug_str_add_fmt(str, XDEBUG_INT_FMT " <font color='%s'>=></font> ", index_key, COLOR_POINTER); - } else { /* string key */ - xdebug_str_addc(str, '\''); - tmp_str = xdebug_xmlize((char*) HASH_APPLY_KEY_VAL(hash_key), HASH_APPLY_KEY_LEN(hash_key) - 1, &newlen); - xdebug_str_addl(str, tmp_str, newlen, 0); - efree(tmp_str); - xdebug_str_add_fmt(str, "' <font color='%s'>=></font> ", COLOR_POINTER); - } - xdebug_var_export_html(zv, str, level + 1, debug_zval, options); - } - if (options->runtimelevel.current_element_nr == options->runtimelevel.end_element_nr) { - xdebug_str_add_fmt(str, "%*s", (level * 4) - 2, ""); - xdebug_str_add_literal(str, "<i>more elements...</i>\n"); - } - options->runtimelevel.current_element_nr++; - return 0; -} - -static int xdebug_object_element_export_html(zval *object, zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, xdebug_str *str, int debug_zval, xdebug_var_export_options *options, char *class_name) -{ - zval **zv = &zv_nptr; - - if (options->runtimelevel.current_element_nr >= options->runtimelevel.start_element_nr && - options->runtimelevel.current_element_nr < options->runtimelevel.end_element_nr) - { - xdebug_str_add_fmt(str, "%*s", (level * 4) - 2, ""); - - if (!HASH_KEY_IS_NUMERIC(hash_key)) { - char *prop_class_name; - xdebug_str *property_name; - xdebug_str *property_type = NULL; - const char *modifier; - - property_type = xdebug_get_property_type(object, zv_nptr); - property_name = xdebug_get_property_info((char*) HASH_APPLY_KEY_VAL(hash_key), HASH_APPLY_KEY_LEN(hash_key), &modifier, &prop_class_name); - - xdebug_str_add_fmt(str, "<i>%s</i> ", modifier); - if (property_type) { - xdebug_str_add_fmt(str, "<i>%s</i> ", property_type->d); - } - xdebug_str_addc(str, '\''); - xdebug_str_add_str(str, property_name); - if (strcmp(modifier, "private") != 0 || strcmp(class_name, prop_class_name) == 0) { - xdebug_str_add_fmt(str, "' <font color='%s'>=></font> ", COLOR_POINTER); - } else { - xdebug_str_add_fmt(str, "' <small>(%s)</small> <font color='%s'>=></font> ", prop_class_name, COLOR_POINTER); - } - - if (property_type) { - xdebug_str_free(property_type); - } - xdebug_str_free(property_name); - xdfree(prop_class_name); - } else { - xdebug_str_add_fmt(str, "<i>public</i> " XDEBUG_INT_FMT " <font color='%s'>=></font> ", index_key, COLOR_POINTER); - } - xdebug_var_export_html(zv, str, level + 1, debug_zval, options); - } - if (options->runtimelevel.current_element_nr == options->runtimelevel.end_element_nr) { - xdebug_str_add_fmt(str, "%*s", (level * 4) - 2, ""); - xdebug_str_add_literal(str, "<i>more elements...</i>\n"); - } - options->runtimelevel.current_element_nr++; - return 0; -} - -static void handle_closure(xdebug_str *str, zval *obj, int level) -{ - const zend_function *closure_function; - - if (Z_TYPE_P(obj) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(obj), zend_ce_closure)) { - return; - } - - closure_function = zend_get_closure_method_def(Z_OBJ_P(obj)); - - xdebug_str_add_fmt(str, "%*s<i>virtual</i> 'closure' <font color='%s'>'", (level * 4) - 2, "", COLOR_STRING); - - if (closure_function->common.scope) { - if (closure_function->common.fn_flags & ZEND_ACC_STATIC) { - xdebug_str_add_zstr(str, closure_function->common.scope->name); - xdebug_str_add_literal(str, "::"); - } else { - xdebug_str_add_literal(str, "$this->"); - } - } - xdebug_str_add_zstr(str, closure_function->common.function_name); - - xdebug_str_add_literal(str, "'</font>\n"); -} - - -void xdebug_var_export_html(zval **struc, xdebug_str *str, int level, int debug_zval, xdebug_var_export_options *options) -{ - HashTable *myht; - char* tmp_str; - size_t newlen; - zend_ulong num; - zend_string *key; - zval *val; - zval *tmpz; - int z_type; - - z_type = Z_TYPE_P(*struc); - - if (debug_zval) { - xdebug_add_variable_attributes(str, *struc, XDEBUG_VAR_ATTR_HTML); - } - if (z_type == IS_INDIRECT) { - tmpz = Z_INDIRECT_P(*struc); - struc = &tmpz; - z_type = Z_TYPE_P(*struc); - } - if (z_type == IS_REFERENCE) { - tmpz = &((*struc)->value.ref->val); - struc = &tmpz; - z_type = Z_TYPE_P(*struc); - } - - switch (z_type) { - case IS_TRUE: - xdebug_str_add_fmt(str, "<small>boolean</small> <font color='%s'>true</font>", COLOR_BOOL); - break; - - case IS_FALSE: - xdebug_str_add_fmt(str, "<small>boolean</small> <font color='%s'>false</font>", COLOR_BOOL); - break; - - case IS_NULL: - xdebug_str_add_fmt(str, "<font color='%s'>null</font>", COLOR_NULL); - break; - - case IS_LONG: - xdebug_str_add_fmt(str, "<small>int</small> <font color='%s'>" XDEBUG_INT_FMT "</font>", COLOR_LONG, Z_LVAL_P(*struc)); - break; - - case IS_DOUBLE: - xdebug_str_add_fmt(str, "<small>float</small> <font color='%s'>%.*H</font>", COLOR_DOUBLE, (int) EG(precision), Z_DVAL_P(*struc)); - break; - - case IS_STRING: - xdebug_str_add_fmt(str, "<small>string</small> <font color='%s'>'", COLOR_STRING); - if ((size_t) Z_STRLEN_P(*struc) > (size_t) options->max_data) { - tmp_str = xdebug_xmlize(Z_STRVAL_P(*struc), options->max_data, &newlen); - xdebug_str_addl(str, tmp_str, newlen, 0); - efree(tmp_str); - xdebug_str_add_literal(str, "'...</font>");
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/lib/var_export_line.c
Deleted
@@ -1,449 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#include "lib/php-header.h" -#include "ext/standard/php_string.h" -#include "Zend/zend_closures.h" -#if PHP_VERSION_ID >= 80100 -# include "zend_enum.h" -#endif - -#include "var_export_line.h" - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - -static int xdebug_array_element_export(zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, xdebug_str *str, int debug_zval, xdebug_var_export_options *options) -{ - zval **zv = &zv_nptr; - - if (options->runtimelevel.current_element_nr >= options->runtimelevel.start_element_nr && - options->runtimelevel.current_element_nr < options->runtimelevel.end_element_nr) - { - if (HASH_KEY_IS_NUMERIC(hash_key)) { /* numeric key */ - xdebug_str_add_fmt(str, XDEBUG_INT_FMT " => ", index_key); - } else { /* string key */ - zend_string *tmp, *tmp2; - - tmp = php_str_to_str(ZSTR_VAL(hash_key), ZSTR_LEN(hash_key), (char*) "'", 1, (char*) "\\'", 2); - tmp2 = php_str_to_str(ZSTR_VAL(tmp), ZSTR_LEN(tmp), (char*) "\0", 1, (char*) "\\0", 2); - if (tmp) { - zend_string_release(tmp); - } - xdebug_str_addc(str, '\''); - if (tmp2) { - xdebug_str_add_zstr(str, tmp2); - zend_string_release(tmp2); - } - xdebug_str_add_literal(str, "' => "); - } - xdebug_var_export_line(zv, str, level + 2, debug_zval, options); - xdebug_str_add_literal(str, ", "); - } - if (options->runtimelevel.current_element_nr == options->runtimelevel.end_element_nr) { - xdebug_str_add_literal(str, "..., "); - } - options->runtimelevel.current_element_nr++; - return 0; -} - -static int xdebug_object_element_export(zval *object, zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, xdebug_str *str, int debug_zval, xdebug_var_export_options *options, char *class_name) -{ - zval **zv = &zv_nptr; - - if (options->runtimelevel.current_element_nr >= options->runtimelevel.start_element_nr && - options->runtimelevel.current_element_nr < options->runtimelevel.end_element_nr) - { - if (!HASH_KEY_IS_NUMERIC(hash_key)) { - xdebug_str *property_name; - xdebug_str *property_type = NULL; - char *prop_class_name; - const char *modifier; - - property_type = xdebug_get_property_type(object, zv_nptr); - property_name = xdebug_get_property_info((char*) HASH_APPLY_KEY_VAL(hash_key), HASH_APPLY_KEY_LEN(hash_key), &modifier, &prop_class_name); - xdebug_str_add(str, modifier, 0); - if (property_type) { - xdebug_str_addc(str, ' '); - xdebug_str_add_str(str, property_type); - } - xdebug_str_add_literal(str, " $"); - if (strcmp(modifier, "private") != 0 || strcmp(class_name, prop_class_name) == 0) { - xdebug_str_add_str(str, property_name); - xdebug_str_add_literal(str, " = "); - } else { - xdebug_str_addc(str, '{'); - xdebug_str_add(str, prop_class_name, 0); - xdebug_str_addc(str, '}'); - xdebug_str_add_str(str, property_name); - xdebug_str_add_literal(str, " = "); - } - - if (property_type) { - xdebug_str_free(property_type); - } - xdebug_str_free(property_name); - xdfree(prop_class_name); - } else { - xdebug_str_add_fmt(str, "public $%d = ", index_key); - } - xdebug_var_export_line(zv, str, level + 2, debug_zval, options); - xdebug_str_add_literal(str, "; "); - } - if (options->runtimelevel.current_element_nr == options->runtimelevel.end_element_nr) { - xdebug_str_add_literal(str, "...; "); - } - options->runtimelevel.current_element_nr++; - return 0; -} - -#if PHP_VERSION_ID < 80200 -static void handle_closure(xdebug_str *str, zval *obj) -{ - const zend_function *closure_function; - - if (Z_TYPE_P(obj) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(obj), zend_ce_closure)) { - return; - } - - closure_function = zend_get_closure_method_def(Z_OBJ_P(obj)); - - xdebug_str_add_literal(str, "virtual $closure = \""); - - if (closure_function->common.scope) { - if (closure_function->common.fn_flags & ZEND_ACC_STATIC) { - xdebug_str_add(str, ZSTR_VAL(closure_function->common.scope->name), 0); - xdebug_str_add_literal(str, "::"); - } else { - xdebug_str_add_literal(str, "$this->"); - } - } - xdebug_str_add_zstr(str, closure_function->common.function_name); - - xdebug_str_add_literal(str, "\", "); -} -#endif - -void xdebug_var_export_line(zval **struc, xdebug_str *str, int level, int debug_zval, xdebug_var_export_options *options) -{ - HashTable *myht; - zend_ulong num; - zend_string *key; - zval *val; - zval *tmpz; - int z_type; - - if (!struc || !(*struc)) { - return; - } - - z_type = Z_TYPE_P(*struc); - - if (debug_zval) { - xdebug_add_variable_attributes(str, *struc, XDEBUG_VAR_ATTR_TEXT); - } - if (z_type == IS_INDIRECT) { - tmpz = Z_INDIRECT_P(*struc); - struc = &tmpz; - z_type = Z_TYPE_P(*struc); - } - if (z_type == IS_REFERENCE) { - tmpz = &((*struc)->value.ref->val); - struc = &tmpz; - z_type = Z_TYPE_P(*struc); - } - - switch (z_type) { - case IS_TRUE: - xdebug_str_add_literal(str, "TRUE"); - break; - - case IS_FALSE: - xdebug_str_add_literal(str, "FALSE"); - break; - - case IS_NULL: - xdebug_str_add_literal(str, "NULL"); - break; - - case IS_LONG: - xdebug_str_add_fmt(str, XDEBUG_INT_FMT, Z_LVAL_P(*struc)); - break; - - case IS_DOUBLE: - xdebug_str_add_fmt(str, "%.*H", (int) EG(precision), Z_DVAL_P(*struc)); - break; - - case IS_STRING: { - if (options->no_decoration) { - xdebug_str_add_zstr(str, Z_STR_P(*struc)); - } else if ((size_t) Z_STRLEN_P(*struc) <= (size_t) options->max_data) { - zend_string *tmp_zstr; - - tmp_zstr = php_addcslashes(Z_STR_P(*struc), (char*) "'\\\0..\37", 7); - - xdebug_str_addc(str, '\''); - xdebug_str_add_zstr(str, tmp_zstr); - xdebug_str_addc(str, '\'');
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/lib/var_export_text.c
Deleted
@@ -1,505 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#include "lib/php-header.h" -#include "ext/standard/php_string.h" -#include "Zend/zend_closures.h" -#if PHP_VERSION_ID >= 80100 -# include "zend_enum.h" -#endif - - -#include "php_xdebug.h" - -#include "var_export_text.h" - -static void xdebug_var_export_text_ansi(zval **struc, xdebug_str *str, int mode, int level, int debug_zval, xdebug_var_export_options *options); -#define xdebug_var_export_text(struc, str, level, debug_zval, options) xdebug_var_export_text_ansi(struc, str, 0, level, debug_zval, options); -#define xdebug_var_export_ansi(struc, str, level, debug_zval, options) xdebug_var_export_text_ansi(struc, str, 1, level, debug_zval, options); - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - - -/***************************************************************************** -** Plain text/ANSI coloured variable printing routines -*/ - -#define ANSI_COLOR_POINTER (mode == 1 ? "0m" : "") -#define ANSI_COLOR_BOOL (mode == 1 ? "35m" : "") -#define ANSI_COLOR_LONG (mode == 1 ? "32m" : "") -#define ANSI_COLOR_NULL (mode == 1 ? "34m" : "") -#define ANSI_COLOR_DOUBLE (mode == 1 ? "33m" : "") -#define ANSI_COLOR_STRING (mode == 1 ? "31m" : "") -#define ANSI_COLOR_EMPTY (mode == 1 ? "30m" : "") -#define ANSI_COLOR_ARRAY (mode == 1 ? "33m" : "") -#define ANSI_COLOR_OBJECT (mode == 1 ? "31m" : "") -#define ANSI_COLOR_RESOURCE (mode == 1 ? "36m" : "") -#define ANSI_COLOR_MODIFIER (mode == 1 ? "32m" : "") -#define ANSI_COLOR_RESET (mode == 1 ? "0m" : "") -#define ANSI_COLOR_BOLD (mode == 1 ? "1m" : "") -#define ANSI_COLOR_BOLD_OFF (mode == 1 ? "22m" : "") - -static int xdebug_array_element_export_text_ansi(zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, int mode, xdebug_str *str, int debug_zval, xdebug_var_export_options *options) -{ - zval **zv = &zv_nptr; - - if (options->runtimelevel.current_element_nr >= options->runtimelevel.start_element_nr && - options->runtimelevel.current_element_nr < options->runtimelevel.end_element_nr) - { - xdebug_str_add_fmt(str, "%*s", (level * 2), ""); - - if (HASH_KEY_IS_NUMERIC(hash_key)) { /* numeric key */ - xdebug_str_add_fmt(str, "" XDEBUG_INT_FMT " %s=>%s\n", index_key, ANSI_COLOR_POINTER, ANSI_COLOR_RESET); - } else { /* string key */ - zend_string *tmp, *tmp2; - - tmp = php_str_to_str(ZSTR_VAL(hash_key), ZSTR_LEN(hash_key), (char*) "'", 1, (char*) "\\'", 2); - tmp2 = php_str_to_str(ZSTR_VAL(tmp), ZSTR_LEN(tmp), (char*) "\0", 1, (char*) "\\0", 2); - if (tmp) { - zend_string_release(tmp); - } - xdebug_str_addc(str, '\''); - if (tmp2) { - xdebug_str_add_zstr(str, tmp2); - zend_string_release(tmp2); - } - xdebug_str_add_literal(str, "' =>\n"); - } - xdebug_var_export_text_ansi(zv, str, mode, level + 1, debug_zval, options); - } - if (options->runtimelevel.current_element_nr == options->runtimelevel.end_element_nr) { - xdebug_str_add_fmt(str, "\n%*s(more elements)...\n", (level * 2), ""); - } - options->runtimelevel.current_element_nr++; - return 0; -} - -static int xdebug_object_element_export_text_ansi(zval *object, zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, int mode, xdebug_str *str, int debug_zval, xdebug_var_export_options *options) -{ - zval **zv = &zv_nptr; - - if (options->runtimelevel.current_element_nr >= options->runtimelevel.start_element_nr && - options->runtimelevel.current_element_nr < options->runtimelevel.end_element_nr) - { - xdebug_str_add_fmt(str, "%*s", (level * 2), ""); - - if (!HASH_KEY_IS_NUMERIC(hash_key)) { - char *class_name; - xdebug_str *property_name; - const char *modifier; - xdebug_str *property_type = NULL; - - property_type = xdebug_get_property_type(object, zv_nptr); - - property_name = xdebug_get_property_info((char*) HASH_APPLY_KEY_VAL(hash_key), HASH_APPLY_KEY_LEN(hash_key), &modifier, &class_name); - xdebug_str_add_fmt( - str, "%s%s%s%s%s%s%s $", - ANSI_COLOR_MODIFIER, ANSI_COLOR_BOLD, modifier, ANSI_COLOR_BOLD_OFF, property_type ? " " : "", property_type ? property_type->d : "", ANSI_COLOR_RESET - ); - xdebug_str_add_str(str, property_name); - xdebug_str_add_fmt(str, " %s=>%s\n", ANSI_COLOR_POINTER, ANSI_COLOR_RESET); - - if (property_type) { - xdebug_str_free(property_type); - } - xdebug_str_free(property_name); - xdfree(class_name); - } else { - xdebug_str_add_fmt(str, "%s%spublic%s%s ${" XDEBUG_INT_FMT "} %s=>%s\n", - ANSI_COLOR_MODIFIER, ANSI_COLOR_BOLD, ANSI_COLOR_BOLD_OFF, ANSI_COLOR_RESET, - index_key, ANSI_COLOR_POINTER, ANSI_COLOR_RESET - ); - } - xdebug_var_export_text_ansi(zv, str, mode, level + 1, debug_zval, options); - } - if (options->runtimelevel.current_element_nr == options->runtimelevel.end_element_nr) { - xdebug_str_add_fmt(str, "\n%*s(more elements)...\n", (level * 2), ""); - } - options->runtimelevel.current_element_nr++; - return 0; -} - -#if PHP_VERSION_ID < 80200 -static void handle_closure(xdebug_str *str, zval *obj, int level, int mode) -{ - const zend_function *closure_function; - - if (Z_TYPE_P(obj) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(obj), zend_ce_closure)) { - return; - } - - closure_function = zend_get_closure_method_def(Z_OBJ_P(obj)); - - xdebug_str_add_fmt( - str, "%*s%s%svirtual%s $closure =>\n%*s\"", - (level * 4) - 2, "", - ANSI_COLOR_MODIFIER, ANSI_COLOR_BOLD, ANSI_COLOR_RESET, - (level * 4) - 2, "" - ); - - if (closure_function->common.scope) { - if (closure_function->common.fn_flags & ZEND_ACC_STATIC) { - xdebug_str_add_fmt(str, "%s", ANSI_COLOR_OBJECT); - xdebug_str_add_zstr(str, closure_function->common.scope->name); - xdebug_str_add_fmt(str, "%s::", ANSI_COLOR_RESET); - } else { - xdebug_str_add_fmt(str, "%s$this%s->", ANSI_COLOR_OBJECT, ANSI_COLOR_RESET); - } - } - - xdebug_str_add_fmt(str, "%s", ANSI_COLOR_STRING); - xdebug_str_add_zstr(str, closure_function->common.function_name); - xdebug_str_add_fmt(str, "%s\"\n", ANSI_COLOR_RESET); -} -#endif - -static void xdebug_var_export_text_ansi(zval **struc, xdebug_str *str, int mode, int level, int debug_zval, xdebug_var_export_options *options) -{ - HashTable *myht; - char* tmp_str; - int tmp_len; - zend_ulong num; - zend_string *key; - zval *val; - zval *tmpz; - int z_type; - - if (!struc || !(*struc)) { - return; - } - - xdebug_str_add_fmt(str, "%*s", (level * 2) - 2, ""); - - z_type = Z_TYPE_P(*struc); - - if (debug_zval) { - xdebug_add_variable_attributes(str, *struc, XDEBUG_VAR_ATTR_TEXT); - } - if (z_type == IS_INDIRECT) { - tmpz = Z_INDIRECT_P(*struc); - struc = &tmpz; - z_type = Z_TYPE_P(*struc); - } - if (z_type == IS_REFERENCE) { - tmpz = &((*struc)->value.ref->val); - struc = &tmpz; - z_type = Z_TYPE_P(*struc);
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/lib/var_export_xml.c
Deleted
@@ -1,827 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2021 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#include "var_export_xml.h" -#include "Zend/zend_closures.h" - -static xdebug_str *prepare_variable_name(xdebug_str *name) -{ - xdebug_str *tmp_name; - - if (name->d0 == '$' || name->d0 == ':') { - tmp_name = xdebug_str_copy(name); - } else { - tmp_name = xdebug_str_new(); - xdebug_str_addc(tmp_name, '$'); - xdebug_str_add_str(tmp_name, name); - } - if (tmp_name->dtmp_name->l - 2 == ':' && tmp_name->dtmp_name->l - 1 == ':') { - xdebug_str_chop(tmp_name, 2); - } - return tmp_name; -} - -/* - * Returns whether we should attempt to encode name, fullname, and value as XML - * elements instead of attribute values, because XML doesn't support nearly all - * characters under ASCII 0x32. - */ -static int encoding_requested(char *value, size_t value_len) -{ - size_t i; - - for (i = 0; i < value_len; i++) { - if (valuei < 0x20) { - return 1; - } - } - return 0; -} - -static void check_if_extended_properties_are_needed(xdebug_var_export_options *options, xdebug_str *name, xdebug_str *fullname, zval *value) -{ - if (!options->extended_properties || options->encode_as_extended_property) { - return; - } - - /* Checking name */ - if (name && encoding_requested(name->d, name->l)) { - options->encode_as_extended_property = 1; - return; - } - - /* Checking full name */ - if (fullname && encoding_requested(fullname->d, fullname->l)) { - options->encode_as_extended_property = 1; - return; - } - - /* Checking for the value portion */ - if (!value) { - return; - } - if (Z_TYPE_P(value) == IS_STRING) { - if (encoding_requested(Z_STRVAL_P(value), Z_STRLEN_P(value))) { - options->encode_as_extended_property = 1; - return; - } - } - if (Z_TYPE_P(value) == IS_OBJECT) { - if (encoding_requested(STR_NAME_VAL(Z_OBJCE_P(value)->name), STR_NAME_LEN(Z_OBJCE_P(value)->name))) { - options->encode_as_extended_property = 1; - return; - } - } -} - -static void add_xml_attribute_or_element(xdebug_var_export_options *options, xdebug_xml_node *node, const char *field, int field_len, xdebug_str *value) -{ - if (options->encode_as_extended_property || (encoding_requested(value->d, value->l) && options->extended_properties)) { - xdebug_xml_node *element; - unsigned char *tmp_base64; - size_t new_len; - - options->encode_as_extended_property = 1; - - element = xdebug_xml_node_init(field); - xdebug_xml_add_attribute(element, "encoding", "base64"); - - tmp_base64 = xdebug_base64_encode((unsigned char*) value->d, value->l, &new_len); - xdebug_xml_add_text_ex(element, (char*) tmp_base64, new_len, 1, 0); - - xdebug_xml_add_child(node, element); - } else { - xdebug_xml_add_attribute_exl(node, field, field_len, xdstrndup(value->d, value->l), value->l, 0, 1); - } -} - -void xdebug_var_xml_attach_uninitialized_var(xdebug_var_export_options *options, xdebug_xml_node *node, xdebug_str *name) -{ - xdebug_xml_node *contents = NULL; - xdebug_str *tmp_name; - - contents = xdebug_xml_node_init("property"); - options->encode_as_extended_property = 0; - - tmp_name = prepare_variable_name(name); - add_xml_attribute_or_element(options, contents, "name", 4, tmp_name); - add_xml_attribute_or_element(options, contents, "fullname", 8, tmp_name); - xdebug_str_free(tmp_name); - - xdebug_xml_add_attribute(contents, "type", "uninitialized"); - xdebug_xml_add_child(node, contents); -} - -/***************************************************************************** -** XML node printing routines -*/ - -#define XDEBUG_OBJECT_ITEM_TYPE_PROPERTY 0 -#define XDEBUG_OBJECT_ITEM_TYPE_STATIC_PROPERTY 1<<0 -#define XDEBUG_OBJECT_ITEM_TYPE_READONLY 1<<1 - - -typedef struct -{ - char type; - char *name; - int name_len; - unsigned long index_key; - zval *zv; -} xdebug_object_item; - -static void merged_hash_object_item_dtor(zval *data) -{ - xdebug_object_item *item = Z_PTR_P(data); - - xdfree(item); -} - -static int object_item_add_to_merged_hash(zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, HashTable *merged, int object_type) -{ - zval **zv = &zv_nptr; - xdebug_object_item *item; - - item = xdcalloc(1, sizeof(xdebug_object_item)); - item->type = object_type; - item->zv = *zv; - - if (hash_key) { - item->name = (char*) HASH_APPLY_KEY_VAL(hash_key); - item->name_len = HASH_APPLY_KEY_LEN(hash_key) - 1; - item->index_key = hash_key->h; - } else { - item->name = xdebug_sprintf(XDEBUG_INT_FMT, index_key); - item->name_len = strlen(item->name); - } - - zend_hash_next_index_insert_ptr(merged, item); - - return 0; -} - -static int object_item_add_zend_prop_to_merged_hash(zend_property_info *zpp, HashTable *merged, int object_type, zend_class_entry *ce) -{ - xdebug_object_item *item; - - if ((zpp->flags & ZEND_ACC_STATIC) == 0) { - return 0; - } - - item = xdmalloc(sizeof(xdebug_object_item)); - item->type = object_type; - item->zv = &CE_STATIC_MEMBERS(ce)zpp->offset; - item->name = (char*) STR_NAME_VAL(zpp->name); - item->name_len = STR_NAME_LEN(zpp->name); - - zend_hash_next_index_insert_ptr(merged, item); - - return 0; -} - -static void add_unencoded_text_value_attribute_or_element(xdebug_var_export_options *options, xdebug_xml_node *node, char *value) -{ - if (options->encode_as_extended_property) { - xdebug_xml_node *element; - unsigned char *tmp_base64;
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/profiler/profiler.c
Deleted
@@ -1,554 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#ifdef PHP_WIN32 -#include <process.h> -#endif - -#include "lib/php-header.h" -#include "TSRM.h" -#include "php_globals.h" -#include "Zend/zend_alloc.h" - -#include "php_xdebug.h" -#include "profiler.h" -#include "profiler_private.h" - -#include "lib/log.h" -#include "lib/mm.h" -#include "lib/str.h" -#include "lib/var.h" -#include "lib/usefulstuff.h" - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - -int xdebug_profiler_exit_handler(XDEBUG_OPCODE_HANDLER_ARGS); - -void xdebug_init_profiler_globals(xdebug_profiler_globals_t *xg) -{ - xg->active = 0; -} - -void xdebug_profiler_minit(void) -{ - /* Overload the "exit" opcode */ - xdebug_set_opcode_handler(ZEND_EXIT, xdebug_profiler_exit_handler); -} - -void xdebug_profiler_mshutdown(void) -{ -} - -void xdebug_profiler_rinit(void) -{ - xdebug_file_init(&XG_PROF(profile_file)); - XG_PROF(profile_filename_refs) = NULL; - XG_PROF(profile_functionname_refs) = NULL; - XG_PROF(profile_last_filename_ref) = 0; - XG_PROF(php_internal_seen_before) = 0; - XG_PROF(profile_last_functionname_ref) = 0; - XG_PROF(active) = 0; -} - -static void deinit_if_active(void) -{ - if (!XG_PROF(active)) { - return; - } - - xdebug_profiler_deinit(); -} - -void xdebug_profiler_post_deactivate(void) -{ - deinit_if_active(); -} - -void xdebug_profiler_pcntl_exec_handler(void) -{ - deinit_if_active(); -} - -int xdebug_profiler_exit_handler(XDEBUG_OPCODE_HANDLER_ARGS) -{ - const zend_op *cur_opcode = execute_data->opline; - - deinit_if_active(); - - return xdebug_call_original_opcode_handler_if_set(cur_opcode->opcode, XDEBUG_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -void xdebug_profiler_init_if_requested(zend_op_array *op_array) -{ - if (XG_PROF(active)) { - return; - } - - if (EG(flags) & EG_FLAGS_IN_SHUTDOWN) { - return; - } - - if (xdebug_lib_start_with_request(XDEBUG_MODE_PROFILING) || xdebug_lib_start_with_trigger(XDEBUG_MODE_PROFILING, NULL)) { - xdebug_profiler_init((char*) STR_NAME_VAL(op_array->filename)); - } -} - -void xdebug_profiler_execute_ex(function_stack_entry *fse, zend_op_array *op_array) -{ - if (!XG_PROF(active)) { - return; - } - - /* Calculate all elements for profile entries */ - xdebug_profiler_add_function_details_user(fse, op_array); - xdebug_profiler_function_begin(fse); -} - -void xdebug_profiler_execute_ex_end(function_stack_entry *fse) -{ - xdebug_profiler_function_end(fse); - xdebug_profiler_free_function_details(fse); -} - -void xdebug_profiler_execute_internal(function_stack_entry *fse) -{ - if (!XG_PROF(active)) { - return; - } - - xdebug_profiler_add_function_details_internal(fse); - xdebug_profiler_function_begin(fse); -} - -void xdebug_profiler_execute_internal_end(function_stack_entry *fse) -{ - if (!XG_PROF(active)) { - return; - } - - xdebug_profiler_function_end(fse); - xdebug_profiler_free_function_details(fse); -} - -void xdebug_profile_call_entry_dtor(void *dummy, void *elem) -{ - xdebug_call_entry *ce = elem; - - if (ce->function) { - xdfree(ce->function); - } - if (ce->filename) { - zend_string_release(ce->filename); - } - xdfree(ce); -} - -static void profiler_write_header(xdebug_file *file, char *script_name) -{ - if (XINI_PROF(profiler_append)) { - xdebug_file_printf(file, "\n==== NEW PROFILING FILE ==============================================\n"); - } - xdebug_file_printf(file, "version: 1\ncreator: xdebug %s (PHP %s)\n", XDEBUG_VERSION, XG_BASE(php_version_run_time)); - xdebug_file_printf(file, "cmd: %s\npart: 1\npositions: line\n\n", script_name); - xdebug_file_printf(file, "events: Time_(10ns) Memory_(bytes)\n\n"); - xdebug_file_flush(file); -} - -#define NANOTIME_SCALE_10NS(nanotime) ((unsigned long)(((nanotime) + 5) / 10)) - -void xdebug_profiler_init(char *script_name) -{ - char *filename = NULL, *fname = NULL; - char *output_dir = NULL; - - if (XG_PROF(active)) { - return; - } - - if (!strlen(XINI_PROF(profiler_output_name)) || - xdebug_format_output_filename(&fname, XINI_PROF(profiler_output_name), script_name) <= 0 - ) { - /* Invalid or empty xdebug.profiler_output_name */ - return; - } - - /* Add a slash if none is present in the output_dir setting */ - output_dir = xdebug_lib_get_output_dir(); /* not duplicated */ - - if (IS_SLASH(output_dirstrlen(output_dir) - 1)) { - filename = xdebug_sprintf("%s%s", output_dir, fname); - } else { - filename = xdebug_sprintf("%s%c%s", output_dir, DEFAULT_SLASH, fname); - } - - if (!xdebug_file_open(&XG_PROF(profile_file), filename, NULL, XINI_PROF(profiler_append) ? "ab" : "wb")) { - xdebug_log_diagnose_permissions(XLOG_CHAN_PROFILE, output_dir, fname);
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/profiler/profiler_private.h
Deleted
@@ -1,32 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2020 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ -#ifndef __XDEBUG_PROFILER_PRIVATE_H__ -#define __XDEBUG_PROFILER_PRIVATE_H__ - -typedef struct _xdebug_call_entry { - int type; /* 0 = function call, 1 = line */ - int user_defined; - zend_string *filename; - char *function; - int lineno; - uint64_t nanotime_taken; - long mem_used; -} xdebug_call_entry; - -#define XG_PROF(v) (XG(globals.profiler.v)) -#define XINI_PROF(v) (XG(settings.profiler.v)) - -#endif
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/tracing/trace_computerized.c
Deleted
@@ -1,272 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ -#include "lib/php-header.h" -#include "ext/standard/php_string.h" - -#include "php_xdebug.h" -#include "tracing_private.h" -#include "trace_computerized.h" - -#include "lib/lib_private.h" -#include "lib/var_export_line.h" - -extern ZEND_DECLARE_MODULE_GLOBALS(xdebug); - -void *xdebug_trace_computerized_init(char *fname, zend_string *script_filename, long options) -{ - xdebug_trace_computerized_context *tmp_computerized_context; - - tmp_computerized_context = xdmalloc(sizeof(xdebug_trace_computerized_context)); - tmp_computerized_context->trace_file = xdebug_trace_open_file(fname, script_filename, options); - - if (!tmp_computerized_context->trace_file) { - xdfree(tmp_computerized_context); - return NULL; - } - - return tmp_computerized_context; -} - -void xdebug_trace_computerized_deinit(void *ctxt) -{ - xdebug_trace_computerized_context *context = (xdebug_trace_computerized_context*) ctxt; - - xdebug_file_close(context->trace_file); - xdebug_file_dtor(context->trace_file); - context->trace_file = NULL; - - xdfree(context); -} - -void xdebug_trace_computerized_write_header(void *ctxt) -{ - xdebug_trace_computerized_context *context = (xdebug_trace_computerized_context*) ctxt; - char *str_time; - - xdebug_file_printf(context->trace_file, "Version: %s\n", XDEBUG_VERSION); - xdebug_file_printf(context->trace_file, "File format: 4\n"); - - str_time = xdebug_nanotime_to_chars(xdebug_get_nanotime(), 6); - xdebug_file_printf(context->trace_file, "TRACE START %s\n", str_time); - xdfree(str_time); - - xdebug_file_flush(context->trace_file); -} - -void xdebug_trace_computerized_write_footer(void *ctxt) -{ - xdebug_trace_computerized_context *context = (xdebug_trace_computerized_context*) ctxt; - char *str_time; - uint64_t nanotime; - - nanotime = xdebug_get_nanotime(); - - xdebug_file_printf(context->trace_file, "\t\t\t%F\t", XDEBUG_SECONDS_SINCE_START(nanotime)); - xdebug_file_printf(context->trace_file, "%zu", zend_memory_usage(0)); - xdebug_file_printf(context->trace_file, "\n"); - - str_time = xdebug_nanotime_to_chars(xdebug_get_nanotime(), 6); - xdebug_file_printf(context->trace_file, "TRACE END %s\n\n", str_time); - xdfree(str_time); - - xdebug_file_flush(context->trace_file); -} - -char *xdebug_trace_computerized_get_filename(void *ctxt) -{ - xdebug_trace_computerized_context *context = (xdebug_trace_computerized_context*) ctxt; - - return context->trace_file->name; -} - -static void add_single_value(xdebug_str *str, zval *zv) -{ - xdebug_str *tmp_value = NULL; - - tmp_value = xdebug_get_zval_value_line(zv, 0, NULL); - - if (tmp_value) { - xdebug_str_add_str(str, tmp_value); - xdebug_str_free(tmp_value); - } else { - xdebug_str_add_literal(str, "???"); - } -} - -static void add_arguments(xdebug_str *line_entry, function_stack_entry *fse) -{ - unsigned int j = 0; /* Counter */ - int sent_variables = fse->varc; - - if (sent_variables > 0 && fse->varsent_variables-1.is_variadic && Z_ISUNDEF(fse->varsent_variables-1.data)) { - sent_variables--; - } - - /* Nr of arguments (11) */ - xdebug_str_add_fmt(line_entry, "\t%d", sent_variables); - - /* Arguments (12-...) */ - for (j = 0; j < sent_variables; j++) { - xdebug_str_addc(line_entry, '\t'); - - if (!Z_ISUNDEF(fse->varj.data)) { - add_single_value(line_entry, &(fse->varj.data)); - } else { - xdebug_str_add_literal(line_entry, "???"); - } - } -} - -void xdebug_trace_computerized_function_entry(void *ctxt, function_stack_entry *fse, int function_nr) -{ - xdebug_trace_computerized_context *context = (xdebug_trace_computerized_context*) ctxt; - char *tmp_name; - xdebug_str str = XDEBUG_STR_INITIALIZER; - - xdebug_str_add_fmt(&str, "%d\t", fse->level); - xdebug_str_add_fmt(&str, "%d\t", function_nr); - - tmp_name = xdebug_show_fname(fse->function, XDEBUG_SHOW_FNAME_DEFAULT); - - xdebug_str_add_literal(&str, "0\t"); - xdebug_str_add_fmt(&str, "%F\t", XDEBUG_SECONDS_SINCE_START(fse->nanotime)); - xdebug_str_add_fmt(&str, "%lu\t", fse->memory); - xdebug_str_add_fmt(&str, "%s\t", tmp_name); - if (fse->user_defined == XDEBUG_USER_DEFINED) { - xdebug_str_add_literal(&str, "1\t"); - } else { - xdebug_str_add_literal(&str, "0\t"); - } - xdfree(tmp_name); - - if (fse->include_filename) { - if (fse->function.type == XFUNC_EVAL) { - zend_string *escaped; - - escaped = php_addcslashes(fse->include_filename, (char*) "'\\\0..\37", 6); - - xdebug_str_addc(&str, '\''); - xdebug_str_add_zstr(&str, escaped); - xdebug_str_addc(&str, '\''); - zend_string_release(escaped); - } else { - xdebug_str_add_zstr(&str, fse->include_filename); - } - } - - /* Filename and Lineno (9, 10) */ - xdebug_str_add_fmt(&str, "\t%s\t%d", ZSTR_VAL(fse->filename), fse->lineno); - - add_arguments(&str, fse); - - /* Trailing \n */ - xdebug_str_addc(&str, '\n'); - - xdebug_file_printf(context->trace_file, "%s", str.d); - xdebug_file_flush(context->trace_file); - xdfree(str.d); -} - -void xdebug_trace_computerized_function_exit(void *ctxt, function_stack_entry *fse, int function_nr) -{ - xdebug_trace_computerized_context *context = (xdebug_trace_computerized_context*) ctxt; - xdebug_str str = XDEBUG_STR_INITIALIZER; - - xdebug_str_add_fmt(&str, "%d\t", fse->level); - xdebug_str_add_fmt(&str, "%d\t", function_nr); - - xdebug_str_add_literal(&str, "1\t"); - xdebug_str_add_fmt(&str, "%F\t", XDEBUG_SECONDS_SINCE_START(xdebug_get_nanotime())); - xdebug_str_add_fmt(&str, "%lu\n", zend_memory_usage(0)); - - xdebug_file_printf(context->trace_file, "%s", str.d); - xdebug_file_flush(context->trace_file); - xdfree(str.d); -} -
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/tracing/trace_html.c
Deleted
@@ -1,136 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ -#include "lib/php-header.h" - -#include "php_xdebug.h" -#include "tracing_private.h" -#include "trace_html.h" - -#include "lib/var.h" - -extern ZEND_DECLARE_MODULE_GLOBALS(xdebug); - -void *xdebug_trace_html_init(char *fname, zend_string *script_filename, long options) -{ - xdebug_trace_html_context *tmp_html_context; - - tmp_html_context = xdmalloc(sizeof(xdebug_trace_html_context)); - tmp_html_context->trace_file = xdebug_trace_open_file(fname, script_filename, options); - - if (!tmp_html_context->trace_file) { - xdfree(tmp_html_context); - return NULL; - } - - return tmp_html_context; -} - -void xdebug_trace_html_deinit(void *ctxt) -{ - xdebug_trace_html_context *context = (xdebug_trace_html_context*) ctxt; - - xdebug_file_close(context->trace_file); - xdebug_file_dtor(context->trace_file); - context->trace_file = NULL; - - xdfree(context); -} - -void xdebug_trace_html_write_header(void *ctxt) -{ - xdebug_trace_html_context *context = (xdebug_trace_html_context*) ctxt; - - xdebug_file_printf(context->trace_file, "<table style='hyphens: auto; -webkit-hyphens: auto; -ms-hyphens: auto;' class='xdebug-trace' dir='ltr' border='1' cellspacing='0'>\n"); - xdebug_file_printf(context->trace_file, "\t<tr><th>#</th><th>Time</th>"); - xdebug_file_printf(context->trace_file, "<th>Mem</th>"); - xdebug_file_printf(context->trace_file, "<th colspan='2'>Function</th><th>Location</th></tr>\n"); - xdebug_file_flush(context->trace_file); -} - -void xdebug_trace_html_write_footer(void *ctxt) -{ - xdebug_trace_html_context *context = (xdebug_trace_html_context*) ctxt; - - xdebug_file_printf(context->trace_file, "</table>\n"); - xdebug_file_flush(context->trace_file); -} - -char *xdebug_trace_html_get_filename(void *ctxt) -{ - xdebug_trace_html_context *context = (xdebug_trace_html_context*) ctxt; - - return context->trace_file->name; -} - -void xdebug_trace_html_function_entry(void *ctxt, function_stack_entry *fse, int function_nr) -{ - xdebug_trace_html_context *context = (xdebug_trace_html_context*) ctxt; - char *tmp_name; - unsigned int j; - xdebug_str str = XDEBUG_STR_INITIALIZER; - - xdebug_str_add_literal(&str, "\t<tr>"); - xdebug_str_add_fmt(&str, "<td>%d</td>", function_nr); - xdebug_str_add_fmt(&str, "<td>%0.6F</td>", XDEBUG_SECONDS_SINCE_START(fse->nanotime)); - xdebug_str_add_fmt(&str, "<td align='right'>%lu</td>", fse->memory); - xdebug_str_add_literal(&str, "<td align='left'>"); - for (j = 0; j < fse->level - 1; j++) { - xdebug_str_add_literal(&str, " "); - } - xdebug_str_add_literal(&str, "-></td>"); - - tmp_name = xdebug_show_fname(fse->function, XDEBUG_SHOW_FNAME_DEFAULT); - xdebug_str_add_fmt(&str, "<td>%s(", tmp_name); - xdfree(tmp_name); - - if (fse->include_filename) { - if (fse->function.type == XFUNC_EVAL) { - xdebug_str *joined; - xdebug_arg *parts; - - parts = xdebug_arg_ctor(); - xdebug_explode("\n", ZSTR_VAL(fse->include_filename), parts, 99999); - joined = xdebug_join("<br />", parts, 0, 99999); - xdebug_arg_dtor(parts); - - xdebug_str_add_fmt(&str, "'%s'", joined->d); - xdebug_str_free(joined); - } else { - xdebug_str_add_zstr(&str, fse->include_filename); - } - } - - xdebug_str_add_fmt(&str, ")</td><td>%s:%d</td>", ZSTR_VAL(fse->filename), fse->lineno); - xdebug_str_add_literal(&str, "</tr>\n"); - - xdebug_file_printf(context->trace_file, "%s", str.d); - xdebug_file_flush(context->trace_file); - xdfree(str.d); -} - -xdebug_trace_handler_t xdebug_trace_handler_html = -{ - xdebug_trace_html_init, - xdebug_trace_html_deinit, - xdebug_trace_html_write_header, - xdebug_trace_html_write_footer, - xdebug_trace_html_get_filename, - xdebug_trace_html_function_entry, - NULL /* xdebug_trace_html_function_exit */, - NULL /* xdebug_trace_html_function_return_value */, - NULL /* xdebug_trace_html_generator_return_value */, - NULL /* xdebug_trace_html_assignment */ -};
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/tracing/trace_textual.c
Deleted
@@ -1,340 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ -#include "lib/php-header.h" -#include "ext/standard/php_string.h" - -#include "php_xdebug.h" -#include "tracing_private.h" -#include "trace_textual.h" - -#include "lib/lib_private.h" -#include "lib/var_export_line.h" - -extern ZEND_DECLARE_MODULE_GLOBALS(xdebug); - -void *xdebug_trace_textual_init(char *fname, zend_string *script_filename, long options) -{ - xdebug_trace_textual_context *tmp_textual_context; - - tmp_textual_context = xdmalloc(sizeof(xdebug_trace_textual_context)); - tmp_textual_context->trace_file = xdebug_trace_open_file(fname, script_filename, options); - - if (!tmp_textual_context->trace_file) { - xdfree(tmp_textual_context); - return NULL; - } - - return tmp_textual_context; -} - -void xdebug_trace_textual_deinit(void *ctxt) -{ - xdebug_trace_textual_context *context = (xdebug_trace_textual_context*) ctxt; - - xdebug_file_close(context->trace_file); - xdebug_file_dtor(context->trace_file); - context->trace_file = NULL; - - xdfree(context); -} - -void xdebug_trace_textual_write_header(void *ctxt) -{ - xdebug_trace_textual_context *context = (xdebug_trace_textual_context*) ctxt; - char *str_time; - - str_time = xdebug_nanotime_to_chars(xdebug_get_nanotime(), 6); - xdebug_file_printf(context->trace_file, "TRACE START %s\n", str_time); - xdfree(str_time); - - xdebug_file_flush(context->trace_file); -} - -void xdebug_trace_textual_write_footer(void *ctxt) -{ - xdebug_trace_textual_context *context = (xdebug_trace_textual_context*) ctxt; - char *str_time; - uint64_t nanotime; - char *tmp; - - nanotime = xdebug_get_nanotime(); - tmp = xdebug_sprintf("%10.4F ", XDEBUG_SECONDS_SINCE_START(nanotime)); - xdebug_file_printf(context->trace_file, "%s", tmp); - xdfree(tmp); - xdebug_file_printf(context->trace_file, "%10zu", zend_memory_usage(0)); - xdebug_file_printf(context->trace_file, "\n"); - - str_time = xdebug_nanotime_to_chars(nanotime, 6); - xdebug_file_printf(context->trace_file, "TRACE END %s\n\n", str_time); - xdfree(str_time); - - xdebug_file_flush(context->trace_file); -} - -char *xdebug_trace_textual_get_filename(void *ctxt) -{ - xdebug_trace_textual_context *context = (xdebug_trace_textual_context*) ctxt; - - return context->trace_file->name; -} - -static void add_single_value(xdebug_str *str, zval *zv) -{ - xdebug_str *tmp_value = NULL; - - tmp_value = xdebug_get_zval_value_line(zv, 0, NULL); - - if (tmp_value) { - xdebug_str_add_str(str, tmp_value); - xdebug_str_free(tmp_value); - } else { - xdebug_str_add_literal(str, "???"); - } -} - -static void add_arguments(xdebug_str *line_entry, function_stack_entry *fse) -{ - unsigned int j = 0; /* Counter */ - int c = 0; /* Comma flag */ - int variadic_opened = 0; - int variadic_count = 0; - int sent_variables = fse->varc; - - if (sent_variables > 0 && fse->varsent_variables-1.is_variadic && Z_ISUNDEF(fse->varsent_variables-1.data)) { - sent_variables--; - } - - for (j = 0; j < sent_variables; j++) { - if (c) { - xdebug_str_add_literal(line_entry, ", "); - } else { - c = 1; - } - - if (fse->varj.is_variadic) { - xdebug_str_add_literal(line_entry, "..."); - variadic_opened = 1; - c = 0; - } - - if (fse->varj.name) { - xdebug_str_addc(line_entry, '$'); - xdebug_str_add_zstr(line_entry, fse->varj.name); - if (variadic_opened && !fse->varj.is_variadic) { - xdebug_str_add_literal(line_entry, " => "); - } else { - xdebug_str_add_literal(line_entry, " = "); - } - } - - if (fse->varj.is_variadic) { - xdebug_str_add_literal(line_entry, "variadic("); - if (Z_ISUNDEF(fse->varj.data)) { - continue; - } - c = 1; - } - - if (variadic_opened && (!fse->varj.name || fse->varj.is_variadic)) { - xdebug_str_add_fmt(line_entry, "%d => ", variadic_count++); - } - - if (!Z_ISUNDEF(fse->varj.data)) { - add_single_value(line_entry, &fse->varj.data); - } else { - xdebug_str_add_literal(line_entry, "???"); - } - } - - if (variadic_opened) { - xdebug_str_addc(line_entry, ')'); - } -} - -void xdebug_trace_textual_function_entry(void *ctxt, function_stack_entry *fse, int function_nr) -{ - xdebug_trace_textual_context *context = (xdebug_trace_textual_context*) ctxt; - unsigned int j = 0; /* Counter */ - char *tmp_name; - xdebug_str str = XDEBUG_STR_INITIALIZER; - - tmp_name = xdebug_show_fname(fse->function, XDEBUG_SHOW_FNAME_DEFAULT); - - xdebug_str_add_fmt(&str, "%10.4F ", XDEBUG_SECONDS_SINCE_START(fse->nanotime)); - xdebug_str_add_fmt(&str, "%10lu ", fse->memory); - for (j = 0; j < fse->level; j++) { - xdebug_str_add_literal(&str, " "); - } - xdebug_str_add_fmt(&str, "-> %s(", tmp_name); - - xdfree(tmp_name); - - add_arguments(&str, fse); - - if (fse->include_filename) { - if (fse->function.type == XFUNC_EVAL) { - zend_string *escaped; - - escaped = php_addcslashes(fse->include_filename, (char*) "'\\\0..\37", 6); - - xdebug_str_addc(&str, '\''); - xdebug_str_add_zstr(&str, escaped); - xdebug_str_addc(&str, '\''); - zend_string_release(escaped); - } else { - xdebug_str_add_zstr(&str, fse->include_filename); - }
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/tracing/tracing.c
Deleted
@@ -1,770 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ -#include "lib/php-header.h" -#include "ext/standard/php_string.h" - -#include "php_xdebug.h" -#include "tracing_private.h" -#include "trace_textual.h" -#include "trace_computerized.h" -#include "trace_html.h" - -#include "lib/compat.h" -#include "lib/log.h" -#include "lib/str.h" -#include "lib/var_export_line.h" - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - -static xdebug_trace_handler_t *xdebug_select_trace_handler(int options) -{ - xdebug_trace_handler_t *tmp; - - switch (XINI_TRACE(trace_format)) { - case 0: tmp = &xdebug_trace_handler_textual; break; - case 1: tmp = &xdebug_trace_handler_computerized; break; - case 2: tmp = &xdebug_trace_handler_html; break; - default: - php_error(E_NOTICE, "A wrong value for xdebug.trace_format was selected (%d), defaulting to the textual format", (int) XINI_TRACE(trace_format)); - tmp = &xdebug_trace_handler_textual; break; - } - - if (options & XDEBUG_TRACE_OPTION_COMPUTERIZED) { - tmp = &xdebug_trace_handler_computerized; - } - if (options & XDEBUG_TRACE_OPTION_HTML) { - tmp = &xdebug_trace_handler_html; - } - - if (!tmp->init || !tmp->deinit || !tmp->get_filename) { - xdebug_log_ex(XLOG_CHAN_TRACE, XLOG_CRIT, "HNDLR", "Broken trace handler for format '%d', missing 'init', 'deinit', or 'get_filename' handler", options); - } - - return tmp; -} - -xdebug_file *xdebug_trace_open_file(char *requested_filename, zend_string *script_filename, long options) -{ - xdebug_file *file = xdebug_file_ctor(); - char *filename_to_use; - char *generated_filename = NULL; - char *output_dir = xdebug_lib_get_output_dir(); /* not duplicated */ - - if (requested_filename && strlen(requested_filename)) { - filename_to_use = xdstrdup(requested_filename); - } else { - - if (!strlen(XINI_TRACE(trace_output_name)) || - xdebug_format_output_filename(&generated_filename, XINI_TRACE(trace_output_name), ZSTR_VAL(script_filename)) <= 0 - ) { - /* Invalid or empty xdebug.trace_output_name */ - xdebug_file_dtor(file); - return NULL; - } - - /* Add a slash if none is present in the output_dir setting */ - output_dir = xdebug_lib_get_output_dir(); /* not duplicated */ - - if (IS_SLASH(output_dirstrlen(output_dir) - 1)) { - filename_to_use = xdebug_sprintf("%s%s", output_dir, generated_filename); - } else { - filename_to_use = xdebug_sprintf("%s%c%s", output_dir, DEFAULT_SLASH, generated_filename); - } - } - - if (!xdebug_file_open( - file, - filename_to_use, - (options & XDEBUG_TRACE_OPTION_NAKED_FILENAME) ? NULL : "xt", - (options & XDEBUG_TRACE_OPTION_APPEND) ? "ab" : "wb" - )) { - xdebug_log_diagnose_permissions(XLOG_CHAN_TRACE, output_dir, generated_filename); - } - - if (generated_filename) { - xdfree(generated_filename); - } - xdfree(filename_to_use); - - return file; -} - -static char* xdebug_start_trace(char* fname, zend_string *script_filename, long options) -{ - if (XG_TRACE(trace_context)) { - return NULL; - } - - XG_TRACE(trace_handler) = xdebug_select_trace_handler(options); - if (!XG_TRACE(trace_handler)) { - return NULL; - } - - XG_TRACE(trace_context) = (void*) XG_TRACE(trace_handler)->init(fname, script_filename, options); - if (!XG_TRACE(trace_context)) { - return NULL; - } - - if (XG_TRACE(trace_handler)->write_header) { - XG_TRACE(trace_handler)->write_header(XG_TRACE(trace_context)); - } - - return xdstrdup(XG_TRACE(trace_handler)->get_filename(XG_TRACE(trace_context))); -} - -static void xdebug_stop_trace(void) -{ - if (!XG_TRACE(trace_context)) { - return; - } - - if (XG_TRACE(trace_handler)->write_footer) { - XG_TRACE(trace_handler)->write_footer(XG_TRACE(trace_context)); - } - XG_TRACE(trace_handler)->deinit(XG_TRACE(trace_context)); - XG_TRACE(trace_context) = NULL; -} - -char *xdebug_get_trace_filename(void) -{ - if (!(XG_TRACE(trace_context) && XG_TRACE(trace_handler) && XG_TRACE(trace_handler)->get_filename)) { - return NULL; - } - - return XG_TRACE(trace_handler)->get_filename(XG_TRACE(trace_context)); -} - -PHP_FUNCTION(xdebug_start_trace) -{ - char *fname = NULL; - size_t fname_len = 0; - char *trace_fname; - zend_long options = XINI_TRACE(trace_options); - function_stack_entry *fse; - - WARN_AND_RETURN_IF_MODE_IS_NOT(XDEBUG_MODE_TRACING); - - if (XG_TRACE(trace_context)) { - php_error(E_NOTICE, "Function trace already started"); - RETURN_FALSE; - } - - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|sl", &fname, &fname_len, &options) == FAILURE) { - return; - } - - fse = xdebug_get_stack_frame(0); - - if ((trace_fname = xdebug_start_trace(fname, fse->filename, options)) != NULL) { - RETVAL_STRING(trace_fname); - xdfree(trace_fname); - return; - } else { - php_error(E_NOTICE, "Trace could not be started"); - } - - RETURN_FALSE; -} - -PHP_FUNCTION(xdebug_stop_trace) -{ - WARN_AND_RETURN_IF_MODE_IS_NOT(XDEBUG_MODE_TRACING); - - if (!XG_TRACE(trace_context)) { - php_error(E_NOTICE, "Function trace was not started"); - RETURN_FALSE; - } - - RETVAL_STRING(XG_TRACE(trace_handler)->get_filename(XG_TRACE(trace_context))); - xdebug_stop_trace(); -} - -PHP_FUNCTION(xdebug_get_tracefile_name) -{ - char *filename; - - WARN_AND_RETURN_IF_MODE_IS_NOT(XDEBUG_MODE_TRACING);
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/src/tracing/tracing.h
Deleted
@@ -1,77 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ -#ifndef XDEBUG_TRACING_H -#define XDEBUG_TRACING_H - -#include "lib/php-header.h" - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeclaration-after-statement" -#include "zend_generators.h" -#pragma GCC diagnostic pop - -typedef struct -{ - void *(*init)(char *fname, zend_string *script_filename, long options); - void (*deinit)(void *ctxt); - void (*write_header)(void *ctxt); - void (*write_footer)(void *ctxt); - char *(*get_filename)(void *ctxt); - void (*function_entry)(void *ctxt, function_stack_entry *fse, int function_nr); - void (*function_exit)(void *ctxt, function_stack_entry *fse, int function_nr); - void (*return_value)(void *ctxt, function_stack_entry *fse, int function_nr, zval *return_value); - void (*generator_return_value)(void *ctxt, function_stack_entry *fse, int function_nr, zend_generator *generator); - void (*assignment)(void *ctxt, function_stack_entry *fse, char *full_varname, zval *value, char *right_full_varname, const char *op, char *file, int lineno); -} xdebug_trace_handler_t; - -typedef struct _xdebug_tracing_globals_t { - xdebug_trace_handler_t *trace_handler; - void *trace_context; -} xdebug_tracing_globals_t; - -typedef struct _xdebug_tracing_settings_t { - char *trace_output_name; - zend_long trace_options; - zend_long trace_format; - - zend_bool collect_assignments; - zend_bool collect_return; -} xdebug_tracing_settings_t; - -void xdebug_init_tracing_globals(xdebug_tracing_globals_t *xg); -void xdebug_tracing_minit(INIT_FUNC_ARGS); -void xdebug_tracing_rinit(void); -void xdebug_tracing_post_deactivate(void); -void xdebug_tracing_register_constants(INIT_FUNC_ARGS); - -void xdebug_tracing_init_if_requested(zend_op_array *op_array); -void xdebug_tracing_execute_ex(int function_nr, function_stack_entry *fse); -void xdebug_tracing_execute_ex_end(int function_nr, function_stack_entry *fse, zend_execute_data *execute_data); -int xdebug_tracing_execute_internal(int function_nr, function_stack_entry *fse); -void xdebug_tracing_execute_internal_end(int function_nr, function_stack_entry *fse, zval *return_value); - -void xdebug_tracing_save_trace_context(void **old_trace_context); -void xdebug_tracing_restore_trace_context(void *old_trace_context); - -char* xdebug_return_trace_stack_retval(function_stack_entry* i, int fnr, zval* retval); -char* xdebug_return_trace_stack_generator_retval(function_stack_entry* i, zend_generator* generator); -char* xdebug_return_trace_assignment(function_stack_entry *i, char *varname, zval *retval, char *op, char *file, int fileno); - -void xdebug_trace_function_begin(function_stack_entry *fse, int function_nr); -void xdebug_trace_function_end(function_stack_entry *fse, int function_nr); - -char *xdebug_get_trace_filename(void); -#endif
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/xdebug.c
Deleted
@@ -1,802 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "lib/php-header.h" -#include "main/php_version.h" -#include "lib/compat.h" - -#if HAVE_XDEBUG - -#ifndef PHP_WIN32 -#include <sys/time.h> -#include <unistd.h> -#else -#include "win32/time.h" -#include <process.h> -#endif - -#include "TSRM.h" -#include "SAPI.h" -#include "zend_extensions.h" -#include "main/php_ini.h" -#include "ext/standard/head.h" -#include "ext/standard/html.h" -#include "ext/standard/info.h" -#include "ext/standard/php_string.h" -#include "php_globals.h" -#include "main/php_output.h" -#include "ext/standard/php_var.h" - -#include "php_xdebug.h" -#include "php_xdebug_arginfo.h" - -#include "base/base.h" -#include "base/filter.h" -#include "coverage/code_coverage.h" -#include "develop/monitor.h" -#include "develop/stack.h" -#include "develop/superglobals.h" -#include "gcstats/gc_stats.h" -#include "lib/usefulstuff.h" -#include "lib/lib.h" -#include "lib/llist.h" -#include "lib/log.h" -#include "lib/mm.h" -#include "lib/var_export_html.h" -#include "lib/var_export_line.h" -#include "lib/var_export_text.h" -#include "profiler/profiler.h" -#include "tracing/tracing.h" - -static zend_result (*xdebug_orig_post_startup_cb)(void); -static zend_result xdebug_post_startup(void); - -int xdebug_include_or_eval_handler(zend_execute_data *execute_data); - -int zend_xdebug_initialised = 0; - -zend_module_entry xdebug_module_entry = { - STANDARD_MODULE_HEADER, - "xdebug", - ext_functions, - PHP_MINIT(xdebug), - PHP_MSHUTDOWN(xdebug), - PHP_RINIT(xdebug), - PHP_RSHUTDOWN(xdebug), - PHP_MINFO(xdebug), - XDEBUG_VERSION, - NO_MODULE_GLOBALS, - ZEND_MODULE_POST_ZEND_DEACTIVATE_N(xdebug), - STANDARD_MODULE_PROPERTIES_EX -}; - -ZEND_DECLARE_MODULE_GLOBALS(xdebug) - -#if COMPILE_DL_XDEBUG -ZEND_GET_MODULE(xdebug) -# ifdef ZTS -ZEND_TSRMLS_CACHE_DEFINE(); -# endif -#endif - -static PHP_INI_MH(OnUpdateServer) -{ - DUMP_TOK(server); -} - -static PHP_INI_MH(OnUpdateGet) -{ - DUMP_TOK(get); -} - -static PHP_INI_MH(OnUpdatePost) -{ - DUMP_TOK(post); -} - -static PHP_INI_MH(OnUpdateCookie) -{ - DUMP_TOK(cookie); -} - -static PHP_INI_MH(OnUpdateFiles) -{ - DUMP_TOK(files); -} - -static PHP_INI_MH(OnUpdateEnv) -{ - DUMP_TOK(env); -} - -static PHP_INI_MH(OnUpdateRequest) -{ - DUMP_TOK(request); -} - -static PHP_INI_MH(OnUpdateSession) -{ - DUMP_TOK(session); -} - -static PHP_INI_MH(OnUpdateStartWithRequest) -{ - if (!new_value) { - return FAILURE; - } - - if (!xdebug_lib_set_start_with_request(ZSTR_VAL(new_value))) { - return FAILURE; - } - - return SUCCESS; -} - -static PHP_INI_MH(OnUpdateStartUponError) -{ - if (!new_value) { - return FAILURE; - } - - if (!xdebug_lib_set_start_upon_error(ZSTR_VAL(new_value))) { - return FAILURE; - } - - return SUCCESS; -} - -static PHP_INI_MH(OnUpdateRemovedSetting) -{ - if (! (EG(error_reporting) & E_DEPRECATED)) { - return SUCCESS; - } - if (new_value && ZSTR_LEN(new_value) > 0 && strncmp("This setting", ZSTR_VAL(new_value), 11) != 0) { - xdebug_log_ex( - XLOG_CHAN_CONFIG, XLOG_CRIT, "REMOVED", - "The setting '%s' has been removed, see the upgrading guide at %supgrade_guide#changed-%s", - ZSTR_VAL(entry->name), xdebug_lib_docs_base(), ZSTR_VAL(entry->name) - ); - } - return FAILURE; -} - -static PHP_INI_MH(OnUpdateChangedSetting) -{ - if (! (EG(error_reporting) & E_DEPRECATED)) { - return SUCCESS; - } - if (new_value && ZSTR_LEN(new_value) > 0 && strncmp("This setting", ZSTR_VAL(new_value), 11) != 0) { - xdebug_log_ex( - XLOG_CHAN_CONFIG, XLOG_CRIT, "CHANGED", - "The setting '%s' has been renamed, see the upgrading guide at %supgrade_guide#changed-%s", - ZSTR_VAL(entry->name), xdebug_lib_docs_base(), ZSTR_VAL(entry->name) - ); - } - return FAILURE; -} - - -#ifdef P_tmpdir -# define XDEBUG_TEMP_DIR P_tmpdir -#else -# ifdef PHP_WIN32
View file
xdebug-3.2.0.tgz/xdebug-3.2.0/xdebug.ini
Deleted
@@ -1,1215 +0,0 @@ -; This file is generated by the 'xdebug.org:html/docs/convert.php' robot -; for Xdebug 3.2.0 — do not modify by hand - -; ----------------------------------------------------------------------------- -; xdebug.cli_color -; -; Type: integer, Default value: 0 -; -; If this setting is 1, Xdebug will color var_dumps and stack traces output when -; in CLI mode and when the output is a tty. On Windows, the ANSICON 1 tool -; needs to be installed. -; -; 1 http://adoxa.altervista.org/ansicon/ -; -; If the setting is 2, then Xdebug will always color var_dumps and stack trace, -; no matter whether it's connected to a tty or whether ANSICON is installed. In -; this case, you might end up seeing escape codes. -; -; See this article 1 for some more information. -; -; 1 https://derickrethans.nl/cli-color.html -; -; .. note:: -; -; This setting can additionally be configured through the -; ``XDEBUG_CONFIG``environment variable 1. 1 -; /docs/all_settings#XDEBUG_CONFIG -; -; -;xdebug.cli_color = 0 - -; ----------------------------------------------------------------------------- -; xdebug.client_discovery_header -; -; Type: string, Default value: "" -; -; If xdebug.client_discovery_header is configured to be a non-empty string, then -; the value is used as key in the ``$_SERVER`` superglobal array to determine -; which header to use to find the IP address or hostname to use for 'connecting -; back to'. This setting is only used in combination with -; xdebug.discover_client_host and is otherwise ignored. -; -; For example, if xdebug.client_discovery_header is set to -; ``HTTP_FORWARD_HOST``, then Xdebug will check -; ``$_SERVER'HTTP_FORWARD_HOST'`` before the -; ``$_SERVER'HTTP_X_FORWARDED_FOR'`` and ``$_SERVER'REMOTE_ADDR'`` -; variables. -; -; .. warning:: -; -; PHP automatically prepends ``HTTP_``, and converts ``-`` to ``_``, for -; received HTTP header names. The ``THIS-IS-MY-HOST`` HTTP header is -; converted into ``$_SERVER'HTTP_THIS_IS_MY_HOST'``. Therefore, the -; xdebug.client_discovery_header needs to be set to ``HTTP_THIS_IS_MY_HOST`` -; to match this. -; -; -;xdebug.client_discovery_header = "" - -; ----------------------------------------------------------------------------- -; xdebug.client_host -; -; Type: string, Default value: localhost -; -; Configures the IP address or hostname where Xdebug will attempt to connect to -; when initiating a debugging connection. This address should be the address of -; the machine where your IDE or debugging client is listening for incoming -; debugging connections. -; -; On non-Windows platforms, it is also possible to configure a Unix domain -; socket 1 which is supported by only a select view debugging clients. In that -; case, instead of the hostname or IP address, use ``unix:///path/to/sock``. -; -; 1 https://en.wikipedia.org/wiki/Unix_domain_socket -; -; If xdebug.discover_client_host is enabled then Xdebug will only use the value -; of this setting in case Xdebug can not connect to an IDE using the information -; it obtained from HTTP headers. In that case, the value of this setting acts as -; a fallback only. -; -; .. note:: -; -; This setting can additionally be configured through the -; ``XDEBUG_CONFIG``environment variable 1. 1 -; /docs/all_settings#XDEBUG_CONFIG -; -; -;xdebug.client_host = localhost - -; ----------------------------------------------------------------------------- -; xdebug.client_port -; -; Type: integer, Default value: 9003 -; -; The port to which Xdebug tries to connect on the remote host. Port ``9003`` is -; the default for both Xdebug and the Command Line Debug Client. As many clients -; use this port number, it is best to leave this setting unchanged. -; -; .. note:: -; -; This setting can additionally be configured through the -; ``XDEBUG_CONFIG``environment variable 1. 1 -; /docs/all_settings#XDEBUG_CONFIG -; -; -;xdebug.client_port = 9003 - -; ----------------------------------------------------------------------------- -; xdebug.cloud_id -; -; Type: string, Default value: -; -; With this setting you configure Xdebug for use with Xdebug Cloud 1. It needs -; to match one of the tokens from your profile page 2. -; -; 1 https://xdebug.cloud -; 2 https://xdebug.cloud/profile#tokens -; -; Your IDE needs to be configured with the same token for Xdebug and your IDE to -; communicate through Xdebug Cloud. -; -; | In PhpStorm you can find this setting under: -; | File | Settings | PHP | Debug | Xdebug Cloud for Windows and Linux -; | PhpStorm | Preferences | PHP | Debug | Xdebug Cloud for macOS -; -; -;xdebug.cloud_id = - -; ----------------------------------------------------------------------------- -; xdebug.collect_assignments -; -; Type: boolean, Default value: false -; -; This setting, defaulting to 0, controls whether Xdebug should add variable -; assignments to function traces. Assign-by-var ( ``=&``) assignments are -; included too. -; -; -;xdebug.collect_assignments = false - -; ----------------------------------------------------------------------------- -; xdebug.collect_return -; -; Type: boolean, Default value: false -; -; This setting, defaulting to 0, controls whether Xdebug should write the return -; value of function calls to the trace files. -; -; -;xdebug.collect_return = false - -; ----------------------------------------------------------------------------- -; xdebug.connect_timeout_ms -; -; Type: integer, Default value: 200 -; -; The amount of time in milliseconds that Xdebug will wait for on an IDE to -; acknowledge an incoming debugging connection. The default value of 200 ms -; should in most cases be enough. In case you often get dropped debugging -; requests, perhaps because you have a high latency network, or a development -; box far away from your IDE, or have a slow firewall, then you can should -; increase this value. -; -; Please note that increasing this value might mean that your requests seem to -; 'hang' in case Xdebug tries to establish a connection, but your IDE is not -; listening. -; -; -;xdebug.connect_timeout_ms = 200 - -; ----------------------------------------------------------------------------- -; xdebug.discover_client_host -; -; Type: boolean, Default value: false -; -; If enabled, Xdebug will first try to connect to the client that made the HTTP -; request. It checks the ``$_SERVER'HTTP_X_FORWARDED_FOR'`` and -; ``$_SERVER'REMOTE_ADDR'`` variables to find out which hostname or IP address -; to use. -; -; If xdebug.client_discovery_header is configured, then the ``$_SERVER`` -; variable with that configured name will be checked before -; ``HTTP_X_FORWARDED_FOR`` and ``REMOTE_ADDR``. -; -; If Xdebug can not connect to a debugging client as found in one of the HTTP -; headers, it will fall back to the hostname or IP address as configured by the -; xdebug.client_host setting. -; -; This setting does not apply for debugging through the CLI, as the ``$_SERVER`` -; header variables are not available there. -; -; .. note:: -; -; This setting can additionally be configured through the -; ``XDEBUG_CONFIG``environment variable 1. 1 -; /docs/all_settings#XDEBUG_CONFIG -; -; .. warning:: -;
View file
xdebug-3.2.0.tgz/package.xml -> xdebug-3.3.2.tgz/package.xml
Changed
@@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="UTF-8"?> +<?xml version="1.0" encoding="ISO-8859-1"?> <package packagerversion="1.10.13" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> <name>xdebug</name> <channel>pecl.php.net</channel> @@ -32,61 +32,25 @@ <email>derick@xdebug.org</email> <active>yes</active> </lead> - <date>2022-12-08</date> - <time>19:00:12</time> + <date>2024-04-15</date> + <time>12:55:17</time> <version> - <release>3.2.0</release> - <api>3.2.0</api> + <release>3.3.2</release> + <api>3.3.2</api> </version> <stability> <release>stable</release> <api>stable</api> </stability> - <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD style</license> + <license filesource="LICENSE" uri="https://xdebug.org/license/1.03">Xdebug-1.03</license> <notes> -Thu, Dec 08, 2022 - Xdebug 3.2.0 - -+ New features: - - - Fixed issue #1819: Allow a list of headers in 'xdebug.client_discovery_header' - - Fixed issue #2079: Add pseudo hosts xdebug://gateway and xdebug://nameserver - - Fixed issue #2086: Include return value in return breakpoint interruption response - - Fixed issue #2087: Introduce step for the return state and virtual property for return value - -+ Improvements: - - - Fixed issue #2062: Xdebug now records whether systemd's PrivateTmp is used in its diagnostics information - - Fixed issue #2104: Add support for PHP 8.2 "SensitiveParameter" attribute - - Fixed issue #2117: Removed emulated properties for closures, as PHP 8.2 adds debug information for them - - Fixed issue #2122: Local variables are now available when using start_upon_error - - Fixed issue #2123: Add warning in log and diagnositics information when a breakpoint is set on a non-existing file - - Fixed issue #2138: Step debugger now disconnects and continues running the script, when the debugging client closes the connection - - Fixed issue #2136: Duplicate line/conditional breakpoints are now rejected - -- Deprecations: - - - Fixed issue #2014: Drop support for PHP 7.2 - - Fixed issue #2102: Drop support for PHP 7.3 - - Fixed issue #2103: Drop support for PHP 7.4 +Mon, Apr 15, 2024 - Xdebug 3.3.2 = Fixed bugs: - - Fixed issue #2002: xdebug_trace_handler_t handler members are not always checked for NULL when executing - - Fixed issue #2045: Inapproriate frowny face - - Fixed issue #2089: Alpine Linux does not support res_ninit - - Fixed issue #2093: Fatal error: linux/rtnetlink.h: No such file or directory linux/rtnetlink.h - - Fixed issue #2098: With breakpoint_include_return_value enabled step_out break at every function - - Fixed issue #2105: 3.2.0alpha1 package misses the php-header.h file - - Fixed issue #2108: Segfault on PHP8.1 with PHPUnit 10 when path coverage is enabled - - Fixed issue #2113: Crash at step_into after thrown exception with return value debugging en - - Fixed issue #2121: Xdebug does not use local independent float-to-string functions - - Fixed issue #2124: Xdebug incorrectly reports that there are no children for static closure properties, even though there are - - Fixed issue #2125: Crash with PHP 8.2 on 32-bit due to change in "not set" value with CATCH opcode - - Fixed issue #2126: Problems with retrieving global variables - - Fixed issue #2127: Tracing does not handle NUL char in anonymous closure scope - - Fixed issue #2133: Warning with regards to extra NUL character in xdebug_setcookie call - - Fixed issue #2134: Xdebug stops at the line where the exception is created, not where it is thrown - - Fixed issue #2135: Xdebug stops twice at the same line after a call breakpoint or xdebug_break() + - Fixed issue #2216: With PHP8.3 and Apache 2.4.58 error_reporting() causing Apache process to hang + - Fixed issue #2230: Crash when xdebug and blackfire extensions are active + - Fixed issue #2233: High and continuous Apache server CPU use </notes> <contents> <dir name="/"> @@ -94,27 +58,31 @@ <file md5sum="ed01d7b0936a39822cd5c9144852e1b9" name="contrib/xt.vim" role="doc" /> <file md5sum="372197f5b791b837269177402b31688c" name="m4/clocks.m4" role="src" /> <file md5sum="c55adfb3a3094c8029687ae1f7a46120" name="m4/pkg.m4" role="src" /> - <file md5sum="6c582d721f4e657a0a1f09eadb05d3c1" name="src/base/base.c" role="src" /> + <file md5sum="e248d2f6f7dac8567156947ce773ab6a" name="src/base/base.c" role="src" /> <file md5sum="7db372db630677292df705a90c07e21c" name="src/base/base.h" role="src" /> - <file md5sum="544be6135ec5b70de44b2205cebc7800" name="src/base/base_globals.h" role="src" /> + <file md5sum="1502ac3e0d317e059f1c75db2b03346e" name="src/base/base_globals.h" role="src" /> <file md5sum="baf483b8b3f68c10d0c3f8863accf0c3" name="src/base/base_private.h" role="src" /> - <file md5sum="d0e04b38a411646d145e3a62afccdd7d" name="src/base/filter.c" role="src" /> + <file md5sum="ecced137dc9c6dc9cbe4c6c946d2cf9c" name="src/base/filter.c" role="src" /> <file md5sum="dc9f79b67b940c0ca6676008b94f0c91" name="src/base/filter.h" role="src" /> - <file md5sum="7dbafec36b9ad06617acbf281c7236e9" name="src/lib/usefulstuff.c" role="src" /> + <file md5sum="0f458f12744ae7226d53e3488f2a12a1" name="src/base/ctrl_socket.c" role="src" /> + <file md5sum="8663469dde1558dab7a03f0814501483" name="src/base/ctrl_socket.h" role="src" /> + <file md5sum="9795180682fad3c69098bfdd07dc968b" name="src/lib/usefulstuff.c" role="src" /> <file md5sum="36f17d040407ee39a71c74b30e88f8b1" name="src/lib/usefulstuff.h" role="src" /> + <file md5sum="fa037aadfa0553ff8eba45f578f36c97" name="src/lib/cmd_parser.c" role="src" /> + <file md5sum="d6e84ac1226cd3add0e8b98a2b5ad1d3" name="src/lib/cmd_parser.h" role="src" /> <file md5sum="67b36ef33accd5b98ccbc1c1cd7ad9e4" name="src/lib/compat.c" role="src" /> - <file md5sum="420d62640093693d4cee3e0812e7a370" name="src/lib/compat.h" role="src" /> + <file md5sum="ab0a3ccfa6b3626e761b5d690fd28f38" name="src/lib/compat.h" role="src" /> <file md5sum="5ded1e8050a567ddf31f15ccf8fc92d8" name="src/lib/crc32.c" role="src" /> <file md5sum="8e3d5ef843f03afab4cb27c4944d204f" name="src/lib/crc32.h" role="src" /> <file md5sum="825fb123306f9531faa11e83fbaa0a9e" name="src/lib/file.c" role="src" /> <file md5sum="5c262995cdd25eb6b65a1fb76eedfd11" name="src/lib/file.h" role="src" /> <file md5sum="53ae56622dd00dccdbffc92c938fe5a0" name="src/lib/hash.c" role="src" /> <file md5sum="77bef9854199eb280ecbd97a83737648" name="src/lib/hash.h" role="src" /> - <file md5sum="b95fb17e72285dd3c99ddd49356cbf80" name="src/lib/headers.c" role="src" /> + <file md5sum="46e1530b296f71bf2d00e282b32de691" name="src/lib/headers.c" role="src" /> <file md5sum="b05e34ecc50ab77d02933c583d88551b" name="src/lib/headers.h" role="src" /> - <file md5sum="d2b67839261cc354974d87d97c1631bb" name="src/lib/lib.c" role="src" /> - <file md5sum="8097bdd8d55f54204939bf7e4e7a7717" name="src/lib/lib.h" role="src" /> - <file md5sum="6c32e7d1b37168e7719f0e7e3e063aef" name="src/lib/log.c" role="src" /> + <file md5sum="72312d3dd877a81ab58df7ee7c606fe6" name="src/lib/lib.c" role="src" /> + <file md5sum="ea8c529b09a8988bf0a2313ba04617be" name="src/lib/lib.h" role="src" /> + <file md5sum="0336d9bd732b83f5f024a6782efc74ce" name="src/lib/log.c" role="src" /> <file md5sum="2ded0176decc29f511215987461419ff" name="src/lib/log.h" role="src" /> <file md5sum="8026528d3daa7d18021442eddbf60176" name="src/lib/lib_private.h" role="src" /> <file md5sum="88171fff82c5233a96d05341e0fcdcf9" name="src/lib/llist.c" role="src" /> @@ -127,79 +95,81 @@ <file md5sum="34d98f97b0e5a32a459a083bae66edfb" name="src/lib/str.h" role="src" /> <file md5sum="326ce360a40b63e768992aee68fe0c9d" name="src/lib/timing.c" role="src" /> <file md5sum="637e3b5e753e6afc8b014b02cec7b0ec" name="src/lib/timing.h" role="src" /> - <file md5sum="01338932374d0f6accbc56a25a42d3b9" name="src/lib/var.c" role="src" /> - <file md5sum="61574c585b50325415382f8e47af452b" name="src/lib/var.h" role="src" /> - <file md5sum="3ac8a9c3b8944c944a36c0efc9031d6b" name="src/lib/var_export_html.c" role="src" /> + <file md5sum="0476851515ef257cb58ec938ebe3c758" name="src/lib/var.c" role="src" /> + <file md5sum="253b8efe31b2bbe7c808aea188fe78e1" name="src/lib/var.h" role="src" /> + <file md5sum="f5d2a1cebc83fe2ae38eff20681463e6" name="src/lib/var_export_html.c" role="src" /> <file md5sum="ab2c1ac724a54c2b50946c7746ee135c" name="src/lib/var_export_html.h" role="src" /> - <file md5sum="c27cbf3693dab0150eafa2875f76c99e" name="src/lib/var_export_line.c" role="src" /> + <file md5sum="51340e6c1d3b77ec4509dc51bd2089fe" name="src/lib/var_export_line.c" role="src" /> <file md5sum="a865240b02e1f698ce57098f01693399" name="src/lib/var_export_line.h" role="src" /> - <file md5sum="1cb41799cc78d5bd3d6c8c8c8abc9ee8" name="src/lib/var_export_text.c" role="src" /> + <file md5sum="5980e5132000a9d1838b22cccb949412" name="src/lib/var_export_text.c" role="src" /> <file md5sum="ce4f91762755006f5df6353465e9927b" name="src/lib/var_export_text.h" role="src" /> - <file md5sum="a6517026d9ce5216ba38455af26652d0" name="src/lib/var_export_xml.c" role="src" /> + <file md5sum="1697176c9ff834e91c6633b333b00de5" name="src/lib/var_export_xml.c" role="src" /> <file md5sum="dc4f5766d9ebe581d6de6319fcc966ab" name="src/lib/var_export_xml.h" role="src" /> <file md5sum="8d1a4cb863697a98bf063b6a4ab79050" name="src/lib/vector.h" role="src" /> <file md5sum="a637b4abdfcc5a1a74ea7fcb94ebf0db" name="src/lib/xml.c" role="src" /> <file md5sum="bf00317cca78941bc659bf15b07fe385" name="src/lib/xml.h" role="src" /> <file md5sum="3bf888cd6a2d69da7738f278cb108561" name="src/coverage/branch_info.c" role="src" /> <file md5sum="963e2650561b374f99943254bda93688" name="src/coverage/branch_info.h" role="src" /> - <file md5sum="2af00c0a4b80185d245f6f956b64bca9" name="src/coverage/code_coverage.c" role="src" /> + <file md5sum="d031d68f6e5a952ef7fc2ea22c8bc0b1" name="src/coverage/code_coverage.c" role="src" /> <file md5sum="c7c6c4688b7654d2a481e64a519596a3" name="src/coverage/code_coverage.h" role="src" /> <file md5sum="b0a609f56e0d13cf7f6c915af1774512" name="src/coverage/code_coverage_private.h" role="src" /> - <file md5sum="14b822a1660aecc8ef04dbf08dabd2a6" name="src/develop/develop.c" role="src" /> - <file md5sum="49cda41235b9d8c88a7b1f927f05a11a" name="src/develop/develop.h" role="src" /> + <file md5sum="89a65d3495bdf205766dd72377f451ab" name="src/develop/develop.c" role="src" /> + <file md5sum="2c7fd0d0257b2db17e5fea6a2a148c8c" name="src/develop/develop.h" role="src" /> <file md5sum="8bc34c16b460129c99c0a43ef3db87e4" name="src/develop/develop_private.h" role="src" /> - <file md5sum="796baf06ff0a1440b5aa75df129cb4c4" name="src/develop/monitor.c" role="src" /> + <file md5sum="90b834c845688751dbb723fb6b9e855b" name="src/develop/monitor.c" role="src" /> <file md5sum="e29f144cd504ee14ebddee4f8ab5b714" name="src/develop/monitor.h" role="src" /> - <file md5sum="a09242412a0af4c90f89f7114dab7028" name="src/develop/php_functions.c" role="src" /> - <file md5sum="ae4598e490b263fd096e29f91268de1b" name="src/develop/stack.c" role="src" /> + <file md5sum="d9a771fa984ea3bf7697373847141abe" name="src/develop/php_functions.c" role="src" /> + <file md5sum="a9044ac300d13ef719e4d6ffc6e4ed83" name="src/develop/stack.c" role="src" /> <file md5sum="8befdeb139efc9a471dc9a3277ca771c" name="src/develop/stack.h" role="src" /> <file md5sum="a27d21b79bdf5acbe4725c7eeb8b1fb7" name="src/develop/superglobals.c" role="src" /> <file md5sum="3a2f095163c396e8945274b6d4595eaf" name="src/develop/superglobals.h" role="src" /> - <file md5sum="481e1743d9d1f4fc0ac1dc66c3fedf34" name="src/debugger/com.c" role="src" /> - <file md5sum="1f5b38bf32e1d1afc2f01f82763f49b2" name="src/debugger/com.h" role="src" /> - <file md5sum="70d94bc2f6219e0df2be859040ef390e" name="src/debugger/debugger.c" role="src" /> - <file md5sum="1339d4ae8b273afbef329b0f8b643ab5" name="src/debugger/debugger.h" role="src" /> + <file md5sum="2c9240f952b0ead40b961f1bcf90569c" name="src/debugger/com.c" role="src" /> + <file md5sum="ca34901978214b6b1eb942b7bfc18b20" name="src/debugger/com.h" role="src" /> + <file md5sum="a0c3a663a287c4a43c9f85411edd290a" name="src/debugger/debugger.c" role="src" /> + <file md5sum="bf74ec2e32c5b75f54b4757ee6b71e8e" name="src/debugger/debugger.h" role="src" /> <file md5sum="57dc7787f58e11c1b703b3c2e32808fe" name="src/debugger/debugger_private.h" role="src" /> <file md5sum="ebb7b99fc1253c60f3caf63bdba60e32" name="src/debugger/handlers.c" role="src" /> - <file md5sum="e185e51f69cc321c0df3e26c5249a98f" name="src/debugger/handlers.h" role="src" /> - <file md5sum="d6f7f24620e72248f5817ce574fb6e38" name="src/debugger/handler_dbgp.c" role="src" /> - <file md5sum="cc1c0092e242bc454c43162a7a86c695" name="src/debugger/handler_dbgp.h" role="src" /> - <file md5sum="9634f8f1bafdd4dad90adb588f22b1eb" name="src/debugger/ip_info.c" role="src" /> + <file md5sum="642ae17b70dc9f5aa96d97ff922dafb5" name="src/debugger/handlers.h" role="src" /> + <file md5sum="40202ff2822142d1f4d16108d35f7293" name="src/debugger/handler_dbgp.c" role="src" /> + <file md5sum="3997f84b9f11a4fdc14ffcebdc76f8ea" name="src/debugger/handler_dbgp.h" role="src" /> + <file md5sum="a7dda9a3ce716c3359caa83adb344676" name="src/debugger/ip_info.c" role="src" /> <file md5sum="e9bb3affd46a34d2ef21a8a251a54599" name="src/debugger/ip_info.h" role="src" /> - <file md5sum="4cdb157d8b1fa26bc97a7f1abd41fd58" name="src/gcstats/gc_stats.c" role="src" /> + <file md5sum="c3b2730b6167353c0bdb14efc8c4a8f1" name="src/gcstats/gc_stats.c" role="src" /> <file md5sum="3bf056d2ba948c4db6ec0375225ace32" name="src/gcstats/gc_stats.h" role="src" /> - <file md5sum="574739da937d570df6371efbbe4369fb" name="src/gcstats/gc_stats_private.h" role="src" /> - <file md5sum="66cfb83461dbba41093c05265d0957ff" name="src/profiler/profiler.c" role="src" /> + <file md5sum="b413a2fc300ffd2f7e4a7f0da5c846a7" name="src/gcstats/gc_stats_private.h" role="src" /> + <file md5sum="d0104dfd8d732115c0c5593dad045df4" name="src/profiler/profiler.c" role="src" /> <file md5sum="96f3f967d882ca71daa2e4225660319e" name="src/profiler/profiler.h" role="src" /> - <file md5sum="bed3b315bb5ac1e7ea43cc09897d3257" name="src/profiler/profiler_private.h" role="src" /> - <file md5sum="74e93aaa403799f6b9eb0ac457c32d12" name="src/tracing/tracing.c" role="src" /> - <file md5sum="1cad6b024160965fe79a8e7ac9b8eabb" name="src/tracing/tracing.h" role="src" /> + <file md5sum="898430e957132a43aeff96f40dddac18" name="src/profiler/profiler_private.h" role="src" /> + <file md5sum="774b937f1fb9713390b94c37787d3bb3" name="src/tracing/tracing.c" role="src" /> + <file md5sum="a9f7754a35cc95addebc3e417c21eb55" name="src/tracing/tracing.h" role="src" /> <file md5sum="f1319418b7165faac0ff1f1ce23467db" name="src/tracing/tracing_private.h" role="src" /> - <file md5sum="e513c3d6d69b1287c56eafd19249c939" name="src/tracing/trace_textual.c" role="src" /> - <file md5sum="13b0dca161acbf3c2f80c0b110b134e8" name="src/tracing/trace_textual.h" role="src" /> - <file md5sum="472f6849d0d31d1bf1e7cc85e2ce8eae" name="src/tracing/trace_computerized.c" role="src" /> + <file md5sum="68281302e760e1f3b7a727b2d90ca6e1" name="src/tracing/trace_computerized.c" role="src" />
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/CONTRIBUTING.rst
Added
@@ -0,0 +1,108 @@ +Contributing +============ + +Xdebug is hosted on Github. The source code can be browsed there and can be +checked out with:: + + git clone https://github.com/xdebug/xdebug.git + +If you think you want to fix a bug or work on a new feature, then you need to +follow the instructions below. Please reach out first to discuss your +suggested changes as well. + +Initial Set-up +-------------- + +- Fork Xdebug on GitHub. +- Make sure you have configured your Author Name and Author Email with GIT. + Xdebug doesn't accept contributions from accounts with unnatural names. +- Clone the repository:: + + git clone git@github.com:{your username}/xdebug.git + +- Change into the ``xdebug`` repository:: + + cd xdebug + +- Add the original repository as ``upstream`` remote:: + + git remote add upstream https://github.com/xdebug/xdebug.git + git fetch upstream + +- Add a tracking branch for Xdebug 3.1:: + + git checkout --track origin/xdebug_3_1 + +Branches +-------- + +There are two branches in operation: + +``master`` + This is were all new feature Pull Requests should be targeted at +``xdebug_3_1`` + This is were all bug fix Pull Requests should be targeted at. The + maintainer will add them to ``master`` too when merging the Pull Request. + +Working on a Pull Request +------------------------- + +- Make sure that your ``master`` and ``xdebug_3_1`` branches are up to date + with the ``upstream`` repository. +- Create an issue in the `issue tracker <https://bugs.xdebug.org>`_ (if none + exists yet). +- Switch to the right target branch (``master`` for features, ``xdebug_3_1`` + for bug fixes). +- Create a feature branch:: + + git checkout -b issue{issue number}-{description} + + For example:: + + git checkout -b issue1893-crash-with-fiber + +- For a bug fix, write one or more test cases to verify that the problem + currently exists, and also to define what the output should be. Xdebug uses + PHP's `phpt tests <https://qa.php.net/write-test.php>`_. The ``README.rst`` + file contains information on how to run the tests. + + Each of Xdebug's modes has a specific directory where to place tests. For + example, for code coverage that is ``tests/coverage``. Test case names + should follow the following pattern:: + + tests/{feature-group}bug0{issue-number}.phpt + + If you need more than one test, append ``-001`` after the issue number. + + Pull Requests without tests won't be accepted. + +- Fix and/or write the code. + +- Before you submit a PR, make sure each commit is a single logical unit. The + main commit that implements the issue, should have as commit message ``Fixed + issue #1893: `` followed by the Summary of the issue in the issue tracker. The + message should state what the change was about. For example:: + + Fixed issue #1893: Crash with ext-fiber with xdebug.mode=coverage + +- Before you submit a PR, make sure to rebase first on the branch that you + will be targeting, for example to rebase against the current bug fix + branch:: + + git fetch upstream && git rebase upstream/xdebug_3_1 + +- Push your changes to your remote repository:: + + git push origin {branch-name} + + For example:: + + git push origin issue1893-crash-with-fiber + +- Once you're satisfied, generate a pull request. Make sure that the title is + in one line, it's fine if it's a few characters larger than what GitHub + likes. Do not let the title spill over into the description with ``...```. + + In the description, explain what you changed, and why, and how your solution + is the right one. Feel free to include questions, and pointers to specific + things that need close review.
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/CREDITS
Changed
(renamed from xdebug-3.2.0/CREDITS)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/LICENSE
Added
@@ -0,0 +1,60 @@ +-------------------------------------------------------------------- + The Xdebug License, version 1.03 + (Based on "The PHP License", version 3.01) + Copyright (c) 2003-2022 Derick Rethans. All rights reserved. +-------------------------------------------------------------------- + +Redistribution and use in source and binary forms, with or without +modification, is permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + 3. The name "Xdebug" must not be used to endorse or promote products + derived from this software without prior written permission. For + written permission, please contact derick@xdebug.org. + + 4. Products derived from this software may not be called "Xdebug", nor + may "Xdebug" appear in their name, without prior written permission + from derick@xdebug.org. + + 5. Derick Rethans may publish revised and/or new versions of the + license from time to time. Each version will be given a + distinguishing version number. Once covered code has been + published under a particular version of the license, you may + always continue to use it under the terms of that version. You + may also choose to use such covered code under the terms of any + subsequent version of the license published by Derick Rethans. No + one other than Derick Rethans has the right to modify the terms + applicable to covered code created under this License. + + 6. Redistributions of any form whatsoever must retain the following + acknowledgment: "This product includes Xdebug software, freely + available from <https://xdebug.org/>". + +THIS SOFTWARE IS PROVIDED BY DERICK RETHANS ``AS IS'' AND ANY +EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP DEVELOPMENT TEAM OR +ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------------------------------------------------------- + +This software consists of voluntary contributions made by some +individuals on behalf of Derick Rethans. + +Derick Rethans can be contacted via e-mail at derick@xdebug.org. + +For more information on Xdebug, please see <https://xdebug.org>.
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/Makefile.frag
Changed
(renamed from xdebug-3.2.0/Makefile.frag)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/README.rst
Changed
(renamed from xdebug-3.2.0/README.rst)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/config.m4
Added
@@ -0,0 +1,133 @@ +dnl config.m4 for extension Xdebug + +PHP_ARG_ENABLE(xdebug, whether to enable Xdebug support, + --enable-xdebug Enable Xdebug support) + +PHP_ARG_ENABLE(xdebug-dev, whether to enable Xdebug developer build flags, + --enable-xdebug-dev Xdebug: Enable developer flags,, no) + +PHP_ARG_WITH(xdebug-compression, whether to compress profiler files (requires zlib), + --without-xdebug-compression Xdebug: Disable compression through zlib,yes,no) + +m4_include(m4/pkg.m4) +m4_include(m4/clocks.m4) + +if test "$PHP_XDEBUG" != "no"; then + AC_MSG_CHECKING(for supported PHP version) + PHP_XDEBUG_FOUND_VERSION=`${PHP_CONFIG} --version` + PHP_XDEBUG_FOUND_VERNUM=`${PHP_CONFIG} --vernum` + if test "$PHP_XDEBUG_FOUND_VERNUM" -lt "80000"; then + AC_MSG_ERROR(not supported. Need a PHP version >= 8.0.0 and < 8.5.0 (found $PHP_XDEBUG_FOUND_VERSION)) + else + if test "$PHP_XDEBUG_FOUND_VERNUM" -ge "80400"; then + AC_MSG_ERROR(not supported. Need a PHP version >= 8.0.0 and < 8.4.0 (found $PHP_XDEBUG_FOUND_VERSION)) + else + AC_MSG_RESULT(supported ($PHP_XDEBUG_FOUND_VERSION)) + fi + fi + + AC_DEFINE(HAVE_XDEBUG,1, ) + + old_CPPFLAGS=$CPPFLAGS + CPPFLAGS="$INCLUDES $CPPFLAGS" + + AC_XDEBUG_CLOCK + + AC_CHECK_HEADERS(netinet/in.h poll.h sys/poll.h) + case $host_os in + linux*) + AC_CHECK_HEADERS(linux/rtnetlink.h, , + case $host_os in + linux-musl*) + AC_MSG_ERROR(rtnetlink.h is required, install the linux-headers package: apk add --update linux-headers) + esac + AC_MSG_ERROR(rtnetlink.h is required, please make sure it is available by installing the correct package) + ) + esac + + PHP_CHECK_FUNC(res_ninit, resolv) + PHP_CHECK_FUNC(res_nclose, resolv) + + PHP_CHECK_LIBRARY(m, cos, PHP_ADD_LIBRARY(m,, XDEBUG_SHARED_LIBADD) ) + + if test "$PHP_XDEBUG_COMPRESSION" != "no"; then + PKG_CHECK_MODULES(ZLIB, zlib >= 1.2.9, + PHP_EVAL_LIBLINE($ZLIB_LIBS, XDEBUG_SHARED_LIBADD) + PHP_EVAL_INCLINE($ZLIB_CFLAGS) + + AC_DEFINE(HAVE_XDEBUG_ZLIB,1, ) + , ) + fi + + CPPFLAGS=$old_CPPFLAGS + + if test "$PHP_XDEBUG_DEV" = "yes"; then + AX_CHECK_COMPILE_FLAG(-Wbool-conversion, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wbool-conversion") + AX_CHECK_COMPILE_FLAG(-Wdeclaration-after-statement, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wdeclaration-after-statement") + AX_CHECK_COMPILE_FLAG(-Wdiscarded-qualifiers, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wdiscarded-qualifiers") + AX_CHECK_COMPILE_FLAG(-Wduplicate-enum, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wduplicate-enum") + AX_CHECK_COMPILE_FLAG(-Wempty-body, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wempty-body") + AX_CHECK_COMPILE_FLAG(-Wenum-compare, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wenum-compare") + AX_CHECK_COMPILE_FLAG(-Werror, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Werror") + AX_CHECK_COMPILE_FLAG(-Wextra, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wextra") + AX_CHECK_COMPILE_FLAG(-Wformat-nonliteral, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wformat-nonliteral") + AX_CHECK_COMPILE_FLAG(-Wformat-security, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wformat-security") + AX_CHECK_COMPILE_FLAG(-Wheader-guard, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wheader-guard") + AX_CHECK_COMPILE_FLAG(-Wincompatible-pointer-types-discards-qualifiers, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wincompatible-pointer-types-discards-qualifiers") + AX_CHECK_COMPILE_FLAG(-Wimplicit-fallthrough, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wimplicit-fallthrough") + AX_CHECK_COMPILE_FLAG(-Winit-self, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Winit-self") + AX_CHECK_COMPILE_FLAG(-Wlogical-not-parentheses, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wlogical-not-parentheses") + AX_CHECK_COMPILE_FLAG(-Wlogical-op, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wlogical-op") + AX_CHECK_COMPILE_FLAG(-Wlogical-op-parentheses, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wlogical-op-parentheses") + AX_CHECK_COMPILE_FLAG(-Wloop-analysis, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wloop-analysis") + AX_CHECK_COMPILE_FLAG(-Wmaybe-uninitialized, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wmaybe-uninitialized") + AX_CHECK_COMPILE_FLAG(-Wmissing-format-attribute, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wmissing-format-attribute") + AX_CHECK_COMPILE_FLAG(-Wno-missing-field-initializers, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wno-missing-field-initializers") + AX_CHECK_COMPILE_FLAG(-Wno-sign-compare, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wno-sign-compare") + AX_CHECK_COMPILE_FLAG(-Wno-unused-but-set-variable, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wno-unused-but-set-variable") + AX_CHECK_COMPILE_FLAG(-Wno-unused-parameter, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wno-unused-parameter") + AX_CHECK_COMPILE_FLAG(-Wno-variadic-macros, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wno-variadic-macros") + AX_CHECK_COMPILE_FLAG(-Wparentheses, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wparentheses") + AX_CHECK_COMPILE_FLAG(-Wpointer-bool-conversion, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wpointer-bool-conversion") + AX_CHECK_COMPILE_FLAG(-Wsizeof-array-argument, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wsizeof-array-argument") + AX_CHECK_COMPILE_FLAG(-Wstring-conversion, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wstring-conversion") + AX_CHECK_COMPILE_FLAG(-Wwrite-strings, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wwrite-strings") + AX_CHECK_COMPILE_FLAG(-Wpointer-arith, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wpointer-arith") + AX_CHECK_COMPILE_FLAG(-fdiagnostics-show-option, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fdiagnostics-show-option") + AX_CHECK_COMPILE_FLAG(-fno-exceptions, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fno-exceptions") + AX_CHECK_COMPILE_FLAG(-fno-omit-frame-pointer, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fno-omit-frame-pointer") + AX_CHECK_COMPILE_FLAG(-fno-optimize-sibling-calls, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fno-optimize-sibling-calls") + AX_CHECK_COMPILE_FLAG(-fsanitize-address, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fsanitize-address") + AX_CHECK_COMPILE_FLAG(-fstack-protector, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fstack-protector") + + MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS" + STD_CFLAGS="-g -O0 -Wall" + fi + + PHP_XDEBUG_CFLAGS="$STD_CFLAGS $MAINTAINER_CFLAGS" + + XDEBUG_BASE_SOURCES="src/base/base.c src/base/ctrl_socket.c src/base/filter.c" + XDEBUG_LIB_SOURCES="src/lib/usefulstuff.c src/lib/cmd_parser.c src/lib/compat.c src/lib/crc32.c src/lib/file.c src/lib/hash.c src/lib/headers.c src/lib/lib.c src/lib/llist.c src/lib/log.c src/lib/set.c src/lib/str.c src/lib/timing.c src/lib/var.c src/lib/var_export_html.c src/lib/var_export_line.c src/lib/var_export_text.c src/lib/var_export_xml.c src/lib/xml.c" + + XDEBUG_COVERAGE_SOURCES="src/coverage/branch_info.c src/coverage/code_coverage.c" + XDEBUG_DEBUGGER_SOURCES="src/debugger/com.c src/debugger/debugger.c src/debugger/handler_dbgp.c src/debugger/handlers.c src/debugger/ip_info.c" + XDEBUG_DEVELOP_SOURCES="src/develop/develop.c src/develop/monitor.c src/develop/php_functions.c src/develop/stack.c src/develop/superglobals.c" + XDEBUG_GCSTATS_SOURCES="src/gcstats/gc_stats.c" + XDEBUG_PROFILER_SOURCES="src/profiler/profiler.c" + XDEBUG_TRACING_SOURCES="src/tracing/trace_computerized.c src/tracing/trace_flamegraph.c src/tracing/trace_html.c src/tracing/trace_textual.c src/tracing/tracing.c" + + PHP_NEW_EXTENSION(xdebug, xdebug.c $XDEBUG_BASE_SOURCES $XDEBUG_LIB_SOURCES $XDEBUG_COVERAGE_SOURCES $XDEBUG_DEBUGGER_SOURCES $XDEBUG_DEVELOP_SOURCES $XDEBUG_GCSTATS_SOURCES $XDEBUG_PROFILER_SOURCES $XDEBUG_TRACING_SOURCES, $ext_shared,,$PHP_XDEBUG_CFLAGS,,yes) + PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(xdebug)/src/base) + PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(xdebug)/src/lib) + PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(xdebug)/src/coverage) + PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(xdebug)/src/debugger) + PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(xdebug)/src/develop) + PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(xdebug)/src/gcstats) + PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(xdebug)/src/profiler) + PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(xdebug)/src/tracing) + PHP_SUBST(XDEBUG_SHARED_LIBADD) + PHP_ADD_MAKEFILE_FRAGMENT + + PHP_ADD_INCLUDE($ext_srcdir/src) + PHP_ADD_INCLUDE($ext_builddir/src) +fi
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/config.w32
Added
@@ -0,0 +1,49 @@ +// vim:ft=javascript + +ARG_WITH("xdebug", "Xdebug support", "no"); + +ARG_WITH("xdebug-compression", "whether to compress profiler files (requires zlib)", "no"); + +if (PHP_XDEBUG != 'no') { + var XDEBUG_BASE_SOURCES="base.c filter.c" + var XDEBUG_LIB_SOURCES="usefulstuff.c cmd_parser.c compat.c crc32.c file.c hash.c headers.c lib.c llist.c log.c set.c str.c timing.c var.c var_export_html.c var_export_line.c var_export_text.c var_export_xml.c xml.c" + + var XDEBUG_COVERAGE_SOURCES="branch_info.c code_coverage.c" + var XDEBUG_DEBUGGER_SOURCES="com.c debugger.c handler_dbgp.c handlers.c" + var XDEBUG_DEVELOP_SOURCES="develop.c monitor.c php_functions.c stack.c superglobals.c" + var XDEBUG_GCSTATS_SOURCES="gc_stats.c" + var XDEBUG_PROFILER_SOURCES="profiler.c" + var XDEBUG_TRACING_SOURCES="trace_computerized.c trace_flamegraph.c trace_html.c trace_textual.c tracing.c" + + var files = "xdebug.c"; + + if (typeof(ZEND_EXTENSION) == 'undefined') { + EXTENSION('xdebug', files); + } else { + ZEND_EXTENSION('xdebug', files); + } + ADD_FLAG("CFLAGS_XDEBUG", " /I " + configure_module_dirname + " "); + ADD_FLAG("CFLAGS_XDEBUG", " /I " + configure_module_dirname + "/src "); + ADD_SOURCES(configure_module_dirname + "/src/base", XDEBUG_BASE_SOURCES, "xdebug"); + ADD_SOURCES(configure_module_dirname + "/src/lib", XDEBUG_LIB_SOURCES, "xdebug"); + ADD_SOURCES(configure_module_dirname + "/src/coverage", XDEBUG_COVERAGE_SOURCES, "xdebug"); + ADD_SOURCES(configure_module_dirname + "/src/debugger", XDEBUG_DEBUGGER_SOURCES, "xdebug"); + ADD_SOURCES(configure_module_dirname + "/src/develop", XDEBUG_DEVELOP_SOURCES, "xdebug"); + ADD_SOURCES(configure_module_dirname + "/src/gcstats", XDEBUG_GCSTATS_SOURCES, "xdebug"); + ADD_SOURCES(configure_module_dirname + "/src/profiler", XDEBUG_PROFILER_SOURCES, "xdebug"); + ADD_SOURCES(configure_module_dirname + "/src/tracing", XDEBUG_TRACING_SOURCES, "xdebug"); + + // PHP_ZLIB is "yes"/"no" for in-tree builds, but boolean for phpize builds + var XDEBUG_ZLIB = (!MODE_PHPIZE && PHP_ZLIB == "yes") || (MODE_PHPIZE && PHP_ZLIB); + + if (PHP_XDEBUG_COMPRESSION != "no") { + if (((!XDEBUG_ZLIB) && (CHECK_LIB("zlib_a.lib;zlib.lib", "xdebug", PHP_XDEBUG))) || + (PHP_ZLIB_SHARED && CHECK_LIB("zlib.lib", "xdebug", PHP_XDEBUG)) || + (XDEBUG_ZLIB && (!PHP_ZLIB_SHARED)) + ) { + AC_DEFINE('HAVE_XDEBUG_ZLIB', 1); + } + } + + AC_DEFINE("HAVE_XDEBUG", 1, "Xdebug support"); +}
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/contrib/tracefile-analyser.php
Changed
(renamed from xdebug-3.2.0/contrib/tracefile-analyser.php)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/contrib/xt.vim
Changed
(renamed from xdebug-3.2.0/contrib/xt.vim)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/m4/clocks.m4
Changed
(renamed from xdebug-3.2.0/m4/clocks.m4)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/m4/pkg.m4
Changed
(renamed from xdebug-3.2.0/m4/pkg.m4)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/php_xdebug.h
Added
@@ -0,0 +1,111 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2024 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#ifndef PHP_XDEBUG_H +#define PHP_XDEBUG_H + +#define XDEBUG_NAME "Xdebug" +#define XDEBUG_VERSION "3.3.2" +#define XDEBUG_AUTHOR "Derick Rethans" +#define XDEBUG_COPYRIGHT "Copyright (c) 2002-2024 by Derick Rethans" +#define XDEBUG_COPYRIGHT_SHORT "Copyright (c) 2002-2024" +#define XDEBUG_URL "https://xdebug.org" +#define XDEBUG_URL_FAQ "https://xdebug.org/docs/faq#api" + +#include "lib/php-header.h" + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "base/base_globals.h" +#include "coverage/branch_info.h" +#include "coverage/code_coverage.h" +#include "debugger/debugger.h" +#include "develop/develop.h" +#include "lib/lib.h" +#include "gcstats/gc_stats.h" +#include "profiler/profiler.h" +#include "tracing/tracing.h" +#include "lib/compat.h" +#include "lib/hash.h" +#include "lib/llist.h" +#include "lib/vector.h" +#include "lib/timing.h" + +extern zend_module_entry xdebug_module_entry; +#define phpext_xdebug_ptr &xdebug_module_entry + +#define OUTPUT_NOT_CHECKED -1 +#define OUTPUT_IS_TTY 1 +#define OUTPUT_NOT_TTY 0 + +#ifdef PHP_WIN32 +#define PHP_XDEBUG_API __declspec(dllexport) +#else +#define PHP_XDEBUG_API +#endif + +#ifdef ZTS +#include "TSRM.h" +#endif + +#include "main/SAPI.h" + +#define XDEBUG_ALLOWED_HALT_LEVELS (E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE ) + +PHP_MINIT_FUNCTION(xdebug); +PHP_MSHUTDOWN_FUNCTION(xdebug); +PHP_RINIT_FUNCTION(xdebug); +PHP_RSHUTDOWN_FUNCTION(xdebug); +PHP_MINFO_FUNCTION(xdebug); +ZEND_MODULE_POST_ZEND_DEACTIVATE_D(xdebug); + +int xdebug_is_output_tty(); + +ZEND_BEGIN_MODULE_GLOBALS(xdebug) + struct { + xdebug_base_globals_t base; + xdebug_coverage_globals_t coverage; + xdebug_debugger_globals_t debugger; + xdebug_develop_globals_t develop; + xdebug_gc_stats_globals_t gc_stats; + xdebug_library_globals_t library; + xdebug_profiler_globals_t profiler; + xdebug_tracing_globals_t tracing; + } globals; + struct { + xdebug_base_settings_t base; + xdebug_coverage_settings_t coverage; + xdebug_debugger_settings_t debugger; + xdebug_develop_settings_t develop; + xdebug_gc_stats_settings_t gc_stats; + xdebug_library_settings_t library; + xdebug_profiler_settings_t profiler; + xdebug_tracing_settings_t tracing; + } settings; +ZEND_END_MODULE_GLOBALS(xdebug) + +#ifdef ZTS +#define XG(v) TSRMG(xdebug_globals_id, zend_xdebug_globals *, v) +#else +#define XG(v) (xdebug_globals.v) +#endif + +#define XG_BASE(v) (XG(globals.base.v)) +#define XINI_BASE(v) (XG(settings.base.v)) + +#endif
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/php_xdebug_arginfo.h
Added
@@ -0,0 +1,210 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: abb3d6c16210384b6ac37292e3e46713125c8b18 */ + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_xdebug_break, 0, 0, _IS_BOOL, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_xdebug_call_class, 0, 0, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, depth, IS_LONG, 0, "2") +ZEND_END_ARG_INFO() + +#define arginfo_xdebug_call_file arginfo_xdebug_call_class + +#define arginfo_xdebug_call_function arginfo_xdebug_call_class + +#define arginfo_xdebug_call_line arginfo_xdebug_call_class + +#define arginfo_xdebug_code_coverage_started arginfo_xdebug_break + +#define arginfo_xdebug_connect_to_client arginfo_xdebug_break + +ZEND_BEGIN_ARG_INFO_EX(arginfo_xdebug_debug_zval, 0, 0, 0) + ZEND_ARG_VARIADIC_TYPE_INFO(0, varname, IS_STRING, 0) +ZEND_END_ARG_INFO() + +#define arginfo_xdebug_debug_zval_stdout arginfo_xdebug_debug_zval + +ZEND_BEGIN_ARG_INFO_EX(arginfo_xdebug_dump_superglobals, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_xdebug_get_code_coverage, 0, 0, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_xdebug_get_collected_errors, 0, 0, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, emptyList, _IS_BOOL, 0, "false") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_xdebug_get_function_count, 0, 0, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_xdebug_get_function_stack, 0, 0, IS_ARRAY, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "") +ZEND_END_ARG_INFO() + +#define arginfo_xdebug_get_gc_run_count arginfo_xdebug_get_function_count + +#define arginfo_xdebug_get_gc_total_collected_roots arginfo_xdebug_get_function_count + +#define arginfo_xdebug_get_gcstats_filename arginfo_xdebug_dump_superglobals + +#define arginfo_xdebug_get_headers arginfo_xdebug_get_code_coverage + +#define arginfo_xdebug_get_monitored_functions arginfo_xdebug_get_code_coverage + +#define arginfo_xdebug_get_profiler_filename arginfo_xdebug_dump_superglobals + +#define arginfo_xdebug_get_stack_depth arginfo_xdebug_get_function_count + +#define arginfo_xdebug_get_tracefile_name arginfo_xdebug_dump_superglobals + +ZEND_BEGIN_ARG_INFO_EX(arginfo_xdebug_info, 0, 0, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, category, IS_STRING, 0, "null") +ZEND_END_ARG_INFO() + +#define arginfo_xdebug_is_debugger_active arginfo_xdebug_break + +#define arginfo_xdebug_memory_usage arginfo_xdebug_get_function_count + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_xdebug_notify, 0, 1, _IS_BOOL, 0) + ZEND_ARG_TYPE_INFO(0, data, IS_MIXED, 0) +ZEND_END_ARG_INFO() + +#define arginfo_xdebug_peak_memory_usage arginfo_xdebug_get_function_count + +ZEND_BEGIN_ARG_INFO_EX(arginfo_xdebug_print_function_stack, 0, 0, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, message, IS_STRING, 0, "\"user triggered\"") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "0") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_xdebug_set_filter, 0, 0, 3) + ZEND_ARG_TYPE_INFO(0, group, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, listType, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, configuration, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_xdebug_start_code_coverage, 0, 0, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "0") +ZEND_END_ARG_INFO() + +#define arginfo_xdebug_start_error_collection arginfo_xdebug_dump_superglobals + +ZEND_BEGIN_ARG_INFO_EX(arginfo_xdebug_start_function_monitor, 0, 0, 1) + ZEND_ARG_TYPE_INFO(0, listOfFunctionsToMonitor, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_xdebug_start_gcstats, 0, 0, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, gcstatsFile, IS_STRING, 1, "null") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_xdebug_start_trace, 0, 0, IS_STRING, 1) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, traceFile, IS_STRING, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "0") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_xdebug_stop_code_coverage, 0, 0, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, cleanUp, _IS_BOOL, 0, "true") +ZEND_END_ARG_INFO() + +#define arginfo_xdebug_stop_error_collection arginfo_xdebug_dump_superglobals + +#define arginfo_xdebug_stop_function_monitor arginfo_xdebug_dump_superglobals + +#define arginfo_xdebug_stop_gcstats arginfo_xdebug_dump_superglobals + +#define arginfo_xdebug_stop_trace arginfo_xdebug_dump_superglobals + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_xdebug_time_index, 0, 0, IS_DOUBLE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_xdebug_var_dump, 0, 0, 0) + ZEND_ARG_VARIADIC_TYPE_INFO(0, variable, IS_MIXED, 0) +ZEND_END_ARG_INFO() + + +ZEND_FUNCTION(xdebug_break); +ZEND_FUNCTION(xdebug_call_class); +ZEND_FUNCTION(xdebug_call_file); +ZEND_FUNCTION(xdebug_call_function); +ZEND_FUNCTION(xdebug_call_line); +ZEND_FUNCTION(xdebug_code_coverage_started); +ZEND_FUNCTION(xdebug_connect_to_client); +ZEND_FUNCTION(xdebug_debug_zval); +ZEND_FUNCTION(xdebug_debug_zval_stdout); +ZEND_FUNCTION(xdebug_dump_superglobals); +ZEND_FUNCTION(xdebug_get_code_coverage); +ZEND_FUNCTION(xdebug_get_collected_errors); +ZEND_FUNCTION(xdebug_get_function_count); +ZEND_FUNCTION(xdebug_get_function_stack); +ZEND_FUNCTION(xdebug_get_gc_run_count); +ZEND_FUNCTION(xdebug_get_gc_total_collected_roots); +ZEND_FUNCTION(xdebug_get_gcstats_filename); +ZEND_FUNCTION(xdebug_get_headers); +ZEND_FUNCTION(xdebug_get_monitored_functions); +ZEND_FUNCTION(xdebug_get_profiler_filename); +ZEND_FUNCTION(xdebug_get_stack_depth); +ZEND_FUNCTION(xdebug_get_tracefile_name); +ZEND_FUNCTION(xdebug_info); +ZEND_FUNCTION(xdebug_is_debugger_active); +ZEND_FUNCTION(xdebug_memory_usage); +ZEND_FUNCTION(xdebug_notify); +ZEND_FUNCTION(xdebug_peak_memory_usage); +ZEND_FUNCTION(xdebug_print_function_stack); +ZEND_FUNCTION(xdebug_set_filter); +ZEND_FUNCTION(xdebug_start_code_coverage); +ZEND_FUNCTION(xdebug_start_error_collection); +ZEND_FUNCTION(xdebug_start_function_monitor); +ZEND_FUNCTION(xdebug_start_gcstats); +ZEND_FUNCTION(xdebug_start_trace); +ZEND_FUNCTION(xdebug_stop_code_coverage); +ZEND_FUNCTION(xdebug_stop_error_collection); +ZEND_FUNCTION(xdebug_stop_function_monitor); +ZEND_FUNCTION(xdebug_stop_gcstats); +ZEND_FUNCTION(xdebug_stop_trace); +ZEND_FUNCTION(xdebug_time_index); +ZEND_FUNCTION(xdebug_var_dump); + + +static const zend_function_entry ext_functions = { + ZEND_FE(xdebug_break, arginfo_xdebug_break) + ZEND_FE(xdebug_call_class, arginfo_xdebug_call_class) + ZEND_FE(xdebug_call_file, arginfo_xdebug_call_file) + ZEND_FE(xdebug_call_function, arginfo_xdebug_call_function) + ZEND_FE(xdebug_call_line, arginfo_xdebug_call_line) + ZEND_FE(xdebug_code_coverage_started, arginfo_xdebug_code_coverage_started) + ZEND_FE(xdebug_connect_to_client, arginfo_xdebug_connect_to_client) + ZEND_FE(xdebug_debug_zval, arginfo_xdebug_debug_zval) + ZEND_FE(xdebug_debug_zval_stdout, arginfo_xdebug_debug_zval_stdout) + ZEND_FE(xdebug_dump_superglobals, arginfo_xdebug_dump_superglobals) + ZEND_FE(xdebug_get_code_coverage, arginfo_xdebug_get_code_coverage) + ZEND_FE(xdebug_get_collected_errors, arginfo_xdebug_get_collected_errors) + ZEND_FE(xdebug_get_function_count, arginfo_xdebug_get_function_count) + ZEND_FE(xdebug_get_function_stack, arginfo_xdebug_get_function_stack) + ZEND_FE(xdebug_get_gc_run_count, arginfo_xdebug_get_gc_run_count) + ZEND_FE(xdebug_get_gc_total_collected_roots, arginfo_xdebug_get_gc_total_collected_roots) + ZEND_FE(xdebug_get_gcstats_filename, arginfo_xdebug_get_gcstats_filename) + ZEND_FE(xdebug_get_headers, arginfo_xdebug_get_headers) + ZEND_FE(xdebug_get_monitored_functions, arginfo_xdebug_get_monitored_functions) + ZEND_FE(xdebug_get_profiler_filename, arginfo_xdebug_get_profiler_filename) + ZEND_FE(xdebug_get_stack_depth, arginfo_xdebug_get_stack_depth) + ZEND_FE(xdebug_get_tracefile_name, arginfo_xdebug_get_tracefile_name) + ZEND_FE(xdebug_info, arginfo_xdebug_info) + ZEND_FE(xdebug_is_debugger_active, arginfo_xdebug_is_debugger_active) + ZEND_FE(xdebug_memory_usage, arginfo_xdebug_memory_usage) + ZEND_FE(xdebug_notify, arginfo_xdebug_notify) + ZEND_FE(xdebug_peak_memory_usage, arginfo_xdebug_peak_memory_usage) + ZEND_FE(xdebug_print_function_stack, arginfo_xdebug_print_function_stack) + ZEND_FE(xdebug_set_filter, arginfo_xdebug_set_filter) + ZEND_FE(xdebug_start_code_coverage, arginfo_xdebug_start_code_coverage) + ZEND_FE(xdebug_start_error_collection, arginfo_xdebug_start_error_collection) + ZEND_FE(xdebug_start_function_monitor, arginfo_xdebug_start_function_monitor)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/run-xdebug-tests.php
Added
@@ -0,0 +1,4042 @@ +#!/usr/bin/env php +<?php +/* + +----------------------------------------------------------------------+ + | Copyright (c) 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: | + | https://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: Ilia Alshanetsky <iliaa@php.net> | + | Preston L. Bannister <pbannister@php.net> | + | Marcus Boerger <helly@php.net> | + | Derick Rethans <derick@php.net> | + | Sander Roobol <sander@php.net> | + | Andrea Faulds <ajf@ajf.me> | + | (based on version by: Stig Bakken <ssb@php.net>) | + | (based on the PHP 3 test framework by Rasmus Lerdorf) | + +----------------------------------------------------------------------+ + */ + +/* $Id: ff8fc1a09b14846e2a5daa9b51cc2b6e97f3ac3c $ */ + +/* Temporary variables while this file is being refactored. */ +/** @var ?JUnit */ +$junit = null; + +/* End temporary variables. */ + +/* Let there be no top-level code beyond this point: + * Only functions and classes, thanks! + * + * Minimum required PHP version: 7.4.0 + */ + +function show_usage(): void +{ + echo <<<HELP +Synopsis: + php run-tests.php options files directories + +Options: + -j<workers> Run up to <workers> simultaneous testing processes in parallel for + quicker testing on systems with multiple logical processors. + Note that this is experimental feature. + + -l <file> Read the testfiles to be executed from <file>. After the test + has finished all failed tests are written to the same <file>. + If the list is empty and no further test is specified then + all tests are executed (same as: -r <file> -w <file>). + + -r <file> Read the testfiles to be executed from <file>. + + -w <file> Write a list of all failed tests to <file>. + + -a <file> Same as -w but append rather then truncating <file>. + + -W <file> Write a list of all tests and their result status to <file>. + + -c <file> Look for php.ini in directory <file> or use <file> as ini. + + -n Pass -n option to the php binary (Do not use a php.ini). + + -d foo=bar Pass -d option to the php binary (Define INI entry foo + with value 'bar'). + + -g Comma separated list of groups to show during test run + (possible values: PASS, FAIL, XFAIL, XLEAK, SKIP, BORK, WARN, LEAK, REDIRECT). + + -m Test for memory leaks with Valgrind (equivalent to -M memcheck). + + -M <tool> Test for errors with Valgrind tool. + + -p <php> Specify PHP executable to run. + + -P Use PHP_BINARY as PHP executable to run (default). + + -q Quiet, no user interaction (same as environment NO_INTERACTION). + + -s <file> Write output to <file>. + + -x Sets 'SKIP_SLOW_TESTS' environmental variable. + + --offline Sets 'SKIP_ONLINE_TESTS' environmental variable. + + --verbose + -v Verbose mode. + + --help + -h This Help. + + --temp-source <sdir> --temp-target <tdir> --temp-urlbase <url> + Write temporary files to <tdir> by replacing <sdir> from the + filenames to generate with <tdir>. In general you want to make + <sdir> the path to your source files and <tdir> some patch in + your web page hierarchy with <url> pointing to <tdir>. + + --keep-all|php|skip|after|clean + Do not delete 'all' files, 'php' test file, 'skip', 'after', + or 'clean' file. + + --set-timeout <n> + Set timeout for individual tests, where <n> is the number of + seconds. The default value is 60 seconds, or 300 seconds when + testing for memory leaks. + + --context <n> + Sets the number of lines of surrounding context to print for diffs. + The default value is 3. + + --show-all|php|skip|clean|after|exp|diff|out|mem + Show 'all' files, 'php' test file, 'skip', 'after', or 'clean' file. + You can also use this to show the output 'out', the expected result + 'exp', the difference between them 'diff' or the valgrind log + 'mem'. The result types get written independent of the log format, + however 'diff' only exists when a test fails. + + --show-slow <n> + Show all tests that took longer than <n> milliseconds to run. + + --no-clean Do not execute clean section if any. + + --color + --no-color Do/Don't colorize the result type in the test result. + + --repeat n + Run the tests multiple times in the same process and check the + output of the last execution (CLI SAPI only). + + --bless Bless failed tests using scripts/dev/bless_tests.php. + +HELP; +} + +/** + * One function to rule them all, one function to find them, one function to + * bring them all and in the darkness bind them. + * This is the entry point and exit point überfunction. It contains all the + * code that was previously found at the top level. It could and should be + * refactored to be smaller and more manageable. + */ +function main(): void +{ + /* This list was derived in a naïve mechanical fashion. If a member + * looks like it doesn't belong, it probably doesn't; cull at will. + */ + global $DETAILED, $PHP_FAILED_TESTS, $SHOW_ONLY_GROUPS, $argc, $argv, $cfg, + $cfgfiles, $cfgtypes, $conf_passed, $end_time, $environment, + $exts_skipped, $exts_tested, $exts_to_test, $failed_tests_file, + $ignored_by_ext, $ini_overwrites, $is_switch, $colorize, + $log_format, $matches, $no_clean, $no_file_cache, + $optionals, $pass_option_n, $pass_options, + $pattern_match, $php, $php_cgi, $phpdbg, $preload, $redir_tests, + $repeat, $result_tests_file, $slow_min_ms, $start_time, $switch, + $temp_source, $temp_target, $test_cnt, $test_dirs, + $test_files, $test_idx, $test_list, $test_results, $testfile, + $user_tests, $valgrind, $sum_results, $shuffle, $file_cache, $num_repeats, + $bless; + // Parallel testing + global $workers, $workerID; + global $context_line_count; + + // Temporary for the duration of refactoring + /** @var JUnit */ + global $junit; + + define('IS_WINDOWS', substr(PHP_OS, 0, 3) == "WIN"); + + $workerID = 0; + if (getenv("TEST_PHP_WORKER")) { + $workerID = intval(getenv("TEST_PHP_WORKER")); + run_worker(); + return; + } + + define('INIT_DIR', getcwd()); + + // Change into the PHP source directory. + if (getenv('TEST_PHP_SRCDIR')) { + @chdir(getenv('TEST_PHP_SRCDIR')); + } + + define('TEST_PHP_SRCDIR', getcwd()); + + check_proc_open_function_exists(); + + // If timezone is not set, use UTC. + if (ini_get('date.timezone') == '') { + date_default_timezone_set('UTC'); + } + + // Delete some security related environment variables + putenv('SSH_CLIENT=deleted'); + putenv('SSH_AUTH_SOCK=deleted'); + putenv('SSH_TTY=deleted');
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/base/base.c
Added
@@ -0,0 +1,1602 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#include "lib/php-header.h" +#include "TSRM.h" +#include "php_globals.h" +#include "zend_closures.h" +#include "zend_exceptions.h" +#if PHP_VERSION_ID >= 80200 +# include "zend_attributes.h" +#endif + +#include "zend_interfaces.h" + +#if PHP_VERSION_ID >= 80100 +# include "base_private.h" +# include "Zend/zend_fibers.h" +# include "Zend/zend_observer.h" +#endif + +#include "php_xdebug.h" +#include "php_xdebug_arginfo.h" + +#include "base.h" +#include "filter.h" +#ifdef __linux__ +# include "ctrl_socket.h" +#endif +#include "develop/develop.h" +#include "develop/stack.h" +#include "gcstats/gc_stats.h" +#include "lib/lib_private.h" +#include "lib/log.h" +#include "lib/var_export_line.h" +#include "lib/var.h" +#include "profiler/profiler.h" + +ZEND_EXTERN_MODULE_GLOBALS(xdebug) + +/* True globals for overloaded functions */ +zif_handler orig_error_reporting_func = NULL; +zif_handler orig_set_time_limit_func = NULL; +zif_handler orig_pcntl_exec_func = NULL; +zif_handler orig_pcntl_fork_func = NULL; + +#if PHP_VERSION_ID >= 80100 +void (*xdebug_old_error_cb)(int type, zend_string *error_filename, const uint32_t error_lineno, zend_string *message); +void (*xdebug_new_error_cb)(int type, zend_string *error_filename, const uint32_t error_lineno, zend_string *message); +static void xdebug_error_cb(int orig_type, zend_string *error_filename, const uint32_t error_lineno, zend_string *message); +#else +void (*xdebug_old_error_cb)(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message); +void (*xdebug_new_error_cb)(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message); +static void xdebug_error_cb(int orig_type, const char *error_filename, const uint32_t error_lineno, zend_string *message); +#endif + +/* execution redirection functions */ +zend_op_array* (*old_compile_file)(zend_file_handle* file_handle, int type); +static void (*xdebug_old_execute_ex)(zend_execute_data *execute_data); +static void (*xdebug_old_execute_internal)(zend_execute_data *current_execute_data, zval *return_value); + +/* error_cb and execption hook overrides */ +void xdebug_base_use_original_error_cb(void); +void xdebug_base_use_xdebug_error_cb(void); +void xdebug_base_use_xdebug_throw_exception_hook(void); + +/* Forward declarations for function overides */ +PHP_FUNCTION(xdebug_set_time_limit); +PHP_FUNCTION(xdebug_error_reporting); +PHP_FUNCTION(xdebug_pcntl_exec); +PHP_FUNCTION(xdebug_pcntl_fork); + + +/* {{{ zend_op_array xdebug_compile_file (file_handle, type) + * This function provides a hook for the execution of bananas */ +static zend_op_array *xdebug_compile_file(zend_file_handle *file_handle, int type) +{ + zend_op_array *op_array; + + op_array = old_compile_file(file_handle, type); + + if (!op_array) { + return NULL; + } + + xdebug_coverage_compile_file(op_array); + xdebug_debugger_compile_file(op_array); + + return op_array; +} +/* }}} */ + +/* I don't like this API, but the function_stack_entry does not keep this as a + * pointer, and hence we need two APIs for freeing :-S */ +void xdebug_func_dtor_by_ref(xdebug_func *elem) +{ + if (elem->function) { + zend_string_release(elem->function); + } + if (elem->object_class) { + zend_string_release(elem->object_class); + } + if (elem->scope_class) { + zend_string_release(elem->scope_class); + } + if (elem->include_filename) { + zend_string_release(elem->include_filename); + } +} + +void xdebug_func_dtor(xdebug_func *elem) +{ + xdebug_func_dtor_by_ref(elem); + xdfree(elem); +} + +static void function_stack_entry_dtor(void *elem) +{ + unsigned int i; + function_stack_entry *e = elem; + + xdebug_func_dtor_by_ref(&e->function); + + if (e->filename) { + zend_string_release(e->filename); + } + + if (e->var) { + for (i = 0; i < e->varc; i++) { + if (e->vari.name) { + zend_string_release(e->vari.name); + } + zval_ptr_dtor(&(e->vari.data)); + } + xdfree(e->var); + } + + if (e->declared_vars) { + xdebug_llist_destroy(e->declared_vars, NULL); + e->declared_vars = NULL; + } + + if (e->profile.call_list) { + xdebug_llist_destroy(e->profile.call_list, NULL); + e->profile.call_list = NULL; + } +} + +int xdebug_include_or_eval_handler(XDEBUG_OPCODE_HANDLER_ARGS) +{ + const zend_op *opline = execute_data->opline; + zval *inc_filename; + zval tmp_inc_filename; + int is_var; + + if (opline->extended_value != ZEND_EVAL) { + return xdebug_call_original_opcode_handler_if_set(opline->opcode, XDEBUG_OPCODE_HANDLER_ARGS_PASSTHRU); + } + + inc_filename = xdebug_get_zval(execute_data, opline->op1_type, &opline->op1, &is_var); + + /* If there is no inc_filename, we're just bailing out instead */ + if (!inc_filename) { + return xdebug_call_original_opcode_handler_if_set(opline->opcode, XDEBUG_OPCODE_HANDLER_ARGS_PASSTHRU); + } + + if (Z_TYPE_P(inc_filename) != IS_STRING) { + tmp_inc_filename = *inc_filename; + zval_copy_ctor(&tmp_inc_filename); + convert_to_string(&tmp_inc_filename); + inc_filename = &tmp_inc_filename; + } + + /* Now let's store this info */ + if (XG_BASE(last_eval_statement)) { + zend_string_release(XG_BASE(last_eval_statement)); + } + XG_BASE(last_eval_statement) = zend_string_init(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename), 0); + + if (inc_filename == &tmp_inc_filename) { + zval_dtor(&tmp_inc_filename); + } + + return xdebug_call_original_opcode_handler_if_set(opline->opcode, XDEBUG_OPCODE_HANDLER_ARGS_PASSTHRU); +} + +static int find_line_number_for_current_execute_point(zend_execute_data *edata)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/base/base.h
Changed
(renamed from xdebug-3.2.0/src/base/base.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/base/base_globals.h
Added
@@ -0,0 +1,95 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2022 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#ifndef __XDEBUG_BASE_GLOBALS_H__ +#define __XDEBUG_BASE_GLOBALS_H__ + +#include "lib/hash.h" +#include "lib/llist.h" +#include "lib/vector.h" + + +#if PHP_WIN32 +typedef void (WINAPI *WIN_PRECISE_TIME_FUNC)(LPFILETIME); +#endif + +typedef struct _xdebug_nanotime_context { + uint64_t start_abs; + uint64_t last_abs; +#if PHP_WIN32 | HAVE_XDEBUG_CLOCK_GETTIME | HAVE_XDEBUG_CLOCK_GETTIME_NSEC_NP + uint64_t start_rel; + uint64_t last_rel; + int use_rel_time; +#endif +#if PHP_WIN32 + WIN_PRECISE_TIME_FUNC win_precise_time_func; + uint64_t win_freq; +#endif +} xdebug_nanotime_context; + + +typedef struct _xdebug_base_globals_t { + xdebug_vector *stack; +#if PHP_VERSION_ID >= 80100 + xdebug_hash *fiber_stacks; +#endif + xdebug_nanotime_context nanotime_context; + uint64_t start_nanotime; + unsigned int prev_memory; + int output_is_tty; + zend_bool in_debug_info; + zend_long error_reporting_override; + zend_bool error_reporting_overridden; + unsigned int function_count; + zend_string *last_eval_statement; + char *last_exception_trace; + + /* in-execution checking */ + zend_bool in_execution; + zend_bool in_var_serialisation; + + /* Systemd Private Temp */ + char *private_tmp; + +#ifdef __linux__ + /* Control Socket */ + char *control_socket_path; + int control_socket_fd; + zend_long control_socket_last_trigger; +#endif + + /* filters */ + zend_long filter_type_code_coverage; + zend_long filter_type_stack; + zend_long filter_type_tracing; + xdebug_llist *filters_code_coverage; + xdebug_llist *filters_stack; + xdebug_llist *filters_tracing; + + /* PHP versions */ + const char *php_version_compile_time; + const char *php_version_run_time; +} xdebug_base_globals_t; + +typedef struct _xdebug_base_settings_t { +#ifdef __linux__ + int control_socket_granularity; + zend_long control_socket_threshold_ms; +#endif + zend_long max_nesting_level; +} xdebug_base_settings_t; + +#endif // __XDEBUG_BASE_GLOBALS_H__
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/base/base_private.h
Changed
(renamed from xdebug-3.2.0/src/base/base_private.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/base/ctrl_socket.c
Added
@@ -0,0 +1,373 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#ifdef __linux__ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <sys/socket.h> +#include <sys/un.h> +#include <arpa/inet.h> +#include <signal.h> +#include <string.h> +#include <errno.h> + +#include "php_xdebug.h" + +#include "ctrl_socket.h" +#include "lib/cmd_parser.h" +#include "lib/log.h" +#include "lib/xml.h" + +ZEND_EXTERN_MODULE_GLOBALS(xdebug) + +typedef struct { + int code; + const char *message; +} xdebug_error_entry; + +static xdebug_error_entry xdebug_error_codes24 = { + { 0, "no error" }, + { 1, "parse error in command" }, + { 2, "duplicate arguments in command" }, + { 3, "invalid or missing options" }, + { 4, "unimplemented command" }, + { 5, "command is not available" }, + { 400, "step debugger is not enabled" }, + { 401, "step debugger did not activate" }, + { -1, NULL } +}; + +static const char *error_message_from_code(int code) +{ + xdebug_error_entry *error_entry = &xdebug_error_codes0; + + while (error_entry->message) { + if (code == error_entry->code) { + return error_entry->message; + } + error_entry++; + } + return NULL; +} + +#define ADD_REASON_MESSAGE(c) { \ + xdebug_xml_node *message = xdebug_xml_node_init("message"); \ + xdebug_xml_add_text(message, xdstrdup(error_message_from_code(c))); \ + xdebug_xml_add_child(error, message); \ +} + + +#define CTRL_FUNC_PARAMETERS xdebug_xml_node **retval, xdebug_dbgp_arg *args +#define CTRL_FUNC(name) static void xdebug_ctrl_handle_##name(CTRL_FUNC_PARAMETERS) +#define CTRL_FUNC_ENTRY(name) { #name, xdebug_ctrl_handle_##name }, + +typedef struct xdebug_ctrl_cmd { + const char *name; + void (*handler)(CTRL_FUNC_PARAMETERS); + int flags; +} xdebug_ctrl_cmd; + +/* Command definition list */ +CTRL_FUNC(ps); +CTRL_FUNC(pause); + +static xdebug_ctrl_cmd ctrl_commands = { + CTRL_FUNC_ENTRY(ps) + CTRL_FUNC_ENTRY(pause) + { NULL, NULL } +}; + +/* Command handler selection */ +static xdebug_ctrl_cmd* lookup_cmd(char *cmd) +{ + xdebug_ctrl_cmd *ptr = ctrl_commands; + + while (ptr->name) { + if (strcmp(ptr->name, cmd) == 0) { + return ptr; + } + ptr++; + } + return NULL; +} + +static xdebug_str *make_message(xdebug_xml_node *message) +{ + xdebug_str xml_message = XDEBUG_STR_INITIALIZER; + xdebug_str *ret = xdebug_str_new(); + + xdebug_xml_return_node(message, &xml_message); + + xdebug_str_add_literal(ret, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); + xdebug_str_add(ret, xml_message.d, 0); + xdebug_str_addc(ret, '\0'); + xdebug_str_destroy(&xml_message); + + return ret; +} + + +static void handle_command(int fd, const char *line) +{ + char *cmd = NULL; + xdebug_dbgp_arg *args; + int res = 0; + xdebug_ctrl_cmd *command; + xdebug_str *message; + xdebug_xml_node *retval; + res = xdebug_cmd_parse(line, (char**) &cmd, (xdebug_dbgp_arg**) &args); + + retval = xdebug_xml_node_init("ctrl-response"); + xdebug_xml_add_attribute(retval, "xmlns:xdebug-ctrl", "https://xdebug.org/ctrl/xdebug"); + + command = lookup_cmd(cmd); + if (command) { + command->handler(&retval, args); + } else { + xdebug_xml_node *error; + error = xdebug_xml_node_init("error"); + xdebug_xml_add_attribute_ex(error, "code", xdebug_sprintf("%lu", XDEBUG_ERROR_COMMAND_UNAVAILABLE), 0, 1); + ADD_REASON_MESSAGE(XDEBUG_ERROR_COMMAND_UNAVAILABLE); + xdebug_xml_add_child(retval, error); + } + + message = make_message(retval); + write(fd, message->d, message->l); + + xdfree(cmd); + xdebug_cmd_arg_dtor(args); +} + +CTRL_FUNC(ps) +{ + xdebug_xml_node *response, *engine, *file, *pid, *time, *memory; + char *pid_str, *time_str, *memory_str; + function_stack_entry *fse = XDEBUG_VECTOR_HEAD(XG_BASE(stack)); + double time_elapsed = XDEBUG_SECONDS_SINCE_START(xdebug_get_nanotime()); + + response = xdebug_xml_node_init("ps"); + xdebug_xml_add_attribute(response, "success", "1"); + + engine = xdebug_xml_node_init("engine"); + xdebug_xml_add_attribute(engine, "version", XDEBUG_VERSION); + xdebug_xml_add_text(engine, xdstrdup(XDEBUG_NAME)); + xdebug_xml_add_child(response, engine); + + file = xdebug_xml_node_init("fileuri"); + xdebug_xml_add_text(file, ZSTR_VAL(fse->filename)); + xdebug_xml_add_child(response, file); + + pid = xdebug_xml_node_init("pid"); + pid_str = xdebug_sprintf("%lu", xdebug_get_pid()); + xdebug_xml_add_text(pid, pid_str); + xdebug_xml_add_child(response, pid); + + time = xdebug_xml_node_init("time"); + time_str = xdebug_sprintf("%f", time_elapsed); + xdebug_xml_add_text(time, time_str); + xdebug_xml_add_child(response, time); + + memory = xdebug_xml_node_init("memory"); + memory_str = xdebug_sprintf("%ld", zend_memory_usage(0) / 1024); + xdebug_xml_add_text(memory, memory_str); + xdebug_xml_add_child(response, memory); + + xdebug_xml_add_child(*retval, response); +} + +CTRL_FUNC(pause) +{ + xdebug_xml_node *response, *pid, *action; + char *pid_str; + + response = xdebug_xml_node_init("pause"); + xdebug_xml_add_attribute(response, "success", "1");
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/base/ctrl_socket.h
Added
@@ -0,0 +1,25 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#ifndef __XDEBUG_CTRL_SOCKET__ +#define __XDEBUG_CTRL_SOCKET__ + +void xdebug_control_socket_setup(void); +void xdebug_control_socket_teardown(void); + +void xdebug_control_socket_dispatch(void); + +#endif // __XDEBUG_CTRL_SOCKET__
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/base/filter.c
Added
@@ -0,0 +1,269 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ +#include "php_xdebug.h" + +#include "filter.h" + +#include "lib/lib.h" +#include "lib/log.h" + +ZEND_EXTERN_MODULE_GLOBALS(xdebug) + +int xdebug_is_stack_frame_filtered(int filter_type, function_stack_entry *fse) +{ + switch (filter_type) { + case XDEBUG_FILTER_CODE_COVERAGE: + return fse->filtered_code_coverage; + + case XDEBUG_FILTER_STACK: + return fse->filtered_stack; + + case XDEBUG_FILTER_TRACING: + return fse->filtered_tracing; + } + + return 0; +} + +int xdebug_is_top_stack_frame_filtered(int filter_type) +{ + function_stack_entry *fse; + fse = XDEBUG_VECTOR_TAIL(XG_BASE(stack)); + return xdebug_is_stack_frame_filtered(filter_type, fse); +} + +void xdebug_filter_register_constants(INIT_FUNC_ARGS) +{ + REGISTER_LONG_CONSTANT("XDEBUG_FILTER_CODE_COVERAGE", XDEBUG_FILTER_CODE_COVERAGE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("XDEBUG_FILTER_STACK", XDEBUG_FILTER_STACK, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("XDEBUG_FILTER_TRACING", XDEBUG_FILTER_TRACING, CONST_CS | CONST_PERSISTENT); + + REGISTER_LONG_CONSTANT("XDEBUG_FILTER_NONE", XDEBUG_FILTER_NONE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("XDEBUG_PATH_INCLUDE", XDEBUG_PATH_INCLUDE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("XDEBUG_PATH_EXCLUDE", XDEBUG_PATH_EXCLUDE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("XDEBUG_NAMESPACE_INCLUDE", XDEBUG_NAMESPACE_INCLUDE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("XDEBUG_NAMESPACE_EXCLUDE", XDEBUG_NAMESPACE_EXCLUDE, CONST_CS | CONST_PERSISTENT); +} + +static int xdebug_filter_match_path_include(function_stack_entry *fse, unsigned char *filtered_flag, char *filter) +{ + if (fse->filename && strncasecmp(filter, ZSTR_VAL(fse->filename), strlen(filter)) == 0) { + *filtered_flag = 0; + return 1; + } + return 0; +} + +static int xdebug_filter_match_path_exclude(function_stack_entry *fse, unsigned char *filtered_flag, char *filter) +{ + if (fse->filename && strncasecmp(filter, ZSTR_VAL(fse->filename), strlen(filter)) == 0) { + *filtered_flag = 1; + return 1; + } + return 0; +} + +static int xdebug_filter_match_namespace_include(function_stack_entry *fse, unsigned char *filtered_flag, char *filter) +{ + if (!fse->function.object_class && filter0 == '\0') { + *filtered_flag = 0; + return 1; + } + if (fse->function.object_class && filter0 != '\0' && strncasecmp(filter, ZSTR_VAL(fse->function.object_class), strlen(filter)) == 0) { + *filtered_flag = 0; + return 1; + } + return 0; +} + +static int xdebug_filter_match_namespace_exclude(function_stack_entry *fse, unsigned char *filtered_flag, char *filter) +{ + if (!fse->function.object_class && filter0 == '\0') { + *filtered_flag = 1; + return 1; + } + if (fse->function.object_class && filter0 != '\0' && strncasecmp(filter, ZSTR_VAL(fse->function.object_class), strlen(filter)) == 0) { + *filtered_flag = 1; + return 1; + } + return 0; +} + + +void xdebug_filter_run_internal(function_stack_entry *fse, int group, unsigned char *filtered_flag, int type, xdebug_llist *filters) +{ + xdebug_llist_element *le; + unsigned int k; + function_stack_entry tmp_fse; + int (*filter_to_run)(function_stack_entry *fse, unsigned char *filtered_flag, char *filter); + + le = XDEBUG_LLIST_HEAD(filters); + + switch (type) { + case XDEBUG_PATH_INCLUDE: + *filtered_flag = 1; + if (group == XDEBUG_FILTER_CODE_COVERAGE && fse->function.type & XFUNC_INCLUDES) { + tmp_fse.filename = fse->function.include_filename; + fse = &tmp_fse; + } + + filter_to_run = xdebug_filter_match_path_include; + break; + + case XDEBUG_PATH_EXCLUDE: + *filtered_flag = 0; + if (group == XDEBUG_FILTER_CODE_COVERAGE && fse->function.type & XFUNC_INCLUDES) { + tmp_fse.filename = fse->function.include_filename; + fse = &tmp_fse; + } + + filter_to_run = xdebug_filter_match_path_exclude; + break; + + case XDEBUG_NAMESPACE_INCLUDE: + *filtered_flag = 1; + filter_to_run = xdebug_filter_match_namespace_include; + break; + + case XDEBUG_NAMESPACE_EXCLUDE: + *filtered_flag = 0; + filter_to_run = xdebug_filter_match_namespace_exclude; + break; + + default: + /* Logically can't happen, but compilers can't detect that */ + return; + } + + for (k = 0; k < filters->size; k++, le = XDEBUG_LLIST_NEXT(le)) { + char *filter = XDEBUG_LLIST_VALP(le); + + /* If the filter matched once, we're done */ + if (filter_to_run(fse, filtered_flag, filter)) { + break; + } + } +} + +void xdebug_filter_run(function_stack_entry *fse) +{ + fse->filtered_stack = 0; + fse->filtered_tracing = 0; + + if (XG_BASE(filter_type_stack) != XDEBUG_FILTER_NONE) { + xdebug_filter_run_internal(fse, XDEBUG_FILTER_STACK, &fse->filtered_stack, XG_BASE(filter_type_stack), XG_BASE(filters_stack)); + } + if (XG_BASE(filter_type_tracing) != XDEBUG_FILTER_NONE) { + xdebug_filter_run_internal(fse, XDEBUG_FILTER_TRACING, &fse->filtered_tracing, XG_BASE(filter_type_tracing), XG_BASE(filters_tracing)); + } +} + +/* {{{ proto void xdebug_set_filter(int group, int type, array filters) + This function configures filters for tracing and code coverage */ +PHP_FUNCTION(xdebug_set_filter) +{ + zend_long filter_group; + zend_long filter_type; + xdebug_llist **filter_list; + zval *filters, *item; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "lla", &filter_group, &filter_type, &filters) == FAILURE) { + return; + } + + switch (filter_group) { + case XDEBUG_FILTER_CODE_COVERAGE: + if (!XDEBUG_MODE_IS(XDEBUG_MODE_COVERAGE)) { + xdebug_log_ex(XLOG_CHAN_BASE, XLOG_WARN, "COV-FILTER", "Can not set a filter for code coverage, because Xdebug mode does not include 'coverage'"); + return; + } + + filter_list = &XG_BASE(filters_code_coverage); + XG_BASE(filter_type_code_coverage) = XDEBUG_FILTER_NONE; + if (filter_type == XDEBUG_NAMESPACE_INCLUDE || filter_type == XDEBUG_NAMESPACE_EXCLUDE) { + php_error(E_WARNING, "The code coverage filter (XDEBUG_FILTER_CODE_COVERAGE) only supports the XDEBUG_PATH_INCLUDE, XDEBUG_PATH_EXCLUDE, and XDEBUG_FILTER_NONE filter types"); + return; + }
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/base/filter.h
Changed
(renamed from xdebug-3.2.0/src/base/filter.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/coverage/branch_info.c
Changed
(renamed from xdebug-3.2.0/src/coverage/branch_info.c)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/coverage/branch_info.h
Changed
(renamed from xdebug-3.2.0/src/coverage/branch_info.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/coverage/code_coverage.c
Added
@@ -0,0 +1,1194 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#include "php_xdebug.h" +#include "zend_extensions.h" + +#include "branch_info.h" +#include "code_coverage_private.h" + +#include "base/base.h" +#include "base/filter.h" +#include "lib/compat.h" +#include "lib/set.h" +#include "lib/var.h" +#include "tracing/tracing.h" + +/* True globals */ +int zend_xdebug_filter_offset = -1; +int zend_xdebug_cc_run_offset = -1; + +extern ZEND_DECLARE_MODULE_GLOBALS(xdebug); + +static void xdebug_coverage_line_dtor(void *data) +{ + xdebug_coverage_line *line = (xdebug_coverage_line *) data; + + xdfree(line); +} + +xdebug_coverage_file *xdebug_coverage_file_ctor(zend_string *filename) +{ + xdebug_coverage_file *file; + + file = xdmalloc(sizeof(xdebug_coverage_file)); + file->name = zend_string_copy(filename); + file->lines = xdebug_hash_alloc(128, xdebug_coverage_line_dtor); + file->functions = xdebug_hash_alloc(128, xdebug_coverage_function_dtor); + file->has_branch_info = 0; + + return file; +} + +static void xdebug_coverage_file_dtor(void *data) +{ + xdebug_coverage_file *file = (xdebug_coverage_file *) data; + + xdebug_hash_destroy(file->lines); + xdebug_hash_destroy(file->functions); + zend_string_release(file->name); + xdfree(file); +} + +xdebug_coverage_function *xdebug_coverage_function_ctor(char *function_name) +{ + xdebug_coverage_function *function; + + function = xdmalloc(sizeof(xdebug_coverage_function)); + function->name = xdstrdup(function_name); + function->branch_info = NULL; + + return function; +} + +void xdebug_coverage_function_dtor(void *data) +{ + xdebug_coverage_function *function = (xdebug_coverage_function *) data; + + if (function->branch_info) { + xdebug_branch_info_free(function->branch_info); + } + xdfree(function->name); + xdfree(function); +} + +static void xdebug_func_format(char *buffer, size_t buffer_size, xdebug_func *func) +{ + if (func->type == XFUNC_NORMAL) { + int len = ZSTR_LEN(func->function); + + if (len + 1 > buffer_size) { + goto error; + } + memcpy(buffer, ZSTR_VAL(func->function), len); + bufferlen = '\0'; + return; + } + + if (func->type == XFUNC_MEMBER) { + int func_len = ZSTR_LEN(func->function); + int len = ZSTR_LEN(func->object_class) + 2 + func_len; + + if (len + 1 > buffer_size) { + goto error; + } + memcpy(buffer, ZSTR_VAL(func->object_class), ZSTR_LEN(func->object_class)); + memcpy(buffer + ZSTR_LEN(func->object_class), "->", 2); + memcpy(buffer + ZSTR_LEN(func->object_class) + 2, ZSTR_VAL(func->function), func_len); + bufferlen = '\0'; + return; + } + +error: + memcpy(buffer, "?", 1); + buffer1 = '\0'; +} + +static void xdebug_build_fname_from_oparray(xdebug_func *tmp, zend_op_array *opa) +{ + int wrapped = 0; + + memset(tmp, 0, sizeof(xdebug_func)); + + if (opa->function_name) { + if (opa->fn_flags & ZEND_ACC_CLOSURE) { + tmp->function = xdebug_wrap_closure_location_around_function_name(opa, opa->function_name); + wrapped = 1; + } else if ( + opa->fn_flags & ZEND_ACC_TRAIT_CLONE + || (opa->scope && opa->scope->ce_flags & ZEND_ACC_TRAIT) + ) { + tmp->function = xdebug_wrap_location_around_function_name("trait-method", opa, opa->function_name); + wrapped = 1; + } else { + tmp->function = zend_string_copy(opa->function_name); + } + } else { + tmp->function = ZSTR_INIT_LITERAL("{main}", false); + tmp->type = XFUNC_MAIN; + } + + if (opa->scope && !wrapped) { + tmp->type = XFUNC_MEMBER; + tmp->object_class = zend_string_copy(opa->scope->name); + } else { + tmp->type = XFUNC_NORMAL; + } +} + +static void xdebug_print_opcode_info(zend_execute_data *execute_data, const zend_op *cur_opcode) +{ + zend_op_array *op_array = &execute_data->func->op_array; + xdebug_func func_info; + char function_name1024; + long opnr = execute_data->opline - execute_data->func->op_array.opcodes; + + xdebug_build_fname_from_oparray(&func_info, op_array); + xdebug_func_format(function_name, sizeof(function_name), &func_info); + if (func_info.object_class) { + zend_string_release(func_info.object_class); + } + if (func_info.scope_class) { + zend_string_release(func_info.scope_class); + } + if (func_info.function) { + zend_string_release(func_info.function); + } + + xdebug_branch_info_mark_reached(op_array->filename, function_name, op_array, opnr); +} + +static int xdebug_check_branch_entry_handler(XDEBUG_OPCODE_HANDLER_ARGS) +{ + zend_op_array *op_array = &execute_data->func->op_array; + const zend_op *cur_opcode = execute_data->opline; + + if (!op_array->reservedXG_COV(code_coverage_filter_offset) && XG_COV(code_coverage_active)) { + xdebug_print_opcode_info(execute_data, cur_opcode); + } + + return xdebug_call_original_opcode_handler_if_set(cur_opcode->opcode, XDEBUG_OPCODE_HANDLER_ARGS_PASSTHRU); +} + +static void xdebug_count_line(zend_string *filename, int lineno, int executable, int deadcode) +{ + xdebug_coverage_file *file; + xdebug_coverage_line *line; + + if (XG_COV(previous_filename) && zend_string_equals(XG_COV(previous_filename), filename)) { + file = XG_COV(previous_file); + } else { + /* Check if the file already exists in the hash */ + if (!xdebug_hash_find(XG_COV(code_coverage_info), ZSTR_VAL(filename), ZSTR_LEN(filename), (void *) &file)) { + /* The file does not exist, so we add it to the hash */ + file = xdebug_coverage_file_ctor(filename); + + xdebug_hash_add(XG_COV(code_coverage_info), ZSTR_VAL(filename), ZSTR_LEN(filename), file);
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/coverage/code_coverage.h
Changed
(renamed from xdebug-3.2.0/src/coverage/code_coverage.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/coverage/code_coverage_private.h
Changed
(renamed from xdebug-3.2.0/src/coverage/code_coverage_private.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/debugger/com.c
Added
@@ -0,0 +1,790 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ +#include "php_xdebug.h" +#include <string.h> +#include <sys/types.h> +#include <errno.h> +#include <stdio.h> +#include <fcntl.h> +#ifndef PHP_WIN32 +# if HAVE_POLL_H +# include <poll.h> +# elif HAVE_SYS_POLL_H +# include <sys/poll.h> +# endif +# include <unistd.h> +# include <sys/socket.h> +# include <sys/un.h> +# include <netinet/tcp.h> +# if HAVE_NETINET_IN_H +# include <netinet/in.h> +# endif +# include <netdb.h> +#else +# include <process.h> +# include <direct.h> +# include "win32/time.h" +# undef UNICODE +# include <winsock2.h> +# include <ws2tcpip.h> +# include <mstcpip.h> +# pragma comment (lib, "Ws2_32.lib") +# define PATH_MAX MAX_PATH +# define poll WSAPoll +#endif + +#include "Zend/zend_extensions.h" + +#include "com.h" + +#include "debugger_private.h" +#include "handler_dbgp.h" +#include "ip_info.h" +#include "lib/crc32.h" +#include "lib/log.h" + +ZEND_EXTERN_MODULE_GLOBALS(xdebug) + +#if !WIN32 && !WINNT +static int xdebug_create_socket_unix(const char *path) +{ + struct sockaddr_un sa; + int sockfd; + + if ((sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) == SOCK_ERR) { + xdebug_log_ex(XLOG_CHAN_DEBUG, XLOG_WARN, "UNIX", "Creating socket for 'unix://%s', socket: %s.", path, strerror(errno)); + return SOCK_ERR; + } + + sa.sun_family = AF_UNIX; + strncpy(sa.sun_path, path, sizeof(sa.sun_path) - 1); + if (connect(sockfd, (struct sockaddr*)&sa, sizeof(sa)) < 0) { + xdebug_log_ex(XLOG_CHAN_DEBUG, XLOG_WARN, "UNIX", "Creating socket for 'unix://%s', connect: %s.", path, strerror(errno)); + SCLOSE(sockfd); + return (errno == EACCES) ? SOCK_ACCESS_ERR : SOCK_ERR; + } + + /* Prevent the socket from being inherited by exec'd children */ + if (fcntl(sockfd, F_SETFD, FD_CLOEXEC) < 0) { + xdebug_log_ex(XLOG_CHAN_DEBUG, XLOG_WARN, "UNIX", "Creating socket for 'unix://%s', fcntl(FD_CLOEXEC): %s.", path, strerror(errno)); + } + + return sockfd; +} +#endif + +#if !WIN32 && !WINNT + +/* For OSX and FreeBSD */ +# if !defined(SOL_TCP) && defined(IPPROTO_TCP) +# define SOL_TCP IPPROTO_TCP +# endif +# if !defined(TCP_KEEPIDLE) && defined(TCP_KEEPALIVE) +# define TCP_KEEPIDLE TCP_KEEPALIVE +# endif + +void set_keepalive_options(int fd) +{ + int optval = 1; + int optlen = sizeof(optval); + int ret; + + ret = setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &optval, optlen); + if (ret) { + xdebug_log_ex(XLOG_CHAN_DEBUG, XLOG_WARN, "KEEPALIVE", "Could not set SO_KEEPALIVE: %s.", strerror(errno)); + return; + } + +# if defined(TCP_KEEPIDLE) + optval = 600; + ret = setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, &optval, optlen); + if (ret) { + xdebug_log_ex(XLOG_CHAN_DEBUG, XLOG_WARN, "KEEPALIVE", "Could not set TCP_KEEPIDLE to %d: %s.", optval, strerror(errno)); + return; + } +# endif + +# if defined(TCP_KEEPCNT) + optval = 20; + ret = setsockopt(fd, SOL_TCP, TCP_KEEPCNT, &optval, optlen); + if (ret) { + xdebug_log_ex(XLOG_CHAN_DEBUG, XLOG_WARN, "KEEPALIVE", "Could not set TCP_KEEPCNT to %d: %s.", optval, strerror(errno)); + return; + } +# endif + +# if defined(TCP_KEEPINTVL) + optval = 60; + ret = setsockopt(fd, SOL_TCP, TCP_KEEPINTVL, &optval, optlen); + if (ret) { + xdebug_log_ex(XLOG_CHAN_DEBUG, XLOG_WARN, "KEEPALIVE", "Could not set TCP_KEEPINTVL to %d: %s.", optval, strerror(errno)); + return; + } +# endif +} +#endif // !WIN32 && !WINNT + +static char* resolve_pseudo_hosts(const char *requested_hostname) +{ +#if __linux__ + /* Does it start with 'xdebug://' ? */ + if (strncmp(requested_hostname, "xdebug://", strlen("xdebug://")) != 0) { + return NULL; + } + + /* Check for 'gateway' pseudo host */ + if (strcmp(requested_hostname, "xdebug://gateway") == 0) { +#if XDEBUG_GATEWAY_SUPPORT + char *gateway = xdebug_get_gateway_ip(); + + if (!gateway) { + xdebug_log_ex(XLOG_CHAN_DEBUG, XLOG_WARN, "GATEWAY", "Could not find network gateway to use for 'gateway' pseudo-host."); + return NULL; + } + + xdebug_log(XLOG_CHAN_DEBUG, XLOG_INFO, "Found 'gateway' pseudo-host, with IP address '%s'.", gateway); + return gateway; +#else + xdebug_log_ex(XLOG_CHAN_DEBUG, XLOG_WARN, "PSEUDO-GW-NO-SUPPORT", "Pseudo-host: '%s' is not supported on this host.", requested_hostname + strlen("xdebug://")); + return NULL; +# endif + } + + /* Check for 'nameserver' pseudo host */ + if (strcmp(requested_hostname, "xdebug://nameserver") == 0) { +#if XDEBUG_NAMESERVER_SUPPORT + char *gateway = xdebug_get_private_nameserver(); + + if (!gateway) { + xdebug_log_ex(XLOG_CHAN_DEBUG, XLOG_WARN, "NAMESERVER", "Could not find a private network nameserver for 'nameserver' pseudo-host."); + return NULL; + } + + xdebug_log(XLOG_CHAN_DEBUG, XLOG_INFO, "Found 'nameserver' pseudo-host, with IP address '%s'.", gateway); + return gateway; +# else + xdebug_log_ex(XLOG_CHAN_DEBUG, XLOG_WARN, "PSEUDO-NS-NO-SUPPORT", "Pseudo-host: '%s' is not supported on this host.", requested_hostname + strlen("xdebug://")); + return NULL; +# endif + } + + xdebug_log_ex(XLOG_CHAN_DEBUG, XLOG_WARN, "PSEUDO-UNKNOWN", "Unknown pseudo-host: '%s', only 'gateway' or 'nameserver' are supported.", requested_hostname + strlen("xdebug://")); +#endif + + return NULL; +} + +static int xdebug_create_socket(const char *hostname, int dport, int timeout) +{ + struct addrinfo hints; + struct addrinfo *remote; + struct addrinfo *ptr; + int status; + int sockfd = 0; + int sockerror; + char sport10; + int actually_connected;
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/debugger/com.h
Added
@@ -0,0 +1,71 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#ifndef __HAVE_XDEBUG_COM_H__ +#define __HAVE_XDEBUG_COM_H__ + +#include "handlers.h" + +#define XDEBUG_CLIENT_PORT_S "9003" +#define XDEBUG_CLOUD_PORT 9020L + +#if WIN32|WINNT +# define SOCK_ERR INVALID_SOCKET +# define SOCK_CONN_ERR SOCKET_ERROR +# define SOCK_RECV_ERR SOCKET_ERROR +#else +# define SOCK_ERR -1 +# define SOCK_CONN_ERR -1 +# define SOCK_RECV_ERR -1 +#endif +#define SOCK_TIMEOUT_ERR -2 +#define SOCK_ACCESS_ERR -3 + +#if WIN32|WINNT +#define SCLOSE(a) closesocket(a) +#define SSENDL(a,b,c) send(a,b,c,0) +#define SSEND(a,b) send(a,b,strlen(b),0) +#define SREAD(a,b,c) recv(a,b,c,0) +#else +#define SCLOSE(a) close(a) +#define SSENDL(a,b,c) write(a,b,c) +#define SSEND(a,b) write(a,b,strlen(b)) +#define SREAD(a,b,c) read(a,b,c) +#endif + + +#define SENDMSG(socket, str) { \ + char *message_buffer; \ + \ + message_buffer = str; \ + SSEND(socket, message_buffer); \ + xdfree(message_buffer); \ +} + +void xdebug_close_socket(int socket); + +/* Remote connection activation and house keeping */ +#define xdebug_is_debug_connection_active() !!XG_DBG(remote_connection_enabled) +void xdebug_abort_debugger(void); +void xdebug_restart_debugger(void); +void xdebug_mark_debug_connection_active(void); +void xdebug_mark_debug_connection_not_active(void); +void xdebug_mark_debug_connection_pending(void); +void xdebug_debug_init_if_requested_at_startup(void); +void xdebug_debug_init_if_requested_on_error(void); +void xdebug_debug_init_if_requested_on_xdebug_break(void); + +#endif
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/debugger/debugger.c
Added
@@ -0,0 +1,1041 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#include "php_xdebug.h" + +#include "ext/standard/info.h" +#include "zend_exceptions.h" + +#include "debugger_private.h" +#include "lib/log.h" +#include "lib/var.h" + +extern ZEND_DECLARE_MODULE_GLOBALS(xdebug); + +static size_t (*xdebug_orig_ub_write)(const char *string, size_t len); +static size_t xdebug_ub_write(const char *string, size_t length); + +static void xdebug_line_list_dtor(xdebug_lines_list *line_list); + +void xdebug_init_debugger_globals(xdebug_debugger_globals_t *xg) +{ + xg->breakpoint_count = 0; + xg->ide_key = NULL; + xg->stdout_mode = 0; + xg->no_exec = 0; + xg->context.program_name = NULL; + xg->context.list.last_filename = NULL; + xg->context.list.last_line = 0; + xg->context.do_break = 0; + xg->context.pending_breakpoint = NULL; + xg->context.do_step = 0; + xg->context.do_next = 0; + xg->context.do_finish = 0; + xg->context.do_connect_to_client = 0; + + xg->remote_connection_enabled = 0; + xg->remote_connection_pid = 0; + xg->breakpoints_allowed = 0; + xg->suppress_return_value_step = 0; + + /* Capturing output */ + if (sapi_module.ub_write != xdebug_ub_write) { + xdebug_orig_ub_write = sapi_module.ub_write; + sapi_module.ub_write = xdebug_ub_write; + } + + /* Statistics and diagnostics */ + xg->context.connected_hostname = NULL; + xg->context.connected_port = 0; + xg->context.detached_message = NULL; +} + +static char *xdebug_debugger_get_ide_key(void) +{ + char *ide_key; + + ide_key = XINI_DBG(ide_key_setting); + if (ide_key && *ide_key) { + return ide_key; + } + + ide_key = getenv("DBGP_IDEKEY"); + if (ide_key && *ide_key) { + return ide_key; + } + + return NULL; +} + +void xdebug_debugger_reset_ide_key(char *envval) +{ + if (XG_DBG(ide_key)) { + xdfree(XG_DBG(ide_key)); + } + XG_DBG(ide_key) = xdstrdup(envval); +} + +int xdebug_debugger_bailout_if_no_exec_requested(void) +{ + /* We need to do this first before the executable clauses are called */ + if (XG_DBG(no_exec) == 1) { + php_printf("DEBUG SESSION ENDED"); + return 1; + } + return 0; +} + +void xdebug_debugger_set_program_name(zend_string *filename) +{ + if (!XG_DBG(context).program_name) { + XG_DBG(context).program_name = zend_string_copy(filename); + } +} + +/* Remote debugger helper functions */ +static int xdebug_handle_hit_value(xdebug_brk_info *brk_info) +{ + /* If this is a temporary breakpoint, disable the breakpoint */ + if (brk_info->temporary) { + brk_info->disabled = 1; + } + + /* Increase hit counter */ + brk_info->hit_count++; + + /* If the hit_value is 0, the condition check is disabled */ + if (!brk_info->hit_value) { + return 1; + } + + switch (brk_info->hit_condition) { + case XDEBUG_HIT_GREATER_EQUAL: + if (brk_info->hit_count >= brk_info->hit_value) { + return 1; + } + break; + case XDEBUG_HIT_EQUAL: + if (brk_info->hit_count == brk_info->hit_value) { + return 1; + } + break; + case XDEBUG_HIT_MOD: + if (brk_info->hit_count % brk_info->hit_value == 0) { + return 1; + } + break; + case XDEBUG_HIT_DISABLED: + return 1; + break; + } + return 0; +} + +int xdebug_do_eval(char *eval_string, zval *ret_zval, zend_string **return_message) +{ + volatile int res = 1; + zend_execute_data *original_execute_data = EG(current_execute_data); + int original_no_extensions = EG(no_extensions); + zend_object *original_exception = EG(exception); + JMP_BUF *original_bailout = EG(bailout); + + /* Remember error reporting level and track errors */ + XG_BASE(error_reporting_override) = EG(error_reporting); + XG_BASE(error_reporting_overridden) = 1; + EG(error_reporting) = 0; + + XG_DBG(context).inhibit_notifications = 1; + XG_DBG(breakpoints_allowed) = 0; + + /* Reset exception in case we're triggered while being in xdebug_throw_exception_hook */ + EG(exception) = NULL; + + /* Do evaluation */ + zend_first_try { + res = (zend_eval_string(eval_string, ret_zval, (char*) "xdebug://debug-eval") == SUCCESS); + } zend_end_try(); + + if (EG(exception)) { + if (return_message != NULL) { + zend_class_entry *base_ce; + zval *prop, rv; + + *return_message = NULL; + + base_ce = zend_get_exception_base(EG(exception)); + if (base_ce) { + prop = zend_read_property_ex(base_ce, EG(exception), ZSTR_KNOWN(ZEND_STR_MESSAGE), 1, &rv); + if (prop) { + *return_message = zval_get_string(prop); + } + } + } + + if (!res) { + zend_clear_exception(); + } + res = 0; + } + + /* Clean up */ + EG(error_reporting) = XG_BASE(error_reporting_override); + XG_BASE(error_reporting_overridden) = 0; + XG_DBG(breakpoints_allowed) = 1; + XG_DBG(suppress_return_value_step) = 0; + XG_DBG(context).inhibit_notifications = 0; +
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/debugger/debugger.h
Added
@@ -0,0 +1,97 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#ifndef __XDEBUG_DEBUGGER_H__ +#define __XDEBUG_DEBUGGER_H__ + +#include "com.h" + +typedef struct _xdebug_debugger_globals_t { + int status; + int reason; + const char *lastcmd; + char *lasttransid; + zval *current_return_value; + + zend_bool remote_connection_enabled; + zend_ulong remote_connection_pid; + zend_bool breakpoints_allowed; + zend_bool suppress_return_value_step; + zend_bool detached; + xdebug_con context; + unsigned int breakpoint_count; + unsigned int no_exec; + char *ide_key; /* As Xdebug uses it, from environment, USER, USERNAME or empty */ + + /* breakpoint resolving */ + size_t function_count; + size_t class_count; + xdebug_hash *breakable_lines_map; + + /* output redirection */ + int stdout_mode; +} xdebug_debugger_globals_t; + +typedef struct _xdebug_debugger_settings_t { + /* Cloud */ + char *cloud_id; + char *cloud_shared_key; + + /* Step Debugger */ + zend_long client_port; /* 9003 */ + char *client_host; /* localhost */ + zend_bool discover_client_host; /* (try to) connect back to the HTTP requestor */ + char *client_discovery_header; /* User configured header to check for forwarded IP address */ + zend_long connect_timeout_ms; /* Timeout in MS for remote connections */ + + char *ide_key_setting; /* Set through php.ini and friends */ +} xdebug_debugger_settings_t; + +PHP_INI_MH(OnUpdateDebugMode); + +void xdebug_init_debugger_globals(xdebug_debugger_globals_t *xg); + +#define XDEBUG_RETURN_VALUE_VAR_NAME "__RETURN_VALUE" + +void xdebug_debugger_reset_ide_key(char *envval); +int xdebug_debugger_bailout_if_no_exec_requested(void); +void xdebug_debugger_set_program_name(zend_string *filename); +void xdebug_debugger_register_eval(function_stack_entry *fse); +void xdebug_debugger_restart_if_pid_changed(void); + +xdebug_set *xdebug_debugger_get_breakable_lines_from_oparray(zend_op_array *opa); +int xdebug_do_eval(char *eval_string, zval *ret_zval, zend_string **return_message); +bool xdebug_debugger_check_evaled_code(zend_string *filename_in, zend_string **filename_out); +void xdebug_debugger_set_has_line_breakpoints(function_stack_entry *fse); + +void xdebug_debugger_statement_call(zend_string *filename, int lineno); +void xdebug_debugger_throw_exception_hook(zend_object *exception, zval *file, zval *line, zval *code, char *code_str, zval *message); +void xdebug_debugger_error_cb(zend_string *error_filename, int error_lineno, int type, char *error_type_str, char *buffer); +void xdebug_debugger_handle_breakpoints(function_stack_entry *fse, int breakpoint_type, zval *return_value); + +void xdebug_debugger_zend_startup(void); +void xdebug_debugger_zend_shutdown(void); +void xdebug_debugger_minit(void); +void xdebug_debugger_minfo(void); +void xdebug_debugger_rinit(void); +void xdebug_debugger_post_deactivate(void); + +void xdebug_debugger_compile_file(zend_op_array *op_array); + +PHP_FUNCTION(xdebug_break); + + +#endif
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/debugger/debugger_private.h
Changed
(renamed from xdebug-3.2.0/src/debugger/debugger_private.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/debugger/handler_dbgp.c
Added
@@ -0,0 +1,3039 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#include <errno.h> +#include <sys/types.h> + +#ifndef PHP_WIN32 +#include <unistd.h> +#endif + +#include "lib/php-header.h" +#include "SAPI.h" + +#include "ext/standard/php_string.h" +#include "ext/standard/url.h" +#include "main/php_version.h" +#include "main/php_network.h" +#include "ext/standard/base64.h" +#include "TSRM.h" + +#include "php_globals.h" +#include "php_xdebug.h" + +#include "com.h" +#include "handler_dbgp.h" +#include "debugger_private.h" + +#include "coverage/code_coverage.h" +#include "develop/stack.h" +#include "lib/compat.h" +#include "lib/hash.h" +#include "lib/llist.h" +#include "lib/log.h" +#include "lib/mm.h" +#include "lib/var_export_xml.h" +#include "lib/vector.h" +#include "lib/xml.h" + +#ifdef PHP_WIN32 +#include "win32/time.h" +#include <process.h> +#endif +#include <fcntl.h> + +ZEND_EXTERN_MODULE_GLOBALS(xdebug) + +xdebug_remote_handler xdebug_handler_dbgp = { + xdebug_dbgp_init, + xdebug_dbgp_deinit, + xdebug_dbgp_error, + xdebug_dbgp_break_on_line, + xdebug_dbgp_breakpoint, + xdebug_dbgp_resolve_breakpoints, + xdebug_dbgp_stream_output, + xdebug_dbgp_notification, + xdebug_dbgp_user_notify, + xdebug_dbgp_register_eval_id, +}; + +static char *create_eval_key_id(int id); +static void line_breakpoint_resolve_helper(xdebug_con *context, xdebug_lines_list *lines_list, xdebug_brk_info *brk_info); + +/***************************************************************************** +** Constants and strings for statii and reasons +*/ + +/* Status structure */ +#define DBGP_STATUS_STARTING 1 +#define DBGP_STATUS_STOPPING 2 +#define DBGP_STATUS_STOPPED 3 +#define DBGP_STATUS_RUNNING 4 +#define DBGP_STATUS_BREAK 5 +#define DBGP_STATUS_DETACHED 6 + +const char *xdebug_dbgp_status_strings7 = + {"", "starting", "stopping", "stopped", "running", "break", "detached"}; + +#define DBGP_REASON_OK 0 +#define DBGP_REASON_ERROR 1 +#define DBGP_REASON_ABORTED 2 +#define DBGP_REASON_EXCEPTION 3 + +const char *xdebug_dbgp_reason_strings4 = + {"ok", "error", "aborted", "exception"}; + +#define XDEBUG_ERROR_OK 0 +#define XDEBUG_ERROR_PARSE 1 +#define XDEBUG_ERROR_DUP_ARG 2 +#define XDEBUG_ERROR_INVALID_ARGS 3 +#define XDEBUG_ERROR_UNIMPLEMENTED 4 +#define XDEBUG_ERROR_COMMAND_UNAVAILABLE 5 + +#define XDEBUG_ERROR_CANT_OPEN_FILE 100 +#define XDEBUG_ERROR_STREAM_REDIRECT_FAILED 101 /* unused */ + +#define XDEBUG_ERROR_BREAKPOINT_NOT_SET 200 +#define XDEBUG_ERROR_BREAKPOINT_TYPE_NOT_SUPPORTED 201 +#define XDEBUG_ERROR_BREAKPOINT_INVALID 202 +#define XDEBUG_ERROR_BREAKPOINT_NO_CODE 203 +#define XDEBUG_ERROR_BREAKPOINT_INVALID_STATE 204 +#define XDEBUG_ERROR_NO_SUCH_BREAKPOINT 205 +#define XDEBUG_ERROR_EVALUATING_CODE 206 +#define XDEBUG_ERROR_INVALID_EXPRESSION 207 /* unused */ + +#define XDEBUG_ERROR_PROPERTY_NON_EXISTENT 300 +#define XDEBUG_ERROR_PROPERTY_NON_EXISTANT 300 /* compatibility typo */ +#define XDEBUG_ERROR_STACK_DEPTH_INVALID 301 +#define XDEBUG_ERROR_CONTEXT_INVALID 302 /* unused */ + +#define XDEBUG_ERROR_PROFILING_NOT_STARTED 800 + +#define XDEBUG_ERROR_ENCODING_NOT_SUPPORTED 900 + +typedef struct { + int code; + const char *message; +} xdebug_error_entry; + +static xdebug_error_entry xdebug_error_codes24 = { + { 0, "no error" }, + { 1, "parse error in command" }, + { 2, "duplicate arguments in command" }, + { 3, "invalid or missing options" }, + { 4, "unimplemented command" }, + { 5, "command is not available" }, + { 100, "can not open file" }, + { 101, "stream redirect failed" }, + { 200, "breakpoint could not be set" }, + { 201, "breakpoint type is not supported" }, + { 202, "invalid breakpoint line" }, + { 203, "no code on breakpoint line" }, + { 204, "invalid breakpoint state" }, + { 205, "no such breakpoint" }, + { 206, "error evaluating code" }, + { 207, "invalid expression" }, + { 300, "can not get property" }, + { 301, "stack depth invalid" }, + { 302, "context invalid" }, + { 800, "profiler not started" }, + { 900, "encoding not supported" }, + { 998, "an internal exception in the debugger" }, + { 999, "unknown error" }, + { -1, NULL } +}; + +static const char *error_message_from_code(int code) +{ + xdebug_error_entry *error_entry = &xdebug_error_codes0; + + while (error_entry->message) { + if (code == error_entry->code) { + return error_entry->message; + } + error_entry++; + } + return NULL; +} + +#define XDEBUG_STR_SWITCH_DECL char *__switch_variable +#define XDEBUG_STR_SWITCH(s) __switch_variable = (s); +#define XDEBUG_STR_CASE(s) if (strcmp(__switch_variable, s) == 0) { +#define XDEBUG_STR_CASE_END } else +#define XDEBUG_STR_CASE_DEFAULT { +#define XDEBUG_STR_CASE_DEFAULT_END } + +#define XDEBUG_TYPES_COUNT 8 +const char *xdebug_dbgp_typemapXDEBUG_TYPES_COUNT3 = { + /* common, lang, schema */ + {"bool", "bool", "xsd:boolean"}, + {"int", "int", "xsd:decimal"}, + {"float", "float", "xsd:double"}, + {"string", "string", "xsd:string"}, + {"null", "null", NULL}, + {"hash", "array", NULL}, + {"object", "object", NULL}, + {"resource", "resource", NULL} +}; + + +typedef struct { + int value; + const char *name; +} xdebug_breakpoint_entry; + +#define XDEBUG_BREAKPOINT_TYPES_COUNT 6 +xdebug_breakpoint_entry xdebug_breakpoint_typesXDEBUG_BREAKPOINT_TYPES_COUNT = {
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/debugger/handler_dbgp.h
Added
@@ -0,0 +1,103 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2022 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#ifndef __HAVE_XDEBUG_HANDLER_DBGP_H__ +#define __HAVE_XDEBUG_HANDLER_DBGP_H__ + +#include <string.h> +#include "handlers.h" +#include "lib/cmd_parser.h" +#include "lib/xml.h" + +#define DBGP_VERSION "1.0" + +typedef struct xdebug_dbgp_result { + int status; + int reason; + int code; +} xdebug_dbgp_result; + +#define ADD_REASON_MESSAGE(c) { \ + xdebug_xml_node *message = xdebug_xml_node_init("message"); \ + xdebug_xml_add_text(message, xdstrdup(error_message_from_code(c))); \ + xdebug_xml_add_child(error, message); \ +} + +#define RETURN_RESULT(s, r, c) { \ + xdebug_xml_node *error = xdebug_xml_node_init("error"); \ + xdebug_xml_node *message = xdebug_xml_node_init("message"); \ + \ + xdebug_xml_add_attribute(*retval, "status", xdebug_dbgp_status_strings(s)); \ + xdebug_xml_add_attribute(*retval, "reason", xdebug_dbgp_reason_strings(r)); \ + xdebug_xml_add_attribute_ex(error, "code", xdebug_sprintf("%u", (c)), 0, 1); \ + xdebug_xml_add_text(message, xdstrdup(error_message_from_code(c))); \ + xdebug_xml_add_child(error, message); \ + \ + xdebug_xml_add_child(*retval, error); \ + return; \ +} + +#define RETURN_RESULT_WITH_MESSAGE(s, r, c, m) { \ + xdebug_xml_node *error = xdebug_xml_node_init("error"); \ + xdebug_xml_node *message = xdebug_xml_node_init("message"); \ + \ + xdebug_xml_add_attribute(*retval, "status", xdebug_dbgp_status_strings(s)); \ + xdebug_xml_add_attribute(*retval, "reason", xdebug_dbgp_reason_strings(r)); \ + xdebug_xml_add_attribute_ex(error, "code", xdebug_sprintf("%u", (c)), 0, 1); \ + xdebug_xml_add_text(message, (m)); \ + xdebug_xml_add_child(error, message); \ + xdebug_xml_add_child(*retval, error); \ + return; \ +} + +#define DBGP_FUNC_PARAMETERS xdebug_xml_node **retval, xdebug_con *context, xdebug_dbgp_arg *args +#define DBGP_FUNC_PASS_PARAMETERS retval, context, args +#define DBGP_FUNC(name) static void xdebug_dbgp_handle_##name(DBGP_FUNC_PARAMETERS) +#define DBGP_FUNC_ENTRY(name,flags) { #name, xdebug_dbgp_handle_##name, 0, flags }, +#define DBGP_CONT_FUNC_ENTRY(name,flags) { #name, xdebug_dbgp_handle_##name, 1, flags }, +#define DBGP_STOP_FUNC_ENTRY(name,flags) { #name, xdebug_dbgp_handle_##name, 2, flags }, + +#define XDEBUG_DBGP_NONE 1 << 0 +#define XDEBUG_DBGP_POST_MORTEM 1 << 1 /* command is valid in 'stopping' (post mortem) state */ + +typedef struct xdebug_dbgp_cmd { + const char *name; + void (*handler)(DBGP_FUNC_PARAMETERS); + int cont; + int flags; +} xdebug_dbgp_cmd; + +typedef struct xdebug_dbgp_resolve_context { + xdebug_con *context; + zend_string *filename; + xdebug_lines_list *lines_list; +} xdebug_dbgp_resolve_context; + +int xdebug_dbgp_init(xdebug_con *context, int mode); +int xdebug_dbgp_deinit(xdebug_con *context); +int xdebug_dbgp_error(xdebug_con *context, int type, char *exception_type, char *message, const char *location, const unsigned int line, xdebug_vector *stack); +int xdebug_dbgp_break_on_line(xdebug_con *context, xdebug_brk_info *brk, zend_string *filename, int lineno); +int xdebug_dbgp_breakpoint(xdebug_con *context, xdebug_vector *stack, zend_string *filename, long lineno, int type, char *exception, char *code, const char *message, xdebug_brk_info *brk_info, zval *return_value); +int xdebug_dbgp_resolve_breakpoints(xdebug_con *context, zend_string *filename); +int xdebug_dbgp_stream_output(const char *string, unsigned int length); +int xdebug_dbgp_notification(xdebug_con *context, zend_string *filename, long lineno, int type, char *type_string, char *message); +int xdebug_dbgp_user_notify(xdebug_con *context, zend_string *filename, long lineno, zval *data); +void XDEBUG_ATTRIBUTE_FORMAT(printf, 2, 3) xdebug_dbgp_log(int log_level, const char *fmt, ...); +int xdebug_dbgp_register_eval_id(xdebug_con *context, function_stack_entry *fse); + +extern xdebug_remote_handler xdebug_handler_dbgp; + +#endif
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/debugger/handlers.c
Changed
(renamed from xdebug-3.2.0/src/debugger/handlers.c)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/debugger/handlers.h
Added
@@ -0,0 +1,169 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2022 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#ifndef __HAVE_XDEBUG_HANDLERS_H__ +#define __HAVE_XDEBUG_HANDLERS_H__ + +#include "php_xdebug.h" +#include "lib/compat.h" +#include "lib/llist.h" +#include "lib/hash.h" +#include "lib/lib.h" +#include "lib/usefulstuff.h" +#include "lib/vector.h" +#include "debugger_private.h" + +typedef struct _xdebug_brk_admin xdebug_brk_admin; +typedef struct _xdebug_brk_info xdebug_brk_info; +typedef struct _xdebug_brk_span xdebug_brk_span; +typedef struct _xdebug_eval_info xdebug_eval_info; +typedef struct _xdebug_con xdebug_con; +typedef struct _xdebug_debug_list xdebug_debug_list; +typedef struct _xdebug_remote_handler xdebug_remote_handler; +typedef struct _xdebug_remote_handler_info xdebug_remote_handler_info; + +struct _xdebug_debug_list { + zend_string *last_filename; + int last_line; +}; + +#define XDEBUG_BREAKPOINT_TYPE_LINE 0x01 +#define XDEBUG_BREAKPOINT_TYPE_CONDITIONAL 0x02 +#define XDEBUG_BREAKPOINT_TYPE_CALL 0x04 +#define XDEBUG_BREAKPOINT_TYPE_RETURN 0x08 +#define XDEBUG_BREAKPOINT_TYPE_EXCEPTION 0x10 +#define XDEBUG_BREAKPOINT_TYPE_WATCH 0x20 +#define XDEBUG_BREAKPOINT_TYPES_MASK 0x3F + +#define XDEBUG_BREAKPOINT_TYPE_EXTERNAL 0x40 // user-defined PHP function + +#define XDEBUG_BREAKPOINT_TYPE_NAME(v) (xdebug_breakpoint_types(int)(log2(v))).name + +struct _xdebug_brk_admin { + int id; + int type; + char *key; +}; + +#define XDEBUG_NORMAL 0x01 +#define XDEBUG_CLOUD 0x02 +#define XDEBUG_CLOUD_FROM_TRIGGER_VALUE 0x03 + +struct _xdebug_con { + int socket; + int host_type; /* XDEBUG_NORMAL, XDEBUG_CLOUD, XDEBUG_CLOUD_FROM_TRIGGER_VALUE */ + void *options; + xdebug_remote_handler *handler; + fd_buf *buffer; + zend_string *program_name; + xdebug_hash *breakpoint_list; + xdebug_hash *function_breakpoints; + xdebug_hash *eval_id_lookup; + int eval_id_sequence; + xdebug_llist *line_breakpoints; + xdebug_hash *exception_breakpoints; + xdebug_debug_list list; + int do_break; + xdebug_brk_info *pending_breakpoint; + xdebug_vector *next_stack; + + int do_step; + int do_next; + int next_level; + int do_finish; + int do_connect_to_client; + int finish_level; + int finish_func_nr; + + int send_notifications; + int inhibit_notifications; + + int resolved_breakpoints; + int breakpoint_details; + int breakpoint_include_return_value; + + /* Statistics and diagnostics */ + char *connected_hostname; + int connected_port; + char *detached_message; +}; + +#define XDEBUG_BRK_UNRESOLVED 0 +#define XDEBUG_BRK_RESOLVED 1 + +#define XDEBUG_HIT_DISABLED 0 +#define XDEBUG_HIT_GREATER_EQUAL 1 +#define XDEBUG_HIT_EQUAL 2 +#define XDEBUG_HIT_MOD 3 + +#define XDEBUG_RESOLVED_SPAN_MAX 2147483647 + +struct _xdebug_brk_info { + int id; + int brk_type; + int resolved; + char *classname; + char *functionname; + char *exceptionname; + int function_break_type; /* XDEBUG_BRK_FUNC_* */ + zend_string *filename; + int original_lineno; /* line number that was set through breakpoint_set */ + int resolved_lineno; /* line number after resolving, initialised with 'original_lineno' */ + char *condition; + int disabled; + int temporary; + int hit_count; + int hit_value; + int hit_condition; +}; + +struct _xdebug_eval_info { + int id; + int refcount; + zend_string *contents; +}; + +struct _xdebug_remote_handler { + /* Init / deinit */ + int (*remote_init)(xdebug_con *h, int mode); + int (*remote_deinit)(xdebug_con *h); + + /* Stack messages */ + int (*remote_error)(xdebug_con *h, int type, char *exception_type, char *message, const char *location, const unsigned int line, xdebug_vector *stack); + + /* Breakpoints */ + int (*break_on_line)(xdebug_con *h, xdebug_brk_info *brk, zend_string *filename, int lineno); + int (*remote_breakpoint)(xdebug_con *h, xdebug_vector *stack, zend_string *filename, long lineno, int type, char *exception, char *code, const char *message, xdebug_brk_info *brk_info, zval *return_value); + int (*resolve_breakpoints)(xdebug_con *h, zend_string *opa); + + /* Output redirection */ + int (*remote_stream_output)(const char *string, unsigned int length); + + /* Notifications & Logging */ + int (*remote_notification)(xdebug_con *h, zend_string *file, long lineno, int type, char *type_string, char *message); + int (*user_notification)(xdebug_con *h, zend_string *filename, long lineno, zval *data); + + /* Eval ID registration and removal */ + int (*register_eval_id)(xdebug_con *h, function_stack_entry *fse); +}; + +xdebug_brk_info *xdebug_brk_info_ctor(void); +void xdebug_brk_info_dtor(xdebug_brk_info *brk); +void xdebug_llist_brk_dtor(void *dummy, xdebug_brk_info *brk); +void xdebug_hash_brk_dtor(xdebug_brk_info *brk); +void xdebug_hash_eval_info_dtor(xdebug_eval_info *ei); + +#endif
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/debugger/ip_info.c
Added
@@ -0,0 +1,290 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ +#ifdef __linux__ + +#include "php_xdebug.h" + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <errno.h> +#include <linux/rtnetlink.h> +#include <arpa/inet.h> +#include <net/if.h> +#include <netinet/in.h> +#include <arpa/nameser.h> +#include <resolv.h> + +#include "ip_info.h" + +#if XDEBUG_GATEWAY_SUPPORT + +#define BUFFER_SIZE 4096 + +static char *convert_to_quad(int domain, void *buf) +{ + char *ip = xdcalloc(1, INET6_ADDRSTRLEN + 1); + + inet_ntop(domain, buf, ip, INET6_ADDRSTRLEN); + + return ip; +} + +static int get_ip(int fd, struct sockaddr_nl *sa, int domain) +{ + char bufBUFFER_SIZE; + struct nlmsghdr *nl; + struct ifaddrmsg *ifa; + struct iovec iov = { 0 }; + struct msghdr msg = { 0 }; + int r; + + memset(buf, 0, BUFFER_SIZE); + + /* Assemble the message according to the netlink protocol */ + nl = (struct nlmsghdr*)buf; + nl->nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg)); + nl->nlmsg_type = RTM_GETADDR; + nl->nlmsg_flags = NLM_F_REQUEST | NLM_F_ROOT; + + ifa = (struct ifaddrmsg*)NLMSG_DATA(nl); + ifa->ifa_family = domain; // We only get IPv4 address here + + /* Prepare struct msghdr for sending */ + iov.iov_base = nl; + iov.iov_len = nl->nlmsg_len; + msg.msg_name = sa; + msg.msg_namelen = sizeof(*sa); + msg.msg_iov = &iov; + msg.msg_iovlen = 1; + msg.msg_control = NULL; + msg.msg_controllen = 0; + msg.msg_flags = 0; + + /* Send netlink message to kernel */ + r = sendmsg(fd, &msg, 0); + return (r < 0) ? -1 : 0; +} + +static int get_msg(int fd, struct sockaddr_nl *sa, void *buf, size_t len) +{ + struct iovec iov; + struct msghdr msg; + + iov.iov_base = buf; + iov.iov_len = len; + + memset(&msg, 0, sizeof(msg)); + msg.msg_name = sa; + msg.msg_namelen = sizeof(*sa); + msg.msg_iov = &iov; + msg.msg_iovlen = 1; + + return recvmsg(fd, &msg, 0); +} + +static char *parse_ifa_msg(struct ifaddrmsg *ifa, void *buf, size_t len, const char *wanted_iface) +{ + char ifnameIF_NAMESIZE; + struct rtattr *rta = NULL; + int fa = ifa->ifa_family; + + if_indextoname(ifa->ifa_index, ifname); + + if (strcmp(ifname, wanted_iface) != 0) { + return NULL; + } + + for (rta = (struct rtattr*)buf; RTA_OK(rta, len); rta = RTA_NEXT(rta, len)) { + if (rta->rta_type == IFA_ADDRESS) { + return convert_to_quad(fa, RTA_DATA(rta)); + } + } + + return NULL; +} + +static uint32_t parse_nl_msg(void *buf, size_t len, const char *iface, char **if_address) +{ + struct nlmsghdr *nl = NULL; + uint32_t nlmsg_type = NLMSG_ERROR; + + for ( + nl = (struct nlmsghdr*)buf; + NLMSG_OK(nl, (uint32_t)len) && nl->nlmsg_type != NLMSG_DONE; + nl = NLMSG_NEXT(nl, len) + ) { + nlmsg_type = nl->nlmsg_type; + + if (nl->nlmsg_type == NLMSG_ERROR) { + return -1; + } + + if (nl->nlmsg_type == RTM_NEWADDR) { + struct ifaddrmsg *ifa; + ifa = (struct ifaddrmsg*)NLMSG_DATA(nl); + + if (*if_address == NULL) { + *if_address = parse_ifa_msg(ifa, IFA_RTA(ifa), IFA_PAYLOAD(nl), iface); + if (*if_address) { + return NLMSG_DONE; + } + } + continue; + } + } + return nlmsg_type; +} + +char *xdebug_get_ip_for_interface(const char *iface) +{ + char bufBUFFER_SIZE; + int fd = 0, len = 0; + char *if_address = NULL; + uint32_t nl_msg_type = NLMSG_DONE; + struct sockaddr_nl sa; + + /* Create a socket with the AF_NETLINK domain */ + fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); + if (fd < 0) { + return NULL; + } + + memset(&sa, 0, sizeof(sa)); + sa.nl_family = AF_NETLINK; + + len = get_ip(fd, &sa, AF_INET); // For IPv6: use AF_INET6 instead + if (len < 0) { + return NULL; + } + + do { + len = get_msg(fd, &sa, buf, BUFFER_SIZE); + if (len < 0) { + return NULL; + } + + nl_msg_type = parse_nl_msg(buf, len, iface, &if_address); + } while (nl_msg_type != NLMSG_DONE && nl_msg_type != NLMSG_ERROR); + + return if_address; +} + +/***/ + +static int get_gateway_and_iface(in_addr_t *addr, char *interface) +{ + long destination, gateway; + char ifaceIF_NAMESIZE; + char bufBUFFER_SIZE; + FILE *file; + + memset(iface, 0, sizeof(iface)); + memset(buf, 0, sizeof(buf)); + + file = fopen("/proc/net/route", "r"); + if (!file) {
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/debugger/ip_info.h
Changed
(renamed from xdebug-3.2.0/src/debugger/ip_info.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/develop/develop.c
Added
@@ -0,0 +1,153 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ +#include "lib/php-header.h" +#include "zend_exceptions.h" + +#include "php_xdebug.h" +#include "monitor.h" +#include "stack.h" +#include "superglobals.h" + +ZEND_EXTERN_MODULE_GLOBALS(xdebug) + +/* True global for overloaded var_dump */ +zif_handler orig_var_dump_func; + +static int xdebug_silence_handler(XDEBUG_OPCODE_HANDLER_ARGS); + +static void xdebug_develop_overloaded_functions_setup(void) +{ + zend_function *orig; + + /* Override var_dump with our own function */ + orig = zend_hash_str_find_ptr(CG(function_table), "var_dump", sizeof("var_dump") - 1); + orig_var_dump_func = orig->internal_function.handler; + orig->internal_function.handler = zif_xdebug_var_dump; +} + + +void xdebug_init_develop_globals(xdebug_develop_globals_t *xg) +{ + xg->do_monitor_functions = 0; + + xg->in_at = 0; /* scream */ + + xdebug_llist_init(&xg->server, xdebug_superglobals_dump_dtor); + xdebug_llist_init(&xg->get, xdebug_superglobals_dump_dtor); + xdebug_llist_init(&xg->post, xdebug_superglobals_dump_dtor); + xdebug_llist_init(&xg->cookie, xdebug_superglobals_dump_dtor); + xdebug_llist_init(&xg->files, xdebug_superglobals_dump_dtor); + xdebug_llist_init(&xg->env, xdebug_superglobals_dump_dtor); + xdebug_llist_init(&xg->request, xdebug_superglobals_dump_dtor); + xdebug_llist_init(&xg->session, xdebug_superglobals_dump_dtor); +} + +void xdebug_deinit_develop_globals(xdebug_develop_globals_t *xg) +{ + xdebug_llist_empty(&xg->server, NULL); + xdebug_llist_empty(&xg->get, NULL); + xdebug_llist_empty(&xg->post, NULL); + xdebug_llist_empty(&xg->cookie, NULL); + xdebug_llist_empty(&xg->files, NULL); + xdebug_llist_empty(&xg->env, NULL); + xdebug_llist_empty(&xg->request, NULL); + xdebug_llist_empty(&xg->session, NULL); +} + +void xdebug_develop_minit(INIT_FUNC_ARGS) +{ + /* Overload opcodes for 'scream' */ + xdebug_set_opcode_handler(ZEND_BEGIN_SILENCE, xdebug_silence_handler); + xdebug_set_opcode_handler(ZEND_END_SILENCE, xdebug_silence_handler); + + REGISTER_LONG_CONSTANT("XDEBUG_STACK_NO_DESC", XDEBUG_STACK_NO_DESC, CONST_CS | CONST_PERSISTENT); + + xdebug_develop_overloaded_functions_setup(); +} + +void xdebug_develop_mshutdown() +{ +} + +void xdebug_develop_rinit() +{ + int i; + + XG_DEV(collected_errors) = xdebug_llist_alloc(xdebug_llist_string_dtor); + + /* Function monitoring */ + XG_DEV(do_monitor_functions) = 0; + XG_DEV(functions_to_monitor) = NULL; + XG_DEV(monitored_functions_found) = xdebug_llist_alloc(xdebug_monitored_function_dtor); + + /* Admin for last exception trace */ + XG_DEV(last_exception_trace).next_slot = 0; + for (i = 0; i < XDEBUG_LAST_EXCEPTION_TRACE_SLOTS; i++) { + XG_DEV(last_exception_trace).obj_ptri = NULL; + ZVAL_UNDEF(&XG_DEV(last_exception_trace).stack_tracei); + } +} + +void xdebug_develop_rshutdown() +{ + int i; + + /* Admin for last exception trace */ + XG_DEV(last_exception_trace).next_slot = 0; + for (i = 0; i < XDEBUG_LAST_EXCEPTION_TRACE_SLOTS; i++) { + if (XG_DEV(last_exception_trace).obj_ptri) { + XG_DEV(last_exception_trace).obj_ptri = NULL; + zval_ptr_dtor(&XG_DEV(last_exception_trace).stack_tracei); + } + } +} + +void xdebug_develop_post_deactivate() +{ + xdebug_llist_destroy(XG_DEV(collected_errors), NULL); + XG_DEV(collected_errors) = NULL; + + xdebug_llist_destroy(XG_DEV(monitored_functions_found), NULL); + XG_DEV(monitored_functions_found) = NULL; + + if (XG_DEV(functions_to_monitor)) { + xdebug_hash_destroy(XG_DEV(functions_to_monitor)); + XG_DEV(functions_to_monitor) = NULL; + } +} + + +static int xdebug_silence_handler(XDEBUG_OPCODE_HANDLER_ARGS) +{ + zend_op_array *op_array = &execute_data->func->op_array; + const zend_op *cur_opcode = execute_data->opline; + + if (XDEBUG_MODE_IS(XDEBUG_MODE_COVERAGE)) { + xdebug_coverage_record_if_active(execute_data, op_array); + } + + if (XINI_DEV(do_scream)) { + execute_data->opline++; + if (cur_opcode->opcode == ZEND_BEGIN_SILENCE) { + XG_DEV(in_at) = 1; + } else { + XG_DEV(in_at) = 0; + } + return ZEND_USER_OPCODE_CONTINUE; + } + + return xdebug_call_original_opcode_handler_if_set(cur_opcode->opcode, XDEBUG_OPCODE_HANDLER_ARGS_PASSTHRU); +}
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/develop/develop.h
Added
@@ -0,0 +1,85 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#ifndef __XDEBUG_DEVELOP_H__ +#define __XDEBUG_DEVELOP_H__ + +#define XDEBUG_LAST_EXCEPTION_TRACE_SLOTS 8 + +typedef struct _xdebug_develop_globals_t { + /* used for function monitoring */ + zend_bool do_monitor_functions; + xdebug_hash *functions_to_monitor; + xdebug_llist *monitored_functions_found; /* List of functions found */ + + /* superglobals */ + xdebug_llist server; + xdebug_llist get; + xdebug_llist post; + xdebug_llist cookie; + xdebug_llist files; + xdebug_llist env; + xdebug_llist request; + xdebug_llist session; + + /* used for collection errors */ + xdebug_llist *collected_errors; + + /* scream */ + zend_bool in_at; + + /* last exception stack trace */ + struct { + int next_slot; + zend_object *obj_ptrXDEBUG_LAST_EXCEPTION_TRACE_SLOTS; + zval stack_traceXDEBUG_LAST_EXCEPTION_TRACE_SLOTS; + } last_exception_trace; +} xdebug_develop_globals_t; + +typedef struct _xdebug_develop_settings_t { + + zend_long max_stack_frames; + zend_bool show_ex_trace; + zend_bool show_error_trace; + zend_bool show_local_vars; + zend_bool force_display_errors; + zend_long force_error_reporting; + zend_long halt_level; + + zend_long cli_color; + + /* superglobals */ + zend_bool dump_globals; + zend_bool dump_once; + zend_bool dump_undefined; + + /* scream */ + zend_bool do_scream; +} xdebug_develop_settings_t; + +void xdebug_init_develop_globals(xdebug_develop_globals_t *xg); +void xdebug_deinit_develop_globals(xdebug_develop_globals_t *xg); + +void xdebug_develop_minit(); +void xdebug_develop_mshutdown(); +void xdebug_develop_rinit(); +void xdebug_develop_post_deactivate(); +void xdebug_develop_rshutdown(); + +void xdebug_develop_throw_exception_hook(zend_object *exception, zval *file, zval *line, zval *code, char *code_str, zval *message); +void xdebug_monitor_handler(function_stack_entry *fse); + +#endif
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/develop/develop_private.h
Changed
(renamed from xdebug-3.2.0/src/develop/develop_private.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/develop/monitor.c
Added
@@ -0,0 +1,176 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2022 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#include "lib/php-header.h" +#include "php_xdebug.h" + +#include "develop_private.h" +#include "monitor.h" + +#include "lib/compat.h" +#include "lib/hash.h" +#include "lib/var.h" + +ZEND_EXTERN_MODULE_GLOBALS(xdebug) + +static void init_function_monitor_hash(xdebug_hash *internal, HashTable *functions_to_monitor) +{ + zval *val; + + ZEND_HASH_FOREACH_VAL(functions_to_monitor, val) { + if (Z_TYPE_P(val) == IS_STRING) { + xdebug_hash_add(internal, Z_STRVAL_P(val), Z_STRLEN_P(val), xdstrdup(Z_STRVAL_P(val))); + } + } ZEND_HASH_FOREACH_END(); +} + +static void xdebug_hash_function_monitor_dtor(char *function) +{ + xdfree(function); +} + +static xdebug_monitored_function_entry *xdebug_monitored_function_init(char *func_name, zend_string *filename, int lineno) +{ + xdebug_monitored_function_entry *tmp = xdmalloc(sizeof(xdebug_monitored_function_entry)); + + tmp->func_name = xdstrdup(func_name); + tmp->filename = zend_string_copy(filename); + tmp->lineno = lineno; + + return tmp; +} + +void xdebug_monitored_function_dtor(void *dummy, void *elem) +{ + xdebug_monitored_function_entry *mfe = (xdebug_monitored_function_entry*) elem; + + xdfree(mfe->func_name); + zend_string_release(mfe->filename); + xdfree(mfe); +} + +void xdebug_function_monitor_record(char *func_name, zend_string *filename, int lineno) +{ + xdebug_monitored_function_entry *record; + + record = xdebug_monitored_function_init(func_name, filename, lineno); + xdebug_llist_insert_next(XG_DEV(monitored_functions_found), XDEBUG_LLIST_TAIL(XG_DEV(monitored_functions_found)), record); +} + +void xdebug_monitor_handler(function_stack_entry *fse) +{ + char *func_name = NULL; + int func_name_len = 0; + void *dummy = NULL; + + if (!XG_DEV(do_monitor_functions)) { + return; + } + + func_name = xdebug_show_fname(fse->function, XDEBUG_SHOW_FNAME_DEFAULT); + func_name_len = strlen(func_name); + + if (xdebug_hash_find(XG_DEV(functions_to_monitor), func_name, func_name_len, (void *) &dummy)) { + xdebug_function_monitor_record(func_name, fse->filename, fse->lineno); + } + + xdfree(func_name); +} + +PHP_FUNCTION(xdebug_start_function_monitor) +{ + HashTable *functions_to_monitor; + + if (!XDEBUG_MODE_IS(XDEBUG_MODE_DEVELOP)) { + php_error(E_WARNING, "Function must be enabled in php.ini by setting 'xdebug.mode' to 'develop'"); + return; + } + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "H", &functions_to_monitor) == FAILURE) { + return; + } + + if (XG_DEV(do_monitor_functions) == 1) { + php_error(E_NOTICE, "Function monitoring was already started"); + } + + /* Clean and store list of functions to monitor */ + if (XG_DEV(functions_to_monitor)) { + xdebug_hash_destroy(XG_DEV(functions_to_monitor)); + } + + /* We add "1" here so that we don't alloc a 0-slot hash table */ + XG_DEV(functions_to_monitor) = xdebug_hash_alloc(zend_hash_num_elements(functions_to_monitor) + 1, (xdebug_hash_dtor_t) xdebug_hash_function_monitor_dtor); + init_function_monitor_hash(XG_DEV(functions_to_monitor), functions_to_monitor); + + /* Disable opcache's optimizer as it prevents some optimized internal functions from being monitored */ + xdebug_disable_opcache_optimizer(); + + XG_DEV(do_monitor_functions) = 1; +} + +PHP_FUNCTION(xdebug_stop_function_monitor) +{ + if (!XDEBUG_MODE_IS(XDEBUG_MODE_DEVELOP)) { + php_error(E_WARNING, "Function must be enabled in php.ini by setting 'xdebug.mode' to 'develop'"); + return; + } + + if (XG_DEV(do_monitor_functions) == 0) { + php_error(E_NOTICE, "Function monitoring was not started"); + } + XG_DEV(do_monitor_functions) = 0; +} + +PHP_FUNCTION(xdebug_get_monitored_functions) +{ + xdebug_llist_element *le; + zend_bool clear = 0; + xdebug_monitored_function_entry *mfe; + + if (!XDEBUG_MODE_IS(XDEBUG_MODE_DEVELOP)) { + php_error(E_WARNING, "Function must be enabled in php.ini by setting 'xdebug.mode' to 'develop'"); + array_init(return_value); + return; + } + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &clear) == FAILURE) { + return; + } + + array_init(return_value); + for (le = XDEBUG_LLIST_HEAD(XG_DEV(monitored_functions_found)); le != NULL; le = XDEBUG_LLIST_NEXT(le)) { + zval *entry; + + mfe = XDEBUG_LLIST_VALP(le); + + XDEBUG_MAKE_STD_ZVAL(entry); + array_init(entry); + + add_assoc_string_ex(entry, "function", HASH_KEY_SIZEOF("function"), mfe->func_name); + add_assoc_string_ex(entry, "filename", HASH_KEY_SIZEOF("filename"), ZSTR_VAL(mfe->filename)); + add_assoc_long(entry, "lineno", mfe->lineno); + + add_next_index_zval(return_value, entry); + efree(entry); + } + + if (clear) { + xdebug_llist_destroy(XG_DEV(monitored_functions_found), NULL); + XG_DEV(monitored_functions_found) = xdebug_llist_alloc(xdebug_monitored_function_dtor); + } +} +/* }}} */
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/develop/monitor.h
Changed
(renamed from xdebug-3.2.0/src/develop/monitor.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/develop/php_functions.c
Added
@@ -0,0 +1,386 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#include "lib/php-header.h" +#include "php_xdebug.h" + +#include "develop_private.h" +#include "stack.h" + +#include "lib/lib_private.h" +#include "lib/var_export_html.h" +#include "lib/var_export_line.h" +#include "lib/var_export_text.h" + +ZEND_EXTERN_MODULE_GLOBALS(xdebug) + +#define MODE_MUST_BE(m,n) \ + if (!XDEBUG_MODE_IS((m))) { \ + php_error(E_WARNING, "Function must be enabled in php.ini by setting 'xdebug.mode' to '%s'", (n)); \ + return; \ + } + +/* {{{ proto void xdebug_var_dump(mixed var , ... ) + Outputs a fancy string representation of a variable */ +PHP_FUNCTION(xdebug_var_dump) +{ + zval *args; + int argc; + int i; + xdebug_str *val; + + argc = ZEND_NUM_ARGS(); + + args = safe_emalloc(argc, sizeof(zval), 0); + if (ZEND_NUM_ARGS() == 0 || zend_get_parameters_array_ex(argc, args) == FAILURE) { + efree(args); + WRONG_PARAM_COUNT; + } + + for (i = 0; i < argc; i++) { + if (PG(html_errors)) { + val = xdebug_get_zval_value_html(NULL, (zval*) &argsi, 0, NULL); + PHPWRITE(val->d, val->l); + xdebug_str_free(val); + } + else if ((XINI_DEV(cli_color) == 1 && xdebug_is_output_tty()) || (XINI_DEV(cli_color) == 2)) { + val = xdebug_get_zval_value_ansi((zval*) &argsi, 0, NULL); + PHPWRITE(val->d, val->l); + xdebug_str_free(val); + } + else { + val = xdebug_get_zval_value_text((zval*) &argsi, 0, NULL); + PHPWRITE(val->d, val->l); + xdebug_str_free(val); + } + } + + efree(args); +} +/* }}} */ + +/* {{{ proto void xdebug_debug_zval(mixed var , ... ) + Outputs a fancy string representation of a variable */ +PHP_FUNCTION(xdebug_debug_zval) +{ + zval *args; + int argc; + int i; + xdebug_str *val; + + argc = ZEND_NUM_ARGS(); + + args = safe_emalloc(argc, sizeof(zval), 0); + if (ZEND_NUM_ARGS() == 0 || zend_get_parameters_array_ex(argc, args) == FAILURE) { + efree(args); + WRONG_PARAM_COUNT; + } + + if (!(ZEND_CALL_INFO(EG(current_execute_data)->prev_execute_data) & ZEND_CALL_HAS_SYMBOL_TABLE)) { + zend_rebuild_symbol_table(); + } + + for (i = 0; i < argc; i++) { + if (Z_TYPE(argsi) == IS_STRING) { + zval debugzval; + xdebug_str *tmp_name; + + xdebug_lib_set_active_symbol_table(EG(current_execute_data)->prev_execute_data->symbol_table); + xdebug_lib_set_active_data(EG(current_execute_data)->prev_execute_data); + + tmp_name = xdebug_str_create(Z_STRVAL(argsi), Z_STRLEN(argsi)); + xdebug_get_php_symbol(&debugzval, tmp_name); + xdebug_str_free(tmp_name); + + /* Reduce refcount for dumping */ + Z_TRY_DELREF(debugzval); + + php_printf("%s: ", Z_STRVAL(argsi)); + if (Z_TYPE(debugzval) != IS_UNDEF) { + if (PG(html_errors)) { + val = xdebug_get_zval_value_html(NULL, &debugzval, 1, NULL); + PHPWRITE(val->d, val->l); + } + else if ((XINI_DEV(cli_color) == 1 && xdebug_is_output_tty()) || (XINI_DEV(cli_color) == 2)) { + val = xdebug_get_zval_value_ansi(&debugzval, 1, NULL); + PHPWRITE(val->d, val->l); + } + else { + val = xdebug_get_zval_value_line(&debugzval, 1, NULL); + PHPWRITE(val->d, val->l); + } + xdebug_str_free(val); + PHPWRITE("\n", 1); + } else { + PHPWRITE("no such symbol\n", 15); + } + + /* Restore original refcount */ + Z_TRY_ADDREF(debugzval); + zval_ptr_dtor_nogc(&debugzval); + } + } + + efree(args); +} +/* }}} */ + +/* {{{ proto void xdebug_debug_zval_stdout(mixed var , ... ) + Outputs a fancy string representation of a variable */ +PHP_FUNCTION(xdebug_debug_zval_stdout) +{ + zval *args; + int argc; + int i; + + argc = ZEND_NUM_ARGS(); + + args = safe_emalloc(argc, sizeof(zval), 0); + if (ZEND_NUM_ARGS() == 0 || zend_get_parameters_array_ex(argc, args) == FAILURE) { + efree(args); + WRONG_PARAM_COUNT; + } + + if (!(ZEND_CALL_INFO(EG(current_execute_data)->prev_execute_data) & ZEND_CALL_HAS_SYMBOL_TABLE)) { + zend_rebuild_symbol_table(); + } + + for (i = 0; i < argc; i++) { + if (Z_TYPE(argsi) == IS_STRING) { + zval debugzval; + xdebug_str *tmp_name; + xdebug_str *val; + + xdebug_lib_set_active_symbol_table(EG(current_execute_data)->prev_execute_data->symbol_table); + xdebug_lib_set_active_data(EG(current_execute_data)->prev_execute_data); + + tmp_name = xdebug_str_create(Z_STRVAL(argsi), Z_STRLEN(argsi)); + xdebug_get_php_symbol(&debugzval, tmp_name); + xdebug_str_free(tmp_name); + + /* Reduce refcount for dumping */ + Z_TRY_DELREF(debugzval); + + printf("%s: ", Z_STRVAL(argsi)); + if (Z_TYPE(debugzval) != IS_UNDEF) { + val = xdebug_get_zval_value_line(&debugzval, 1, NULL); + printf("%s(%zd)", val->d, val->l); + xdebug_str_free(val); + printf("\n"); + } else { + printf("no such symbol\n\n"); + } + + /* Restore original refcount */ + Z_TRY_ADDREF(debugzval); + zval_ptr_dtor_nogc(&debugzval); + } + } + + efree(args); +} +/* }}} */ + +PHP_FUNCTION(xdebug_start_error_collection) +{ + MODE_MUST_BE(XDEBUG_MODE_DEVELOP, "develop");
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/develop/stack.c
Added
@@ -0,0 +1,1352 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ +#include "php_xdebug.h" + +#include "main/php_ini.h" + +#include "ext/standard/html.h" +#include "ext/standard/php_smart_string.h" +#include "zend_exceptions.h" +#include "zend_generators.h" + +#include "monitor.h" +#include "stack.h" +#include "superglobals.h" + +#include "base/filter.h" +#include "coverage/code_coverage.h" +#include "lib/compat.h" +#include "lib/lib_private.h" +#include "lib/str.h" +#include "lib/var_export_html.h" +#include "lib/var_export_line.h" +#include "profiler/profiler.h" + +ZEND_EXTERN_MODULE_GLOBALS(xdebug) + +static const char* text_formats22 = { + "\n", + "%s: %s in %s on line %d\n", + "\nCall Stack:\n", + "%10.4F %10ld %3d. %s(", + "'%s'", + ") %s:%d\n", + "\n\nVariables in local scope (#%d):\n", + "\n", + " $%s = %s\n", + " $%s = *uninitialized*\n", + "SCREAM: Error suppression ignored for\n", + NULL, + NULL, + + // 13+ (for xdebug_append_printable_stack_from_zval) + "\n%sCall Stack:\n", + "", + "%sThe stack is empty or not available\n", + "%s%10.4F %10ld %3d. %s() %s:%d\n", + "\n%s", + "\n%sNested Exceptions:\n", + "", // nested exceptions footer + NULL, // alternative to 16 for html only + "\t" // indenter +}; + +static const char* ansi_formats22 = { + "\n", + "1m31m%s0m: %s22m in 31m%s0m on line 32m%d0m22m\n", + "\n1mCall Stack:22m\n", + "%10.4F %10ld %3d. %s(", + "'%s'", + ") %s:%d\n", + "\n\nVariables in local scope (#%d):\n", + "\n", + " $%s = %s\n", + " $%s = *uninitialized*\n", + "1m31mSCREAM0m: Error suppression ignored for\n", + NULL, + NULL, + + // 13+ (for xdebug_append_printable_stack_from_zval) + "\n%s1mCall Stack:22m\n", + "", + "%sThe stack is empty or not available\n", + "%s%10.4F %10ld %3d. %s() %s:%d\n", + "\n%s", + "\n%s1mNested Exceptions:22m\n", + "", // nested exceptions footer + NULL, // alternative to 16 for html only + "\t" // indenter +}; + +static const char* html_formats22 = { + "<br />\n<font size='1'><table class='xdebug-error xe-%s%s' dir='ltr' border='1' cellspacing='0' cellpadding='1'>\n", + "<tr><th align='left' bgcolor='#f57900' colspan=\"5\"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> %s: %s in %s on line <i>%d</i></th></tr>\n", + "<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>\n<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>\n", + "<tr><td bgcolor='#eeeeec' align='center'>%d</td><td bgcolor='#eeeeec' align='center'>%.4F</td><td bgcolor='#eeeeec' align='right'>%ld</td><td bgcolor='#eeeeec'>%s( ", + "<font color='#00bb00'>'%s'</font>", + " )</td><td title='%s' bgcolor='#eeeeec'>%s<b>:</b>%d</td></tr>\n", + "<tr><th align='left' colspan='5' bgcolor='#e9b96e'>Variables in local scope (#%d)</th></tr>\n", + "</table></font>\n", + "<tr><td colspan='2' align='right' bgcolor='#eeeeec' valign='top'><pre>$%s =</pre></td><td colspan='3' bgcolor='#eeeeec'>%s</td></tr>\n", + "<tr><td colspan='2' align='right' bgcolor='#eeeeec' valign='top'><pre>$%s =</pre></td><td colspan='3' bgcolor='#eeeeec' valign='top'><i>Undefined</i></td></tr>\n", + " )</td><td title='%s' bgcolor='#eeeeec'><a style='color: black' href='%s'>%s<b>:</b>%d</a></td></tr>\n", + "<tr><th align='left' bgcolor='#f57900' colspan=\"5\"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> %s: %s in <a style='color: black' href='%s'>%s</a> on line <i>%d</i></th></tr>\n", + "<tr><th align='left' bgcolor='#f57900' colspan=\"5\"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> SCREAM: Error suppression ignored for</th></tr>\n", + + // 13+ (for xdebug_append_printable_stack_from_zval) + "%s<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>\n<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>\n", + "", + "%s<tr><td colspan='5' bgcolor='#eeeeec'>The stack is empty or not available</td></tr>\n", + "%s<tr><td bgcolor='#eeeeec' align='center'>%d</td><td bgcolor='#eeeeec' align='center'>%.4F</td><td bgcolor='#eeeeec' align='right'>%ld</td><td bgcolor='#eeeeec'>%s()</td><td title='%s' bgcolor='#eeeeec'><a style='color: black' href='%s'>%s<b>:</b>%d</a></td></tr>\n", + "%s<table class='xdebug-error xe-nested' style='width: 80%; margin: 1em' dir='ltr' border='1' cellspacing='0' cellpadding='1'>\n", + "%s<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Nested Exceptions</th></tr><tr><td colspan='5'>\n", + "</table></tr>\n", // nested exceptions footer + "<tr><td bgcolor='#eeeeec' align='center'>%d</td><td bgcolor='#eeeeec' align='center'>%.4F</td><td bgcolor='#eeeeec' align='right'>%ld</td><td bgcolor='#eeeeec'>%s()</td><td title='%s' bgcolor='#eeeeec'>%s<b>:</b>%d</td></tr>\n", + "" // indenter (not used for HTML) +}; + +static const char** select_formats(int html) +{ + if (html) { + return html_formats; + } else if ((XINI_DEV(cli_color) == 1 && xdebug_is_output_tty()) || (XINI_DEV(cli_color) == 2)) { + return ansi_formats; + } else { + return text_formats; + } +} + +void xdebug_log_stack(const char *error_type_str, char *buffer, const char *error_filename, const int error_lineno) +{ + char *tmp_log_message; + int i; + function_stack_entry *fse; + + tmp_log_message = xdebug_sprintf( "PHP %s: %s in %s on line %d", error_type_str, buffer, error_filename, error_lineno); + php_log_err(tmp_log_message); + xdfree(tmp_log_message); + + if (!XG_BASE(stack) || XDEBUG_VECTOR_COUNT(XG_BASE(stack)) < 1) { + return; + } + + fse = XDEBUG_VECTOR_HEAD(XG_BASE(stack)); + + php_log_err((char*) "PHP Stack trace:"); + + for (i = 0; i < XDEBUG_VECTOR_COUNT(XG_BASE(stack)); i++, fse++) + { + int c = 0; /* Comma flag */ + unsigned int j = 0; /* Counter */ + char *tmp_name; + xdebug_str log_buffer = XDEBUG_STR_INITIALIZER; + int variadic_opened = 0; + int sent_variables = fse->varc; + + if (sent_variables > 0 && fse->varsent_variables-1.is_variadic && Z_ISUNDEF(fse->varsent_variables-1.data)) { + sent_variables--; + } + + tmp_name = xdebug_show_fname(fse->function, XDEBUG_SHOW_FNAME_DEFAULT); + xdebug_str_add_fmt(&log_buffer, "PHP %3d. %s(", fse->level, tmp_name); + xdfree(tmp_name); + + /* Printing vars */ + for (j = 0; j < sent_variables; j++) { + xdebug_str *tmp_value; + + if (c) { + xdebug_str_add_literal(&log_buffer, ", "); + } else { + c = 1; + } + + if (fse->varj.is_variadic) { + xdebug_str_add_literal(&log_buffer, "..."); + variadic_opened = 1; + } + + if (fse->varj.name) { + xdebug_str_add_fmt(&log_buffer, "$%s = ", ZSTR_VAL(fse->varj.name)); + } + + if (fse->varj.is_variadic) { + xdebug_str_add_literal(&log_buffer, "variadic("); + c = 0; + continue; + } + + if (!Z_ISUNDEF(fse->varj.data)) { + tmp_value = xdebug_get_zval_value_line(&fse->varj.data, 0, NULL); + xdebug_str_add_str(&log_buffer, tmp_value); + xdebug_str_free(tmp_value); + } else { + xdebug_str_add_literal(&log_buffer, "*uninitialized*"); + } + }
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/develop/stack.h
Changed
(renamed from xdebug-3.2.0/src/develop/stack.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/develop/superglobals.c
Changed
(renamed from xdebug-3.2.0/src/develop/superglobals.c)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/develop/superglobals.h
Changed
(renamed from xdebug-3.2.0/src/develop/superglobals.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/gcstats/gc_stats.c
Added
@@ -0,0 +1,356 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ +#include "lib/php-header.h" +#include "zend_builtin_functions.h" +#include "SAPI.h" +#include "Zend/zend_long.h" + +#include "php_xdebug.h" +#include "gc_stats_private.h" + +#include "base/base.h" +#include "lib/lib.h" +#include "lib/log.h" + +/* Set correct int format to use */ +#define XDEBUG_GCINT_FMT ZEND_LONG_FMT_SPEC + +ZEND_EXTERN_MODULE_GLOBALS(xdebug) + +static void xdebug_gc_stats_print_run(xdebug_gc_run *run); +static void xdebug_gc_stats_run_free(xdebug_gc_run *run); +int (*xdebug_old_gc_collect_cycles)(void); + +static int xdebug_gc_collect_cycles(void) +{ + int ret; + uint32_t collected; + xdebug_gc_run *run; + zend_execute_data *execute_data; + long int memory; + uint64_t start; + xdebug_func tmp; + zend_gc_status status; + + if (!XG_GCSTATS(active)) { + return xdebug_old_gc_collect_cycles(); + } + + execute_data = EG(current_execute_data); + + zend_gc_get_status(&status); + collected = status.collected; + start = xdebug_get_nanotime(); + memory = zend_memory_usage(0); + + ret = xdebug_old_gc_collect_cycles(); + + run = xdmalloc(sizeof(xdebug_gc_run)); + run->function_name = NULL; + run->class_name = NULL; + + zend_gc_get_status(&status); + run->collected = status.collected - collected; + run->duration = xdebug_get_nanotime() - start; + run->memory_before = memory; + run->memory_after = zend_memory_usage(0); + + xdebug_build_fname(&tmp, execute_data); + + run->function_name = tmp.function ? zend_string_copy(tmp.function) : NULL; + run->class_name = tmp.object_class ? zend_string_copy(tmp.object_class) : NULL; + + xdebug_gc_stats_print_run(run); + + xdebug_gc_stats_run_free(run); + xdebug_func_dtor_by_ref(&tmp); + + return ret; +} + +static void xdebug_gc_stats_run_free(xdebug_gc_run *run) +{ + if (!run) { + return; + } + + if (run->function_name) { + zend_string_release(run->function_name); + } + if (run->class_name) { + zend_string_release(run->class_name); + } + xdfree(run); +} + +static int xdebug_gc_stats_init(char *requested_filename, zend_string *script_name) +{ + char *filename_to_use = NULL; + char *generated_filename = NULL; + char *output_dir = xdebug_lib_get_output_dir(); /* not duplicated */ + + if (!gc_enabled()) { + xdebug_log_ex(XLOG_CHAN_GCSTATS, XLOG_ERR, "DISABLED", "PHP's Garbage Collection is disabled"); + return FAILURE; + } + + if (requested_filename && strlen(requested_filename)) { + filename_to_use = xdstrdup(requested_filename); + } else { + if (!strlen(XINI_GCSTATS(output_name)) || + xdebug_format_output_filename(&generated_filename, XINI_GCSTATS(output_name), ZSTR_VAL(script_name)) <= 0) + { + return FAILURE; + } + + if (IS_SLASH(output_dirstrlen(output_dir) - 1)) { + filename_to_use = xdebug_sprintf("%s%s", output_dir, generated_filename); + } else { + filename_to_use = xdebug_sprintf("%s%c%s", output_dir, DEFAULT_SLASH, generated_filename); + } + } + + XG_GCSTATS(file) = xdebug_fopen(filename_to_use, "w", NULL, &XG_GCSTATS(filename)); + + if (!XG_GCSTATS(file)) { + xdebug_log_diagnose_permissions(XLOG_CHAN_GCSTATS, output_dir, filename_to_use); + + xdfree(filename_to_use); + if (generated_filename) { + xdfree(generated_filename); + } + + return FAILURE; + } + xdfree(filename_to_use); + + fprintf(XG_GCSTATS(file), "Garbage Collection Report\n"); + fprintf(XG_GCSTATS(file), "version: 1\ncreator: xdebug %s (PHP %s)\n\n", XDEBUG_VERSION, PHP_VERSION); + + fprintf(XG_GCSTATS(file), "Collected | Efficiency%% | Duration | Memory Before | Memory After | Reduction%% | Function\n"); + fprintf(XG_GCSTATS(file), "----------+-------------+----------+---------------+--------------+------------+---------\n"); + + fflush(XG_GCSTATS(file)); + + if (generated_filename) { + xdfree(generated_filename); + } + + return SUCCESS; +} + +static void xdebug_gc_stats_stop() +{ + XG_GCSTATS(active) = 0; + + if (XG_GCSTATS(file)) { + if (!gc_enabled()) { + fprintf(XG_GCSTATS(file), "Garbage Collection Disabled End\n"); + xdebug_log_ex(XLOG_CHAN_GCSTATS, XLOG_ERR, "DISABLED", "PHP's Garbage Collection is disabled at the end of the script"); + } + + fclose(XG_GCSTATS(file)); + XG_GCSTATS(file) = NULL; + } +} + +#define AS_PERCENT(n) ((n)*100.0) +#define ROOTS_AS_PERCENT(n) AS_PERCENT((n) / 10000.0) + +static void xdebug_gc_stats_print_run(xdebug_gc_run *run) +{ + double reduction; + + if (run->memory_before) { + reduction = (1 - (float)run->memory_after / (float)run->memory_before) * 100.0; + } else { + reduction = 0; + } + + if (!XG_GCSTATS(file)) { + return; + } + + if (!run->function_name) { + fprintf(XG_GCSTATS(file), + "%9" XDEBUG_GCINT_FMT " | %9.2f %% | %5.2f ms | %13" XDEBUG_GCINT_FMT " | %12" XDEBUG_GCINT_FMT " | %8.2f %% | -\n", + run->collected, + ROOTS_AS_PERCENT(run->collected), + run->duration / (double)NANOS_IN_MILLISEC, + run->memory_before, + run->memory_after, + reduction + ); + } else if (!run->class_name && run->function_name) { + fprintf(XG_GCSTATS(file), + "%9" XDEBUG_GCINT_FMT " | %9.2f %% | %5.2f ms | %13" XDEBUG_GCINT_FMT " | %12" XDEBUG_GCINT_FMT " | %8.2f %% | %s\n",
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/gcstats/gc_stats.h
Changed
(renamed from xdebug-3.2.0/src/gcstats/gc_stats.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/gcstats/gc_stats_private.h
Added
@@ -0,0 +1,34 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#ifndef __XDEBUG_GC_STATS_PRIVATE_H__ +#define __XDEBUG_GC_STATS_PRIVATE_H__ + +#include "gc_stats.h" + +typedef struct _xdebug_gc_run { + zend_long collected; + zend_long duration; + zend_long memory_before; + zend_long memory_after; + zend_string *function_name; + zend_string *class_name; +} xdebug_gc_run; + +#define XINI_GCSTATS(v) (XG(settings.gc_stats.v)) +#define XG_GCSTATS(v) (XG(globals.gc_stats.v)) + +#endif
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/cmd_parser.c
Added
@@ -0,0 +1,171 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#include "usefulstuff.h" +#include "cmd_parser.h" + +/* {{{ Constants for state machine */ +#define STATE_NORMAL 0 +#define STATE_QUOTED 1 +#define STATE_OPT_FOLLOWS 2 +#define STATE_SEP_FOLLOWS 3 +#define STATE_VALUE_FOLLOWS_FIRST_CHAR 4 +#define STATE_VALUE_FOLLOWS 5 +#define STATE_SKIP_CHAR 6 +#define STATE_ESCAPED_CHAR_FOLLOWS 7 +/* }}} */ + +void xdebug_cmd_arg_dtor(xdebug_dbgp_arg *arg) +{ + int i; + + for (i = 0; i < 27; i++) { + if (arg->valuei) { + xdebug_str_free(arg->valuei); + } + } + xdfree(arg); +} + +int xdebug_cmd_parse(const char *line, char **cmd, xdebug_dbgp_arg **ret_args) +{ + xdebug_dbgp_arg *args = NULL; + char *ptr; + int state; + int charescaped = 0; + char opt = ' ', *value_begin = NULL; + + args = xdmalloc(sizeof (xdebug_dbgp_arg)); + memset(args->value, 0, sizeof(args->value)); + *cmd = NULL; + + /* Find the end of the command, this is always on the first space */ + ptr = strchr(line, ' '); + if (!ptr) { + /* No space found. If the line is not empty, return the line + * and assume it only consists of the command name. If the line + * is 0 chars long, we return a failure. */ + if (strlen(line)) { + *cmd = strdup(line); + *ret_args = args; + return XDEBUG_ERROR_OK; + } else { + goto parse_error; + } + } else { + /* A space was found, so we copy everything before it + * into the cmd parameter. */ + *cmd = xdcalloc(1, ptr - line + 1); + memcpy(*cmd, line, ptr - line); + } + /* Now we loop until we find the end of the string, which is the \0 + * character */ + state = STATE_NORMAL; + do { + ptr++; + switch (state) { + case STATE_NORMAL: + if (*ptr != '-') { + goto parse_error; + } else { + state = STATE_OPT_FOLLOWS; + } + break; + case STATE_OPT_FOLLOWS: + opt = *ptr; + state = STATE_SEP_FOLLOWS; + break; + case STATE_SEP_FOLLOWS: + if (*ptr != ' ') { + goto parse_error; + } else { + state = STATE_VALUE_FOLLOWS_FIRST_CHAR; + value_begin = ptr + 1; + } + break; + case STATE_VALUE_FOLLOWS_FIRST_CHAR: + if (*ptr == '"' && opt != '-') { + value_begin = ptr + 1; + state = STATE_QUOTED; + } else { + state = STATE_VALUE_FOLLOWS; + } + break; + case STATE_VALUE_FOLLOWS: + if ((*ptr == ' ' && opt != '-') || *ptr == '\0') { + int opt_index = opt - 'a'; + + if (opt == '-') { + opt_index = 26; + } + + if (!args->valueopt_index) { + args->valueopt_index = xdebug_str_create(value_begin, ptr - value_begin); + state = STATE_NORMAL; + } else { + goto duplicate_opts; + } + } + break; + case STATE_QUOTED: + if (*ptr == '\\') { + state = STATE_ESCAPED_CHAR_FOLLOWS; + } else + if (*ptr == '"') { + int opt_index = opt - 'a'; + + if (charescaped) { + charescaped = 0; + break; + } + if (opt == '-') { + opt_index = 26; + } + + if (!args->valueopt_index) { + int len = ptr - value_begin; + + args->valueopt_index = xdebug_str_create(value_begin, len); + xdebug_stripcslashes(args->valueopt_index->d, &len); + args->valueopt_index->l = len; + + state = STATE_SKIP_CHAR; + } else { + goto duplicate_opts; + } + } + break; + case STATE_SKIP_CHAR: + state = STATE_NORMAL; + break; + case STATE_ESCAPED_CHAR_FOLLOWS: + state = STATE_QUOTED; + break; + + } + } while (*ptr); + *ret_args = args; + return XDEBUG_ERROR_OK; + +parse_error: + *ret_args = args; + return XDEBUG_ERROR_PARSE; + +duplicate_opts: + *ret_args = args; + return XDEBUG_ERROR_DUP_ARG; +} +
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/cmd_parser.h
Added
@@ -0,0 +1,46 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#ifndef __HAVE_CMD_PARSER_H__ +#define __HAVE_CMD_PARSER_H__ + +#include "php_xdebug.h" +#include "src/lib/usefulstuff.h" + +/* Argument structure */ +typedef struct xdebug_dbgp_arg { + xdebug_str *value27; /* one extra for - */ +} xdebug_dbgp_arg; + +#define CMD_OPTION_SET(opt) (!!(opt == '-' ? args->value26 : args->value(opt) - 'a')) +#define CMD_OPTION_CHAR(opt) (opt == '-' ? args->value26->d : args->value(opt) - 'a'->d) +#define CMD_OPTION_LEN(opt) (opt == '-' ? args->value26->l : args->value(opt) - 'a'->l) +#define CMD_OPTION_XDEBUG_STR(opt) (opt == '-' ? args->value26 : args->value(opt) - 'a') + +void xdebug_cmd_arg_dtor(xdebug_dbgp_arg *arg); +int xdebug_cmd_parse(const char *line, char **cmd, xdebug_dbgp_arg **ret_args); + +#define XDEBUG_ERROR_OK 0 +#define XDEBUG_ERROR_PARSE 1 +#define XDEBUG_ERROR_DUP_ARG 2 +#define XDEBUG_ERROR_INVALID_ARGS 3 +#define XDEBUG_ERROR_UNIMPLEMENTED 4 +#define XDEBUG_ERROR_COMMAND_UNAVAILABLE 5 + +#define XDEBUG_ERROR_STEP_DEBUG_MODE_NOT_ENABLED 400 +#define XDEBUG_ERROR_STEP_DEBUG_NOT_STARTED 401 + +#endif
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/compat.c
Changed
(renamed from xdebug-3.2.0/src/lib/compat.c)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/compat.h
Added
@@ -0,0 +1,84 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2022 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#ifndef __HAVE_XDEBUG_COMPAT_H__ +#define __HAVE_XDEBUG_COMPAT_H__ + +#include "lib/php-header.h" +#include "str.h" + +#include "ext/standard/head.h" +#include "ext/standard/php_var.h" +#define xdebug_php_var_dump php_var_dump + +char *xdebug_str_to_str(char *haystack, size_t length, const char *needle, size_t needle_len, const char *str, size_t str_len, size_t *new_len); + +unsigned char *xdebug_base64_encode(unsigned char *data, size_t data_len, size_t *new_len); +unsigned char *xdebug_base64_decode(unsigned char *data, size_t data_len, size_t *new_len); + +zend_string *xdebug_addslashes(zend_string *str); +void xdebug_stripcslashes(char *string, int *new_len); + +zend_ulong xdebug_get_pid(void); + +void xdebug_setcookie(const char *name, int name_len, char *value, int value_len, time_t expires, const char *path, int path_len, const char *domain, int domain_len, int secure, int url_encode, int httponly); +char *xdebug_get_compiled_variable_name(zend_op_array *op_array, uint32_t var, int *cv_len); + +/* Recursion protection is done differently from PHP 7.3 onwards */ +zend_bool xdebug_zend_hash_is_recursive(HashTable* ht); +zend_bool xdebug_zend_hash_apply_protection_begin(HashTable* ht); +zend_bool xdebug_zend_hash_apply_protection_end(HashTable* ht); + +#ifndef ZSTR_INIT_LITERAL +# define ZSTR_INIT_LITERAL(s, persistent) (zend_string_init((s), strlen(s), (persistent))) +#endif + +# define XDEBUG_MAKE_STD_ZVAL(zv) \ + zv = ecalloc(sizeof(zval), 1); + +# define HASH_KEY_SIZEOF(k) (sizeof(k) - 1) +# define HASH_KEY_STRLEN(k) (strlen(k)) +# define HASH_KEY_IS_NUMERIC(k) ((k) == NULL) +# define HASH_APPLY_KEY_VAL(k) (k)->val +# define HASH_APPLY_KEY_LEN(k) (k)->len + 1 + +# define STR_NAME_VAL(k) (k)->val +# define STR_NAME_LEN(k) (k)->len + +# if defined (__GNUC__) +# define XDEBUG_GNUC_CHECK_VERSION(major, minor) \ + ((__GNUC__ > (major)) || \ + ((__GNUC__ == (major)) && (__GNUC_MINOR__ >= (minor)))) +# else +# define XDEBUG_GNUC_CHECK_VERSION(major, minor) 0 +# endif + +# if XDEBUG_GNUC_CHECK_VERSION(7, 0) +# define XDEBUG_BREAK_INTENTIONALLY_MISSING __attribute__ ((fallthrough)); +# else +# define XDEBUG_BREAK_INTENTIONALLY_MISSING +# endif + +# if XDEBUG_GNUC_CHECK_VERSION(2, 7) || __has_attribute(format) +# define XDEBUG_ATTRIBUTE_FORMAT(type, idx, first) __attribute__ ((format(type, idx, first))) +# else +# define XDEBUG_ATTRIBUTE_FORMAT(type, idx, first) +# endif + +#define XDEBUG_OPCODE_HANDLER_ARGS zend_execute_data *execute_data +#define XDEBUG_OPCODE_HANDLER_ARGS_PASSTHRU execute_data + +#endif
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/crc32.c
Changed
(renamed from xdebug-3.2.0/src/lib/crc32.c)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/crc32.h
Changed
(renamed from xdebug-3.2.0/src/lib/crc32.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/file.c
Changed
(renamed from xdebug-3.2.0/src/lib/file.c)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/file.h
Changed
(renamed from xdebug-3.2.0/src/lib/file.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/hash.c
Changed
(renamed from xdebug-3.2.0/src/lib/hash.c)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/hash.h
Changed
(renamed from xdebug-3.2.0/src/lib/hash.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/headers.c
Added
@@ -0,0 +1,110 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2020 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ +#include "php_xdebug.h" + +#include "lib_private.h" + +extern ZEND_DECLARE_MODULE_GLOBALS(xdebug); + +static int xdebug_header_handler(sapi_header_struct *h, sapi_header_op_enum op, sapi_headers_struct *s); +static int (*xdebug_orig_header_handler)(sapi_header_struct *h, sapi_header_op_enum op, sapi_headers_struct *s); + +static void xdebug_header_remove_with_prefix(xdebug_llist *headers, char *prefix, size_t prefix_len) +{ + xdebug_llist_element *le; + char *header; + + for (le = XDEBUG_LLIST_HEAD(XG_LIB(headers)); le != NULL; /* intentionally left blank*/) { + header = XDEBUG_LLIST_VALP(le); + + if ((strlen(header) > prefix_len + 1) && (headerprefix_len == ':') && (strncasecmp(header, prefix, prefix_len) == 0)) { + xdebug_llist_element *current = le; + + le = XDEBUG_LLIST_NEXT(le); + xdebug_llist_remove(headers, current, NULL); + } else { + le = XDEBUG_LLIST_NEXT(le); + } + } +} + +static int xdebug_header_handler(sapi_header_struct *h, sapi_header_op_enum op, sapi_headers_struct *s) +{ + if (XG_LIB(headers)) { + switch (op) { + case SAPI_HEADER_ADD: + xdebug_llist_insert_next(XG_LIB(headers), XDEBUG_LLIST_TAIL(XG_LIB(headers)), xdstrdup(h->header)); + break; + case SAPI_HEADER_REPLACE: { + char *colon_offset = strchr(h->header, ':'); + + if (colon_offset) { + char save = *colon_offset; + + *colon_offset = '\0'; + xdebug_header_remove_with_prefix(XG_LIB(headers), h->header, strlen(h->header)); + *colon_offset = save; + } + + xdebug_llist_insert_next(XG_LIB(headers), XDEBUG_LLIST_TAIL(XG_LIB(headers)), xdstrdup(h->header)); + } break; + case SAPI_HEADER_DELETE_ALL: + xdebug_llist_empty(XG_LIB(headers), NULL); + case SAPI_HEADER_DELETE: + case SAPI_HEADER_SET_STATUS: + break; + } + } + if (xdebug_orig_header_handler) { + return xdebug_orig_header_handler(h, op, s); + } + return SAPI_HEADER_ADD; +} + +void xdebug_lib_zend_startup_overload_sapi_headers(void) +{ + /* Override header handler in SAPI */ + if (xdebug_orig_header_handler != NULL) { + return; + } + + xdebug_orig_header_handler = sapi_module.header_handler; + sapi_module.header_handler = xdebug_header_handler; +} + +void xdebug_lib_zend_shutdown_restore_sapi_headers(void) +{ + /* Restore original header handler in SAPI */ + sapi_module.header_handler = xdebug_orig_header_handler; + xdebug_orig_header_handler = NULL; +} + + +PHP_FUNCTION(xdebug_get_headers) +{ + xdebug_llist_element *le; + char *string; + + array_init(return_value); + + if (!XG_LIB(headers)) { + return; + } + for (le = XDEBUG_LLIST_HEAD(XG_LIB(headers)); le != NULL; le = XDEBUG_LLIST_NEXT(le)) { + string = XDEBUG_LLIST_VALP(le); + add_next_index_string(return_value, string); + } +}
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/headers.h
Changed
(renamed from xdebug-3.2.0/src/lib/headers.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/lib.c
Added
@@ -0,0 +1,811 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#include "php_xdebug.h" + +#include "headers.h" + +#include "lib_private.h" +#include "log.h" + +extern ZEND_DECLARE_MODULE_GLOBALS(xdebug); + +void xdebug_init_library_globals(xdebug_library_globals_t *xg) +{ + xg->headers = NULL; + xg->mode_from_environment = 0; + + xg->log_file = 0; + + xg->active_execute_data = NULL; + xg->opcode_handlers_set = xdebug_set_create(256); + memset(xg->original_opcode_handlers, 0, sizeof(xg->original_opcode_handlers)); + memset(xg->opcode_multi_handlers, 0, sizeof(xg->opcode_multi_handlers)); + + XINI_LIB(log_level) = 0; + xg->diagnosis_buffer = NULL; +} + + +void xdebug_library_zend_startup(void) +{ + xdebug_lib_zend_startup_overload_sapi_headers(); +} + +void xdebug_library_zend_shutdown(void) +{ + xdebug_lib_zend_shutdown_restore_sapi_headers(); +} + + +void xdebug_library_minit(void) +{ + xdebug_set_opcode_multi_handler(ZEND_ASSIGN); + xdebug_set_opcode_multi_handler(ZEND_ASSIGN_DIM); + xdebug_set_opcode_multi_handler(ZEND_ASSIGN_OBJ); + xdebug_set_opcode_multi_handler(ZEND_ASSIGN_STATIC_PROP); + xdebug_set_opcode_multi_handler(ZEND_QM_ASSIGN); + xdebug_set_opcode_multi_handler(ZEND_INCLUDE_OR_EVAL); +} + +static void xdebug_multi_opcode_handler_dtor(xdebug_multi_opcode_handler_t *ptr) +{ + if (ptr->next) { + xdebug_multi_opcode_handler_dtor(ptr->next); + } + xdfree(ptr); +} + +void xdebug_library_mshutdown(void) +{ + int i; + + /* Restore all opcode handlers that we have set */ + for (i = 0; i < 256; i++) { + if (XG_LIB(opcode_multi_handlers)i != NULL) { + xdebug_multi_opcode_handler_dtor(XG_LIB(opcode_multi_handlers)i); + } + xdebug_unset_opcode_handler(i); + } + + xdebug_set_free(XG_LIB(opcode_handlers_set)); +} + +void xdebug_library_rinit(void) +{ + XG_LIB(diagnosis_buffer) = xdebug_str_new(); + xdebug_open_log(); + + XG_LIB(headers) = xdebug_llist_alloc(xdebug_llist_string_dtor); + + XG_LIB(dumped) = 0; + XG_LIB(do_collect_errors) = 0; + + XG_LIB(trait_location_map) = xdebug_hash_alloc(256, (xdebug_hash_dtor_t) zend_string_release); +} + +void xdebug_library_post_deactivate(void) +{ + /* Clean up collected headers */ + xdebug_llist_destroy(XG_LIB(headers), NULL); + XG_LIB(headers) = NULL; + + xdebug_hash_destroy(XG_LIB(trait_location_map)); + + xdebug_close_log(); + xdebug_str_free(XG_LIB(diagnosis_buffer)); + XG_LIB(diagnosis_buffer) = NULL; +} + + +void xdebug_disable_opcache_optimizer(void) +{ + zend_string *key = zend_string_init(ZEND_STRL("opcache.optimization_level"), 1); + zend_string *value = zend_string_init(ZEND_STRL("0"), 1); + + zend_alter_ini_entry(key, value, ZEND_INI_SYSTEM, ZEND_INI_STAGE_STARTUP); + + zend_string_release(key); + zend_string_release(value); +} + + +static int xdebug_lib_set_mode_item(const char *mode, int len) +{ + if (strncmp(mode, "off", len) == 0) { + xdebug_global_mode |= XDEBUG_MODE_OFF; + return 1; + } + if (strncmp(mode, "develop", len) == 0) { + xdebug_global_mode |= XDEBUG_MODE_DEVELOP; + return 1; + } + if (strncmp(mode, "coverage", len) == 0) { + xdebug_global_mode |= XDEBUG_MODE_COVERAGE; + return 1; + } + if (strncmp(mode, "debug", len) == 0) { + xdebug_global_mode |= XDEBUG_MODE_STEP_DEBUG; + return 1; + } + if (strncmp(mode, "gcstats", len) == 0) { + xdebug_global_mode |= XDEBUG_MODE_GCSTATS; + return 1; + } + if (strncmp(mode, "profile", len) == 0) { + xdebug_global_mode |= XDEBUG_MODE_PROFILING; + return 1; + } + if (strncmp(mode, "trace", len) == 0) { + xdebug_global_mode |= XDEBUG_MODE_TRACING; + return 1; + } + + return 0; +} + +static int xdebug_lib_set_mode_from_setting(const char *mode) +{ + const char *mode_ptr = mode; + char *comma = NULL; + int errors = 0; + + xdebug_global_mode = 0; + + comma = strchr(mode_ptr, ','); + while (comma) { + errors += !xdebug_lib_set_mode_item(mode_ptr, comma - mode_ptr); + mode_ptr = comma + 1; + while (*mode_ptr == ' ') { + mode_ptr++; + } + comma = strchr(mode_ptr, ','); + } + errors += !xdebug_lib_set_mode_item(mode_ptr, strlen(mode_ptr)); + + return !errors; +} + +int xdebug_lib_set_mode(const char *mode) +{ + char *config = getenv("XDEBUG_MODE"); + int result = 0; + + /* XDEBUG_MODE environment variable */ + if (config && strlen(config)) { + result = xdebug_lib_set_mode_from_setting(config); + + if (!result) { + xdebug_log_ex(XLOG_CHAN_CONFIG, XLOG_CRIT, "ENVMODE", "Invalid mode '%s' set for 'XDEBUG_MODE' environment variable, fall back to 'xdebug.mode' configuration setting", config); + } else { + XG_LIB(mode_from_environment) = 1; + return result; + } + } + + /* 'xdebug.mode' configuration setting */
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/lib.h
Added
@@ -0,0 +1,326 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#ifndef __XDEBUG_LIBRARY_H__ +#define __XDEBUG_LIBRARY_H__ + +#ifdef ZTS +# include "TSRM.h" +#endif + +#include "zend.h" +#include "zend_API.h" +#include "compat.h" + +extern int xdebug_global_mode; + +typedef struct xdebug_var_name { + zend_string *name; + zval data; + int is_variadic; +} xdebug_var_name; + +#define XFUNC_UNKNOWN 0x00 +#define XFUNC_NORMAL 0x01 +#define XFUNC_STATIC_MEMBER 0x02 +#define XFUNC_MEMBER 0x03 + +#define XFUNC_INCLUDES 0x10 +#define XFUNC_EVAL 0x10 +#define XFUNC_INCLUDE 0x11 +#define XFUNC_INCLUDE_ONCE 0x12 +#define XFUNC_REQUIRE 0x13 +#define XFUNC_REQUIRE_ONCE 0x14 +#define XFUNC_MAIN 0x15 +#if PHP_VERSION_ID >= 80100 +# define XFUNC_FIBER 0x16 +#endif + +#define XFUNC_ZEND_PASS 0x20 + +#define XDEBUG_IS_NORMAL_FUNCTION(f) ((f)->type == XFUNC_NORMAL || (f)->type == XFUNC_STATIC_MEMBER || (f)->type == XFUNC_MEMBER) + +#define XDEBUG_REGISTER_LONG_CONSTANT(__c) REGISTER_LONG_CONSTANT(#__c, __c, CONST_CS|CONST_PERSISTENT) + +#define XDEBUG_NONE 0 +#define XDEBUG_JIT 1 +#define XDEBUG_REQ 2 + +#define XDEBUG_BREAK 1 +#define XDEBUG_STEP 2 + +#define XDEBUG_BUILT_IN 0 +#define XDEBUG_USER_DEFINED 1 + +#define XDEBUG_MAX_FUNCTION_LEN 1024 + +#define XDEBUG_TRACE_OPTION_APPEND 0x01 +#define XDEBUG_TRACE_OPTION_COMPUTERIZED 0x02 +#define XDEBUG_TRACE_OPTION_HTML 0x04 +#define XDEBUG_TRACE_OPTION_NAKED_FILENAME 0x08 +#define XDEBUG_TRACE_OPTION_FLAMEGRAPH_COST 0x10 +#define XDEBUG_TRACE_OPTION_FLAMEGRAPH_MEM 0x20 + +#define XDEBUG_CC_OPTION_UNUSED 1 +#define XDEBUG_CC_OPTION_DEAD_CODE 2 +#define XDEBUG_CC_OPTION_BRANCH_CHECK 4 + +#define STATUS_STARTING 0 +#define STATUS_STOPPING 1 +#define STATUS_STOPPED 2 +#define STATUS_RUNNING 3 +#define STATUS_BREAK 4 + +#define REASON_OK 0 +#define REASON_ERROR 1 +#define REASON_ABORTED 2 +#define REASON_EXCEPTION 3 + +#define XDEBUG_CMDLOOP_NONBLOCK 0 +#define XDEBUG_CMDLOOP_BLOCK 1 + +#define XDEBUG_CMDLOOP_NONBAIL 0 +#define XDEBUG_CMDLOOP_BAIL 1 + +typedef struct _xdebug_func { + zend_string *object_class; + zend_string *scope_class; + zend_string *function; + zend_string *include_filename; + int type; + int internal; +} xdebug_func; + +typedef struct xdebug_profile { + uint64_t nanotime; + uint64_t nanotime_mark; + long memory; + long mem_mark; + xdebug_llist *call_list; +} xdebug_profile; + +typedef struct _function_stack_entry { + /* function properties */ + xdebug_func function; + unsigned int function_nr; + unsigned short user_defined:1; + unsigned short level:15; + + /* argument properties */ + unsigned short varc; + xdebug_var_name *var; + zval *return_value; + xdebug_llist *declared_vars; + HashTable *symbol_table; + zend_execute_data *execute_data; + unsigned char is_variadic; + unsigned char is_trampoline; + unsigned char arg_done; + + /* debugging properties */ + bool has_line_breakpoints; + + /* filter properties */ + unsigned char filtered_code_coverage; + unsigned char filtered_stack; + unsigned char filtered_tracing; + + /* coverage properties */ + bool code_coverage_init; + char *code_coverage_function_name; + zend_string *code_coverage_filename; + + /* location properties */ + int lineno; + zend_string *filename; + + /* tracing properties */ + signed long memory; + signed long prev_memory; + uint64_t nanotime; + bool function_call_traced; + + /* profiling properties */ + xdebug_profile profile; + struct { + int lineno; + zend_string *filename; + zend_string *function; + } profiler; + + /* misc properties */ + zend_op_array *op_array; +#if PHP_VERSION_ID >= 80100 + void (*soap_error_cb)(int type, zend_string *error_filename, const uint32_t error_lineno, zend_string *message); +#else + void (*soap_error_cb)(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message); +#endif +} function_stack_entry; + +function_stack_entry *xdebug_get_stack_frame(int nr); + + +xdebug_hash* xdebug_declared_var_hash_from_llist(xdebug_llist *list); +int xdebug_trigger_enabled(int setting, const char *var_name, char *var_value); + +typedef struct _xdebug_multi_opcode_handler_t xdebug_multi_opcode_handler_t; + +struct _xdebug_multi_opcode_handler_t +{ + user_opcode_handler_t handler; + xdebug_multi_opcode_handler_t *next; +}; + +typedef struct _xdebug_library_globals_t { + int start_with_request; /* One of the XDEBUG_START_WITH_REQUEST_* constants */ + int start_upon_error; /* One of the XDEBUG_START_UPON_ERROR_* constants */ + int mode_from_environment; /* Keeps track whether the mode was set with XDEBUG_MODE for diagnostics purposes */ + + zend_execute_data *active_execute_data; + function_stack_entry *active_stack_entry; + HashTable *active_symbol_table; + zval *active_object; + + /* Headers */ + xdebug_llist *headers; +
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/lib_private.h
Changed
(renamed from xdebug-3.2.0/src/lib/lib_private.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/llist.c
Changed
(renamed from xdebug-3.2.0/src/lib/llist.c)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/llist.h
Changed
(renamed from xdebug-3.2.0/src/lib/llist.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/log.c
Added
@@ -0,0 +1,938 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2022 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#include <errno.h> + +#include "php_xdebug.h" +#include "ext/standard/info.h" + +#include "headers.h" + +#include "lib_private.h" +#include "log.h" +#include "var.h" + +#define DOCS_LINK_ICON "⊕" + +char* xdebug_lib_docs_base(void) +{ + char *env = getenv("XDEBUG_DOCS_BASE"); + + if (env) { + return env; + } + + return (char*) "https://xdebug.org/docs/"; +} + +extern ZEND_DECLARE_MODULE_GLOBALS(xdebug); + +const char *xdebug_level_msg_prefix11 = { + "C", "E", "", "W", "", "", "", "I", "", "", "D" +}; +const char *xdebug_log_prefix11 = { + "CRIT:", "ERR: ", "", "WARN: ", "", "", "", "INFO: ", "", "", "DEBUG: " +}; +const char *xdebug_log_prefix_emoji11 = { + "☠", "🛑 ", "", "⚠️ ", "", "", "", "🛈 ", "", "", "• " +}; +const char *xdebug_channel_msg_prefix8 = { + "CFG-", "LOG-", "DBG-", "GC-", "PROF-", "TRACE-", "COV-", "BASE-" +}; +const char *xdebug_channel_name8 = { + "Config ", "Log Files ", "Step Debug ", "GC Stats ", "Profiler ", "Tracing ", "Coverage ", "Base " +}; + +static inline int xdebug_internal_log(int channel, int log_level, const char *message) +{ + zend_ulong pid; + + if (!XG_LIB(log_file)) { + return 0; + } + + pid = xdebug_get_pid(); + + if (!XG_LIB(log_opened_message_sent) && XG_LIB(log_open_timestring)) { + XG_LIB(log_opened_message_sent) = 1; + + fprintf(XG_LIB(log_file), "" ZEND_ULONG_FMT " Log opened at %s\n", pid, XG_LIB(log_open_timestring)); + fflush(XG_LIB(log_file)); + xdfree(XG_LIB(log_open_timestring)); + XG_LIB(log_open_timestring) = NULL; + } + + fprintf( + XG_LIB(log_file), + "" ZEND_ULONG_FMT " %s%s%s\n", + pid, + xdebug_channel_namechannel, + xdebug_log_prefixlog_level, + message + ); + + fflush(XG_LIB(log_file)); + + return 1; +} + +#define TR_START "<tr><td class=\"e\">" +#define TR_END "</td></tr>\n" + +static inline void xdebug_diagnostic_log(int channel, int log_level, const char *error_code, const char *message) +{ + if (!XG_LIB(diagnosis_buffer) || log_level > XLOG_WARN) { + return; + } + + if (sapi_module.phpinfo_as_text) { + xdebug_str_add(XG_LIB(diagnosis_buffer), xdebug_channel_namechannel, 0); + xdebug_str_add(XG_LIB(diagnosis_buffer), xdebug_log_prefixlog_level, 0); + xdebug_str_add(XG_LIB(diagnosis_buffer), message, 0); + } else { + xdebug_str_add_const(XG_LIB(diagnosis_buffer), "<tr><td class=\"i\">"); + xdebug_str_add(XG_LIB(diagnosis_buffer), xdebug_log_prefix_emojilog_level, 0); + xdebug_str_add_const(XG_LIB(diagnosis_buffer), "</td><td class=\"v\">"); + xdebug_str_add(XG_LIB(diagnosis_buffer), xdebug_channel_namechannel, 0); + xdebug_str_add(XG_LIB(diagnosis_buffer), message, 0); + xdebug_str_add_const(XG_LIB(diagnosis_buffer), "</td><td class=\"d\"><a href=\""); + xdebug_str_add(XG_LIB(diagnosis_buffer), xdebug_lib_docs_base(), 0); + xdebug_str_add_const(XG_LIB(diagnosis_buffer), "errors#"); + xdebug_str_add(XG_LIB(diagnosis_buffer), xdebug_channel_msg_prefixchannel, 0); + xdebug_str_add(XG_LIB(diagnosis_buffer), xdebug_level_msg_prefixlog_level, 0); + if (error_code) { + xdebug_str_addc(XG_LIB(diagnosis_buffer), '-'); + xdebug_str_add(XG_LIB(diagnosis_buffer), error_code, 0); + } + xdebug_str_add_const(XG_LIB(diagnosis_buffer), "\">" DOCS_LINK_ICON "</a></td></tr>"); + } + + xdebug_str_addc(XG_LIB(diagnosis_buffer), '\n'); +} + +static inline void xdebug_php_log(int channel, int log_level, const char *error_code, const char *message) +{ + xdebug_str formatted_message = XDEBUG_STR_INITIALIZER; + + if (log_level > XLOG_ERR) { + return; + } + + xdebug_str_add_const(&formatted_message, "Xdebug: "); + xdebug_str_add(&formatted_message, xdebug_channel_namechannel, 0); + xdebug_str_add(&formatted_message, message, 0); + + if (error_code && log_level == XLOG_CRIT) { + xdebug_str_add_const(&formatted_message, " (See: "); + xdebug_str_add(&formatted_message, xdebug_lib_docs_base(), 0); + xdebug_str_add_const(&formatted_message, "errors#"); + xdebug_str_add(&formatted_message, xdebug_channel_msg_prefixchannel, 0); + xdebug_str_add(&formatted_message, xdebug_level_msg_prefixlog_level, 0); + xdebug_str_addc(&formatted_message, '-'); + xdebug_str_add(&formatted_message, error_code, 0); + xdebug_str_addc(&formatted_message, ')'); + } + + php_log_err(formatted_message.d); + + xdebug_str_destroy(&formatted_message); +} + +void XDEBUG_ATTRIBUTE_FORMAT(printf, 4, 5) xdebug_log_ex(int channel, int log_level, const char *error_code, const char *fmt, ...) +{ + xdebug_str message = XDEBUG_STR_INITIALIZER; + va_list argv; + int logged_to_xdebug_log = 0; + + if (XINI_LIB(log_level) < log_level) { + return; + } + + va_start(argv, fmt); + xdebug_str_add_va_fmt(&message, fmt, argv); + va_end(argv); + + logged_to_xdebug_log = xdebug_internal_log(channel, log_level, message.d); + + xdebug_diagnostic_log(channel, log_level, error_code, message.d); + + if (!logged_to_xdebug_log || XINI_LIB(log_level) == XLOG_CRIT) { + xdebug_php_log(channel, log_level, error_code, message.d); + } + + xdebug_str_destroy(&message); +} + +static void log_filename_not_opened(int channel, const char *directory, const char *filename) +{ + xdebug_str full_filename = XDEBUG_STR_INITIALIZER; + + if (directory) { + xdebug_str_add(&full_filename, directory, 0); + if (!IS_SLASH(directorystrlen(directory) - 1)) { + xdebug_str_addc(&full_filename, DEFAULT_SLASH); + } + } + xdebug_str_add(&full_filename, filename, 0); + + xdebug_log_ex(channel, XLOG_ERR, "OPEN", "File '%s' could not be opened.", full_filename.d); + + xdebug_str_destroy(&full_filename); +} + +void xdebug_log_diagnose_permissions(int channel, const char *directory, const char *filename) +{ +#ifndef WIN32 + struct stat dir_info;
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/log.h
Changed
(renamed from xdebug-3.2.0/src/lib/log.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/mm.h
Changed
(renamed from xdebug-3.2.0/src/lib/mm.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/php-header.h
Changed
(renamed from xdebug-3.2.0/src/lib/php-header.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/set.c
Changed
(renamed from xdebug-3.2.0/src/lib/set.c)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/set.h
Changed
(renamed from xdebug-3.2.0/src/lib/set.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/str.c
Changed
(renamed from xdebug-3.2.0/src/lib/str.c)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/str.h
Changed
(renamed from xdebug-3.2.0/src/lib/str.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/timing.c
Changed
(renamed from xdebug-3.2.0/src/lib/timing.c)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/timing.h
Changed
(renamed from xdebug-3.2.0/src/lib/timing.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/usefulstuff.c
Added
@@ -0,0 +1,725 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2022 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#include <errno.h> +#include <stdlib.h> +#include <string.h> + +#ifndef WIN32 +# include <unistd.h> +# include <sys/types.h> +# include <sys/socket.h> +# include <sys/resource.h> +# include <sys/file.h> +#else +# define PATH_MAX MAX_PATH +# include <winsock2.h> +# include <io.h> +# include <process.h> +#endif + +#include "php_xdebug.h" + +#include "mm.h" +#include "crc32.h" +#include "str.h" + +#include "lib_private.h" +#include "usefulstuff.h" +#include "log.h" + +#include "ext/standard/php_lcg.h" +#include "ext/standard/flock_compat.h" +#include "main/php_ini.h" + +#ifndef NAME_MAX +# ifdef _AIX +# include <unistd.h> +# define NAME_MAX pathconf("/dev/null",_PC_NAME_MAX) +# else +# define NAME_MAX (MAXNAMELEN-1) +# endif +#endif + +ZEND_EXTERN_MODULE_GLOBALS(xdebug) + +xdebug_arg *xdebug_arg_ctor(void) +{ + xdebug_arg *tmp = /*(xdebug_arg*)*/ xdmalloc(sizeof(xdebug_arg)); + + tmp->args = NULL; + tmp->c = 0; + + return tmp; +} + +void xdebug_arg_dtor(xdebug_arg *arg) +{ + int i; + + for (i = 0; i < arg->c; i++) { + xdfree(arg->argsi); + } + if (arg->args) { + xdfree(arg->args); + } + xdfree(arg); +} + +xdebug_str* xdebug_join(const char *delim, xdebug_arg *args, int begin, int end) +{ + int i; + xdebug_str *ret = xdebug_str_new(); + + if (begin < 0) { + begin = 0; + } + if (end > args->c - 1) { + end = args->c - 1; + } + for (i = begin; i < end; i++) { + xdebug_str_add(ret, args->argsi, 0); + xdebug_str_add(ret, delim, 0); + } + xdebug_str_add(ret, args->argsend, 0); + return ret; +} + +void xdebug_explode(const char *delim, const char *str, xdebug_arg *args, int limit) +{ + const char *p1, *p2, *endp; + + endp = str + strlen(str); + + p1 = str; + p2 = xdebug_memnstr(str, delim, strlen(delim), endp); + + if (p2 == NULL) { + args->c++; + args->args = (char**) xdrealloc(args->args, sizeof(char*) * args->c); + args->argsargs->c - 1 = (char*) xdmalloc(strlen(str) + 1); + memcpy(args->argsargs->c - 1, p1, strlen(str)); + args->argsargs->c - 1strlen(str) = '\0'; + } else { + do { + args->c++; + args->args = (char**) xdrealloc(args->args, sizeof(char*) * args->c); + args->argsargs->c - 1 = (char*) xdmalloc(p2 - p1 + 1); + memcpy(args->argsargs->c - 1, p1, p2 - p1); + args->argsargs->c - 1p2 - p1 = '\0'; + p1 = p2 + strlen(delim); + } while ((p2 = xdebug_memnstr(p1, delim, strlen(delim), endp)) != NULL && (limit == -1 || --limit > 1)); + + if (p1 <= endp) { + args->c++; + args->args = (char**) xdrealloc(args->args, sizeof(char*) * args->c); + args->argsargs->c - 1 = (char*) xdmalloc(endp - p1 + 1); + memcpy(args->argsargs->c - 1, p1, endp - p1); + args->argsargs->c - 1endp - p1 = '\0'; + } + } +} + +const char* xdebug_memnstr(const char *haystack, const char *needle, int needle_len, const char *end) +{ + const char *p = haystack; + char first = *needle; + + /* let end point to the last character where needle may start */ + end -= needle_len; + + while (p <= end) { + while (*p != first) + if (++p > end) + return NULL; + if (memcmp(p, needle, needle_len) == 0) + return p; + p++; + } + return NULL; +} + +char* xdebug_strrstr(const char* haystack, const char* needle) +{ + char *loc = NULL; + char *found = NULL; + size_t pos = 0; + + while ((found = strstr(haystack + pos, needle)) != 0) { + loc = found; + pos = (found - haystack) + 1; + } + + return loc; +} + +char *xdebug_trim(const char *str) +{ + char *trimmed = NULL, *begin = (char *) str, *end = NULL; + + /* trim leading space */ + while (isspace((unsigned char) *begin)) { + ++begin; + } + + /* All spaces */ + if (*begin == '\0') { + return xdstrdup(""); + } + + /* trim trailing space */ + end = begin + strlen(begin) - 1; + while (end > begin && isspace((unsigned char) *end)) { + --end; + } + end++; + + trimmed = xdmalloc(end - begin + 1); + memcpy(trimmed, begin, (end - begin)); + trimmed(end - begin) = '\0'; + + return trimmed; +} + +/* not all versions of php export this */ +static int xdebug_htoi(char *s) +{
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/usefulstuff.h
Changed
(renamed from xdebug-3.2.0/src/lib/usefulstuff.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/var.c
Added
@@ -0,0 +1,1198 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#include "lib/php-header.h" +#include "ext/standard/php_string.h" +#include "ext/standard/url.h" +#include "zend.h" +#include "zend_exceptions.h" +#include "zend_extensions.h" +#include "ext/standard/php_smart_string.h" +#include "zend_smart_str.h" +#include "zend_closures.h" + +#include "php_xdebug.h" + +#include "lib/compat.h" +#include "lib/lib_private.h" +#include "lib/mm.h" +#include "lib/var.h" +#include "lib/var_export_html.h" +#include "lib/var_export_line.h" +#include "lib/xml.h" + +ZEND_EXTERN_MODULE_GLOBALS(xdebug) + +static inline int object_or_ancestor_is_internal(zval dzval) +{ + zend_class_entry *tmp_ce = Z_OBJCE(dzval); + + do { + if (tmp_ce->type == ZEND_INTERNAL_CLASS) { + return 1; + } + tmp_ce = tmp_ce->parent; + } while (tmp_ce); + + return 0; +} + +typedef struct _xdebug_zend_closure_copy { + zend_object std; + zend_function func; + zval this_ptr; + zend_class_entry *called_scope; + zif_handler orig_internal_handler; +} xdebug_zend_closure_copy; + +static int object_with_missing_closure_variables(zval dzval) +{ + zend_class_entry *tmp_ce = NULL; + xdebug_zend_closure_copy *closure = NULL; + + if (Z_TYPE(dzval) != IS_OBJECT) { + return 0; + } + + tmp_ce = Z_OBJCE(dzval); + if (tmp_ce != zend_ce_closure) { + return 0; + } + + closure = (xdebug_zend_closure_copy *) Z_OBJ(dzval); + + if (closure->func.type == ZEND_USER_FUNCTION && closure->func.op_array.static_variables) { + HashTable *static_variables = ZEND_MAP_PTR_GET(closure->func.op_array.static_variables_ptr); + + if (!static_variables) { + return 1; + } + } + + return 0; +} + +HashTable *xdebug_objdebug_pp(zval **zval_pp, int flags) +{ + zval dzval = **zval_pp; + HashTable *tmp; + + if ( + !XG_BASE(in_debug_info) && + (object_or_ancestor_is_internal(dzval) || (flags & XDEBUG_VAR_OBJDEBUG_USE_DEBUGINFO)) && + !object_with_missing_closure_variables(dzval) && + Z_OBJ_HANDLER(dzval, get_debug_info) && + !EG(exception) + ) { + void *original_trace_context; + zend_object *orig_exception; + + xdebug_tracing_save_trace_context(&original_trace_context); + XG_BASE(in_debug_info) = 1; + orig_exception = EG(exception); + EG(exception) = NULL; + + tmp = zend_get_properties_for(&dzval, ZEND_PROP_PURPOSE_DEBUG); + + XG_BASE(in_debug_info) = 0; + xdebug_tracing_restore_trace_context(original_trace_context); + EG(exception) = orig_exception; + + return tmp; + } else { + return zend_get_properties_for(&dzval, ZEND_PROP_PURPOSE_VAR_EXPORT); + } + return NULL; +} + +char* xdebug_error_type_simple(int type) +{ + switch (type) { + case E_ERROR: + case E_CORE_ERROR: + case E_COMPILE_ERROR: + case E_USER_ERROR: + return xdstrdup("fatal-error"); + break; + case E_RECOVERABLE_ERROR: + return xdstrdup("recoverable-fatal-error"); + break; + case E_WARNING: + case E_CORE_WARNING: + case E_COMPILE_WARNING: + case E_USER_WARNING: + return xdstrdup("warning"); + break; + case E_PARSE: + return xdstrdup("parse-error"); + break; + case E_NOTICE: + case E_USER_NOTICE: + return xdstrdup("notice"); + break; + case E_STRICT: + return xdstrdup("strict-standards"); + break; + case E_DEPRECATED: + case E_USER_DEPRECATED: + return xdstrdup("deprecated"); + break; + case 0: + return xdstrdup("xdebug"); + break; + default: + return xdstrdup("unknown-error"); + break; + } +} + +char* xdebug_error_type(int type) +{ + switch (type) { + case E_ERROR: + case E_CORE_ERROR: + case E_COMPILE_ERROR: + case E_USER_ERROR: + return xdstrdup("Fatal error"); + break; + case E_RECOVERABLE_ERROR: + return xdstrdup("Recoverable fatal error"); + break; + case E_WARNING: + case E_CORE_WARNING: + case E_COMPILE_WARNING: + case E_USER_WARNING: + return xdstrdup("Warning"); + break; + case E_PARSE: + return xdstrdup("Parse error"); + break; + case E_NOTICE: + case E_USER_NOTICE: + return xdstrdup("Notice"); + break; + case E_STRICT: + return xdstrdup("Strict standards"); + break; + case E_DEPRECATED: + case E_USER_DEPRECATED: + return xdstrdup("Deprecated"); + break; + case 0: + return xdstrdup("Xdebug"); + break; + default: + return xdstrdup("Unknown error"); + break;
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/var.h
Added
@@ -0,0 +1,90 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#include "lib/php-header.h" +#include "php_xdebug.h" + +#include "lib/compat.h" +#include "lib/lib.h" +#include "lib/str.h" +#include "lib/xml.h" + +#ifndef __HAVE_XDEBUG_VAR_H__ +#define __HAVE_XDEBUG_VAR_H__ + +/* Set correct int format to use */ +#include "Zend/zend_long.h" +#if SIZEOF_ZEND_LONG == 4 +# define XDEBUG_INT_FMT "%ld" +#else +# define XDEBUG_INT_FMT "%lld" +#endif + +typedef struct +{ + int page; /* The number of the page to retrieve */ + int current_element_nr; + int start_element_nr; + int end_element_nr; +} xdebug_var_runtime_page; + +typedef struct xdebug_var_export_options { + int max_children; + int max_data; + int max_depth; + int show_hidden; + int extended_properties; /* Whether the feature is enabled */ + int encode_as_extended_property; /* Whether the current node's elements need to be encoded */ + int show_location; + xdebug_var_runtime_page *runtime; + int no_decoration; +} xdebug_var_export_options; + +#define XDEBUG_VAR_TYPE_NORMAL 0x00 +#define XDEBUG_VAR_TYPE_STATIC 0x01 +#define XDEBUG_VAR_TYPE_CONSTANT 0x02 + +void xdebug_get_php_symbol(zval *retval, xdebug_str* name); + +xdebug_var_export_options* xdebug_var_export_options_from_ini(void); +xdebug_var_export_options* xdebug_var_get_nolimit_options(void); + +xdebug_str* xdebug_get_property_type(zval* object, zval *val); +xdebug_str* xdebug_get_property_info(char *mangled_property, int mangled_len, const char **modifier, char **class_name); + +#define XDEBUG_VAR_OBJDEBUG_DEFAULT 0x00 +#define XDEBUG_VAR_OBJDEBUG_USE_DEBUGINFO 0x01 +HashTable *xdebug_objdebug_pp(zval **zval_pp, int flags); + + +#define XDEBUG_VAR_ATTR_TEXT 0 +#define XDEBUG_VAR_ATTR_HTML 1 +void xdebug_add_variable_attributes(xdebug_str *str, zval *struc, zend_bool fancy); + + +char* xdebug_xmlize(char *s_string, size_t len, size_t *newlen); +char* xdebug_error_type_simple(int type); +char* xdebug_error_type(int type); +zval *xdebug_get_zval(zend_execute_data *zdata, int node_type, const znode_op *node, int *is_var); +zval *xdebug_get_zval_with_opline(zend_execute_data *zdata, const zend_op *opline, int node_type, const znode_op *node, int *is_var); + +#define XDEBUG_SHOW_FNAME_DEFAULT 0 +#define XDEBUG_SHOW_FNAME_ALLOW_HTML 1<<1 +#define XDEBUG_SHOW_FNAME_IGNORE_SCOPE 1<<2 +#define XDEBUG_SHOW_FNAME_ADD_FILE_NAME 1<<3 +char* xdebug_show_fname(xdebug_func t, int flags); + +#endif
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/var_export_html.c
Added
@@ -0,0 +1,462 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2021 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#include "var_export_html.h" +#include "lib_private.h" +#include "Zend/zend_closures.h" +#if PHP_VERSION_ID >= 80100 +# include "zend_enum.h" +#endif + +ZEND_EXTERN_MODULE_GLOBALS(xdebug) + +/***************************************************************************** +** Fancy variable printing routines +*/ + +#define COLOR_POINTER "#888a85" +#define COLOR_BOOL "#75507b" +#define COLOR_LONG "#4e9a06" +#define COLOR_NULL "#3465a4" +#define COLOR_DOUBLE "#f57900" +#define COLOR_STRING "#cc0000" +#define COLOR_EMPTY "#888a85" +#define COLOR_ARRAY "#ce5c00" +#define COLOR_OBJECT "#8f5902" +#define COLOR_RESOURCE "#2e3436" + +static int xdebug_array_element_export_html(zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, xdebug_str *str, int debug_zval, xdebug_var_export_options *options) +{ + zval **zv = &zv_nptr; + size_t newlen; + char *tmp_str; + + if (options->runtimelevel.current_element_nr >= options->runtimelevel.start_element_nr && + options->runtimelevel.current_element_nr < options->runtimelevel.end_element_nr) + { + xdebug_str_add_fmt(str, "%*s", (level * 4) - 2, ""); + + if (HASH_KEY_IS_NUMERIC(hash_key)) { /* numeric key */ + xdebug_str_add_fmt(str, XDEBUG_INT_FMT " <font color='%s'>=></font> ", index_key, COLOR_POINTER); + } else { /* string key */ + xdebug_str_addc(str, '\''); + tmp_str = xdebug_xmlize((char*) HASH_APPLY_KEY_VAL(hash_key), HASH_APPLY_KEY_LEN(hash_key) - 1, &newlen); + xdebug_str_addl(str, tmp_str, newlen, 0); + efree(tmp_str); + xdebug_str_add_fmt(str, "' <font color='%s'>=></font> ", COLOR_POINTER); + } + xdebug_var_export_html(zv, str, level + 1, debug_zval, options); + } + if (options->runtimelevel.current_element_nr == options->runtimelevel.end_element_nr) { + xdebug_str_add_fmt(str, "%*s", (level * 4) - 2, ""); + xdebug_str_add_literal(str, "<i>more elements...</i>\n"); + } + options->runtimelevel.current_element_nr++; + return 0; +} + +static int xdebug_object_element_export_html(zval *object, zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, xdebug_str *str, int debug_zval, xdebug_var_export_options *options, char *class_name) +{ + zval **zv = &zv_nptr; + + if (options->runtimelevel.current_element_nr >= options->runtimelevel.start_element_nr && + options->runtimelevel.current_element_nr < options->runtimelevel.end_element_nr) + { + xdebug_str_add_fmt(str, "%*s", (level * 4) - 2, ""); + + if (!HASH_KEY_IS_NUMERIC(hash_key)) { + char *prop_class_name; + xdebug_str *property_name; + xdebug_str *property_type = NULL; + const char *modifier; + + property_type = xdebug_get_property_type(object, zv_nptr); + property_name = xdebug_get_property_info((char*) HASH_APPLY_KEY_VAL(hash_key), HASH_APPLY_KEY_LEN(hash_key), &modifier, &prop_class_name); + + xdebug_str_add_fmt(str, "<i>%s</i> ", modifier); + if (property_type) { + xdebug_str_add_fmt(str, "<i>%s</i> ", property_type->d); + } + xdebug_str_addc(str, '\''); + xdebug_str_add_str(str, property_name); + if (strcmp(modifier, "private") != 0 || strcmp(class_name, prop_class_name) == 0) { + xdebug_str_add_fmt(str, "' <font color='%s'>=></font> ", COLOR_POINTER); + } else { + xdebug_str_add_fmt(str, "' <small>(%s)</small> <font color='%s'>=></font> ", prop_class_name, COLOR_POINTER); + } + + if (property_type) { + xdebug_str_free(property_type); + } + xdebug_str_free(property_name); + xdfree(prop_class_name); + } else { + xdebug_str_add_fmt(str, "<i>public</i> " XDEBUG_INT_FMT " <font color='%s'>=></font> ", index_key, COLOR_POINTER); + } + xdebug_var_export_html(zv, str, level + 1, debug_zval, options); + } + if (options->runtimelevel.current_element_nr == options->runtimelevel.end_element_nr) { + xdebug_str_add_fmt(str, "%*s", (level * 4) - 2, ""); + xdebug_str_add_literal(str, "<i>more elements...</i>\n"); + } + options->runtimelevel.current_element_nr++; + return 0; +} + +static void handle_closure(xdebug_str *str, zval *obj, int level) +{ + const zend_function *closure_function; + + if (Z_TYPE_P(obj) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(obj), zend_ce_closure)) { + return; + } + + closure_function = zend_get_closure_method_def(Z_OBJ_P(obj)); + + xdebug_str_add_fmt(str, "%*s<i>virtual</i> 'closure' <font color='%s'>'", (level * 4) - 2, "", COLOR_STRING); + + if (closure_function->common.scope) { + if (closure_function->common.fn_flags & ZEND_ACC_STATIC) { + xdebug_str_add_zstr(str, closure_function->common.scope->name); + xdebug_str_add_literal(str, "::"); + } else { + xdebug_str_add_literal(str, "$this->"); + } + } + xdebug_str_add_zstr(str, closure_function->common.function_name); + + xdebug_str_add_literal(str, "'</font>\n"); +} + + +void xdebug_var_export_html(zval **struc, xdebug_str *str, int level, int debug_zval, xdebug_var_export_options *options) +{ + HashTable *myht; + char* tmp_str; + size_t newlen; + zend_ulong num; + zend_string *key; + zval *val; + zval *tmpz; + int z_type; + + z_type = Z_TYPE_P(*struc); + + if (debug_zval) { + xdebug_add_variable_attributes(str, *struc, XDEBUG_VAR_ATTR_HTML); + } + if (z_type == IS_INDIRECT) { + tmpz = Z_INDIRECT_P(*struc); + struc = &tmpz; + z_type = Z_TYPE_P(*struc); + } + if (z_type == IS_REFERENCE) { + tmpz = &((*struc)->value.ref->val); + struc = &tmpz; + z_type = Z_TYPE_P(*struc); + } + + switch (z_type) { + case IS_TRUE: + xdebug_str_add_fmt(str, "<small>boolean</small> <font color='%s'>true</font>", COLOR_BOOL); + break; + + case IS_FALSE: + xdebug_str_add_fmt(str, "<small>boolean</small> <font color='%s'>false</font>", COLOR_BOOL); + break; + + case IS_NULL: + xdebug_str_add_fmt(str, "<font color='%s'>null</font>", COLOR_NULL); + break; + + case IS_LONG: + xdebug_str_add_fmt(str, "<small>int</small> <font color='%s'>" XDEBUG_INT_FMT "</font>", COLOR_LONG, Z_LVAL_P(*struc)); + break; + + case IS_DOUBLE: + xdebug_str_add_fmt(str, "<small>float</small> <font color='%s'>%.*H</font>", COLOR_DOUBLE, (int) EG(precision), Z_DVAL_P(*struc)); + break; + + case IS_STRING: + xdebug_str_add_fmt(str, "<small>string</small> <font color='%s'>'", COLOR_STRING); + if ((size_t) Z_STRLEN_P(*struc) > (size_t) options->max_data) { + tmp_str = xdebug_xmlize(Z_STRVAL_P(*struc), options->max_data, &newlen); + xdebug_str_addl(str, tmp_str, newlen, 0); + efree(tmp_str); + xdebug_str_add_literal(str, "'...</font>");
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/var_export_html.h
Changed
(renamed from xdebug-3.2.0/src/lib/var_export_html.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/var_export_line.c
Added
@@ -0,0 +1,445 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2022 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#include "lib/php-header.h" +#include "ext/standard/php_string.h" +#include "Zend/zend_closures.h" +#if PHP_VERSION_ID >= 80100 +# include "zend_enum.h" +#endif + +#include "var_export_line.h" + +ZEND_EXTERN_MODULE_GLOBALS(xdebug) + +static int xdebug_array_element_export(zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, xdebug_str *str, int debug_zval, xdebug_var_export_options *options) +{ + zval **zv = &zv_nptr; + + if (options->runtimelevel.current_element_nr >= options->runtimelevel.start_element_nr && + options->runtimelevel.current_element_nr < options->runtimelevel.end_element_nr) + { + if (HASH_KEY_IS_NUMERIC(hash_key)) { /* numeric key */ + xdebug_str_add_fmt(str, XDEBUG_INT_FMT " => ", index_key); + } else { /* string key */ + zend_string *tmp_zstr; + + tmp_zstr = php_addcslashes(hash_key, (char*) "'\\\0..\37", 7); + + xdebug_str_addc(str, '\''); + xdebug_str_add_zstr(str, tmp_zstr); + xdebug_str_add_literal(str, "' => "); + + zend_string_release(tmp_zstr); + } + xdebug_var_export_line(zv, str, level + 2, debug_zval, options); + xdebug_str_add_literal(str, ", "); + } + if (options->runtimelevel.current_element_nr == options->runtimelevel.end_element_nr) { + xdebug_str_add_literal(str, "..., "); + } + options->runtimelevel.current_element_nr++; + return 0; +} + +static int xdebug_object_element_export(zval *object, zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, xdebug_str *str, int debug_zval, xdebug_var_export_options *options, char *class_name) +{ + zval **zv = &zv_nptr; + + if (options->runtimelevel.current_element_nr >= options->runtimelevel.start_element_nr && + options->runtimelevel.current_element_nr < options->runtimelevel.end_element_nr) + { + if (!HASH_KEY_IS_NUMERIC(hash_key)) { + xdebug_str *property_name; + xdebug_str *property_type = NULL; + char *prop_class_name; + const char *modifier; + + property_type = xdebug_get_property_type(object, zv_nptr); + property_name = xdebug_get_property_info((char*) HASH_APPLY_KEY_VAL(hash_key), HASH_APPLY_KEY_LEN(hash_key), &modifier, &prop_class_name); + xdebug_str_add(str, modifier, 0); + if (property_type) { + xdebug_str_addc(str, ' '); + xdebug_str_add_str(str, property_type); + } + xdebug_str_add_literal(str, " $"); + if (strcmp(modifier, "private") != 0 || strcmp(class_name, prop_class_name) == 0) { + xdebug_str_add_str(str, property_name); + xdebug_str_add_literal(str, " = "); + } else { + xdebug_str_addc(str, '{'); + xdebug_str_add(str, prop_class_name, 0); + xdebug_str_addc(str, '}'); + xdebug_str_add_str(str, property_name); + xdebug_str_add_literal(str, " = "); + } + + if (property_type) { + xdebug_str_free(property_type); + } + xdebug_str_free(property_name); + xdfree(prop_class_name); + } else { + xdebug_str_add_fmt(str, "public $%d = ", index_key); + } + xdebug_var_export_line(zv, str, level + 2, debug_zval, options); + xdebug_str_add_literal(str, "; "); + } + if (options->runtimelevel.current_element_nr == options->runtimelevel.end_element_nr) { + xdebug_str_add_literal(str, "...; "); + } + options->runtimelevel.current_element_nr++; + return 0; +} + +#if PHP_VERSION_ID < 80200 +static void handle_closure(xdebug_str *str, zval *obj) +{ + const zend_function *closure_function; + + if (Z_TYPE_P(obj) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(obj), zend_ce_closure)) { + return; + } + + closure_function = zend_get_closure_method_def(Z_OBJ_P(obj)); + + xdebug_str_add_literal(str, "virtual $closure = \""); + + if (closure_function->common.scope) { + if (closure_function->common.fn_flags & ZEND_ACC_STATIC) { + xdebug_str_add(str, ZSTR_VAL(closure_function->common.scope->name), 0); + xdebug_str_add_literal(str, "::"); + } else { + xdebug_str_add_literal(str, "$this->"); + } + } + xdebug_str_add_zstr(str, closure_function->common.function_name); + + xdebug_str_add_literal(str, "\", "); +} +#endif + +void xdebug_var_export_line(zval **struc, xdebug_str *str, int level, int debug_zval, xdebug_var_export_options *options) +{ + HashTable *myht; + zend_ulong num; + zend_string *key; + zval *val; + zval *tmpz; + int z_type; + + if (!struc || !(*struc)) { + return; + } + + z_type = Z_TYPE_P(*struc); + + if (debug_zval) { + xdebug_add_variable_attributes(str, *struc, XDEBUG_VAR_ATTR_TEXT); + } + if (z_type == IS_INDIRECT) { + tmpz = Z_INDIRECT_P(*struc); + struc = &tmpz; + z_type = Z_TYPE_P(*struc); + } + if (z_type == IS_REFERENCE) { + tmpz = &((*struc)->value.ref->val); + struc = &tmpz; + z_type = Z_TYPE_P(*struc); + } + + switch (z_type) { + case IS_TRUE: + xdebug_str_add_literal(str, "TRUE"); + break; + + case IS_FALSE: + xdebug_str_add_literal(str, "FALSE"); + break; + + case IS_NULL: + xdebug_str_add_literal(str, "NULL"); + break; + + case IS_LONG: + xdebug_str_add_fmt(str, XDEBUG_INT_FMT, Z_LVAL_P(*struc)); + break; + + case IS_DOUBLE: + xdebug_str_add_fmt(str, "%.*H", (int) EG(precision), Z_DVAL_P(*struc)); + break; + + case IS_STRING: { + if (options->no_decoration) { + xdebug_str_add_zstr(str, Z_STR_P(*struc)); + } else if ((size_t) Z_STRLEN_P(*struc) <= (size_t) options->max_data) { + zend_string *tmp_zstr; + + tmp_zstr = php_addcslashes(Z_STR_P(*struc), (char*) "'\\\0..\37", 7); + + xdebug_str_addc(str, '\''); + xdebug_str_add_zstr(str, tmp_zstr); + xdebug_str_addc(str, '\''); + + zend_string_release(tmp_zstr); + } else { + zend_string *tmp_zstr = php_addcslashes_str(ZSTR_VAL(Z_STR_P(*struc)), options->max_data, (char*) "'\\\0..\37", 7);
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/var_export_line.h
Changed
(renamed from xdebug-3.2.0/src/lib/var_export_line.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/var_export_text.c
Added
@@ -0,0 +1,505 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2022 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#include "lib/php-header.h" +#include "ext/standard/php_string.h" +#include "Zend/zend_closures.h" +#if PHP_VERSION_ID >= 80100 +# include "zend_enum.h" +#endif + + +#include "php_xdebug.h" + +#include "var_export_text.h" + +static void xdebug_var_export_text_ansi(zval **struc, xdebug_str *str, int mode, int level, int debug_zval, xdebug_var_export_options *options); +#define xdebug_var_export_text(struc, str, level, debug_zval, options) xdebug_var_export_text_ansi(struc, str, 0, level, debug_zval, options); +#define xdebug_var_export_ansi(struc, str, level, debug_zval, options) xdebug_var_export_text_ansi(struc, str, 1, level, debug_zval, options); + +ZEND_EXTERN_MODULE_GLOBALS(xdebug) + + +/***************************************************************************** +** Plain text/ANSI coloured variable printing routines +*/ + +#define ANSI_COLOR_POINTER (mode == 1 ? "0m" : "") +#define ANSI_COLOR_BOOL (mode == 1 ? "35m" : "") +#define ANSI_COLOR_LONG (mode == 1 ? "32m" : "") +#define ANSI_COLOR_NULL (mode == 1 ? "34m" : "") +#define ANSI_COLOR_DOUBLE (mode == 1 ? "33m" : "") +#define ANSI_COLOR_STRING (mode == 1 ? "31m" : "") +#define ANSI_COLOR_EMPTY (mode == 1 ? "30m" : "") +#define ANSI_COLOR_ARRAY (mode == 1 ? "33m" : "") +#define ANSI_COLOR_OBJECT (mode == 1 ? "31m" : "") +#define ANSI_COLOR_RESOURCE (mode == 1 ? "36m" : "") +#define ANSI_COLOR_MODIFIER (mode == 1 ? "32m" : "") +#define ANSI_COLOR_RESET (mode == 1 ? "0m" : "") +#define ANSI_COLOR_BOLD (mode == 1 ? "1m" : "") +#define ANSI_COLOR_BOLD_OFF (mode == 1 ? "22m" : "") + +static int xdebug_array_element_export_text_ansi(zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, int mode, xdebug_str *str, int debug_zval, xdebug_var_export_options *options) +{ + zval **zv = &zv_nptr; + + if (options->runtimelevel.current_element_nr >= options->runtimelevel.start_element_nr && + options->runtimelevel.current_element_nr < options->runtimelevel.end_element_nr) + { + xdebug_str_add_fmt(str, "%*s", (level * 2), ""); + + if (HASH_KEY_IS_NUMERIC(hash_key)) { /* numeric key */ + xdebug_str_add_fmt(str, "" XDEBUG_INT_FMT " %s=>%s\n", index_key, ANSI_COLOR_POINTER, ANSI_COLOR_RESET); + } else { /* string key */ + zend_string *tmp, *tmp2; + + tmp = php_str_to_str(ZSTR_VAL(hash_key), ZSTR_LEN(hash_key), (char*) "'", 1, (char*) "\\'", 2); + tmp2 = php_str_to_str(ZSTR_VAL(tmp), ZSTR_LEN(tmp), (char*) "\0", 1, (char*) "\\0", 2); + if (tmp) { + zend_string_release(tmp); + } + xdebug_str_addc(str, '\''); + if (tmp2) { + xdebug_str_add_zstr(str, tmp2); + zend_string_release(tmp2); + } + xdebug_str_add_literal(str, "' =>\n"); + } + xdebug_var_export_text_ansi(zv, str, mode, level + 1, debug_zval, options); + } + if (options->runtimelevel.current_element_nr == options->runtimelevel.end_element_nr) { + xdebug_str_add_fmt(str, "\n%*s(more elements)...\n", (level * 2), ""); + } + options->runtimelevel.current_element_nr++; + return 0; +} + +static int xdebug_object_element_export_text_ansi(zval *object, zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, int mode, xdebug_str *str, int debug_zval, xdebug_var_export_options *options) +{ + zval **zv = &zv_nptr; + + if (options->runtimelevel.current_element_nr >= options->runtimelevel.start_element_nr && + options->runtimelevel.current_element_nr < options->runtimelevel.end_element_nr) + { + xdebug_str_add_fmt(str, "%*s", (level * 2), ""); + + if (!HASH_KEY_IS_NUMERIC(hash_key)) { + char *class_name; + xdebug_str *property_name; + const char *modifier; + xdebug_str *property_type = NULL; + + property_type = xdebug_get_property_type(object, zv_nptr); + + property_name = xdebug_get_property_info((char*) HASH_APPLY_KEY_VAL(hash_key), HASH_APPLY_KEY_LEN(hash_key), &modifier, &class_name); + xdebug_str_add_fmt( + str, "%s%s%s%s%s%s%s $", + ANSI_COLOR_MODIFIER, ANSI_COLOR_BOLD, modifier, ANSI_COLOR_BOLD_OFF, property_type ? " " : "", property_type ? property_type->d : "", ANSI_COLOR_RESET + ); + xdebug_str_add_str(str, property_name); + xdebug_str_add_fmt(str, " %s=>%s\n", ANSI_COLOR_POINTER, ANSI_COLOR_RESET); + + if (property_type) { + xdebug_str_free(property_type); + } + xdebug_str_free(property_name); + xdfree(class_name); + } else { + xdebug_str_add_fmt(str, "%s%spublic%s%s ${" XDEBUG_INT_FMT "} %s=>%s\n", + ANSI_COLOR_MODIFIER, ANSI_COLOR_BOLD, ANSI_COLOR_BOLD_OFF, ANSI_COLOR_RESET, + index_key, ANSI_COLOR_POINTER, ANSI_COLOR_RESET + ); + } + xdebug_var_export_text_ansi(zv, str, mode, level + 1, debug_zval, options); + } + if (options->runtimelevel.current_element_nr == options->runtimelevel.end_element_nr) { + xdebug_str_add_fmt(str, "\n%*s(more elements)...\n", (level * 2), ""); + } + options->runtimelevel.current_element_nr++; + return 0; +} + +#if PHP_VERSION_ID < 80200 +static void handle_closure(xdebug_str *str, zval *obj, int level, int mode) +{ + const zend_function *closure_function; + + if (Z_TYPE_P(obj) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(obj), zend_ce_closure)) { + return; + } + + closure_function = zend_get_closure_method_def(Z_OBJ_P(obj)); + + xdebug_str_add_fmt( + str, "%*s%s%svirtual%s $closure =>\n%*s\"", + (level * 4) - 2, "", + ANSI_COLOR_MODIFIER, ANSI_COLOR_BOLD, ANSI_COLOR_RESET, + (level * 4) - 2, "" + ); + + if (closure_function->common.scope) { + if (closure_function->common.fn_flags & ZEND_ACC_STATIC) { + xdebug_str_add_fmt(str, "%s", ANSI_COLOR_OBJECT); + xdebug_str_add_zstr(str, closure_function->common.scope->name); + xdebug_str_add_fmt(str, "%s::", ANSI_COLOR_RESET); + } else { + xdebug_str_add_fmt(str, "%s$this%s->", ANSI_COLOR_OBJECT, ANSI_COLOR_RESET); + } + } + + xdebug_str_add_fmt(str, "%s", ANSI_COLOR_STRING); + xdebug_str_add_zstr(str, closure_function->common.function_name); + xdebug_str_add_fmt(str, "%s\"\n", ANSI_COLOR_RESET); +} +#endif + +static void xdebug_var_export_text_ansi(zval **struc, xdebug_str *str, int mode, int level, int debug_zval, xdebug_var_export_options *options) +{ + HashTable *myht; + char* tmp_str; + int tmp_len; + zend_ulong num; + zend_string *key; + zval *val; + zval *tmpz; + int z_type; + + if (!struc || !(*struc)) { + return; + } + + xdebug_str_add_fmt(str, "%*s", (level * 2) - 2, ""); + + z_type = Z_TYPE_P(*struc); + + if (debug_zval) { + xdebug_add_variable_attributes(str, *struc, XDEBUG_VAR_ATTR_TEXT); + } + if (z_type == IS_INDIRECT) { + tmpz = Z_INDIRECT_P(*struc); + struc = &tmpz; + z_type = Z_TYPE_P(*struc); + } + if (z_type == IS_REFERENCE) { + tmpz = &((*struc)->value.ref->val); + struc = &tmpz; + z_type = Z_TYPE_P(*struc);
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/var_export_text.h
Changed
(renamed from xdebug-3.2.0/src/lib/var_export_text.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/var_export_xml.c
Added
@@ -0,0 +1,827 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#include "var_export_xml.h" +#include "Zend/zend_closures.h" + +static xdebug_str *prepare_variable_name(xdebug_str *name) +{ + xdebug_str *tmp_name; + + if (name->d0 == '$' || name->d0 == ':') { + tmp_name = xdebug_str_copy(name); + } else { + tmp_name = xdebug_str_new(); + xdebug_str_addc(tmp_name, '$'); + xdebug_str_add_str(tmp_name, name); + } + if (tmp_name->dtmp_name->l - 2 == ':' && tmp_name->dtmp_name->l - 1 == ':') { + xdebug_str_chop(tmp_name, 2); + } + return tmp_name; +} + +/* + * Returns whether we should attempt to encode name, fullname, and value as XML + * elements instead of attribute values, because XML doesn't support nearly all + * characters under ASCII 0x32. + */ +static int encoding_requested(char *value, size_t value_len) +{ + size_t i; + + for (i = 0; i < value_len; i++) { + if (valuei < 0x20) { + return 1; + } + } + return 0; +} + +static void check_if_extended_properties_are_needed(xdebug_var_export_options *options, xdebug_str *name, xdebug_str *fullname, zval *value) +{ + if (!options->extended_properties || options->encode_as_extended_property) { + return; + } + + /* Checking name */ + if (name && encoding_requested(name->d, name->l)) { + options->encode_as_extended_property = 1; + return; + } + + /* Checking full name */ + if (fullname && encoding_requested(fullname->d, fullname->l)) { + options->encode_as_extended_property = 1; + return; + } + + /* Checking for the value portion */ + if (!value) { + return; + } + if (Z_TYPE_P(value) == IS_STRING) { + if (encoding_requested(Z_STRVAL_P(value), Z_STRLEN_P(value))) { + options->encode_as_extended_property = 1; + return; + } + } + if (Z_TYPE_P(value) == IS_OBJECT) { + if (encoding_requested(STR_NAME_VAL(Z_OBJCE_P(value)->name), STR_NAME_LEN(Z_OBJCE_P(value)->name))) { + options->encode_as_extended_property = 1; + return; + } + } +} + +static void add_xml_attribute_or_element(xdebug_var_export_options *options, xdebug_xml_node *node, const char *field, int field_len, xdebug_str *value) +{ + if (options->encode_as_extended_property || (encoding_requested(value->d, value->l) && options->extended_properties)) { + xdebug_xml_node *element; + unsigned char *tmp_base64; + size_t new_len; + + options->encode_as_extended_property = 1; + + element = xdebug_xml_node_init(field); + xdebug_xml_add_attribute(element, "encoding", "base64"); + + tmp_base64 = xdebug_base64_encode((unsigned char*) value->d, value->l, &new_len); + xdebug_xml_add_text_ex(element, (char*) tmp_base64, new_len, 1, 0); + + xdebug_xml_add_child(node, element); + } else { + xdebug_xml_add_attribute_exl(node, field, field_len, xdstrndup(value->d, value->l), value->l, 0, 1); + } +} + +void xdebug_var_xml_attach_uninitialized_var(xdebug_var_export_options *options, xdebug_xml_node *node, xdebug_str *name) +{ + xdebug_xml_node *contents = NULL; + xdebug_str *tmp_name; + + contents = xdebug_xml_node_init("property"); + options->encode_as_extended_property = 0; + + tmp_name = prepare_variable_name(name); + add_xml_attribute_or_element(options, contents, "name", 4, tmp_name); + add_xml_attribute_or_element(options, contents, "fullname", 8, tmp_name); + xdebug_str_free(tmp_name); + + xdebug_xml_add_attribute(contents, "type", "uninitialized"); + xdebug_xml_add_child(node, contents); +} + +/***************************************************************************** +** XML node printing routines +*/ + +#define XDEBUG_OBJECT_ITEM_TYPE_PROPERTY 0 +#define XDEBUG_OBJECT_ITEM_TYPE_STATIC_PROPERTY 1<<0 +#define XDEBUG_OBJECT_ITEM_TYPE_READONLY 1<<1 + + +typedef struct +{ + char type; + char *name; + int name_len; + unsigned long index_key; + zval *zv; +} xdebug_object_item; + +static void merged_hash_object_item_dtor(zval *data) +{ + xdebug_object_item *item = Z_PTR_P(data); + + xdfree(item); +} + +static int object_item_add_to_merged_hash(zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, HashTable *merged, int object_type) +{ + zval **zv = &zv_nptr; + xdebug_object_item *item; + + item = xdcalloc(1, sizeof(xdebug_object_item)); + item->type = object_type; + item->zv = *zv; + + if (hash_key) { + item->name = (char*) HASH_APPLY_KEY_VAL(hash_key); + item->name_len = HASH_APPLY_KEY_LEN(hash_key) - 1; + item->index_key = hash_key->h; + } else { + item->name = xdebug_sprintf(XDEBUG_INT_FMT, index_key); + item->name_len = strlen(item->name); + } + + zend_hash_next_index_insert_ptr(merged, item); + + return 0; +} + +static int object_item_add_zend_prop_to_merged_hash(zend_property_info *zpp, HashTable *merged, int object_type, zend_class_entry *ce) +{ + xdebug_object_item *item; + + if ((zpp->flags & ZEND_ACC_STATIC) == 0) { + return 0; + } + + item = xdmalloc(sizeof(xdebug_object_item)); + item->type = object_type; + item->zv = &CE_STATIC_MEMBERS(ce)zpp->offset; + item->name = (char*) STR_NAME_VAL(zpp->name); + item->name_len = STR_NAME_LEN(zpp->name); + + zend_hash_next_index_insert_ptr(merged, item); + + return 0; +} + +static void add_unencoded_text_value_attribute_or_element(xdebug_var_export_options *options, xdebug_xml_node *node, char *value) +{ + if (options->encode_as_extended_property) { + xdebug_xml_node *element; + unsigned char *tmp_base64;
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/var_export_xml.h
Changed
(renamed from xdebug-3.2.0/src/lib/var_export_xml.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/vector.h
Changed
(renamed from xdebug-3.2.0/src/lib/vector.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/xml.c
Changed
(renamed from xdebug-3.2.0/src/lib/xml.c)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/xml.h
Changed
(renamed from xdebug-3.2.0/src/lib/xml.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/profiler/profiler.c
Added
@@ -0,0 +1,554 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#ifdef PHP_WIN32 +#include <process.h> +#endif + +#include "lib/php-header.h" +#include "TSRM.h" +#include "php_globals.h" +#include "Zend/zend_alloc.h" + +#include "php_xdebug.h" +#include "profiler.h" +#include "profiler_private.h" + +#include "lib/log.h" +#include "lib/mm.h" +#include "lib/str.h" +#include "lib/var.h" +#include "lib/usefulstuff.h" + +ZEND_EXTERN_MODULE_GLOBALS(xdebug) + +int xdebug_profiler_exit_handler(XDEBUG_OPCODE_HANDLER_ARGS); + +void xdebug_init_profiler_globals(xdebug_profiler_globals_t *xg) +{ + xg->active = 0; +} + +void xdebug_profiler_minit(void) +{ + /* Overload the "exit" opcode */ + xdebug_set_opcode_handler(ZEND_EXIT, xdebug_profiler_exit_handler); +} + +void xdebug_profiler_mshutdown(void) +{ +} + +void xdebug_profiler_rinit(void) +{ + xdebug_file_init(&XG_PROF(profile_file)); + XG_PROF(profile_filename_refs) = NULL; + XG_PROF(profile_functionname_refs) = NULL; + XG_PROF(profile_last_filename_ref) = 0; + XG_PROF(php_internal_seen_before) = 0; + XG_PROF(profile_last_functionname_ref) = 0; + XG_PROF(active) = 0; +} + +static void deinit_if_active(void) +{ + if (!XG_PROF(active)) { + return; + } + + xdebug_profiler_deinit(); +} + +void xdebug_profiler_post_deactivate(void) +{ + deinit_if_active(); +} + +void xdebug_profiler_pcntl_exec_handler(void) +{ + deinit_if_active(); +} + +int xdebug_profiler_exit_handler(XDEBUG_OPCODE_HANDLER_ARGS) +{ + const zend_op *cur_opcode = execute_data->opline; + + deinit_if_active(); + + return xdebug_call_original_opcode_handler_if_set(cur_opcode->opcode, XDEBUG_OPCODE_HANDLER_ARGS_PASSTHRU); +} + + +void xdebug_profiler_init_if_requested(zend_op_array *op_array) +{ + if (XG_PROF(active)) { + return; + } + + if (EG(flags) & EG_FLAGS_IN_SHUTDOWN) { + return; + } + + if (xdebug_lib_start_with_request(XDEBUG_MODE_PROFILING) || xdebug_lib_start_with_trigger(XDEBUG_MODE_PROFILING, NULL)) { + xdebug_profiler_init((char*) STR_NAME_VAL(op_array->filename)); + } +} + +void xdebug_profiler_execute_ex(function_stack_entry *fse, zend_op_array *op_array) +{ + if (!XG_PROF(active)) { + return; + } + + /* Calculate all elements for profile entries */ + xdebug_profiler_add_function_details_user(fse, op_array); + xdebug_profiler_function_begin(fse); +} + +void xdebug_profiler_execute_ex_end(function_stack_entry *fse) +{ + xdebug_profiler_function_end(fse); + xdebug_profiler_free_function_details(fse); +} + +void xdebug_profiler_execute_internal(function_stack_entry *fse) +{ + if (!XG_PROF(active)) { + return; + } + + xdebug_profiler_add_function_details_internal(fse); + xdebug_profiler_function_begin(fse); +} + +void xdebug_profiler_execute_internal_end(function_stack_entry *fse) +{ + if (!XG_PROF(active)) { + return; + } + + xdebug_profiler_function_end(fse); + xdebug_profiler_free_function_details(fse); +} + +void xdebug_profile_call_entry_dtor(void *dummy, void *elem) +{ + xdebug_call_entry *ce = elem; + + if (ce->function) { + zend_string_release(ce->function); + } + if (ce->filename) { + zend_string_release(ce->filename); + } + xdfree(ce); +} + +static void profiler_write_header(xdebug_file *file, char *script_name) +{ + if (XINI_PROF(profiler_append)) { + xdebug_file_printf(file, "\n==== NEW PROFILING FILE ==============================================\n"); + } + xdebug_file_printf(file, "version: 1\ncreator: xdebug %s (PHP %s)\n", XDEBUG_VERSION, XG_BASE(php_version_run_time)); + xdebug_file_printf(file, "cmd: %s\npart: 1\npositions: line\n\n", script_name); + xdebug_file_printf(file, "events: Time_(10ns) Memory_(bytes)\n\n"); + xdebug_file_flush(file); +} + +#define NANOTIME_SCALE_10NS(nanotime) ((unsigned long)(((nanotime) + 5) / 10)) + +void xdebug_profiler_init(char *script_name) +{ + char *filename = NULL, *fname = NULL; + char *output_dir = NULL; + + if (XG_PROF(active)) { + return; + } + + if (!strlen(XINI_PROF(profiler_output_name)) || + xdebug_format_output_filename(&fname, XINI_PROF(profiler_output_name), script_name) <= 0 + ) { + /* Invalid or empty xdebug.profiler_output_name */ + return; + } + + /* Add a slash if none is present in the output_dir setting */ + output_dir = xdebug_lib_get_output_dir(); /* not duplicated */ + + if (IS_SLASH(output_dirstrlen(output_dir) - 1)) { + filename = xdebug_sprintf("%s%s", output_dir, fname); + } else { + filename = xdebug_sprintf("%s%c%s", output_dir, DEFAULT_SLASH, fname); + } + + if (!xdebug_file_open(&XG_PROF(profile_file), filename, NULL, XINI_PROF(profiler_append) ? "ab" : "wb")) { + xdebug_log_diagnose_permissions(XLOG_CHAN_PROFILE, output_dir, fname);
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/profiler/profiler.h
Changed
(renamed from xdebug-3.2.0/src/profiler/profiler.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/profiler/profiler_private.h
Added
@@ -0,0 +1,32 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ +#ifndef __XDEBUG_PROFILER_PRIVATE_H__ +#define __XDEBUG_PROFILER_PRIVATE_H__ + +typedef struct _xdebug_call_entry { + int type; /* 0 = function call, 1 = line */ + int user_defined; + zend_string *filename; + zend_string *function; + int lineno; + uint64_t nanotime_taken; + long mem_used; +} xdebug_call_entry; + +#define XG_PROF(v) (XG(globals.profiler.v)) +#define XINI_PROF(v) (XG(settings.profiler.v)) + +#endif
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/tracing/trace_computerized.c
Added
@@ -0,0 +1,274 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ +#include "lib/php-header.h" +#include "ext/standard/php_string.h" + +#include "php_xdebug.h" +#include "tracing_private.h" +#include "trace_computerized.h" + +#include "lib/lib_private.h" +#include "lib/var_export_line.h" + +extern ZEND_DECLARE_MODULE_GLOBALS(xdebug); + +void *xdebug_trace_computerized_init(char *fname, zend_string *script_filename, long options) +{ + xdebug_trace_computerized_context *tmp_computerized_context; + + tmp_computerized_context = xdmalloc(sizeof(xdebug_trace_computerized_context)); + tmp_computerized_context->trace_file = xdebug_trace_open_file(fname, script_filename, options); + + if (!tmp_computerized_context->trace_file) { + xdfree(tmp_computerized_context); + return NULL; + } + + return tmp_computerized_context; +} + +void xdebug_trace_computerized_deinit(void *ctxt) +{ + xdebug_trace_computerized_context *context = (xdebug_trace_computerized_context*) ctxt; + + xdebug_file_close(context->trace_file); + xdebug_file_dtor(context->trace_file); + context->trace_file = NULL; + + xdfree(context); +} + +void xdebug_trace_computerized_write_header(void *ctxt) +{ + xdebug_trace_computerized_context *context = (xdebug_trace_computerized_context*) ctxt; + char *str_time; + + xdebug_file_printf(context->trace_file, "Version: %s\n", XDEBUG_VERSION); + xdebug_file_printf(context->trace_file, "File format: 4\n"); + + str_time = xdebug_nanotime_to_chars(xdebug_get_nanotime(), 6); + xdebug_file_printf(context->trace_file, "TRACE START %s\n", str_time); + xdfree(str_time); + + xdebug_file_flush(context->trace_file); +} + +void xdebug_trace_computerized_write_footer(void *ctxt) +{ + xdebug_trace_computerized_context *context = (xdebug_trace_computerized_context*) ctxt; + char *str_time; + uint64_t nanotime; + + nanotime = xdebug_get_nanotime(); + + xdebug_file_printf(context->trace_file, "\t\t\t%F\t", XDEBUG_SECONDS_SINCE_START(nanotime)); + xdebug_file_printf(context->trace_file, "%zu", zend_memory_usage(0)); + xdebug_file_printf(context->trace_file, "\n"); + + str_time = xdebug_nanotime_to_chars(xdebug_get_nanotime(), 6); + xdebug_file_printf(context->trace_file, "TRACE END %s\n\n", str_time); + xdfree(str_time); + + xdebug_file_flush(context->trace_file); +} + +char *xdebug_trace_computerized_get_filename(void *ctxt) +{ + xdebug_trace_computerized_context *context = (xdebug_trace_computerized_context*) ctxt; + + return context->trace_file->name; +} + +static void add_single_value(xdebug_str *str, zval *zv) +{ + xdebug_str *tmp_value = NULL; + + tmp_value = xdebug_get_zval_value_line(zv, 0, NULL); + + if (tmp_value) { + xdebug_str_add_str(str, tmp_value); + xdebug_str_free(tmp_value); + } else { + xdebug_str_add_literal(str, "???"); + } +} + +static void add_arguments(xdebug_str *line_entry, function_stack_entry *fse) +{ + unsigned int j = 0; /* Counter */ + int sent_variables = fse->varc; + + if (sent_variables > 0 && fse->varsent_variables-1.is_variadic && Z_ISUNDEF(fse->varsent_variables-1.data)) { + sent_variables--; + } + + /* Nr of arguments (11) */ + xdebug_str_add_fmt(line_entry, "\t%d", sent_variables); + + /* Arguments (12-...) */ + for (j = 0; j < sent_variables; j++) { + xdebug_str_addc(line_entry, '\t'); + + if (!Z_ISUNDEF(fse->varj.data)) { + add_single_value(line_entry, &(fse->varj.data)); + } else { + xdebug_str_add_literal(line_entry, "???"); + } + } +} + +void xdebug_trace_computerized_function_entry(void *ctxt, function_stack_entry *fse) +{ + xdebug_trace_computerized_context *context = (xdebug_trace_computerized_context*) ctxt; + char *tmp_name; + xdebug_str str = XDEBUG_STR_INITIALIZER; + + xdebug_str_add_fmt(&str, "%d\t", fse->level); + xdebug_str_add_fmt(&str, "%d\t", fse->function_nr); + + tmp_name = xdebug_show_fname(fse->function, XDEBUG_SHOW_FNAME_DEFAULT); + + xdebug_str_add_literal(&str, "0\t"); + xdebug_str_add_fmt(&str, "%F\t", XDEBUG_SECONDS_SINCE_START(fse->nanotime)); + xdebug_str_add_fmt(&str, "%lu\t", fse->memory); + xdebug_str_add_fmt(&str, "%s\t", tmp_name); + if (fse->user_defined == XDEBUG_USER_DEFINED) { + xdebug_str_add_literal(&str, "1\t"); + } else { + xdebug_str_add_literal(&str, "0\t"); + } + xdfree(tmp_name); + + if (fse->function.include_filename) { + if (fse->function.type == XFUNC_EVAL) { + zend_string *escaped; + + escaped = php_addcslashes(fse->function.include_filename, (char*) "'\\\0..\37", 6); + + xdebug_str_addc(&str, '\''); + xdebug_str_add_zstr(&str, escaped); + xdebug_str_addc(&str, '\''); + zend_string_release(escaped); + } else { + xdebug_str_add_zstr(&str, fse->function.include_filename); + } + } + + /* Filename and Lineno (9, 10) */ + xdebug_str_add_fmt(&str, "\t%s\t%d", ZSTR_VAL(fse->filename), fse->lineno); + + if (XINI_TRACE(collect_params)) { + add_arguments(&str, fse); + } + + /* Trailing \n */ + xdebug_str_addc(&str, '\n'); + + xdebug_file_printf(context->trace_file, "%s", str.d); + xdebug_file_flush(context->trace_file); + xdfree(str.d); +} + +void xdebug_trace_computerized_function_exit(void *ctxt, function_stack_entry *fse) +{ + xdebug_trace_computerized_context *context = (xdebug_trace_computerized_context*) ctxt; + xdebug_str str = XDEBUG_STR_INITIALIZER; + + xdebug_str_add_fmt(&str, "%d\t", fse->level); + xdebug_str_add_fmt(&str, "%d\t", fse->function_nr); + + xdebug_str_add_literal(&str, "1\t"); + xdebug_str_add_fmt(&str, "%F\t", XDEBUG_SECONDS_SINCE_START(xdebug_get_nanotime())); + xdebug_str_add_fmt(&str, "%lu\n", zend_memory_usage(0)); + + xdebug_file_printf(context->trace_file, "%s", str.d); + xdebug_file_flush(context->trace_file); + xdfree(str.d);
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/tracing/trace_computerized.h
Changed
(renamed from xdebug-3.2.0/src/tracing/trace_computerized.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/tracing/trace_flamegraph.c
Added
@@ -0,0 +1,281 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ +#include "lib/php-header.h" +#include "ext/standard/php_string.h" + +#include "php_xdebug.h" +#include "tracing_private.h" +#include "trace_flamegraph.h" + +#include "lib/lib_private.h" +#include "lib/var_export_line.h" + +extern ZEND_DECLARE_MODULE_GLOBALS(xdebug); + +static flamegraph_function *fg_function_ctor() +{ + flamegraph_function *ret; + ret = xdmalloc(sizeof(flamegraph_function)); + ret->value = 0; + ret->prefix = NULL; + return ret; +} + +static inline void fg_function_dtor(flamegraph_function *function) +{ + if (function->prefix) { + xdebug_str_free(function->prefix); + } + xdfree(function); +} + +static inline xdebug_str *fg_function_key(const int function_nr) +{ + xdebug_str *key = xdebug_str_new(); + + xdebug_str_add_fmt(key, "%d", function_nr); + + return key; +} + +static inline void fg_function_add(const xdebug_trace_flamegraph_context *context, const int function_nr, const flamegraph_function *function) +{ + xdebug_str *key = fg_function_key(function_nr); + + xdebug_hash_add(context->functions, key->d, key->l, (void*) function); + + xdebug_str_free(key); +} + +static inline flamegraph_function *fg_function_find(const xdebug_trace_flamegraph_context *context, const int function_nr) +{ + flamegraph_function *function = NULL; + xdebug_str *key = fg_function_key(function_nr); + + xdebug_hash_find(context->functions, key->d, key->l, (void*) &function); + + xdebug_str_free(key); + + return function; +} + +static inline void fg_function_delete(const xdebug_trace_flamegraph_context *context, const int function_nr) +{ + xdebug_str *key = fg_function_key(function_nr); + + xdebug_hash_delete(context->functions, key->d, key->l); + + xdebug_str_free(key); +} + +/* Find parent function in xdebug stack, which is Fiber-safe. */ +static inline function_stack_entry *fg_parent_find() +{ + function_stack_entry *parent_fse; + int parent_index = XDEBUG_VECTOR_COUNT(XG_BASE(stack)) - 2; + + parent_fse = xdebug_vector_element_get(XG_BASE(stack), parent_index); + + return parent_fse; +} + +/* This function computes the 'self' cost for a function trace output. By only including the + * 'inclusive' function cost, then in each stack, all functions will have more or less the same + * cost, each top level will have only a few nanosec less than the previous: in this scenario, the + * generated flamegraph will look flat, it will not highlight functions that really did cost a lot. + * The 'self' cost is simply computed by removing children function call cost from its own inclusive + * value. This is true as well for memory cost, in order to identify a potential leak it must + * identify the function that allocated memory, if we don't sub children cost from parent cost, once + * again the generated flamegraph will look linear and it will be harder to deduce which function + * did allocate. */ +static inline int compute_inclusive_value(const xdebug_trace_flamegraph_context *context, const function_stack_entry *fse) +{ + int value = 0, current_mem; + + switch (context->mode) { + case XDEBUG_TRACE_OPTION_FLAMEGRAPH_MEM: + /* We compare with 'memory' because 'prev_memory' is not memory when starting the + * function execution, 'memory' is. */ + current_mem = zend_memory_usage(0); + if (current_mem < fse->memory) { + /* When memory is below 0, flamegraph generator will error, and you won't have a + * good visual. This happens when garbage collection happened during this function + * and freed something it didn't allocate, I guess. */ + value = 0; + } else { + value = current_mem - fse->memory; + } + break; + + case XDEBUG_TRACE_OPTION_FLAMEGRAPH_COST: + value = xdebug_get_nanotime() - fse->nanotime; + break; + } + + return value; +} + +xdebug_trace_flamegraph_context *xdebug_trace_flamegraph_init(char *fname, zend_string *script_filename, int mode, long options) +{ + xdebug_trace_flamegraph_context *tmp_flamegraph_context; + + tmp_flamegraph_context = xdmalloc(sizeof(xdebug_trace_flamegraph_context)); + tmp_flamegraph_context->trace_file = xdebug_trace_open_file(fname, script_filename, options); + + if (!tmp_flamegraph_context->trace_file) { + xdfree(tmp_flamegraph_context); + return NULL; + } + + tmp_flamegraph_context->mode = mode; + tmp_flamegraph_context->functions = xdebug_hash_alloc(64, (xdebug_hash_dtor_t) fg_function_dtor); + + return tmp_flamegraph_context; +} + +void *xdebug_trace_flamegraph_init_cost(char *fname, zend_string *script_filename, long options) +{ + return xdebug_trace_flamegraph_init(fname, script_filename, XDEBUG_TRACE_OPTION_FLAMEGRAPH_COST, options); +} + +void *xdebug_trace_flamegraph_init_mem(char *fname, zend_string *script_filename, long options) +{ + return xdebug_trace_flamegraph_init(fname, script_filename, XDEBUG_TRACE_OPTION_FLAMEGRAPH_MEM, options); +} + +void xdebug_trace_flamegraph_deinit(void *ctxt) +{ + xdebug_trace_flamegraph_context *context = (xdebug_trace_flamegraph_context*) ctxt; + + xdebug_file_close(context->trace_file); + xdebug_file_dtor(context->trace_file); + context->trace_file = NULL; + + if (context->functions) { + xdebug_hash_destroy(context->functions); + context->functions = NULL; + } + + xdfree(context); +} + +char *xdebug_trace_flamegraph_get_filename(void *ctxt) +{ + xdebug_trace_flamegraph_context *context = (xdebug_trace_flamegraph_context*) ctxt; + + return context->trace_file->name; +} + +void xdebug_trace_flamegraph_function_entry(void *ctxt, function_stack_entry *fse) +{ + xdebug_trace_flamegraph_context *context = (xdebug_trace_flamegraph_context*) ctxt; + function_stack_entry *parent_fse; + flamegraph_function *function; + flamegraph_function *parent_function; + xdebug_str *prefix = xdebug_str_new(); + char *tmp_name; + + tmp_name = xdebug_show_fname(fse->function, XDEBUG_SHOW_FNAME_ADD_FILE_NAME); + function = fg_function_ctor(); + + parent_fse = fg_parent_find(); + + if (!parent_fse) { + /* No parent means we are top-level, prefix is function name. */ + xdebug_str_add_fmt(prefix, tmp_name); + } else {
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/tracing/trace_flamegraph.h
Added
@@ -0,0 +1,36 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ +#ifndef XDEBUG_TRACE_FLAMEGRAPH_H +#define XDEBUG_TRACE_FLAMEGRAPH_H + +#include "tracing_private.h" + +typedef struct _flamegraph_function +{ + xdebug_str *prefix; + int value; +} flamegraph_function; + +typedef struct _xdebug_trace_flamegraph_context +{ + xdebug_file *trace_file; + int mode; + xdebug_hash *functions; +} xdebug_trace_flamegraph_context; + +extern xdebug_trace_handler_t xdebug_trace_handler_flamegraph_cost; +extern xdebug_trace_handler_t xdebug_trace_handler_flamegraph_mem; +#endif
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/tracing/trace_html.c
Added
@@ -0,0 +1,136 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ +#include "lib/php-header.h" + +#include "php_xdebug.h" +#include "tracing_private.h" +#include "trace_html.h" + +#include "lib/var.h" + +extern ZEND_DECLARE_MODULE_GLOBALS(xdebug); + +void *xdebug_trace_html_init(char *fname, zend_string *script_filename, long options) +{ + xdebug_trace_html_context *tmp_html_context; + + tmp_html_context = xdmalloc(sizeof(xdebug_trace_html_context)); + tmp_html_context->trace_file = xdebug_trace_open_file(fname, script_filename, options); + + if (!tmp_html_context->trace_file) { + xdfree(tmp_html_context); + return NULL; + } + + return tmp_html_context; +} + +void xdebug_trace_html_deinit(void *ctxt) +{ + xdebug_trace_html_context *context = (xdebug_trace_html_context*) ctxt; + + xdebug_file_close(context->trace_file); + xdebug_file_dtor(context->trace_file); + context->trace_file = NULL; + + xdfree(context); +} + +void xdebug_trace_html_write_header(void *ctxt) +{ + xdebug_trace_html_context *context = (xdebug_trace_html_context*) ctxt; + + xdebug_file_printf(context->trace_file, "<table style='hyphens: auto; -webkit-hyphens: auto; -ms-hyphens: auto;' class='xdebug-trace' dir='ltr' border='1' cellspacing='0'>\n"); + xdebug_file_printf(context->trace_file, "\t<tr><th>#</th><th>Time</th>"); + xdebug_file_printf(context->trace_file, "<th>Mem</th>"); + xdebug_file_printf(context->trace_file, "<th colspan='2'>Function</th><th>Location</th></tr>\n"); + xdebug_file_flush(context->trace_file); +} + +void xdebug_trace_html_write_footer(void *ctxt) +{ + xdebug_trace_html_context *context = (xdebug_trace_html_context*) ctxt; + + xdebug_file_printf(context->trace_file, "</table>\n"); + xdebug_file_flush(context->trace_file); +} + +char *xdebug_trace_html_get_filename(void *ctxt) +{ + xdebug_trace_html_context *context = (xdebug_trace_html_context*) ctxt; + + return context->trace_file->name; +} + +void xdebug_trace_html_function_entry(void *ctxt, function_stack_entry *fse) +{ + xdebug_trace_html_context *context = (xdebug_trace_html_context*) ctxt; + char *tmp_name; + unsigned int j; + xdebug_str str = XDEBUG_STR_INITIALIZER; + + xdebug_str_add_literal(&str, "\t<tr>"); + xdebug_str_add_fmt(&str, "<td>%d</td>", fse->function_nr); + xdebug_str_add_fmt(&str, "<td>%0.6F</td>", XDEBUG_SECONDS_SINCE_START(fse->nanotime)); + xdebug_str_add_fmt(&str, "<td align='right'>%lu</td>", fse->memory); + xdebug_str_add_literal(&str, "<td align='left'>"); + for (j = 0; j < fse->level - 1; j++) { + xdebug_str_add_literal(&str, " "); + } + xdebug_str_add_literal(&str, "-></td>"); + + tmp_name = xdebug_show_fname(fse->function, XDEBUG_SHOW_FNAME_DEFAULT); + xdebug_str_add_fmt(&str, "<td>%s(", tmp_name); + xdfree(tmp_name); + + if (fse->function.include_filename) { + if (fse->function.type == XFUNC_EVAL) { + xdebug_str *joined; + xdebug_arg *parts; + + parts = xdebug_arg_ctor(); + xdebug_explode("\n", ZSTR_VAL(fse->function.include_filename), parts, 99999); + joined = xdebug_join("<br />", parts, 0, 99999); + xdebug_arg_dtor(parts); + + xdebug_str_add_fmt(&str, "'%s'", joined->d); + xdebug_str_free(joined); + } else { + xdebug_str_add_zstr(&str, fse->function.include_filename); + } + } + + xdebug_str_add_fmt(&str, ")</td><td>%s:%d</td>", ZSTR_VAL(fse->filename), fse->lineno); + xdebug_str_add_literal(&str, "</tr>\n"); + + xdebug_file_printf(context->trace_file, "%s", str.d); + xdebug_file_flush(context->trace_file); + xdfree(str.d); +} + +xdebug_trace_handler_t xdebug_trace_handler_html = +{ + xdebug_trace_html_init, + xdebug_trace_html_deinit, + xdebug_trace_html_write_header, + xdebug_trace_html_write_footer, + xdebug_trace_html_get_filename, + xdebug_trace_html_function_entry, + NULL /* xdebug_trace_html_function_exit */, + NULL /* xdebug_trace_html_function_return_value */, + NULL /* xdebug_trace_html_generator_return_value */, + NULL /* xdebug_trace_html_assignment */ +};
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/tracing/trace_html.h
Changed
(renamed from xdebug-3.2.0/src/tracing/trace_html.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/tracing/trace_textual.c
Added
@@ -0,0 +1,343 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ +#include "lib/php-header.h" +#include "ext/standard/php_string.h" + +#include "php_xdebug.h" +#include "tracing_private.h" +#include "trace_textual.h" + +#include "lib/lib_private.h" +#include "lib/var_export_line.h" + +extern ZEND_DECLARE_MODULE_GLOBALS(xdebug); + +void *xdebug_trace_textual_init(char *fname, zend_string *script_filename, long options) +{ + xdebug_trace_textual_context *tmp_textual_context; + + tmp_textual_context = xdmalloc(sizeof(xdebug_trace_textual_context)); + tmp_textual_context->trace_file = xdebug_trace_open_file(fname, script_filename, options); + + if (!tmp_textual_context->trace_file) { + xdfree(tmp_textual_context); + return NULL; + } + + return tmp_textual_context; +} + +void xdebug_trace_textual_deinit(void *ctxt) +{ + xdebug_trace_textual_context *context = (xdebug_trace_textual_context*) ctxt; + + xdebug_file_close(context->trace_file); + xdebug_file_dtor(context->trace_file); + context->trace_file = NULL; + + xdfree(context); +} + +void xdebug_trace_textual_write_header(void *ctxt) +{ + xdebug_trace_textual_context *context = (xdebug_trace_textual_context*) ctxt; + char *str_time; + + str_time = xdebug_nanotime_to_chars(xdebug_get_nanotime(), 6); + xdebug_file_printf(context->trace_file, "TRACE START %s\n", str_time); + xdfree(str_time); + + xdebug_file_flush(context->trace_file); +} + +void xdebug_trace_textual_write_footer(void *ctxt) +{ + xdebug_trace_textual_context *context = (xdebug_trace_textual_context*) ctxt; + char *str_time; + uint64_t nanotime; + char *tmp; + + nanotime = xdebug_get_nanotime(); + tmp = xdebug_sprintf("%10.4F ", XDEBUG_SECONDS_SINCE_START(nanotime)); + xdebug_file_printf(context->trace_file, "%s", tmp); + xdfree(tmp); + xdebug_file_printf(context->trace_file, "%10zu", zend_memory_usage(0)); + xdebug_file_printf(context->trace_file, "\n"); + + str_time = xdebug_nanotime_to_chars(nanotime, 6); + xdebug_file_printf(context->trace_file, "TRACE END %s\n\n", str_time); + xdfree(str_time); + + xdebug_file_flush(context->trace_file); +} + +char *xdebug_trace_textual_get_filename(void *ctxt) +{ + xdebug_trace_textual_context *context = (xdebug_trace_textual_context*) ctxt; + + return context->trace_file->name; +} + +static void add_single_value(xdebug_str *str, zval *zv) +{ + xdebug_str *tmp_value = NULL; + + tmp_value = xdebug_get_zval_value_line(zv, 0, NULL); + + if (tmp_value) { + xdebug_str_add_str(str, tmp_value); + xdebug_str_free(tmp_value); + } else { + xdebug_str_add_literal(str, "???"); + } +} + +static void add_arguments(xdebug_str *line_entry, function_stack_entry *fse) +{ + unsigned int j = 0; /* Counter */ + int c = 0; /* Comma flag */ + int variadic_opened = 0; + int variadic_count = 0; + int sent_variables = fse->varc; + + if (sent_variables > 0 && fse->varsent_variables-1.is_variadic && Z_ISUNDEF(fse->varsent_variables-1.data)) { + sent_variables--; + } + + for (j = 0; j < sent_variables; j++) { + if (c) { + xdebug_str_add_literal(line_entry, ", "); + } else { + c = 1; + } + + if (fse->varj.is_variadic) { + xdebug_str_add_literal(line_entry, "..."); + variadic_opened = 1; + c = 0; + } + + if (fse->varj.name) { + xdebug_str_addc(line_entry, '$'); + xdebug_str_add_zstr(line_entry, fse->varj.name); + if (variadic_opened && !fse->varj.is_variadic) { + xdebug_str_add_literal(line_entry, " => "); + } else { + xdebug_str_add_literal(line_entry, " = "); + } + } + + if (fse->varj.is_variadic) { + xdebug_str_add_literal(line_entry, "variadic("); + if (Z_ISUNDEF(fse->varj.data)) { + continue; + } + c = 1; + } + + if (variadic_opened && (!fse->varj.name || fse->varj.is_variadic)) { + xdebug_str_add_fmt(line_entry, "%d => ", variadic_count++); + } + + if (!Z_ISUNDEF(fse->varj.data)) { + add_single_value(line_entry, &fse->varj.data); + } else { + xdebug_str_add_literal(line_entry, "???"); + } + } + + if (variadic_opened) { + xdebug_str_addc(line_entry, ')'); + } +} + +void xdebug_trace_textual_function_entry(void *ctxt, function_stack_entry *fse) +{ + xdebug_trace_textual_context *context = (xdebug_trace_textual_context*) ctxt; + unsigned int j = 0; /* Counter */ + char *tmp_name; + xdebug_str str = XDEBUG_STR_INITIALIZER; + + tmp_name = xdebug_show_fname(fse->function, XDEBUG_SHOW_FNAME_DEFAULT); + + xdebug_str_add_fmt(&str, "%10.4F ", XDEBUG_SECONDS_SINCE_START(fse->nanotime)); + xdebug_str_add_fmt(&str, "%10lu ", fse->memory); + for (j = 0; j < fse->level; j++) { + xdebug_str_add_literal(&str, " "); + } + xdebug_str_add_fmt(&str, "-> %s(", tmp_name); + + xdfree(tmp_name); + + if (XINI_TRACE(collect_params)) { + add_arguments(&str, fse); + } + + if (fse->function.include_filename) { + if (fse->function.type == XFUNC_EVAL) { + zend_string *escaped; + + escaped = php_addcslashes(fse->function.include_filename, (char*) "'\\\0..\37", 6); + + xdebug_str_addc(&str, '\''); + xdebug_str_add_zstr(&str, escaped); + xdebug_str_addc(&str, '\''); + zend_string_release(escaped); + } else {
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/tracing/trace_textual.h
Changed
(renamed from xdebug-3.2.0/src/tracing/trace_textual.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/tracing/tracing.c
Added
@@ -0,0 +1,784 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ +#include "lib/php-header.h" +#include "ext/standard/php_string.h" + +#include "php_xdebug.h" +#include "tracing_private.h" +#include "trace_textual.h" +#include "trace_flamegraph.h" +#include "trace_computerized.h" +#include "trace_html.h" + +#include "lib/compat.h" +#include "lib/log.h" +#include "lib/str.h" +#include "lib/var_export_line.h" + +ZEND_EXTERN_MODULE_GLOBALS(xdebug) + +static xdebug_trace_handler_t *xdebug_select_trace_handler(int options) +{ + xdebug_trace_handler_t *tmp; + + switch (XINI_TRACE(trace_format)) { + case 0: tmp = &xdebug_trace_handler_textual; break; + case 1: tmp = &xdebug_trace_handler_computerized; break; + case 2: tmp = &xdebug_trace_handler_html; break; + case 3: tmp = &xdebug_trace_handler_flamegraph_cost; break; + case 4: tmp = &xdebug_trace_handler_flamegraph_mem; break; + default: + php_error(E_NOTICE, "A wrong value for xdebug.trace_format was selected (%d), defaulting to the textual format", (int) XINI_TRACE(trace_format)); + tmp = &xdebug_trace_handler_textual; break; + } + + /* Override handler based on options */ + if (options & XDEBUG_TRACE_OPTION_FLAMEGRAPH_COST) { + tmp = &xdebug_trace_handler_flamegraph_cost; + } + if (options & XDEBUG_TRACE_OPTION_FLAMEGRAPH_MEM) { + tmp = &xdebug_trace_handler_flamegraph_mem; + } + if (options & XDEBUG_TRACE_OPTION_COMPUTERIZED) { + tmp = &xdebug_trace_handler_computerized; + } + if (options & XDEBUG_TRACE_OPTION_HTML) { + tmp = &xdebug_trace_handler_html; + } + + if (!tmp->init || !tmp->deinit || !tmp->get_filename) { + xdebug_log_ex(XLOG_CHAN_TRACE, XLOG_CRIT, "HNDLR", "Broken trace handler for format '%d', missing 'init', 'deinit', or 'get_filename' handler", options); + } + + return tmp; +} + +xdebug_file *xdebug_trace_open_file(char *requested_filename, zend_string *script_filename, long options) +{ + xdebug_file *file = xdebug_file_ctor(); + char *filename_to_use; + char *generated_filename = NULL; + char *output_dir = xdebug_lib_get_output_dir(); /* not duplicated */ + + if (requested_filename && strlen(requested_filename)) { + filename_to_use = xdstrdup(requested_filename); + } else { + + if (!strlen(XINI_TRACE(trace_output_name)) || + xdebug_format_output_filename(&generated_filename, XINI_TRACE(trace_output_name), ZSTR_VAL(script_filename)) <= 0 + ) { + /* Invalid or empty xdebug.trace_output_name */ + xdebug_file_dtor(file); + return NULL; + } + + /* Add a slash if none is present in the output_dir setting */ + output_dir = xdebug_lib_get_output_dir(); /* not duplicated */ + + if (IS_SLASH(output_dirstrlen(output_dir) - 1)) { + filename_to_use = xdebug_sprintf("%s%s", output_dir, generated_filename); + } else { + filename_to_use = xdebug_sprintf("%s%c%s", output_dir, DEFAULT_SLASH, generated_filename); + } + } + + if (!xdebug_file_open( + file, + filename_to_use, + (options & XDEBUG_TRACE_OPTION_NAKED_FILENAME) ? NULL : "xt", + (options & XDEBUG_TRACE_OPTION_APPEND) ? "ab" : "wb" + )) { + xdebug_log_diagnose_permissions(XLOG_CHAN_TRACE, output_dir, generated_filename); + } + + if (generated_filename) { + xdfree(generated_filename); + } + xdfree(filename_to_use); + + return file; +} + +static char* xdebug_start_trace(char* fname, zend_string *script_filename, long options) +{ + if (XG_TRACE(trace_context)) { + return NULL; + } + + XG_TRACE(trace_handler) = xdebug_select_trace_handler(options); + if (!XG_TRACE(trace_handler)) { + return NULL; + } + + XG_TRACE(trace_context) = (void*) XG_TRACE(trace_handler)->init(fname, script_filename, options); + if (!XG_TRACE(trace_context)) { + return NULL; + } + + if (XG_TRACE(trace_handler)->write_header) { + XG_TRACE(trace_handler)->write_header(XG_TRACE(trace_context)); + } + + return xdstrdup(XG_TRACE(trace_handler)->get_filename(XG_TRACE(trace_context))); +} + +static void xdebug_stop_trace(void) +{ + if (!XG_TRACE(trace_context)) { + return; + } + + if (XG_TRACE(trace_handler)->write_footer) { + XG_TRACE(trace_handler)->write_footer(XG_TRACE(trace_context)); + } + XG_TRACE(trace_handler)->deinit(XG_TRACE(trace_context)); + XG_TRACE(trace_context) = NULL; +} + +char *xdebug_get_trace_filename(void) +{ + if (!(XG_TRACE(trace_context) && XG_TRACE(trace_handler) && XG_TRACE(trace_handler)->get_filename)) { + return NULL; + } + + return XG_TRACE(trace_handler)->get_filename(XG_TRACE(trace_context)); +} + +PHP_FUNCTION(xdebug_start_trace) +{ + char *fname = NULL; + size_t fname_len = 0; + char *trace_fname; + zend_long options = XINI_TRACE(trace_options); + function_stack_entry *fse; + + WARN_AND_RETURN_IF_MODE_IS_NOT(XDEBUG_MODE_TRACING); + + if (XG_TRACE(trace_context)) { + php_error(E_NOTICE, "Function trace already started"); + RETURN_FALSE; + } + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|sl", &fname, &fname_len, &options) == FAILURE) { + return; + } + + fse = xdebug_get_stack_frame(0); + + if ((trace_fname = xdebug_start_trace(fname, fse->filename, options)) != NULL) { + RETVAL_STRING(trace_fname); + xdfree(trace_fname); + return; + } else { + php_error(E_NOTICE, "Trace could not be started"); + } + + RETURN_FALSE; +} + +PHP_FUNCTION(xdebug_stop_trace) +{ + WARN_AND_RETURN_IF_MODE_IS_NOT(XDEBUG_MODE_TRACING); + + if (!XG_TRACE(trace_context)) { + php_error(E_NOTICE, "Function trace was not started"); + RETURN_FALSE; + }
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/tracing/tracing.h
Added
@@ -0,0 +1,78 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ +#ifndef XDEBUG_TRACING_H +#define XDEBUG_TRACING_H + +#include "lib/php-header.h" + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeclaration-after-statement" +#include "zend_generators.h" +#pragma GCC diagnostic pop + +typedef struct +{ + void *(*init)(char *fname, zend_string *script_filename, long options); + void (*deinit)(void *ctxt); + void (*write_header)(void *ctxt); + void (*write_footer)(void *ctxt); + char *(*get_filename)(void *ctxt); + void (*function_entry)(void *ctxt, function_stack_entry *fse); + void (*function_exit)(void *ctxt, function_stack_entry *fse); + void (*return_value)(void *ctxt, function_stack_entry *fse, zval *return_value); + void (*generator_return_value)(void *ctxt, function_stack_entry *fse, zend_generator *generator); + void (*assignment)(void *ctxt, function_stack_entry *fse, char *full_varname, zval *value, char *right_full_varname, const char *op, char *file, int lineno); +} xdebug_trace_handler_t; + +typedef struct _xdebug_tracing_globals_t { + xdebug_trace_handler_t *trace_handler; + void *trace_context; +} xdebug_tracing_globals_t; + +typedef struct _xdebug_tracing_settings_t { + char *trace_output_name; + zend_long trace_options; + zend_long trace_format; + + zend_bool collect_assignments; + zend_bool collect_params; + zend_bool collect_return; +} xdebug_tracing_settings_t; + +void xdebug_init_tracing_globals(xdebug_tracing_globals_t *xg); +void xdebug_tracing_minit(INIT_FUNC_ARGS); +void xdebug_tracing_rinit(void); +void xdebug_tracing_post_deactivate(void); +void xdebug_tracing_register_constants(INIT_FUNC_ARGS); + +void xdebug_tracing_init_if_requested(zend_op_array *op_array); +void xdebug_tracing_execute_ex(function_stack_entry *fse); +void xdebug_tracing_execute_ex_end(function_stack_entry *fse, zend_execute_data *execute_data, zval *return_value); +int xdebug_tracing_execute_internal(function_stack_entry *fse); +void xdebug_tracing_execute_internal_end(function_stack_entry *fse, zval *return_value); + +void xdebug_tracing_save_trace_context(void **old_trace_context); +void xdebug_tracing_restore_trace_context(void *old_trace_context); + +char* xdebug_return_trace_stack_retval(function_stack_entry* i, int fnr, zval* retval); +char* xdebug_return_trace_stack_generator_retval(function_stack_entry* i, zend_generator* generator); +char* xdebug_return_trace_assignment(function_stack_entry *i, char *varname, zval *retval, char *op, char *file, int fileno); + +void xdebug_trace_function_begin(function_stack_entry *fse); +void xdebug_trace_function_end(function_stack_entry *fse); + +char *xdebug_get_trace_filename(void); +#endif
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/tracing/tracing_private.h
Changed
(renamed from xdebug-3.2.0/src/tracing/tracing_private.h)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/xdebug.c
Added
@@ -0,0 +1,852 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "lib/php-header.h" +#include "main/php_version.h" +#include "lib/compat.h" + +#if HAVE_XDEBUG + +#ifndef PHP_WIN32 +#include <sys/time.h> +#include <unistd.h> +#else +#include "win32/time.h" +#include <process.h> +#endif + +#include "TSRM.h" +#include "SAPI.h" +#include "zend_extensions.h" +#include "main/php_ini.h" +#include "ext/standard/head.h" +#include "ext/standard/html.h" +#include "ext/standard/info.h" +#include "ext/standard/php_string.h" +#include "php_globals.h" +#include "main/php_output.h" +#include "ext/standard/php_var.h" + +#include "php_xdebug.h" +#include "php_xdebug_arginfo.h" + +#include "base/base.h" +#ifdef __linux__ +# include "base/ctrl_socket.h" +#endif +#include "base/filter.h" +#include "coverage/code_coverage.h" +#include "develop/monitor.h" +#include "develop/stack.h" +#include "develop/superglobals.h" +#include "debugger/com.h" +#include "gcstats/gc_stats.h" +#include "lib/usefulstuff.h" +#include "lib/lib.h" +#include "lib/llist.h" +#include "lib/log.h" +#include "lib/mm.h" +#include "lib/var_export_html.h" +#include "lib/var_export_line.h" +#include "lib/var_export_text.h" +#include "profiler/profiler.h" +#include "tracing/tracing.h" + +static zend_result (*xdebug_orig_post_startup_cb)(void); +static zend_result xdebug_post_startup(void); + +int xdebug_include_or_eval_handler(zend_execute_data *execute_data); + +/* True globals */ +int zend_xdebug_initialised = 0; +int xdebug_global_mode = 0; + +zend_module_entry xdebug_module_entry = { + STANDARD_MODULE_HEADER, + "xdebug", + ext_functions, + PHP_MINIT(xdebug), + PHP_MSHUTDOWN(xdebug), + PHP_RINIT(xdebug), + PHP_RSHUTDOWN(xdebug), + PHP_MINFO(xdebug), + XDEBUG_VERSION, + NO_MODULE_GLOBALS, + ZEND_MODULE_POST_ZEND_DEACTIVATE_N(xdebug), + STANDARD_MODULE_PROPERTIES_EX +}; + +ZEND_DECLARE_MODULE_GLOBALS(xdebug) + +#if COMPILE_DL_XDEBUG +ZEND_GET_MODULE(xdebug) +# ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE(); +# endif +#endif + +static PHP_INI_MH(OnUpdateServer) +{ + DUMP_TOK(server); +} + +static PHP_INI_MH(OnUpdateGet) +{ + DUMP_TOK(get); +} + +static PHP_INI_MH(OnUpdatePost) +{ + DUMP_TOK(post); +} + +static PHP_INI_MH(OnUpdateCookie) +{ + DUMP_TOK(cookie); +} + +static PHP_INI_MH(OnUpdateFiles) +{ + DUMP_TOK(files); +} + +static PHP_INI_MH(OnUpdateEnv) +{ + DUMP_TOK(env); +} + +static PHP_INI_MH(OnUpdateRequest) +{ + DUMP_TOK(request); +} + +static PHP_INI_MH(OnUpdateSession) +{ + DUMP_TOK(session); +} + +static PHP_INI_MH(OnUpdateStartWithRequest) +{ + if (!new_value) { + return FAILURE; + } + + if (!xdebug_lib_set_start_with_request(ZSTR_VAL(new_value))) { + return FAILURE; + } + + return SUCCESS; +} + +static PHP_INI_MH(OnUpdateStartUponError) +{ + if (!new_value) { + return FAILURE; + } + + if (!xdebug_lib_set_start_upon_error(ZSTR_VAL(new_value))) { + return FAILURE; + } + + return SUCCESS; +} + +static PHP_INI_MH(OnUpdateRemovedSetting) +{ + if (! (EG(error_reporting) & E_DEPRECATED)) { + return SUCCESS; + } + if (new_value && ZSTR_LEN(new_value) > 0 && strncmp("This setting", ZSTR_VAL(new_value), 11) != 0) { + xdebug_log_ex( + XLOG_CHAN_CONFIG, XLOG_CRIT, "REMOVED", + "The setting '%s' has been removed, see the upgrading guide at %supgrade_guide#changed-%s", + ZSTR_VAL(entry->name), xdebug_lib_docs_base(), ZSTR_VAL(entry->name) + ); + } + return FAILURE; +} + +static PHP_INI_MH(OnUpdateChangedSetting) +{ + if (! (EG(error_reporting) & E_DEPRECATED)) { + return SUCCESS; + } + if (new_value && ZSTR_LEN(new_value) > 0 && strncmp("This setting", ZSTR_VAL(new_value), 11) != 0) { + xdebug_log_ex( + XLOG_CHAN_CONFIG, XLOG_CRIT, "CHANGED", + "The setting '%s' has been renamed, see the upgrading guide at %supgrade_guide#changed-%s", + ZSTR_VAL(entry->name), xdebug_lib_docs_base(), ZSTR_VAL(entry->name) + ); + } + return FAILURE; +}
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/xdebug.ini
Added
@@ -0,0 +1,1275 @@ +; This file is generated by the 'xdebug.org:html/docs/convert.php' robot +; for Xdebug 3.3.2 — do not modify by hand + +; ----------------------------------------------------------------------------- +; xdebug.cli_color +; +; Type: integer, Default value: 0 +; +; If this setting is 1, Xdebug will color var_dumps and stack traces output when +; in CLI mode and when the output is a tty. On Windows, the ANSICON 1 tool +; needs to be installed. +; +; 1 http://adoxa.altervista.org/ansicon/ +; +; If the setting is 2, then Xdebug will always color var_dumps and stack trace, +; no matter whether it's connected to a tty or whether ANSICON is installed. In +; this case, you might end up seeing escape codes. +; +; See this article 1 for some more information. +; +; 1 https://derickrethans.nl/cli-color.html +; +; .. note:: +; +; This setting can additionally be configured through the +; ``XDEBUG_CONFIG``environment variable 1. 1 +; /docs/all_settings#XDEBUG_CONFIG +; +; +;xdebug.cli_color = 0 + +; ----------------------------------------------------------------------------- +; xdebug.client_discovery_header +; +; Type: string, Default value: "HTTP_X_FORWARDED_FOR,REMOTE_ADDR" +; +; If xdebug.client_discovery_header is configured to be a non-empty string, then +; the value is used as key in the ``$_SERVER`` superglobal array to determine +; which header to use to find the IP address or hostname to use for 'connecting +; back to'. This setting is only used in combination with +; xdebug.discover_client_host and is otherwise ignored. +; +; For example, if xdebug.client_discovery_header is set to +; ``HTTP_FORWARD_HOST``, then Xdebug will check +; ``$_SERVER'HTTP_FORWARD_HOST'`` to obtain the IP address to use for +; 'connecting back'. +; +; It is possible to configure multiple fallbacks by using a comma separated list +; of values. For example if you want to use ``HTTP_FORWARD_HOST`` first, and +; then also want to check ``REMOTE_ADDR``, then you set +; xdebug.client_discovery_header to ``HTTP_FORWARD_HOST,REMOTE_ADDR``. +; +; .. warning:: +; +; PHP automatically prepends ``HTTP_``, and converts ``-`` to ``_``, for +; received HTTP header names. The ``THIS-IS-MY-HOST`` HTTP header is +; converted into ``$_SERVER'HTTP_THIS_IS_MY_HOST'``. Therefore, the +; xdebug.client_discovery_header needs to be set to ``HTTP_THIS_IS_MY_HOST`` +; to match this. +; +; If you have logging enabled, and set the xdebug.log_level setting to ``10``, +; then Xdebug will list every header, the header value, and the used header (if +; any) when attempting to find the IP address to connect back to. +; +; .. note:: +; +; Xdebug 3.2 and later no longer fall back to the +; ``$_SERVER'HTTP_X_FORWARDED_FOR'`` and ``$_SERVER'REMOTE_ADDR'`` header +; values by default. If you want these headers to be used as well, you +; specifically need to add these to the list of headers, by setting +; xdebug.client_discovery_header to +; ``YOUR_OWN_HEADER,HTTP_X_FORWARDED_FOR,REMOTE_ADDR``. +; +; +;xdebug.client_discovery_header = "HTTP_X_FORWARDED_FOR,REMOTE_ADDR" + +; ----------------------------------------------------------------------------- +; xdebug.client_host +; +; Type: string, Default value: localhost +; +; Configures the IP address or hostname where Xdebug will attempt to connect to +; when initiating a debugging connection. This address should be the address of +; the machine where your IDE or debugging client is listening for incoming +; debugging connections. +; +; On non-Windows platforms, it is also possible to configure a Unix domain +; socket 1 which is supported by only a select view debugging clients. In that +; case, instead of the hostname or IP address, use ``unix:///path/to/sock``. +; +; 1 https://en.wikipedia.org/wiki/Unix_domain_socket +; +; If xdebug.discover_client_host is enabled then Xdebug will only use the value +; of this setting in case Xdebug can not connect to an IDE using the information +; it obtained from HTTP headers. In that case, the value of this setting acts as +; a fallback only. +; +; .. note:: +; +; This setting can additionally be configured through the +; ``XDEBUG_CONFIG``environment variable 1. 1 +; /docs/all_settings#XDEBUG_CONFIG +; +; +;xdebug.client_host = localhost + +; ----------------------------------------------------------------------------- +; xdebug.client_port +; +; Type: integer, Default value: 9003 +; +; The port to which Xdebug tries to connect on the remote host. Port ``9003`` is +; the default for both Xdebug and the Command Line Debug Client. As many clients +; use this port number, it is best to leave this setting unchanged. +; +; .. note:: +; +; This setting can additionally be configured through the +; ``XDEBUG_CONFIG``environment variable 1. 1 +; /docs/all_settings#XDEBUG_CONFIG +; +; +;xdebug.client_port = 9003 + +; ----------------------------------------------------------------------------- +; xdebug.cloud_id +; +; Type: string, Default value: +; +; With this setting you configure Xdebug for use with Xdebug Cloud 1. It needs +; to match one of the tokens from your profile page 2. +; +; 1 https://xdebug.cloud +; 2 https://xdebug.cloud/profile#tokens +; +; Your IDE needs to be configured with the same token for Xdebug and your IDE to +; communicate through Xdebug Cloud. +; +; | In PhpStorm you can find this setting under: +; | File | Settings | PHP | Debug | Xdebug Cloud for Windows and Linux +; | PhpStorm | Preferences | PHP | Debug | Xdebug Cloud for macOS +; +; +;xdebug.cloud_id = + +; ----------------------------------------------------------------------------- +; xdebug.collect_assignments +; +; Type: boolean, Default value: false +; +; This setting, defaulting to 0, controls whether Xdebug should add variable +; assignments to function traces. Assign-by-var ( ``=&``) assignments are +; included too. +; +; +;xdebug.collect_assignments = false + +; ----------------------------------------------------------------------------- +; xdebug.collect_params +; +; Introduced in version 3.3 +; +; Type: boolean, Default value: true +; +; If enabled (default), files created with the Function Trace feature will +; include all arguments to functions and methods. +; +; When disabled, the argument to each function and method will not be present in +; the trace files. +; +; +;xdebug.collect_params = true + +; ----------------------------------------------------------------------------- +; xdebug.collect_return +; +; Type: boolean, Default value: false +; +; This setting, defaulting to 0, controls whether Xdebug should write the return +; value of function calls to the trace files. +; +; +;xdebug.collect_return = false + +; ----------------------------------------------------------------------------- +; xdebug.connect_timeout_ms +; +; Type: integer, Default value: 200 +; +; The amount of time in milliseconds that Xdebug will wait for on an IDE to +; acknowledge an incoming debugging connection. The default value of 200 ms +; should in most cases be enough. In case you often get dropped debugging +; requests, perhaps because you have a high latency network, or a development +; box far away from your IDE, or have a slow firewall, then you can should +; increase this value. +; +; Please note that increasing this value might mean that your requests seem to +; 'hang' in case Xdebug tries to establish a connection, but your IDE is not +; listening.
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.