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 6
View file
php8-xdebug.changes
Changed
@@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Wed Nov 25 15:07:19 UTC 2026 - Angelo Grossini <angelo@intercom.it> + +- update to 3.5.3 + +------------------------------------------------------------------- Mon May 19 07:24:13 UTC 2025 - Angelo Grossini <angelo@intercom.it> - update to 3.4.3
View file
php8-xdebug.spec
Changed
@@ -19,7 +19,7 @@ %define pkg_name xdebug %define pkg_version %{version} Name: php8-%{pkg_name} -Version: 3.4.3 +Version: 3.5.3 Release: 0 Summary: Extended PHP debugger License: PHP-3.0
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/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 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.3:: - - git checkout --track origin/xdebug_3_3 - -Branches --------- - -There are two branches in operation: - -``master`` - This is were all new feature Pull Requests should be targeted at -``xdebug_3_3`` - 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_3`` 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_3`` - 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_3 - -- 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.4.3.tgz/xdebug-3.4.3/README.rst
Deleted
@@ -1,149 +0,0 @@ -Xdebug -====== - -.. image:: https://github.com/xdebug/xdebug/workflows/Build/badge.svg - :target: https://github.com/xdebug/xdebug/actions?query=workflow%3ABuild -.. image:: https://ci.appveyor.com/api/projects/status/glp9xfsmt1p25nkn?svg=true - :target: https://ci.appveyor.com/project/derickr/xdebug -.. image:: https://circleci.com/gh/xdebug/xdebug/tree/master.svg?style=svg - :target: https://circleci.com/gh/xdebug/xdebug - -.. image:: https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg - :target: https://stand-with-ukraine.pp.ua/ - -Xdebug is a debugging tool for PHP. It provides step-debugging and a whole -range of development helpers, such as stack traces, a code profiler, features to -dump the full execution of your script to a file, and more. - -|Repography logo| / Recent activity |Time period| ------ -|recent-activity_timeline| |recent-activity_prs| |recent-activity_words| |recent-activity_users| - -.. |Time period| image:: https://images.repography.com/0/xdebug/xdebug/recent-activity/ef1290ac5bfa674f07dcfa4f915ce6b3_badge.svg - :alt: Time period - :target: https://repography.com -.. |Repography logo| image:: https://images.repography.com/logo.svg - :alt: Repography logo - :target: https://repography.com -.. |recent-activity_timeline| image:: https://images.repography.com/0/xdebug/xdebug/recent-activity/ef1290ac5bfa674f07dcfa4f915ce6b3_timeline.svg - :alt: Timeline graph - :target: https://github.com/xdebug/xdebug/commits -.. |recent-activity_prs| image:: https://images.repography.com/0/xdebug/xdebug/recent-activity/ef1290ac5bfa674f07dcfa4f915ce6b3_prs.svg - :alt: Pull request status graph - :target: https://github.com/xdebug/xdebug/pulls -.. |recent-activity_words| image:: https://images.repography.com/0/xdebug/xdebug/recent-activity/ef1290ac5bfa674f07dcfa4f915ce6b3_words.svg - :alt: Trending topics - :target: https://github.com/xdebug/xdebug/commits -.. |recent-activity_users| image:: https://images.repography.com/0/xdebug/xdebug/recent-activity/ef1290ac5bfa674f07dcfa4f915ce6b3_users.svg - :alt: Top contributors - :target: https://github.com/xdebug/xdebug/graphs/contributors - -Requirements ------------- - -Xdebug requires a `supported version <https://www.php.net/supported-versions.php>`_ of PHP. For -installation it requires the `pecl` tool (available through the `php-pear` -package), unless your Linux distribution has an Xdebug package (`php-xdebug`). - -Installation ------------- - -On most Linux distributions you can install Xdebug through its package -manager. You can also compile from source with the `pecl` tool through `pecl -install xdebug`. The latter also works for MacOS as long as PHP is installed -with Homebrew. - -On Windows, you need to `download <https://xdebug.org/download#releases>`_ a -binary. Use the `Wizard <https://xdebug.org/wizard>`_. - -Unless you have installed Xdebug with a package manager on Linux, you also -need to add the following line to your `php.ini` file, or create a new Xdebug -specific ini file `xdebug.ini` in the `conf.d` directory. In either case, it -needs the following line added:: - - zend_extension=xdebug - -For more extensive installation instructions, see the documentation at -https://xdebug.org/docs/install - -Configuration -------------- - -Most features in Xdebug have to be opted in into. Each feature has a specific -opt-in. For example to use the `step debugger -<https://xdebug.org/docs/remote>`_ you need to set `xdebug.remote_enable=1` in -your configuration file. The step debugger requires an IDE (client), of which -there are many `available <https://xdebug.org/docs/remote#clients>`_. - -The documentation has instructions for each of Xdebug's features: -https://xdebug.org/docs/ and a full list of `settings -<https://xdebug.org/docs/all_settings>`_ is also available there. - -Contributing ------------- - -Xdebug is written in C, and extensive knowledge of PHP's internals is -necessary to be able to contribute. Contributing guidance is available -`separately <https://github.com/xdebug/xdebug/blob/master/CONTRIBUTING.rst>`_. - -Before you begin to contribute, please reach out first. Either through email -(address at the bottom), an issue in the `issue tracker -<https://bugs.xdebug.org>`_ or preferably through IRC on Freenode's #xdebug -channel. - -Testing -------- - -If you are familiar with compiling PHP extension from source, have a local -checkout of Xdebug's GitHub repository, and have compiled Xdebug in that -directory following the instructions under `installation -<https://xdebug.org/docs/install#source>`_ you can run Xdebug's tests by -running:: - - php run-xdebug-tests.php - -The test framework requires that the PHP binary on the path has Xdebug loaded, -with remote debugging enabled through `xdebug.mode=debug`. It is possible -to skip remote debugging tests by exporting the `SKIP_DBGP_TESTS=1` environment -variable. - -The `SKIP_UNPARALLEL_TESTS=1` can be used to skip tests that can not run in -parallel environments, and the `SKIP_SLOW_TESTS=1` environment variable to skip -slow tests. The `OPCACHE` environment variable can either be `yes` or `no` and -controls whether the test framework enables or disables OpCache. - -Licensing ---------- - -Xdebug is released under `The Xdebug License -<https://github.com/xdebug/xdebug/blob/master/LICENSE>`_, which is based on -`The PHP License <https://github.com/php/php-src/blob/master/LICENSE>`_. It is -an Open Source license (though not explicitly endorsed by the Open Source -Initiative). - -Further Reading ---------------- - -Xdebug has extensive documentation on its `website <https://xdebug.org/docs>`_. -There are over a hundred settings and many functions documented. Please have a -look through the wealth of information that Xdebug can provide to make your -every day development with PHP easier. - -Support -------- - -For questions regarding Xdebug, please use `StackOverflow -<https://stackoverflow.com/questions/tagged/xdebug>`_, and tag your question -with `xdebug`. - -You can also find ad-hoc and sporadic support on IRC: ``freenode/#xdebug``. -You can do that with your favourite client, or by using their `webchat -<http://webchat.freenode.net/?channels=#xdebug>`_. - -If you think that you encountered a bug, please file a detailed bug report -at https://bugs.xdebug.org. You are required to create an account, this is -so that you can be contacted for additional information and to keep out -spam. - - -Derick Rethans — derick@xdebug.org
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/config.m4
Deleted
@@ -1,134 +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(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 "80500"; then - AC_MSG_ERROR(not supported. Need a PHP version >= 8.0.0 and < 8.5.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_DEFINE(HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT,1, do have control socket support? ) - 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, do we have zlib support compiled in? ) - , ) - 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.4.3.tgz/xdebug-3.4.3/config.w32
Deleted
@@ -1,58 +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 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"; - - var XDEBUG_PHP_VERSION = 10000 * PHP_VERSION + 100 * PHP_MINOR_VERSION + 1 * PHP_RELEASE_VERSION; - if (XDEBUG_PHP_VERSION < 80000) { - ERROR("not supported. Need a PHP version >= 8.0.0 and < 8.5.0 (found " + XDEBUG_PHP_VERSION + ")"); - } else if (XDEBUG_PHP_VERSION >= 80500) { - ERROR("not supported. Need a PHP version >= 8.0.0 and < 8.5.0 (found " + XDEBUG_PHP_VERSION + ")"); - } else { - MESSAGE("supported (" + XDEBUG_PHP_VERSION + ")"); - } - - 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.4.3.tgz/xdebug-3.4.3/php_xdebug.h
Deleted
@@ -1,111 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2025 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.4.3" -#define XDEBUG_AUTHOR "Derick Rethans" -#define XDEBUG_COPYRIGHT "Copyright (c) 2002-2025 by Derick Rethans" -#define XDEBUG_COPYRIGHT_SHORT "Copyright (c) 2002-2025" -#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.4.3.tgz/xdebug-3.4.3/run-xdebug-tests.php
Deleted
@@ -1,4057 +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.4.3.tgz/xdebug-3.4.3/src/base/base.c
Deleted
@@ -1,1634 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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. | - +----------------------------------------------------------------------+ - */ - -#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" -#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT -# 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; -zif_handler orig_exit_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); -PHP_FUNCTION(xdebug_exit); - - -/* {{{ 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; - - 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); - - /* 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); -} -
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/base/base_globals.h
Deleted
@@ -1,96 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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 __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 working_tsc_clock; /* -1 = unknown, 0 = not available, 1 = available */ - 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; - -#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT - /* 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 { -#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT - 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.4.3.tgz/xdebug-3.4.3/src/base/ctrl_socket.c
Deleted
@@ -1,374 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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. | - +----------------------------------------------------------------------+ - */ - -#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" - -#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT - -#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.4.3.tgz/xdebug-3.4.3/src/coverage/code_coverage.c
Deleted
@@ -1,1268 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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.4.3.tgz/xdebug-3.4.3/src/coverage/code_coverage.h
Deleted
@@ -1,79 +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_CODE_COVERAGE_H__ -#define __XDEBUG_CODE_COVERAGE_H__ - -#include "lib/lib.h" - -typedef struct xdebug_coverage_file { - zend_string *name; - xdebug_hash *lines; - xdebug_hash *functions; /* Used for branch coverage */ - int has_branch_info; -} xdebug_coverage_file; - -typedef struct _xdebug_coverage_globals_t { - zend_bool code_coverage_active; /* Whether code coverage is currently running */ - xdebug_hash *code_coverage_info; /* Stores code coverage information */ - zend_bool code_coverage_unused; - zend_bool code_coverage_dead_code_analysis; - zend_bool code_coverage_branch_check; - int dead_code_analysis_tracker_offset; - long dead_code_last_start_id; - long code_coverage_filter_offset; - size_t prefill_function_count; - size_t prefill_class_count; - zend_string *previous_filename; - xdebug_coverage_file *previous_file; - zend_string *previous_mark_filename; - xdebug_coverage_file *previous_mark_file; - xdebug_path_info *paths_stack; - xdebug_hash *visited_branches; - struct { - unsigned int size; - int *last_branch_nr; - } branches; -} xdebug_coverage_globals_t; - -typedef struct _xdebug_coverage_settings_t { - int dummy; -} xdebug_coverage_settings_t; - -void xdebug_init_coverage_globals(xdebug_coverage_globals_t *xg); -void xdebug_coverage_count_line_if_active(zend_op_array *op_array, zend_string *file, int lineno); -void xdebug_coverage_count_line_if_branch_check_active(zend_op_array *op_array, zend_string *file, int lineno); -void xdebug_coverage_record_if_active(zend_execute_data *execute_data, zend_op_array *op_array); -void xdebug_coverage_compile_file(zend_op_array *op_array); - -int xdebug_coverage_execute_ex(function_stack_entry *fse, zend_op_array *op_array, zend_string **tmp_filename, char **tmp_function_name); -void xdebug_coverage_execute_ex_end(function_stack_entry *fse, zend_op_array *op_array, zend_string *tmp_filename, char *tmp_function_name); -void xdebug_coverage_init_oparray(zend_op_array *op_array); - -void xdebug_coverage_minit(INIT_FUNC_ARGS); -void xdebug_coverage_mshutdown(void); -void xdebug_coverage_rinit(void); -void xdebug_coverage_post_deactivate(void); -void xdebug_coverage_register_constants(INIT_FUNC_ARGS); - -PHP_FUNCTION(xdebug_start_code_coverage); -PHP_FUNCTION(xdebug_stop_code_coverage); -PHP_FUNCTION(xdebug_get_code_coverage); -PHP_FUNCTION(xdebug_code_coverage_started); - -PHP_FUNCTION(xdebug_get_function_count); - -#endif
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/debugger/com.c
Deleted
@@ -1,828 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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.4.3.tgz/xdebug-3.4.3/src/debugger/debugger.c
Deleted
@@ -1,1078 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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.4.3.tgz/xdebug-3.4.3/src/debugger/debugger.h
Deleted
@@ -1,97 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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.4.3.tgz/xdebug-3.4.3/src/debugger/handler_dbgp.c
Deleted
@@ -1,3047 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2025 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.4.3.tgz/xdebug-3.4.3/src/debugger/handler_dbgp.h
Deleted
@@ -1,103 +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/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.4.3.tgz/xdebug-3.4.3/src/debugger/handlers.c
Deleted
@@ -1,85 +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 "com.h" -#include "handlers.h" -#include "handler_dbgp.h" -#include "lib/mm.h" - -xdebug_brk_info *xdebug_brk_info_ctor(void) -{ - xdebug_brk_info *tmp = xdmalloc(sizeof(xdebug_brk_info)); - - tmp->id = -1; - tmp->brk_type = -1; - tmp->resolved = XDEBUG_BRK_UNRESOLVED; - tmp->filename = NULL; - tmp->original_lineno = 0; - tmp->resolved_lineno = 0; - tmp->classname = NULL; - tmp->functionname = NULL; - tmp->function_break_type = 0; - tmp->exceptionname = NULL; - tmp->condition = NULL; - tmp->disabled = 0; - tmp->temporary = 0; - tmp->hit_count = 0; - tmp->hit_value = 0; - tmp->hit_condition = XDEBUG_HIT_DISABLED; - - return tmp; -} - -void xdebug_brk_info_dtor(xdebug_brk_info *brk_info) -{ - if (brk_info->classname) { - xdfree(brk_info->classname); - } - if (brk_info->functionname) { - xdfree(brk_info->functionname); - } - if (brk_info->filename) { - zend_string_release(brk_info->filename); - } - if (brk_info->exceptionname) { - xdfree(brk_info->exceptionname); - } - if (brk_info->condition) { - xdfree(brk_info->condition); - } - xdfree(brk_info); -} - -void xdebug_hash_brk_dtor(xdebug_brk_info *brk_info) -{ - xdebug_brk_info_dtor(brk_info); -} - -void xdebug_llist_brk_dtor(void *dummy, xdebug_brk_info *brk_info) -{ - xdebug_brk_info_dtor(brk_info); -} - -void xdebug_hash_eval_info_dtor(xdebug_eval_info *ei) -{ - ei->refcount--; - - if (ei->refcount == 0) { - zend_string_release(ei->contents); - xdfree(ei); - } -}
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/debugger/handlers.h
Deleted
@@ -1,169 +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; - 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.4.3.tgz/xdebug-3.4.3/src/develop/stack.c
Deleted
@@ -1,1353 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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.4.3.tgz/xdebug-3.4.3/src/lib/cmd_parser.c
Deleted
@@ -1,171 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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.4.3.tgz/xdebug-3.4.3/src/lib/cmd_parser.h
Deleted
@@ -1,46 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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.4.3.tgz/xdebug-3.4.3/src/lib/compat.c
Deleted
@@ -1,446 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans <derick@xdebug.org> | - | (c) 1997-2004 Jim Winstead <jimw@trainedmonkey.com> | - | (c) 1998-2004 Andi Gutmans <andi@zend.com> and | - | Zeev Suraski <zeev@zend.com> | - +----------------------------------------------------------------------+ - | This source file is subject to the following Modified BSD license: | - | | - | Redistribution and use in source and binary forms, with or without | - | modification, are 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 of the author may not be used to endorse or promote | - | products derived from this software without specific prior | - | written permission. | - | | - | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 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 AUTHOR 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. | - +----------------------------------------------------------------------+ - */ - -#include "lib/php-header.h" -#include "main/php_version.h" -#include "compat.h" -#include "zend_extensions.h" - -#include "zend_compile.h" -#include "ext/standard/base64.h" -#include "ext/standard/php_string.h" - -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) -{ - zend_string *new_str; - char *retval; - - new_str = php_str_to_str(haystack, length, (char*) needle, needle_len, (char*) str, str_len); - *new_len = new_str->len; - - retval = estrndup(new_str->val, new_str->len); - - zend_string_release(new_str); - - return retval; -} - -/* {{{ base64 tables */ -static const char base64_table = { - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', - 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', - 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', '\0' -}; - -static const char base64_pad = '='; - -static const short base64_reverse_table256 = { - -2, -2, -2, -2, -2, -2, -2, -2, -2, -1, -1, -2, -2, -1, -2, -2, - -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, - -1, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, 62, -2, -2, -2, 63, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -2, -2, -2, -2, -2, -2, - -2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -2, -2, -2, -2, -2, - -2, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -2, -2, -2, -2, -2, - -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, - -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, - -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, - -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, - -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, - -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, - -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, - -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2 -}; -/* }}} */ - -static unsigned char *xdebug_base64_encode_impl(const unsigned char *in, size_t inl, unsigned char *out) /* {{{ */ -{ - - while (inl > 2) { /* keep going until we have less than 24 bits */ - *out++ = base64_tablein0 >> 2; - *out++ = base64_table((in0 & 0x03) << 4) + (in1 >> 4); - *out++ = base64_table((in1 & 0x0f) << 2) + (in2 >> 6); - *out++ = base64_tablein2 & 0x3f; - - in += 3; - inl -= 3; /* we just handle 3 octets of data */ - } - - /* now deal with the tail end of things */ - if (inl != 0) { - *out++ = base64_tablein0 >> 2; - if (inl > 1) { - *out++ = base64_table((in0 & 0x03) << 4) + (in1 >> 4); - *out++ = base64_table(in1 & 0x0f) << 2; - *out++ = base64_pad; - } else { - *out++ = base64_table(in0 & 0x03) << 4; - *out++ = base64_pad; - *out++ = base64_pad; - } - } - - *out = '\0'; - - return out; -} -/* }}} */ - -static int xdebug_base64_decode_impl(const unsigned char *in, size_t inl, unsigned char *out, size_t *outl, zend_bool strict) /* {{{ */ -{ - int ch; - size_t i = 0, padding = 0, j = *outl; - - /* run through the whole string, converting as we go */ - while (inl-- > 0) { - ch = *in++; - if (ch == base64_pad) { - padding++; - continue; - } - - ch = base64_reverse_tablech; - if (!strict) { - /* skip unknown characters and whitespace */ - if (ch < 0) { - continue; - } - } else { - /* skip whitespace */ - if (ch == -1) { - continue; - } - /* fail on bad characters or if any data follows padding */ - if (ch == -2 || padding) { - goto fail; - } - } - - switch (i % 4) { - case 0: - outj = ch << 2; - break; - case 1: - outj++ |= ch >> 4; - outj = (ch & 0x0f) << 4; - break; - case 2: - outj++ |= ch >>2; - outj = (ch & 0x03) << 6; - break; - case 3: - outj++ |= ch; - break; - } - i++; - } - - /* fail if the input is truncated (only one char in last group) */ - if (strict && i % 4 == 1) { - goto fail; - } - - /* fail if the padding length is wrong (not VV==, VVV=), but accept zero padding - * RFC 4648: "In some circumstances, the use of padding -- is not required" */ - if (strict && padding && (padding > 2 || (i + padding) % 4 != 0)) { - goto fail; - } - - *outl = j; - outj = '\0'; - - return 1; - -fail: - return 0; -} -/* }}} */ -
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/hash.h
Deleted
@@ -1,80 +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_HASH_H__ -#define __XDEBUG_HASH_H__ - -#include <stddef.h> - -#include "llist.h" - -#define XDEBUG_HASH_KEY_IS_STRING 0 -#define XDEBUG_HASH_KEY_IS_NUM 1 - -#define xdebug_ui32 unsigned long - -typedef void (*xdebug_hash_dtor_t)(void *); -typedef int (*xdebug_hash_apply_sorter_t)(const void *le1, const void *le2); - -typedef struct _xdebug_hash { - xdebug_llist **table; - xdebug_hash_dtor_t dtor; - xdebug_hash_apply_sorter_t sorter; - int slots; - size_t size; -} xdebug_hash; - -typedef struct _xdebug_hash_key { - union { - struct { - char *val; - unsigned int len; - } str; - - unsigned long num; - } value; - - int type; -} xdebug_hash_key; - -typedef struct _xdebug_hash_element { - void *ptr; - xdebug_hash_key key; -} xdebug_hash_element; - -/* Helper functions */ -char* xdebug_hash_key_to_str(xdebug_hash_key* key, int* new_len); - -/* Standard functions */ -xdebug_hash *xdebug_hash_alloc(int slots, xdebug_hash_dtor_t dtor); -xdebug_hash *xdebug_hash_alloc_with_sort(int slots, xdebug_hash_dtor_t dtor, xdebug_hash_apply_sorter_t sort_func); -int xdebug_hash_add_or_update(xdebug_hash *h, const char *str_key, unsigned int str_key_len, unsigned long num_key, const void *p); -int xdebug_hash_extended_delete(xdebug_hash *h, const char *str_key, unsigned int str_key_len, unsigned long num_key); -int xdebug_hash_extended_find(xdebug_hash *h, const char *str_key, unsigned int str_key_len, unsigned long num_key, void **p); -void xdebug_hash_apply(xdebug_hash *h, void *user, void (*cb)(void *, xdebug_hash_element *)); -void xdebug_hash_apply_with_argument(xdebug_hash *h, void *user, void (*cb)(void *, xdebug_hash_element *, void *), void *argument); -void xdebug_hash_destroy(xdebug_hash *h); - -#define xdebug_hash_find(h, key, key_len, p) xdebug_hash_extended_find(h, key, key_len, 0, p) -#define xdebug_hash_delete(h, key, key_len) xdebug_hash_extended_delete(h, key, key_len, 0) -#define xdebug_hash_add(h, key, key_len, p) xdebug_hash_add_or_update(h, key, key_len, 0, p) -#define xdebug_hash_update xdebug_hash_add -#define xdebug_hash_index_find(h, key, p) xdebug_hash_extended_find(h, NULL, 0, key, p) -#define xdebug_hash_index_delete(h, key) xdebug_hash_extended_delete(h, NULL, 0, key) -#define xdebug_hash_index_add(h, key, p) xdebug_hash_add_or_update(h, NULL, 0, key, p) -#define xdebug_hash_index_update xdebug_hash_index_add - -#endif /* __XDEBUG_HASH_H__ */
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/headers.c
Deleted
@@ -1,110 +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); - - 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.4.3.tgz/xdebug-3.4.3/src/lib/lib.c
Deleted
@@ -1,882 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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. | - +----------------------------------------------------------------------+ - */ - -#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.4.3.tgz/xdebug-3.4.3/src/lib/lib.h
Deleted
@@ -1,329 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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 __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.4.3.tgz/xdebug-3.4.3/src/lib/log.c
Deleted
@@ -1,946 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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. | - +----------------------------------------------------------------------+ - */ - -#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.4.3.tgz/xdebug-3.4.3/src/lib/log.h
Deleted
@@ -1,55 +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_LIBRARY_LOG_H__ -#define __XDEBUG_LIBRARY_LOG_H__ - -#ifdef ZTS -# include "TSRM.h" -#endif - -#include "lib.h" - -#include "zend.h" -#include "zend_API.h" -#include "compat.h" - -#define XLOG_CRIT 0 -#define XLOG_ERR 1 -#define XLOG_WARN 3 -#define XLOG_COM 5 -#define XLOG_INFO 7 -#define XLOG_DEBUG 10 -#define XLOG_DEFAULT "7" /* as a string, as that's what STD_PHP_INI_ENTRY wants */ - -#define XLOG_CHAN_CONFIG 0 -#define XLOG_CHAN_LOGFILE 1 -#define XLOG_CHAN_DEBUG 2 -#define XLOG_CHAN_GCSTATS 3 -#define XLOG_CHAN_PROFILE 4 -#define XLOG_CHAN_TRACE 5 -#define XLOG_CHAN_COVERAGE 6 -#define XLOG_CHAN_BASE 7 - -extern const char* xdebug_log_prefix11; - -void XDEBUG_ATTRIBUTE_FORMAT(printf, 4, 5) xdebug_log_ex(int channel, int log_level, const char *error_code, const char *fmt, ...); -#define xdebug_log(c,l,f, ...) xdebug_log_ex((c), (l), NULL, (f), ##__VA_ARGS__) -void xdebug_log_diagnose_permissions(int channel, const char *directory, const char *filename); - -char* xdebug_lib_docs_base(void); - -#endif
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/php-header.h
Deleted
@@ -1,20 +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. | - +----------------------------------------------------------------------+ - */ - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeclaration-after-statement" -#include "php.h" -#pragma GCC diagnostic pop
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/str.c
Deleted
@@ -1,265 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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. | - +----------------------------------------------------------------------+ - */ - -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <locale.h> - -#if PHP_VERSION_ID < 80200 -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wdeclaration-after-statement" -# include "zend_smart_str.h" -# pragma GCC diagnostic pop -#endif - -#include "lib/php-header.h" -#include "ext/standard/php_string.h" - -#include "mm.h" -#include "str.h" - -inline static void realloc_if_needed(xdebug_str *xs, int size_to_fit) -{ - if (!xs->a || !xs->l || xs->l + size_to_fit > xs->a - 1) { - xs->d = xdrealloc(xs->d, xs->a + size_to_fit + XDEBUG_STR_PREALLOC); - xs->a = xs->a + size_to_fit + XDEBUG_STR_PREALLOC; - } - if (!xs->l) { - xs->d0 = '\0'; - } -} - -inline static void xdebug_str_internal_addl(xdebug_str *xs, const char *str, int le, int f) -{ - realloc_if_needed(xs, le); - - memcpy(xs->d + xs->l, str, le); - xs->dxs->l + le = '\0'; - xs->l = xs->l + le; - - if (f) { - xdfree((char*) str); - } -} - -void xdebug_str_add(xdebug_str *xs, const char *str, int f) -{ - xdebug_str_internal_addl(xs, str, strlen(str), f); -} - -void xdebug_str_addl(xdebug_str *xs, const char *str, int le, int f) -{ - xdebug_str_internal_addl(xs, str, le, f); -} - -void xdebug_str_add_str(xdebug_str *xs, const xdebug_str *str) -{ - xdebug_str_internal_addl(xs, str->d, str->l, 0); -} - -void xdebug_str_add_zstr(xdebug_str *xs, const zend_string *str) -{ - xdebug_str_internal_addl(xs, ZSTR_VAL(str), ZSTR_LEN(str), 0); -} - -void xdebug_str_addc(xdebug_str *xs, char letter) -{ - realloc_if_needed(xs, 1); - - xs->dxs->l = letter; - xs->dxs->l + 1 = '\0'; - xs->l = xs->l + 1; -} - -void xdebug_str_add_uint64(xdebug_str *xs, uint64_t num) -{ - char buffer21; - char *pos; - int digit; - - pos = &buffer20; - *pos = '\0'; - - do { - digit = num % 10; - num = num / 10; - if (digit < 10) { - *--pos = '0' + digit; - } else { - *--pos = 'a' + digit - 10; - } - } while (num != 0L); - - xdebug_str_internal_addl(xs, pos, &buffer20 - pos, 0); -} - -#if PHP_VERSION_ID >= 80200 -void xdebug_str_add_va_fmt(xdebug_str *xs, const char *fmt, va_list argv) -{ - int size; - int n; - va_list argv_size, argv_copy; - - realloc_if_needed(xs, 1); - size = xs->a - xs->l; - - va_copy(argv_size, argv); - n = vsnprintf(xs->d + xs->l, size, fmt, argv_size); - va_end(argv_size); - if (n > -1 && n < size) { - xs->l += n; - return; - } - - realloc_if_needed(xs, n + 1); - size = xs->a - xs->l; - - va_copy(argv_copy, argv); - n = vsnprintf(xs->d + xs->l, size, fmt, argv_copy); - va_end(argv_copy); - - if (n > -1 && n < size) { - xs->l += n; - return; - } - - assert(0); -} -#else -void xdebug_str_add_va_fmt(xdebug_str *xs, const char *fmt, va_list argv) -{ - smart_str buf = {0}; - - php_printf_to_smart_str(&buf, fmt, argv); - - if (!buf.s) { - return; - } - - xdebug_str_add_zstr(xs, buf.s); - - smart_str_free(&buf); -} -#endif - - -void xdebug_str_add_fmt(xdebug_str *xs, const char *fmt, ...) -{ - va_list args; - - va_start(args, fmt); - xdebug_str_add_va_fmt(xs, fmt, args); - va_end(args); -} - -void xdebug_str_chop(xdebug_str *xs, size_t c) -{ - if (c > xs->l) { - /* Do nothing if the chop amount is larger than the buffer size */ - } else { - xs->l -= c; - xs->dxs->l = '\0'; - } -} - -xdebug_str *xdebug_str_new(void) -{ - xdebug_str *tmp = xdmalloc(sizeof(xdebug_str)); - - tmp->l = 0; - tmp->a = 0; - tmp->d = NULL; - - return tmp; -} - -xdebug_str *xdebug_str_create(const char *c, size_t len) -{ - xdebug_str *tmp = xdebug_str_new(); - - tmp->l = tmp->a = len; - tmp->a++; - tmp->d = xdmalloc(tmp->a); - memcpy(tmp->d, c, tmp->l); - tmp->dtmp->l = '\0';
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/str.h
Deleted
@@ -1,62 +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_STR_H__ -#define __HAVE_XDEBUG_STR_H__ - -#include <stddef.h> - -#include "lib/php-header.h" - -#include "mm.h" - -#define XDEBUG_STR_INITIALIZER { 0, 0, NULL } -#define XDEBUG_STR_PREALLOC 1024 -#define xdebug_str_dtor(str) xdfree(str.d) - -#define XDEBUG_STR_WRAP_CHAR(v) (&((xdebug_str){strlen(v), strlen(v)+1, ((char*)(v))})) - -typedef struct xdebug_str { - size_t l; - size_t a; - char *d; -} xdebug_str; - -void xdebug_str_add(xdebug_str *xs, const char *str, int f); -void xdebug_str_addl(xdebug_str *xs, const char *str, int le, int f); -void xdebug_str_add_str(xdebug_str *xs, const xdebug_str *str); -void xdebug_str_add_zstr(xdebug_str *xs, const zend_string *str); -void xdebug_str_addc(xdebug_str *xs, char letter); -void xdebug_str_add_uint64(xdebug_str *xs, uint64_t num); -void xdebug_str_add_fmt(xdebug_str *xs, const char *fmt, ...); -void xdebug_str_add_va_fmt(xdebug_str *xs, const char *fmt, va_list argv); -#define xdebug_str_add_literal(s,l) xdebug_str_addl((s), (l), sizeof(l)-1, 0) -#define xdebug_str_add_const(s,l) xdebug_str_addl((s), (l), strlen(l), 0) - -void xdebug_str_chop(xdebug_str *xs, size_t c); - -xdebug_str *xdebug_str_new(void); -xdebug_str *xdebug_str_create_from_char(char *c); -#define xdebug_str_create_from_const_char(c) xdebug_str_create_from_char((char*) (c)) -xdebug_str *xdebug_str_create(const char *c, size_t len); -xdebug_str *xdebug_str_copy(xdebug_str *orig); -void xdebug_str_destroy(xdebug_str *s); -void xdebug_str_free(xdebug_str *s); - -char* xdebug_sprintf(const char* fmt, ...); -char* xdebug_strndup(const char *s, int length); - -#endif
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/usefulstuff.c
Deleted
@@ -1,729 +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 <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" - -#if PHP_VERSION_ID >= 80200 -# include "ext/random/php_random.h" -#else -# include "ext/standard/php_lcg.h" -#endif -#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; -}
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/usefulstuff.h
Deleted
@@ -1,43 +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 __HAVE_USEFULSTUFF_H__ -#define __HAVE_USEFULSTUFF_H__ - -#include "php_xdebug.h" -#include "src/lib/compat.h" - -typedef struct xdebug_arg { - int c; - char **args; -} xdebug_arg; - -xdebug_arg *xdebug_arg_ctor(void); -void xdebug_arg_dtor(xdebug_arg *arg); - -xdebug_str* xdebug_join(const char *delim, xdebug_arg *args, int begin, int end); -void xdebug_explode(const char *delim, const char *str, xdebug_arg *args, int limit); -const char* xdebug_memnstr(const char *haystack, const char *needle, int needle_len, const char *end); -char* xdebug_strrstr(const char* haystack, const char* needle); -char *xdebug_trim(const char *str); -char *xdebug_path_to_url(zend_string *fileurl); -char *xdebug_path_from_url(zend_string *fileurl); -FILE *xdebug_fopen(char *fname, const char *mode, const char *extension, char **new_fname); -int xdebug_format_output_filename(char **filename, char *format, char *script_name); -int xdebug_format_file_link(char **filename, const char *error_filename, int error_lineno); -int xdebug_format_filename(char **formatted_name, const char *default_format, zend_string *filename); - -#endif
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/var.c
Deleted
@@ -1,1218 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2025 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); - if (EG(exception)) { - zend_clear_exception(); - } - - 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;
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/var_export_line.c
Deleted
@@ -1,445 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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. | - +----------------------------------------------------------------------+ - */ - -#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) PG(serialize_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.4.3.tgz/xdebug-3.4.3/src/lib/var_export_xml.c
Deleted
@@ -1,874 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2025 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; - zend_object *zobj; -} 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, zend_object *zobj) -{ - zval **zv = &zv_nptr; - xdebug_object_item *item; - - item = xdcalloc(1, sizeof(xdebug_object_item)); - item->type = object_type; - item->zv = *zv; - item->zobj = zobj; - - 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_object *zobj, 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->zobj = zobj; - 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) -{
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/vector.h
Deleted
@@ -1,115 +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_VECTOR_H__ -#define __XDEBUG_VECTOR_H__ - -#include <stddef.h> -#include "mm.h" - -typedef void (*xdebug_vector_dtor)(void *); - -typedef struct _xdebug_vector { - size_t capacity; - size_t count; - - size_t element_size; - void *data; - xdebug_vector_dtor dtor; -} xdebug_vector; - -static void __xdebug_grow_vector_if_needed(xdebug_vector *v) -{ - if (v->count + 1 > v->capacity) { - if (v->capacity == 0) { - v->capacity = 32; - } else { - v->capacity = v->capacity * 3 / 2; - } - - v->data = xdrealloc(v->data, v->capacity * v->element_size); - } -} - -static inline void *xdebug_vector_push(xdebug_vector *v) -{ - void *tmp_top = NULL; - - __xdebug_grow_vector_if_needed(v); - - v->count++; - - tmp_top = ((char*) v->data + ((v->count - 1) * v->element_size)); - memset(tmp_top, '\0', v->element_size); - - return tmp_top; -} - -static inline void xdebug_vector_pop(xdebug_vector *v) -{ - v->dtor(((char*) v->data + ((v->count - 1) * v->element_size))); - v->count--; -} - -static inline void *xdebug_vector_element_get(xdebug_vector *v, size_t index) -{ - if (!v || index >= v->count) { - return NULL; - } - return ((char*) v->data + (index * (v)->element_size)); -} - -static inline int xdebug_vector_element_is_valid(xdebug_vector *v, void *element) -{ - if ((char*) element < (char*) v->data) { - return 0; - } - if ((char*) element > ((char*) v->data + ((v->count - 1) * v->element_size))) { - return 0; - } - - return 1; -} - -#define XDEBUG_VECTOR_HEAD(v) xdebug_vector_element_get((v), 0) -#define XDEBUG_VECTOR_TAIL(v) xdebug_vector_element_get((v), (v)->count-1) - -#define XDEBUG_VECTOR_COUNT(v) (v)->count - -static inline xdebug_vector *xdebug_vector_alloc(size_t element_size, xdebug_vector_dtor dtor) -{ - xdebug_vector *tmp; - - tmp = xdmalloc(sizeof(xdebug_vector)); - tmp->capacity = 0; - tmp->count = 0; - tmp->data = NULL; - tmp->dtor = dtor; - tmp->element_size = element_size; - - return tmp; -} - -static inline void xdebug_vector_destroy(xdebug_vector *v) -{ - while (XDEBUG_VECTOR_COUNT(v)) { - xdebug_vector_pop(v); - } - xdfree(v->data); - xdfree(v); -} - -#endif /* __XDEBUG_VECTOR_H__ */
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/profiler/profiler.c
Deleted
@@ -1,566 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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 "Zend/zend_exceptions.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) -{ -#if PHP_VERSION_ID < 80400 - /* Overload the "exit" opcode */ - xdebug_set_opcode_handler(ZEND_EXIT, xdebug_profiler_exit_handler); -#endif -} - -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(); -} - -void xdebug_profiler_exit_function_handler(void) -{ - function_stack_entry *fse = XDEBUG_VECTOR_TAIL(XG_BASE(stack)); - - deinit_if_active(); - - xdebug_profiler_free_function_details(fse); -} - -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; - }
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/tracing/tracing.c
Deleted
@@ -1,782 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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.4.3.tgz/xdebug-3.4.3/src/tracing/tracing.h
Deleted
@@ -1,78 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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.4.3.tgz/xdebug-3.4.3/xdebug.c
Deleted
@@ -1,859 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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. | - +----------------------------------------------------------------------+ - */ - -#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" -#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT -# 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.4.3.tgz/xdebug-3.4.3/xdebug.ini
Deleted
@@ -1,1277 +0,0 @@ -; This file is generated by the 'xdebug.org:html/docs/convert.php' robot -; for Xdebug 3.4.3 — 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.
View file
xdebug-3.4.3.tgz/package.xml -> xdebug-3.5.3.tgz/package.xml
Changed
@@ -32,11 +32,11 @@ <email>derick@xdebug.org</email> <active>yes</active> </lead> - <date>2025-05-14</date> - <time>09:39:21</time> + <date>2026-06-08</date> + <time>14:38:52</time> <version> - <release>3.4.3</release> - <api>3.4.3</api> + <release>3.5.3</release> + <api>3.5.3</api> </version> <stability> <release>stable</release> @@ -44,18 +44,23 @@ </stability> <license filesource="LICENSE" uri="https://xdebug.org/license/1.03">Xdebug-1.03</license> <notes> -Wed, May 14, 2025 - Xdebug 3.4.3 +Mon, Jun 08, 2026 - Xdebug 3.5.3 = Fixed bugs: - - Fixed issue #2322: Xdebug tries to open debugging connection in destructors during shutdown - - Fixed issue #2325: Referred chrome browser extension is no longer working - - Fixed issue #2326: Step debugger finishes if property debugging handler in PHP throws an exception - - Fixed issue #2331: Segmentation fault with 'invalid' variable names - - Fixed issue #2339: Trying to throw an exception can cause a zend_mm_heap corrupted error under specific circumstances - - Fixed issue #2340: Xdebug case sensitivity issues on some files introduced since 3.3.0 - - Fixed issue #2343: Fatal error on virtual property hook step debugging - - Fixed issue #2348: Xdebug does not resolve breakpoints in property hooks + - Fixed issue #2404: Xdebug outputs a message to stderr when path mapping is enabled, and a directory is present + - Fixed issue #2405: Handle minimum path in .xdebug directory discovery + - Fixed issue #2411: Native Path Mapping is not applied to the initial fileuri in the init packet + - Fixed issue #2421: Crash with wrong option letter in DBGP and socket commands + - Fixed issue #2422: No limit on DBGP read buffer + - Fixed issue #2423: Don't follow symlinks with file creation + - Fixed issue #2424: Control-socket buffer crashes + - Fixed issue #2426: xdebug_get_tracefile_name incorrectly throws notice + - Fixed issue #2427: Crash when file_link_format setting is wrong + - Fixed issue #2429: Crash when trace_output_name setting is wrong + - Fixed issue #2430: Variable fetching may crash with `::` if there is no active stack + - Fixed issue #2431: Crash when trying to retrieve Windows-style URL with not enough characters + - Fixed issue #2433: Refactor finding variable names in trace files with assignments </notes> <contents> <dir name="/"> @@ -63,60 +68,75 @@ <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="c7aecda0faa7e572a734b67b25b74a07" name="src/base/base.c" role="src" /> + <file md5sum="ed79df8184d282f801e459018dc84de0" name="src/base/base.c" role="src" /> <file md5sum="7db372db630677292df705a90c07e21c" name="src/base/base.h" role="src" /> - <file md5sum="462f11891e8d2b7db11857161abb8f10" name="src/base/base_globals.h" role="src" /> + <file md5sum="0afa846b6a31cba4fabe7af94932082e" name="src/base/base_globals.h" role="src" /> <file md5sum="baf483b8b3f68c10d0c3f8863accf0c3" name="src/base/base_private.h" role="src" /> <file md5sum="ecced137dc9c6dc9cbe4c6c946d2cf9c" name="src/base/filter.c" role="src" /> <file md5sum="dc9f79b67b940c0ca6676008b94f0c91" name="src/base/filter.h" role="src" /> - <file md5sum="3faec657adf80bbc8cf06eca7f1e620f" name="src/base/ctrl_socket.c" role="src" /> + <file md5sum="e8159b8eed23cfc5f2fc2d97366250e9" name="src/base/ctrl_socket.c" role="src" /> <file md5sum="8663469dde1558dab7a03f0814501483" name="src/base/ctrl_socket.h" role="src" /> - <file md5sum="d061bdd81e2d04abdd412dcca978bfda" 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="e2997ef1849ad7d4aa5cb487c91a6198" name="src/lib/maps/maps.c" role="src" /> + <file md5sum="55f2c367598b9540a91287c5facaa8e8" name="src/lib/maps/maps.h" role="src" /> + <file md5sum="1a73038352560f6ab0c9d4a74eef832e" name="src/lib/maps/maps_private.c" role="src" /> + <file md5sum="6b8d9e20f84614992a4a7240dfdcbd8d" name="src/lib/maps/maps_private.h" role="src" /> + <file md5sum="c67c709b6e9b864a5c69e42bc164f457" name="src/lib/maps/parser.c" role="src" /> + <file md5sum="2b029efa34495b7fa835a7b3592dc323" name="src/lib/maps/parser.h" role="src" /> + <file md5sum="747e8c638cb317b736986449d204d315" name="src/lib/usefulstuff.c" role="src" /> + <file md5sum="457dca4fdb27d7bfb63a12c49e2ff174" name="src/lib/usefulstuff.h" role="src" /> + <file md5sum="9db5fb7eefa1f3f12b11c8cf2fb292eb" name="src/lib/cmd_parser.c" role="src" /> + <file md5sum="5f81c7032747f5cf25cf89c3bc817f7a" name="src/lib/cmd_parser.h" role="src" /> + <file md5sum="ead135f2ae254d0fd9478dc949cc9e3c" name="src/lib/compat.c" role="src" /> <file md5sum="ec6b26fbcd1232fd1e97e0c437901c71" 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="46e1530b296f71bf2d00e282b32de691" name="src/lib/headers.c" role="src" /> + <file md5sum="0a10cabff3f3f8c21c1a41bd6f288918" name="src/lib/hash.h" role="src" /> + <file md5sum="36e8a2546949f80339886c2bfe7e8584" name="src/lib/headers.c" role="src" /> <file md5sum="b05e34ecc50ab77d02933c583d88551b" name="src/lib/headers.h" role="src" /> - <file md5sum="2bc8b8a1d6f1e5e6c6e68ff0fdcab511" name="src/lib/lib.c" role="src" /> - <file md5sum="b4af46472f26e1f7f86d8ea602d31cf8" name="src/lib/lib.h" role="src" /> - <file md5sum="d1a7ffc5273a68829a86d24ae0091d15" name="src/lib/log.c" role="src" /> - <file md5sum="2ded0176decc29f511215987461419ff" name="src/lib/log.h" role="src" /> + <file md5sum="8a51a1ba40840b211eb0a906d6f0b517" name="src/lib/lib.c" role="src" /> + <file md5sum="07df08dbe8a67924ccfd2b38eea6fd3a" name="src/lib/lib.h" role="src" /> + <file md5sum="1b3124565536a5acdb0dc6c807b697d0" name="src/lib/log.c" role="src" /> + <file md5sum="db30484306f4465611253190e22336d0" 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" /> <file md5sum="833b8b23d247ee19d10a58a0e9159174" name="src/lib/llist.h" role="src" /> <file md5sum="78eb2398cc1a535be67632e0de82b727" name="src/lib/mm.h" role="src" /> - <file md5sum="39d07a6b4e982c8d5787e188a93c8af9" name="src/lib/php-header.h" role="src" /> + <file md5sum="755ab4cafa76bee1bf1620a9c2cbd469" name="src/lib/normalize_path.c" role="src" /> + <file md5sum="86509a53f260e0d259f06ed49ccf1482" name="src/lib/normalize_path.h" role="src" /> + <file md5sum="4ccd9c3332d36f3ddcb36af0dd3a7d23" name="src/lib/php-header.h" role="src" /> <file md5sum="7ad345e09f5c1768900ce690e5efd770" name="src/lib/set.c" role="src" /> <file md5sum="dc03fc37187e29189e906e577d5b9c4c" name="src/lib/set.h" role="src" /> - <file md5sum="06957affcf5343b01df7b9b90cb23a8d" name="src/lib/str.c" role="src" /> - <file md5sum="34d98f97b0e5a32a459a083bae66edfb" name="src/lib/str.h" role="src" /> + <file md5sum="137548b665c4a6e1e90dd8fbe5984c66" name="src/lib/str.c" role="src" /> + <file md5sum="f20ac43b5ee8e66dc4d993cb43be8832" name="src/lib/str.h" role="src" /> + <file md5sum="98f10016851605885ca93564adb82183" name="src/lib/stripcslashes.c" role="src" /> + <file md5sum="86c3fb0e4784feda72d3ba4eab7c5437" name="src/lib/stripcslashes.h" role="src" /> + <file md5sum="a19cd6f76cc97f53dab1aca50e62b46e" name="src/lib/strrnchr.h" role="src" /> <file md5sum="5b9f132ac452b6a5077bd401a3af0099" name="src/lib/timing.c" role="src" /> <file md5sum="637e3b5e753e6afc8b014b02cec7b0ec" name="src/lib/timing.h" role="src" /> - <file md5sum="024ca4b6d121244fd98bab98f30c1e61" name="src/lib/var.c" role="src" /> + <file md5sum="9cb8eab36edb38f875a80a3c9e91791d" name="src/lib/trim.c" role="src" /> + <file md5sum="b9678be93ff64fc15403dfe270209085" name="src/lib/trim.h" role="src" /> + <file md5sum="b61b7cd4add29333422466e4dbc56b91" name="src/lib/var.c" role="src" /> <file md5sum="3c779b9832916c8fc106df56da6f7304" name="src/lib/var.h" role="src" /> <file md5sum="2f6fadc3c352bdd9b76210aed95db5db" name="src/lib/var_export_html.c" role="src" /> <file md5sum="ab2c1ac724a54c2b50946c7746ee135c" name="src/lib/var_export_html.h" role="src" /> - <file md5sum="986a17594601b6e83d20c1dc2a470f5d" name="src/lib/var_export_line.c" role="src" /> + <file md5sum="15f4c1baf34e4aca2b4dddc24b4c4db5" name="src/lib/var_export_line.c" role="src" /> <file md5sum="a865240b02e1f698ce57098f01693399" name="src/lib/var_export_line.h" role="src" /> <file md5sum="05df82b845c25a343be4c3796d37074e" name="src/lib/var_export_text.c" role="src" /> <file md5sum="ce4f91762755006f5df6353465e9927b" name="src/lib/var_export_text.h" role="src" /> - <file md5sum="07c7dd11f25ad530b0147a8d40944740" name="src/lib/var_export_xml.c" role="src" /> + <file md5sum="b2e0a7fb0e62518206fd12d882334dc0" 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="6cf7c152bfca6843c25ccc69d0ede155" name="src/lib/vector.h" role="src" /> + <file md5sum="a4ecf2d4782e26dfda36c0e0a0d26168" name="src/lib/xdebug_strndup.c" role="src" /> + <file md5sum="24a9368c6609848a98d0ef14b187ca5f" name="src/lib/xdebug_strndup.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="836e22fbb91ac61473a26796610afda8" name="src/coverage/code_coverage.c" role="src" /> - <file md5sum="c7c6c4688b7654d2a481e64a519596a3" name="src/coverage/code_coverage.h" role="src" /> + <file md5sum="5072a13aceb3d37bacd03d91efe3faca" name="src/coverage/code_coverage.c" role="src" /> + <file md5sum="cdc4e93f940a5e524f1446c13d8514be" name="src/coverage/code_coverage.h" role="src" /> <file md5sum="b0a609f56e0d13cf7f6c915af1774512" name="src/coverage/code_coverage_private.h" role="src" /> <file md5sum="89a65d3495bdf205766dd72377f451ab" name="src/develop/develop.c" role="src" /> <file md5sum="f7cf8df6eb57d3a4fbd41ce614a6fc5b" name="src/develop/develop.h" role="src" /> @@ -124,29 +144,29 @@ <file md5sum="90b834c845688751dbb723fb6b9e855b" name="src/develop/monitor.c" role="src" /> <file md5sum="e29f144cd504ee14ebddee4f8ab5b714" name="src/develop/monitor.h" role="src" /> <file md5sum="d9a771fa984ea3bf7697373847141abe" name="src/develop/php_functions.c" role="src" /> - <file md5sum="5934860c8fd20d6ea1cedfe248ca9aad" name="src/develop/stack.c" role="src" /> + <file md5sum="bb338f6661656aae9c1fc578716ca146" name="src/develop/stack.c" role="src" /> <file md5sum="8befdeb139efc9a471dc9a3277ca771c" name="src/develop/stack.h" role="src" /> <file md5sum="f8075b29ea1cd537822b1640cc847888" name="src/develop/superglobals.c" role="src" /> <file md5sum="3a2f095163c396e8945274b6d4595eaf" name="src/develop/superglobals.h" role="src" /> - <file md5sum="aded20852ffec095aef78ef958250155" name="src/debugger/com.c" role="src" /> + <file md5sum="9abd92f7100c86fd92ef8dcdabd97014" name="src/debugger/com.c" role="src" /> <file md5sum="9a69d4bd80f97d8fc0694314bf146cbf" name="src/debugger/com.h" role="src" /> - <file md5sum="2eed1d7e2e904591447e758ea9492d21" name="src/debugger/debugger.c" role="src" /> - <file md5sum="bf74ec2e32c5b75f54b4757ee6b71e8e" name="src/debugger/debugger.h" role="src" /> + <file md5sum="2f295645e54d3a18b93139a0c12edbf4" name="src/debugger/debugger.c" role="src" /> + <file md5sum="0a9f5a13aadab33a931014b74188ff0a" name="src/debugger/debugger.h" role="src" /> <file md5sum="9fcd238d717652b90ac59fd8a518a7a7" name="src/debugger/debugger_private.h" role="src" /> - <file md5sum="ebb7b99fc1253c60f3caf63bdba60e32" name="src/debugger/handlers.c" role="src" /> - <file md5sum="642ae17b70dc9f5aa96d97ff922dafb5" name="src/debugger/handlers.h" role="src" /> - <file md5sum="12ba5be5e5337bd9e57fe19f5828ae98" name="src/debugger/handler_dbgp.c" role="src" /> - <file md5sum="3997f84b9f11a4fdc14ffcebdc76f8ea" name="src/debugger/handler_dbgp.h" role="src" /> + <file md5sum="18aae49457118ac68a386a532f5a478c" name="src/debugger/handlers.c" role="src" /> + <file md5sum="9533c60538b0e1a434f741248642956a" name="src/debugger/handlers.h" role="src" /> + <file md5sum="4ea821553b9b200f5626c6b6017005aa" name="src/debugger/handler_dbgp.c" role="src" /> + <file md5sum="5d7dfdf54c9e5933bd3cf6a5fc70fd63" 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="c3b2730b6167353c0bdb14efc8c4a8f1" name="src/gcstats/gc_stats.c" role="src" /> <file md5sum="3bf056d2ba948c4db6ec0375225ace32" name="src/gcstats/gc_stats.h" role="src" /> <file md5sum="b413a2fc300ffd2f7e4a7f0da5c846a7" name="src/gcstats/gc_stats_private.h" role="src" /> - <file md5sum="d1db003b2ba10291853a94a8b6066085" name="src/profiler/profiler.c" role="src" /> + <file md5sum="e370ae14cc9df44e38298b3b73fee23a" name="src/profiler/profiler.c" role="src" /> <file md5sum="cc5756875c989340b0985fd5688892cf" name="src/profiler/profiler.h" role="src" /> <file md5sum="898430e957132a43aeff96f40dddac18" name="src/profiler/profiler_private.h" role="src" /> - <file md5sum="e1d47d5878c5b58916432c6a122b8847" name="src/tracing/tracing.c" role="src" /> - <file md5sum="a9f7754a35cc95addebc3e417c21eb55" name="src/tracing/tracing.h" role="src" /> + <file md5sum="32f19119400848309560d45773188bf8" name="src/tracing/tracing.c" role="src" /> + <file md5sum="a3d47ae66e1fdd13d505ccaf52b35870" name="src/tracing/tracing.h" role="src" /> <file md5sum="f1319418b7165faac0ff1f1ce23467db" name="src/tracing/tracing_private.h" role="src" /> <file md5sum="68281302e760e1f3b7a727b2d90ca6e1" name="src/tracing/trace_computerized.c" role="src" /> <file md5sum="caf12732954476c16d0057cafee32451" name="src/tracing/trace_computerized.h" role="src" /> @@ -156,17 +176,17 @@ <file md5sum="cb9721509e7356c52dd87d724c5b6ddc" name="src/tracing/trace_html.h" role="src" /> <file md5sum="5f03fdcb8f3ad236c4f8c51190bb9847" name="src/tracing/trace_textual.c" role="src" /> <file md5sum="13b0dca161acbf3c2f80c0b110b134e8" name="src/tracing/trace_textual.h" role="src" /> - <file md5sum="954d53d2f8e6ccf9db8baf3bcd443811" name="config.m4" role="src" /> - <file md5sum="899406f5ace0030d435509c2fe4afe39" name="config.w32" role="src" /> + <file md5sum="007f796b35307c7fa38eaed517edcb63" name="config.m4" role="src" /> + <file md5sum="39f0ffd2c0b06e5d40887ace4ea42d9d" name="config.w32" role="src" /> <file md5sum="8f9a93feba6ff23c4bc1bc2929babcc4" name="CREDITS" role="doc" /> <file md5sum="afd6ce4aa04fdc346e5b3c6e634bd75c" name="LICENSE" role="doc" /> - <file md5sum="a1c7dbacec64553da9e8ff0a333093f0" name="xdebug.ini" role="doc" />
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/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.4:: + + git checkout --track origin/xdebug_3_4 + +Branches +-------- + +There are two branches in operation: + +``master`` + This is were all new feature Pull Requests should be targeted at +``xdebug_3_4`` + 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_4`` 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_4`` + 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_4 + +- 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.5.3.tgz/xdebug-3.5.3/CREDITS
Changed
(renamed from xdebug-3.4.3/CREDITS)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/LICENSE
Changed
(renamed from xdebug-3.4.3/LICENSE)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/Makefile.frag
Changed
(renamed from xdebug-3.4.3/Makefile.frag)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/README.rst
Added
@@ -0,0 +1,139 @@ +Xdebug +====== + +.. image:: https://github.com/xdebug/xdebug/actions/workflows/tests.yml/badge.svg + :target: https://github.com/xdebug/xdebug/actions/workflows/tests.yml +.. image:: https://circleci.com/gh/xdebug/xdebug/tree/master.svg?style=svg + :target: https://circleci.com/gh/xdebug/xdebug + +.. image:: https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg + :target: https://stand-with-ukraine.pp.ua/ + +Xdebug is a debugging tool for PHP. It provides step-debugging and a whole +range of development helpers, such as stack traces, a code profiler, features to +dump the full execution of your script to a file, and more. + +|Repography logo| / Recent activity |Time period| +----- +|recent-activity_timeline| |recent-activity_prs| |recent-activity_words| |recent-activity_users| + +.. |Time period| image:: https://images.repography.com/0/xdebug/xdebug/recent-activity/ef1290ac5bfa674f07dcfa4f915ce6b3_badge.svg + :alt: Time period + :target: https://repography.com +.. |Repography logo| image:: https://images.repography.com/logo.svg + :alt: Repography logo + :target: https://repography.com +.. |recent-activity_timeline| image:: https://images.repography.com/0/xdebug/xdebug/recent-activity/ef1290ac5bfa674f07dcfa4f915ce6b3_timeline.svg + :alt: Timeline graph + :target: https://github.com/xdebug/xdebug/commits +.. |recent-activity_prs| image:: https://images.repography.com/0/xdebug/xdebug/recent-activity/ef1290ac5bfa674f07dcfa4f915ce6b3_prs.svg + :alt: Pull request status graph + :target: https://github.com/xdebug/xdebug/pulls +.. |recent-activity_words| image:: https://images.repography.com/0/xdebug/xdebug/recent-activity/ef1290ac5bfa674f07dcfa4f915ce6b3_words.svg + :alt: Trending topics + :target: https://github.com/xdebug/xdebug/commits +.. |recent-activity_users| image:: https://images.repography.com/0/xdebug/xdebug/recent-activity/ef1290ac5bfa674f07dcfa4f915ce6b3_users.svg + :alt: Top contributors + :target: https://github.com/xdebug/xdebug/graphs/contributors + +Requirements +------------ + +Xdebug requires a `supported version <https://www.php.net/supported-versions.php>`_ +of PHP. For installation it requires the ``pie`` tool, unless your Linux +distribution has an Xdebug package (most often: ``php-xdebug``). + +Installation +------------ + +On most Linux distributions you can install Xdebug through `their package +manager <https://xdebug.org/docs/install#linux>`_. + +You can also install Xdebug on Linux, macOS, and Windows, with the +`PIE <https://github.com/php/pie?tab=readme-ov-file#using-pie---what-do-i-need-to-get-started>`_ +installer through ``pie install xdebug/xdebug``. + +For more extensive installation instructions, see the documentation at +https://xdebug.org/docs/install + +Configuration +------------- + +Most features in Xdebug have to be opted in into. Each feature has a specific +opt-in. For example to use the `step debugger +<https://xdebug.org/docs/remote>`_ you need to set `xdebug.remote_enable=1` in +your configuration file. The step debugger requires an IDE (client), of which +there are many `available <https://xdebug.org/docs/remote#clients>`_. + +The documentation has instructions for each of Xdebug's features: +https://xdebug.org/docs/ and a full list of `settings +<https://xdebug.org/docs/all_settings>`_ is also available there. + +Contributing +------------ + +Xdebug is written in C, and extensive knowledge of PHP's internals is +necessary to be able to contribute. Contributing guidance is available +`separately <https://github.com/xdebug/xdebug/blob/master/CONTRIBUTING.rst>`_. + +Before you begin to contribute, please reach out first. Either through email +(address at the bottom), an issue in the `issue tracker +<https://bugs.xdebug.org>`_ or preferably through IRC on Freenode's #xdebug +channel. + +Testing +------- + +If you are familiar with compiling PHP extension from source, have a local +checkout of Xdebug's GitHub repository, and have compiled Xdebug in that +directory following the instructions under `installation +<https://xdebug.org/docs/install#source>`_ you can run Xdebug's tests by +running:: + + php run-xdebug-tests.php + +The test framework requires that the PHP binary on the path has Xdebug loaded, +with remote debugging enabled through `xdebug.mode=debug`. It is possible +to skip remote debugging tests by exporting the `SKIP_DBGP_TESTS=1` environment +variable. + +The `SKIP_UNPARALLEL_TESTS=1` can be used to skip tests that can not run in +parallel environments, and the `SKIP_SLOW_TESTS=1` environment variable to skip +slow tests. The `OPCACHE` environment variable can either be `yes` or `no` and +controls whether the test framework enables or disables OpCache. + +Licensing +--------- + +Xdebug is released under `The Xdebug License +<https://github.com/xdebug/xdebug/blob/master/LICENSE>`_, which is based on +`The PHP License <https://github.com/php/php-src/blob/master/LICENSE>`_. It is +an Open Source license (though not explicitly endorsed by the Open Source +Initiative). + +Further Reading +--------------- + +Xdebug has extensive documentation on its `website <https://xdebug.org/docs>`_. +There are over a hundred settings and many functions documented. Please have a +look through the wealth of information that Xdebug can provide to make your +every day development with PHP easier. + +Support +------- + +For questions regarding Xdebug, please use `StackOverflow +<https://stackoverflow.com/questions/tagged/xdebug>`_, and tag your question +with `xdebug`. + +You can also find ad-hoc and sporadic support on IRC: ``freenode/#xdebug``. +You can do that with your favourite client, or by using their `webchat +<http://webchat.freenode.net/?channels=#xdebug>`_. + +If you think that you encountered a bug, please file a detailed bug report +at https://bugs.xdebug.org. You are required to create an account, this is +so that you can be contacted for additional information and to keep out +spam. + + +Derick Rethans — derick@xdebug.org
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/config.m4
Added
@@ -0,0 +1,136 @@ +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.6.0 (found $PHP_XDEBUG_FOUND_VERSION)) + else + if test "$PHP_XDEBUG_FOUND_VERNUM" -ge "80600"; then + AC_MSG_ERROR(not supported. Need a PHP version >= 8.0.0 and < 8.6.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_DEFINE(HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT,1, do have control socket support? ) + 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, do we have zlib support compiled in? ) + , ) + 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/normalize_path.c src/lib/set.c src/lib/str.c src/lib/stripcslashes.c src/lib/timing.c src/lib/trim.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/xdebug_strndup.c src/lib/xml.c" + XDEBUG_LIB_MAPS_SOURCES="src/lib/maps/maps.c src/lib/maps/maps_private.c src/lib/maps/parser.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_LIB_MAPS_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/lib/maps) + 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.5.3.tgz/xdebug-3.5.3/config.w32
Added
@@ -0,0 +1,62 @@ +// 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 ctrl_socket.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 normalize_path.c set.c str.c stripcslashes.c timing.c trim.c var.c var_export_html.c var_export_line.c var_export_text.c var_export_xml.c xdebug_strndup.c xml.c" + var XDEBUG_LIB_MAPS_SOURCES="maps.c maps_private.c parser.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"; + + var XDEBUG_PHP_VERSION = 10000 * PHP_VERSION + 100 * PHP_MINOR_VERSION + 1 * PHP_RELEASE_VERSION; + if (XDEBUG_PHP_VERSION < 80000) { + ERROR("not supported. Need a PHP version >= 8.0.0 and < 8.6.0 (found " + XDEBUG_PHP_VERSION + ")"); + } else if (XDEBUG_PHP_VERSION >= 80600) { + ERROR("not supported. Need a PHP version >= 8.0.0 and < 8.6.0 (found " + XDEBUG_PHP_VERSION + ")"); + } else { + MESSAGE("supported (" + XDEBUG_PHP_VERSION + ")"); + } + + 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/lib/maps", XDEBUG_LIB_MAPS_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_CONTROL_SOCKET_SUPPORT", 1, "Xdebug control socket support"); + + AC_DEFINE("HAVE_XDEBUG", 1, "Xdebug support"); +}
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/contrib/tracefile-analyser.php
Changed
(renamed from xdebug-3.4.3/contrib/tracefile-analyser.php)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/contrib/xt.vim
Changed
(renamed from xdebug-3.4.3/contrib/xt.vim)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/m4/clocks.m4
Changed
(renamed from xdebug-3.4.3/m4/clocks.m4)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/m4/pkg.m4
Changed
(renamed from xdebug-3.4.3/m4/pkg.m4)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/php_xdebug.h
Added
@@ -0,0 +1,111 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2026 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.5.3" +#define XDEBUG_AUTHOR "Derick Rethans" +#define XDEBUG_COPYRIGHT "Copyright (c) 2002-2026 by Derick Rethans" +#define XDEBUG_COPYRIGHT_SHORT "Copyright (c) 2002-2026" +#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.5.3.tgz/xdebug-3.5.3/php_xdebug_arginfo.h
Changed
(renamed from xdebug-3.4.3/php_xdebug_arginfo.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/run-xdebug-tests.php
Added
@@ -0,0 +1,4220 @@ +#!/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://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: 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) | + +----------------------------------------------------------------------+ + */ + +require_once __DIR__ . '/tests/utils.inc'; + + +/* Let there be no top-level code beyond this point: + * Only functions and classes, thanks! + * + * Minimum required PHP version: 8.0.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 than 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' environment variable. + + --online Prevents setting the 'SKIP_ONLINE_TESTS' environment variable. + + --offline Sets 'SKIP_ONLINE_TESTS' environment variable (default). + + --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 path 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. + + --progress + --no-progress Do/Don't show the current progress. + + --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, + $end_time, $environment, + $exts_skipped, $exts_tested, $exts_to_test, $failed_tests_file, + $ignored_by_ext, $ini_overwrites, $colorize, + $log_format, $no_clean, $no_file_cache, + $pass_options, $php, $php_cgi, $preload, + $result_tests_file, $slow_min_ms, $start_time, + $temp_source, $temp_target, $test_cnt, + $test_files, $test_idx, $test_results, $testfile, + $valgrind, $sum_results, $shuffle, $file_cache, $num_repeats, + $show_progress; + // Parallel testing + global $workers, $workerID; + global $context_line_count; + + // Temporary for the duration of refactoring + /** @var JUnit $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'); + putenv('SSH_CONNECTION=deleted');
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/base/base.c
Added
@@ -0,0 +1,1640 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2025 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" +#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT +# 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 "lib/xdebug_strndup.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; +zif_handler orig_exit_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 *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); +PHP_FUNCTION(xdebug_exit); + + +/* {{{ 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; + + 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); + + /* 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); +}
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/base/base.h
Changed
(renamed from xdebug-3.4.3/src/base/base.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/base/base_globals.h
Added
@@ -0,0 +1,100 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2025 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 working_tsc_clock; /* -1 = unknown, 0 = not available, 1 = available */ + 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; + +#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT + /* Control Socket */ + char *control_socket_path; + zend_long control_socket_last_trigger; +# ifdef __linux__ + int control_socket_fd; +# elif WIN32 + HANDLE control_socket_h; + OVERLAPPED control_socket_ov; +# endif +#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 { +#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT + 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.5.3.tgz/xdebug-3.5.3/src/base/base_private.h
Changed
(renamed from xdebug-3.4.3/src/base/base_private.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/base/ctrl_socket.c
Added
@@ -0,0 +1,575 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2025 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> +#endif + +#include "php_xdebug.h" + +#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT + +#include "ctrl_socket.h" +#include "lib/cmd_parser.h" +#include "lib/log.h" +#include "lib/xml.h" + +#if WIN32 +#include <windows.h> +#endif + +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; +} + +#if __linux__ +static void handle_command(int fd, const char *line) +#elif WIN32 +static void handle_command(HANDLE h, const char *line) +#endif +{ + char *cmd = NULL; + xdebug_dbgp_arg *args; + int res = 0; + xdebug_ctrl_cmd *command = NULL; + 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"); + + if (res != XDEBUG_ERROR_OK) { + xdebug_xml_node *error = xdebug_xml_node_init("error"); + xdebug_xml_add_attribute_ex(error, "code", xdebug_sprintf("%lu", XDEBUG_ERROR_INVALID_ARGS), 0, 1); + ADD_REASON_MESSAGE(XDEBUG_ERROR_INVALID_ARGS); + xdebug_xml_add_child(retval, error); + + goto send_result; + } + + command = lookup_cmd(cmd); + + if (!command) { + xdebug_xml_node *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); + + goto send_result; + } + + command->handler(&retval, args); + +send_result: + message = make_message(retval); +#if __linux__ + write(fd, message->d, message->l); +#elif WIN32 + if (WriteFile(h, message->d, message->l, NULL, &XG_BASE(control_socket_ov))) { + SetEvent(XG_BASE(control_socket_ov).hEvent); + } +#endif + + 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));
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/base/ctrl_socket.h
Changed
(renamed from xdebug-3.4.3/src/base/ctrl_socket.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/base/filter.c
Changed
(renamed from xdebug-3.4.3/src/base/filter.c)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/base/filter.h
Changed
(renamed from xdebug-3.4.3/src/base/filter.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/coverage/branch_info.c
Changed
(renamed from xdebug-3.4.3/src/coverage/branch_info.c)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/coverage/branch_info.h
Changed
(renamed from xdebug-3.4.3/src/coverage/branch_info.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/coverage/code_coverage.c
Added
@@ -0,0 +1,1391 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2025 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" + +#if PHP_VERSION_ID >= 80100 +# include "Zend/zend_fibers.h" +# include "Zend/zend_observer.h" +#endif + +#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 */
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/coverage/code_coverage.h
Added
@@ -0,0 +1,82 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2025 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_CODE_COVERAGE_H__ +#define __XDEBUG_CODE_COVERAGE_H__ + +#include "lib/lib.h" + +typedef struct xdebug_coverage_file { + zend_string *name; + xdebug_hash *lines; + xdebug_hash *functions; /* Used for branch coverage */ + int has_branch_info; +} xdebug_coverage_file; + +typedef struct _xdebug_coverage_globals_t { + zend_bool code_coverage_active; /* Whether code coverage is currently running */ + xdebug_hash *code_coverage_info; /* Stores code coverage information */ + zend_bool code_coverage_unused; + zend_bool code_coverage_dead_code_analysis; + zend_bool code_coverage_branch_check; + int dead_code_analysis_tracker_offset; + long dead_code_last_start_id; + long code_coverage_filter_offset; + size_t prefill_function_count; + size_t prefill_class_count; + zend_string *previous_filename; + xdebug_coverage_file *previous_file; + zend_string *previous_mark_filename; + xdebug_coverage_file *previous_mark_file; + xdebug_path_info *paths_stack; +#if PHP_VERSION_ID >= 80100 + xdebug_hash *fiber_path_info_stacks; +#endif + xdebug_hash *visited_branches; + struct { + unsigned int size; + int *last_branch_nr; + } branches; +} xdebug_coverage_globals_t; + +typedef struct _xdebug_coverage_settings_t { + int dummy; +} xdebug_coverage_settings_t; + +void xdebug_init_coverage_globals(xdebug_coverage_globals_t *xg); +void xdebug_coverage_count_line_if_active(zend_op_array *op_array, zend_string *file, int lineno); +void xdebug_coverage_count_line_if_branch_check_active(zend_op_array *op_array, zend_string *file, int lineno); +void xdebug_coverage_record_if_active(zend_execute_data *execute_data, zend_op_array *op_array); +void xdebug_coverage_compile_file(zend_op_array *op_array); + +int xdebug_coverage_execute_ex(function_stack_entry *fse, zend_op_array *op_array, zend_string **tmp_filename, char **tmp_function_name); +void xdebug_coverage_execute_ex_end(function_stack_entry *fse, zend_op_array *op_array, zend_string *tmp_filename, char *tmp_function_name); +void xdebug_coverage_init_oparray(zend_op_array *op_array); + +void xdebug_coverage_minit(INIT_FUNC_ARGS); +void xdebug_coverage_mshutdown(void); +void xdebug_coverage_rinit(void); +void xdebug_coverage_post_deactivate(void); +void xdebug_coverage_register_constants(INIT_FUNC_ARGS); + +PHP_FUNCTION(xdebug_start_code_coverage); +PHP_FUNCTION(xdebug_stop_code_coverage); +PHP_FUNCTION(xdebug_get_code_coverage); +PHP_FUNCTION(xdebug_code_coverage_started); + +PHP_FUNCTION(xdebug_get_function_count); + +#endif
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/coverage/code_coverage_private.h
Changed
(renamed from xdebug-3.4.3/src/coverage/code_coverage_private.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/debugger/com.c
Added
@@ -0,0 +1,856 @@ +/* + +----------------------------------------------------------------------+ + | 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" +#include "lib/trim.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;
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/debugger/com.h
Changed
(renamed from xdebug-3.4.3/src/debugger/com.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/debugger/debugger.c
Added
@@ -0,0 +1,1275 @@ +/* + +----------------------------------------------------------------------+ + | 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_catch { + res = 0; + } 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;
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/debugger/debugger.h
Added
@@ -0,0 +1,101 @@ +/* + +----------------------------------------------------------------------+ + | 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" +#define XDEBUG_EXCEPTION_VALUE_VAR_NAME "__EXCEPTION" +#define XDEBUG_INTERMEDIATE_VALUE_VAR_NAME "__INTERMEDIATE_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_zstr(zend_string *filename_in, zend_string **filename_out); +bool xdebug_debugger_check_evaled_code_xdebug_str(xdebug_str *filename_in, zend_string **filename_out); +void xdebug_debugger_set_has_line_breakpoints(function_stack_entry *fse); +int xdebug_debugger_map_remote_to_local(zend_string *remote_filename, int remote_lineno, xdebug_str **local_path, size_t *local_line, bool *must_free); + +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.5.3.tgz/xdebug-3.5.3/src/debugger/debugger_private.h
Changed
(renamed from xdebug-3.4.3/src/debugger/debugger_private.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/debugger/handler_dbgp.c
Added
@@ -0,0 +1,3294 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2025 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/xdebug_strndup.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
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/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, xdebug_str *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, xdebug_str *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.5.3.tgz/xdebug-3.5.3/src/debugger/handlers.c
Added
@@ -0,0 +1,85 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2025 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 "com.h" +#include "handlers.h" +#include "handler_dbgp.h" +#include "lib/mm.h" + +xdebug_brk_info *xdebug_brk_info_ctor(void) +{ + xdebug_brk_info *tmp = xdmalloc(sizeof(xdebug_brk_info)); + + tmp->id = -1; + tmp->brk_type = -1; + tmp->resolved = XDEBUG_BRK_UNRESOLVED; + tmp->filename = NULL; + tmp->original_lineno = 0; + tmp->resolved_lineno = 0; + tmp->classname = NULL; + tmp->functionname = NULL; + tmp->function_break_type = 0; + tmp->exceptionname = NULL; + tmp->condition = NULL; + tmp->disabled = 0; + tmp->temporary = 0; + tmp->hit_count = 0; + tmp->hit_value = 0; + tmp->hit_condition = XDEBUG_HIT_DISABLED; + + return tmp; +} + +void xdebug_brk_info_dtor(xdebug_brk_info *brk_info) +{ + if (brk_info->classname) { + xdfree(brk_info->classname); + } + if (brk_info->functionname) { + xdfree(brk_info->functionname); + } + if (brk_info->filename) { + zend_string_release(brk_info->filename); + } + if (brk_info->exceptionname) { + xdfree(brk_info->exceptionname); + } + if (brk_info->condition) { + xdfree(brk_info->condition); + } + xdfree(brk_info); +} + +void xdebug_hash_brk_dtor(xdebug_brk_info *brk_info) +{ + xdebug_brk_info_dtor(brk_info); +} + +void xdebug_llist_brk_dtor(void *dummy, xdebug_brk_info *brk_info) +{ + xdebug_brk_info_dtor(brk_info); +} + +void xdebug_hash_eval_info_dtor(xdebug_eval_info *ei) +{ + ei->refcount--; + + if (ei->refcount == 0) { + zend_string_release(ei->contents); + xdfree(ei); + } +}
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/debugger/handlers.h
Added
@@ -0,0 +1,170 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2025 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; + int virtual_exception_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, xdebug_str *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, xdebug_str *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.5.3.tgz/xdebug-3.5.3/src/debugger/ip_info.c
Changed
(renamed from xdebug-3.4.3/src/debugger/ip_info.c)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/debugger/ip_info.h
Changed
(renamed from xdebug-3.4.3/src/debugger/ip_info.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/develop/develop.c
Changed
(renamed from xdebug-3.4.3/src/develop/develop.c)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/develop/develop.h
Changed
(renamed from xdebug-3.4.3/src/develop/develop.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/develop/develop_private.h
Changed
(renamed from xdebug-3.4.3/src/develop/develop_private.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/develop/monitor.c
Changed
(renamed from xdebug-3.4.3/src/develop/monitor.c)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/develop/monitor.h
Changed
(renamed from xdebug-3.4.3/src/develop/monitor.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/develop/php_functions.c
Changed
(renamed from xdebug-3.4.3/src/develop/php_functions.c)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/develop/stack.c
Added
@@ -0,0 +1,1361 @@ +/* + +----------------------------------------------------------------------+ + | 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. | + +----------------------------------------------------------------------+ + */ +#include "php_xdebug.h" + +#include "main/php_ini.h" + +#include "ext/standard/html.h" +#include "zend_exceptions.h" +#include "zend_generators.h" +#include "zend_smart_string.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.5.3.tgz/xdebug-3.5.3/src/develop/stack.h
Changed
(renamed from xdebug-3.4.3/src/develop/stack.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/develop/superglobals.c
Changed
(renamed from xdebug-3.4.3/src/develop/superglobals.c)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/develop/superglobals.h
Changed
(renamed from xdebug-3.4.3/src/develop/superglobals.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/gcstats/gc_stats.c
Changed
(renamed from xdebug-3.4.3/src/gcstats/gc_stats.c)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/gcstats/gc_stats.h
Changed
(renamed from xdebug-3.4.3/src/gcstats/gc_stats.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/gcstats/gc_stats_private.h
Changed
(renamed from xdebug-3.4.3/src/gcstats/gc_stats_private.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/cmd_parser.c
Added
@@ -0,0 +1,178 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2026 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> + +#include "cmd_parser.h" +#include "stripcslashes.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 = (xdebug_dbgp_arg*) 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 = (char*) 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 = (char*) 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; + /* Only accept option letters in a-z plus '-' */ + if ((opt < 'a' || opt > 'z') && opt != '-') { + goto parse_error; + } + 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.5.3.tgz/xdebug-3.5.3/src/lib/cmd_parser.h
Added
@@ -0,0 +1,45 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2026 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 "str.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.5.3.tgz/xdebug-3.5.3/src/lib/compat.c
Added
@@ -0,0 +1,395 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2026 Derick Rethans <derick@xdebug.org> | + | (c) 1997-2004 Jim Winstead <jimw@trainedmonkey.com> | + | (c) 1998-2004 Andi Gutmans <andi@zend.com> and | + | Zeev Suraski <zeev@zend.com> | + +----------------------------------------------------------------------+ + | This source file is subject to the following Modified BSD license: | + | | + | Redistribution and use in source and binary forms, with or without | + | modification, are 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 of the author may not be used to endorse or promote | + | products derived from this software without specific prior | + | written permission. | + | | + | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 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 AUTHOR 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. | + +----------------------------------------------------------------------+ + */ + +#include "lib/php-header.h" +#include "main/php_version.h" +#include "compat.h" +#include "zend_extensions.h" + +#include "zend_compile.h" +#include "ext/standard/base64.h" +#include "ext/standard/php_string.h" + +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) +{ + zend_string *new_str; + char *retval; + + new_str = php_str_to_str(haystack, length, (char*) needle, needle_len, (char*) str, str_len); + *new_len = new_str->len; + + retval = estrndup(new_str->val, new_str->len); + + zend_string_release(new_str); + + return retval; +} + +/* {{{ base64 tables */ +static const char base64_table = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', + 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', + 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', '\0' +}; + +static const char base64_pad = '='; + +static const short base64_reverse_table256 = { + -2, -2, -2, -2, -2, -2, -2, -2, -2, -1, -1, -2, -2, -1, -2, -2, + -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, + -1, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, 62, -2, -2, -2, 63, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -2, -2, -2, -2, -2, -2, + -2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -2, -2, -2, -2, -2, + -2, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -2, -2, -2, -2, -2, + -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, + -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, + -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, + -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, + -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, + -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, + -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, + -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2 +}; +/* }}} */ + +static unsigned char *xdebug_base64_encode_impl(const unsigned char *in, size_t inl, unsigned char *out) /* {{{ */ +{ + + while (inl > 2) { /* keep going until we have less than 24 bits */ + *out++ = base64_tablein0 >> 2; + *out++ = base64_table((in0 & 0x03) << 4) + (in1 >> 4); + *out++ = base64_table((in1 & 0x0f) << 2) + (in2 >> 6); + *out++ = base64_tablein2 & 0x3f; + + in += 3; + inl -= 3; /* we just handle 3 octets of data */ + } + + /* now deal with the tail end of things */ + if (inl != 0) { + *out++ = base64_tablein0 >> 2; + if (inl > 1) { + *out++ = base64_table((in0 & 0x03) << 4) + (in1 >> 4); + *out++ = base64_table(in1 & 0x0f) << 2; + *out++ = base64_pad; + } else { + *out++ = base64_table(in0 & 0x03) << 4; + *out++ = base64_pad; + *out++ = base64_pad; + } + } + + *out = '\0'; + + return out; +} +/* }}} */ + +static bool xdebug_base64_decode_impl(const unsigned char *in, size_t inl, unsigned char *out, size_t *outl, zend_bool strict) /* {{{ */ +{ + int ch; + size_t i = 0, padding = 0, j = *outl; + + /* run through the whole string, converting as we go */ + while (inl-- > 0) { + ch = *in++; + if (ch == base64_pad) { + padding++; + continue; + } + + ch = base64_reverse_tablech; + if (!strict) { + /* skip unknown characters and whitespace */ + if (ch < 0) { + continue; + } + } else { + /* skip whitespace */ + if (ch == -1) { + continue; + } + /* fail on bad characters or if any data follows padding */ + if (ch == -2 || padding) { + goto fail; + } + } + + switch (i % 4) { + case 0: + outj = ch << 2; + break; + case 1: + outj++ |= ch >> 4; + outj = (ch & 0x0f) << 4; + break; + case 2: + outj++ |= ch >>2; + outj = (ch & 0x03) << 6; + break; + case 3: + outj++ |= ch; + break; + } + i++; + } + + /* fail if the input is truncated (only one char in last group) */ + if (strict && i % 4 == 1) { + goto fail; + } + + /* fail if the padding length is wrong (not VV==, VVV=), but accept zero padding + * RFC 4648: "In some circumstances, the use of padding -- is not required" */ + if (strict && padding && (padding > 2 || (i + padding) % 4 != 0)) { + goto fail; + } + + *outl = j; + outj = '\0'; + + return true; + +fail: + return false; +} +/* }}} */ +
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/compat.h
Changed
(renamed from xdebug-3.4.3/src/lib/compat.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/crc32.c
Changed
(renamed from xdebug-3.4.3/src/lib/crc32.c)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/crc32.h
Changed
(renamed from xdebug-3.4.3/src/lib/crc32.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/file.c
Changed
(renamed from xdebug-3.4.3/src/lib/file.c)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/file.h
Changed
(renamed from xdebug-3.4.3/src/lib/file.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/hash.c
Changed
(renamed from xdebug-3.4.3/src/lib/hash.c)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/hash.h
Added
@@ -0,0 +1,88 @@ +/* + +----------------------------------------------------------------------+ + | 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_HASH_H__ +#define __XDEBUG_HASH_H__ + +#include <stddef.h> + +#include "llist.h" + +#define XDEBUG_HASH_KEY_IS_STRING 0 +#define XDEBUG_HASH_KEY_IS_NUM 1 + +#define xdebug_ui32 unsigned long + +typedef void (*xdebug_hash_dtor_t)(void *); +typedef int (*xdebug_hash_apply_sorter_t)(const void *le1, const void *le2); + +typedef struct _xdebug_hash { + xdebug_llist **table; + xdebug_hash_dtor_t dtor; + xdebug_hash_apply_sorter_t sorter; + int slots; + size_t size; +} xdebug_hash; + +typedef struct _xdebug_hash_key { + union { + struct { + char *val; + unsigned int len; + } str; + + unsigned long num; + } value; + + int type; +} xdebug_hash_key; + +typedef struct _xdebug_hash_element { + void *ptr; + xdebug_hash_key key; +} xdebug_hash_element; + +#ifdef __cplusplus +extern "C" { +#endif + +/* Helper functions */ +char* xdebug_hash_key_to_str(xdebug_hash_key* key, int* new_len); + +/* Standard functions */ +xdebug_hash *xdebug_hash_alloc(int slots, xdebug_hash_dtor_t dtor); +xdebug_hash *xdebug_hash_alloc_with_sort(int slots, xdebug_hash_dtor_t dtor, xdebug_hash_apply_sorter_t sort_func); +int xdebug_hash_add_or_update(xdebug_hash *h, const char *str_key, unsigned int str_key_len, unsigned long num_key, const void *p); +int xdebug_hash_extended_delete(xdebug_hash *h, const char *str_key, unsigned int str_key_len, unsigned long num_key); +int xdebug_hash_extended_find(xdebug_hash *h, const char *str_key, unsigned int str_key_len, unsigned long num_key, void **p); +void xdebug_hash_apply(xdebug_hash *h, void *user, void (*cb)(void *, xdebug_hash_element *)); +void xdebug_hash_apply_with_argument(xdebug_hash *h, void *user, void (*cb)(void *, xdebug_hash_element *, void *), void *argument); +void xdebug_hash_destroy(xdebug_hash *h); + +#define xdebug_hash_find(h, key, key_len, p) xdebug_hash_extended_find(h, key, key_len, 0, p) +#define xdebug_hash_delete(h, key, key_len) xdebug_hash_extended_delete(h, key, key_len, 0) +#define xdebug_hash_add(h, key, key_len, p) xdebug_hash_add_or_update(h, key, key_len, 0, p) +#define xdebug_hash_update xdebug_hash_add +#define xdebug_hash_index_find(h, key, p) xdebug_hash_extended_find(h, NULL, 0, key, p) +#define xdebug_hash_index_delete(h, key) xdebug_hash_extended_delete(h, NULL, 0, key) +#define xdebug_hash_index_add(h, key, p) xdebug_hash_add_or_update(h, NULL, 0, key, p) +#define xdebug_hash_index_update xdebug_hash_index_add + +#ifdef __cplusplus +} +#endif + +#endif /* __XDEBUG_HASH_H__ */
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/headers.c
Added
@@ -0,0 +1,113 @@ +/* + +----------------------------------------------------------------------+ + | 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: +#if PHP_VERSION_ID >= 80500 + case SAPI_HEADER_DELETE_PREFIX: +#endif + 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.5.3.tgz/xdebug-3.5.3/src/lib/headers.h
Changed
(renamed from xdebug-3.4.3/src/lib/headers.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/lib.c
Added
@@ -0,0 +1,915 @@ +/* + +----------------------------------------------------------------------+ + | 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. | + +----------------------------------------------------------------------+ + */ + +#include "php_xdebug.h" + +#include "headers.h" + +#include "lib_private.h" +#include "log.h" +#include "maps/maps.h" +#include "trim.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); + + XG_LIB(path_mapping_information) = NULL; + if (XINI_LIB(path_mapping)) { + XG_LIB(path_mapping_information) = xdebug_path_maps_ctor(); + if (SG(request_info).path_translated) { + xdebug_path_maps_scan(SG(request_info).path_translated); + } else { + char pathMAXPATHLEN; + char *ret = NULL; + +#ifdef HAVE_GETCWD + ret = VCWD_GETCWD(path, MAXPATHLEN); +#elif defined(HAVE_GETWD) + ret = VCWD_GETWD(path); +#endif + + if (ret) { + xdebug_log_ex(XLOG_CHAN_PATHMAP, XLOG_DEBUG, "NO-PATH-TRANSLATED", "The SAPI request info 'path_translated' is empty, falling back to current working directory (%s)", path); + xdebug_path_maps_scan(path); + } + } + } +} + +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; + + if (XG_LIB(path_mapping_information)) { + xdebug_path_maps_dtor(XG_LIB(path_mapping_information)); + } +} + + +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;
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/lib.h
Added
@@ -0,0 +1,340 @@ +/* + +----------------------------------------------------------------------+ + | 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 __XDEBUG_LIBRARY_H__ +#define __XDEBUG_LIBRARY_H__ + +#ifdef ZTS +# include "TSRM.h" +#endif + +#include "zend.h" +#include "zend_API.h" +#include "compat.h" +#include "set.h" +#include "maps/maps_private.h" +#include "maps/maps.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; +
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/lib_private.h
Changed
(renamed from xdebug-3.4.3/src/lib/lib_private.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/llist.c
Changed
(renamed from xdebug-3.4.3/src/lib/llist.c)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/llist.h
Changed
(renamed from xdebug-3.4.3/src/lib/llist.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/log.c
Added
@@ -0,0 +1,955 @@ +/* + +----------------------------------------------------------------------+ + | 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. | + +----------------------------------------------------------------------+ + */ + +#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_prefix9 = { + "CFG-", "LOG-", "DBG-", "GC-", "PROF-", "TRACE-", "COV-", "BASE-" , "PATHMAP-" +}; +const char *xdebug_channel_name9 = { + "Config ", "Log Files ", "Step Debug ", "GC Stats ", "Profiler ", "Tracing ", "Coverage ", "Base ", "Path Mapping " +}; + +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.5.3.tgz/xdebug-3.5.3/src/lib/log.h
Added
@@ -0,0 +1,56 @@ +/* + +----------------------------------------------------------------------+ + | 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_LIBRARY_LOG_H__ +#define __XDEBUG_LIBRARY_LOG_H__ + +#ifdef ZTS +# include "TSRM.h" +#endif + +#include "lib.h" + +#include "zend.h" +#include "zend_API.h" +#include "compat.h" + +#define XLOG_CRIT 0 +#define XLOG_ERR 1 +#define XLOG_WARN 3 +#define XLOG_COM 5 +#define XLOG_INFO 7 +#define XLOG_DEBUG 10 +#define XLOG_DEFAULT "7" /* as a string, as that's what STD_PHP_INI_ENTRY wants */ + +#define XLOG_CHAN_CONFIG 0 +#define XLOG_CHAN_LOGFILE 1 +#define XLOG_CHAN_DEBUG 2 +#define XLOG_CHAN_GCSTATS 3 +#define XLOG_CHAN_PROFILE 4 +#define XLOG_CHAN_TRACE 5 +#define XLOG_CHAN_COVERAGE 6 +#define XLOG_CHAN_BASE 7 +#define XLOG_CHAN_PATHMAP 8 + +extern const char* xdebug_log_prefix11; + +void XDEBUG_ATTRIBUTE_FORMAT(printf, 4, 5) xdebug_log_ex(int channel, int log_level, const char *error_code, const char *fmt, ...); +#define xdebug_log(c,l,f, ...) xdebug_log_ex((c), (l), NULL, (f), ##__VA_ARGS__) +void xdebug_log_diagnose_permissions(int channel, const char *directory, const char *filename); + +char* xdebug_lib_docs_base(void); + +#endif
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/maps/maps.c
Added
@@ -0,0 +1,222 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2025 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 <stddef.h> +#include <stdlib.h> + +#ifndef XDEBUG_NO_PHP_FEATURES +# include "php_xdebug.h" +#endif + +#if PHP_VERSION_ID >= 80500 +# include "php_glob.h" +# define xdebug_glob php_glob +# define xdebug_glob_t php_glob_t +# define xdebug_globfree php_globfree +#else +# ifndef PHP_WIN32 +# include <glob.h> +# else +# include "php.h" +# include "win32/glob.h" +# endif +# define xdebug_glob glob +# define xdebug_glob_t glob_t +# define xdebug_globfree globfree +#endif + +#ifndef PHP_GLOB_NOMATCH +# define PHP_GLOB_NOMATCH GLOB_NOMATCH +#endif + +#include "maps_private.h" +#include "parser.h" +#include "../lib_private.h" +#include "../log.h" +#include "../mm.h" +#include "../php-header.h" +#include "../usefulstuff.h" + +extern ZEND_DECLARE_MODULE_GLOBALS(xdebug); + +static bool scan_directory_exists(const char *dir) +{ +#ifndef WIN32 + struct stat dir_info; +#endif + char *map_dir = xdebug_sprintf("%s%c.xdebug", dir, DEFAULT_SLASH); + +#ifndef WIN32 + /* See if .xdebug directory exists */ + if (stat(map_dir, &dir_info) == -1) { + xdebug_log_ex(XLOG_CHAN_PATHMAP, XLOG_DEBUG, "NODIR", "The map directory '%s' does not exist", map_dir); + return false; + } + + if (!S_ISDIR(dir_info.st_mode)) { + xdebug_log_ex(XLOG_CHAN_PATHMAP, XLOG_WARN, "NOTADIR", "The map directory '%s' is not a directory", map_dir); + return false; + } +#endif + + return true; +} + +static void scan_directory(const char *dir) +{ + char *scan_dir = xdebug_sprintf("%s%c.xdebug%c*.map", dir, DEFAULT_SLASH, DEFAULT_SLASH); + xdebug_glob_t globbuf; + int glob_result = 0; + size_t i; + + /* Read all files ending in .map */ + xdebug_log_ex(XLOG_CHAN_PATHMAP, XLOG_INFO, "SCAN", "Scanning for map files with pattern '%s'", scan_dir); + + glob_result = xdebug_glob(scan_dir, 0, NULL, &globbuf); + + switch (glob_result) { + case 0: /* No error */ + break; + + case PHP_GLOB_NOMATCH: + xdebug_log_ex(XLOG_CHAN_PATHMAP, XLOG_DEBUG, "NOMATCH", "No map files found with pattern '%s'", scan_dir); + xdfree(scan_dir); + + return; + + default: + xdebug_log_ex(XLOG_CHAN_PATHMAP, XLOG_WARN, "ERR-SCAN", "Scanning for map files with pattern '%s' failed", scan_dir); + xdfree(scan_dir); + + return; + } + + for (i = 0; i < globbuf.gl_pathc; i++) { + int error_code; + int error_line; + char *error_message; + + xdebug_log_ex(XLOG_CHAN_PATHMAP, XLOG_INFO, "SCAN-READ", "Reading mapping file '%s'", globbuf.gl_pathvi); + + if (!xdebug_path_maps_parse_file(XG_LIB(path_mapping_information), dir, globbuf.gl_pathvi, &error_code, &error_line, &error_message)) { + xdebug_log_ex( + XLOG_CHAN_PATHMAP, XLOG_WARN, + "ERR-FILE", "Parse error in path mapping file '%s' on line %d: %s", + globbuf.gl_pathvi, error_line, error_message + ); + } + } + + xdebug_globfree(&globbuf); + xdfree(scan_dir); +} + +static void dump_rule_info(void *ret, xdebug_hash_element *e) +{ + xdebug_path_mapping *rule = (xdebug_path_mapping*) e->ptr; + + if ((rule->type & XDEBUG_PATH_MAP_FLAGS_MASK) == XDEBUG_PATH_MAP_FLAGS_SKIP) { + switch (rule->type & XDEBUG_PATH_MAP_TYPE_MASK) { + case XDEBUG_PATH_MAP_TYPE_DIRECTORY: + xdebug_log_ex(XLOG_CHAN_PATHMAP, XLOG_DEBUG, "RULE", "Skip directory '%s'", XDEBUG_STR_VAL(rule->remote_path)); + break; + case XDEBUG_PATH_MAP_TYPE_FILE: + xdebug_log_ex(XLOG_CHAN_PATHMAP, XLOG_DEBUG, "RULE", "Skip file '%s'", XDEBUG_STR_VAL(rule->remote_path)); + break; + } + } else { + switch (rule->type & XDEBUG_PATH_MAP_TYPE_MASK) { + case XDEBUG_PATH_MAP_TYPE_DIRECTORY: + xdebug_log_ex(XLOG_CHAN_PATHMAP, XLOG_DEBUG, "RULE", "Map directory '%s' to '%s'", XDEBUG_STR_VAL(rule->remote_path), XDEBUG_STR_VAL(rule->m.local_path)); + break; + case XDEBUG_PATH_MAP_TYPE_FILE: + xdebug_log_ex(XLOG_CHAN_PATHMAP, XLOG_DEBUG, "RULE", "Map file '%s' to '%s'", XDEBUG_STR_VAL(rule->remote_path), XDEBUG_STR_VAL(rule->m.local_path)); + break; + } + } +} + +static void dump_mapping_rules(xdebug_path_maps *map_info) +{ + xdebug_hash_apply(map_info->remote_to_local_map, NULL, dump_rule_info); + xdebug_hash_apply(map_info->local_to_remote_map, NULL, dump_rule_info); +} + +void xdebug_path_maps_scan(const char *script_source) +{ + xdebug_arg *parts; + char *slash; + xdebug_str *current_dir = NULL, *parent_dir = NULL, *grand_dir = NULL; + + /* For CLI scripts, only scan the current directory for map files */ + if (strcmp(script_source, "Standard input code") == 0) { + size_t length; + char *current_directory = virtual_getcwd_ex(&length); + + if (scan_directory_exists(current_directory)) { + scan_directory(current_directory); + } + + efree(current_directory); + + return; + } + + /* Otherwise, find the grand parent, parent, and script directory from the path */ + slash = xdebug_sprintf("%c", DEFAULT_SLASH); + parts = xdebug_arg_ctor(); + xdebug_explode(slash, script_source, parts, -1); + + current_dir = parts->c >= 2 ? xdebug_join(slash, parts, 0, parts->c - 2) : NULL; + parent_dir = parts->c >= 3 ? xdebug_join(slash, parts, 0, parts->c - 3) : NULL; + grand_dir = parts->c >= 4 ? xdebug_join(slash, parts, 0, parts->c - 4) : NULL; + + if (grand_dir) { + scan_directory(grand_dir->d); + xdebug_str_free(grand_dir); + } + if (parent_dir) { + scan_directory(parent_dir->d); + xdebug_str_free(parent_dir); + } + if (current_dir) { + scan_directory(current_dir->d); + xdebug_str_free(current_dir); + } + + xdfree(slash);
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/maps/maps.h
Added
@@ -0,0 +1,28 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2025 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_MAPS_MAPS_H__ +#define __XDEBUG_MAPS_MAPS_H__ + +#define XDEBUG_PATH_MAP_RESULT_OK 0 +#define XDEBUG_PATH_MAP_RESULT_SKIP 1 +#define XDEBUG_PATH_MAP_RESULT_UNKNOWN 2 + +void xdebug_path_maps_scan(const char *script_source); +int xdebug_path_maps_local_to_remote(const char *local_path, size_t local_line, xdebug_str **remote_path, size_t *remote_line); +int xdebug_path_maps_remote_to_local(const char *remote_path, size_t remote_line, xdebug_str **local_path, size_t *local_line); + +#endif
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/maps/maps_private.c
Added
@@ -0,0 +1,380 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2026 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 <assert.h> +#include <stdlib.h> +#include <string.h> + +#include "maps_private.h" +#include "../mm.h" +#include "../normalize_path.h" +#include "../strrnchr.h" +#include "../vector.h" +#include "../xdebug_strndup.h" + +#ifndef DEFAULT_SLASH +# define DEFAULT_SLASH '/' +#endif + +static bool do_local_binary_search(xdebug_vector *line_ranges, int low, int high, size_t remote_line, xdebug_str **local_path, size_t *local_line) +{ + while (low <= high) { + int mid = low + (high - low) / 2; + xdebug_path_map_range *ptr = (xdebug_path_map_range*) xdebug_vector_element_get(line_ranges, mid); + + /* 1:1 match */ + if (ptr->remote_begin == ptr->remote_end && ptr->local_begin == ptr->local_end && remote_line == ptr->remote_begin) { + *local_path = ptr->local_path; + *local_line = ptr->local_begin; + return true; + } + /* n:1 match */ + if (ptr->local_begin == ptr->local_end && (remote_line >= ptr->remote_begin) && (remote_line <= ptr->remote_end)) { + *local_path = ptr->local_path; + *local_line = ptr->local_begin; + return true; + } + /* n:m match */ + if ((remote_line >= ptr->remote_begin) && (remote_line <= ptr->remote_end)) { + *local_path = ptr->local_path; + *local_line = remote_line - ptr->remote_begin + ptr->local_begin; + return true; + } + + /* Not found, so choose between first or second half */ + if (remote_line < ptr->remote_begin) { + high = mid - 1; + } else { + low = mid + 1; + } + } + + return false; +} + +static bool find_local_line_number_from_ranges(size_t remote_line, xdebug_vector *line_ranges, xdebug_str **local_path, size_t *local_line) +{ + return do_local_binary_search(line_ranges, 0, XDEBUG_VECTOR_COUNT(line_ranges) - 1, remote_line, local_path, local_line); +} + +/* Returns the remote type, and sets *local_path and *local_line if the type is not XDEBUG_PATH_MAP_TYPE_UNKNOWN or XDEBUG_PATH_MAP_FLAGS_SKIP */ +int remote_to_local(xdebug_path_maps *maps, const char *remote_path, size_t remote_line, xdebug_str **local_path, size_t *local_line) +{ + xdebug_path_mapping *result; + xdebug_hash *map = maps->remote_to_local_map; + + if (!xdebug_hash_find(map, remote_path, strlen(remote_path), (void**) &result)) { + /* We can't find an exact file match, so now try to see if we have a directory match, starting with the full + * path and then removing the trailing directory path until there are none left */ + char *end_slash; + char *directory; + + end_slash = strrchr((char*) remote_path, DEFAULT_SLASH); + if (!end_slash) { + return XDEBUG_PATH_MAP_TYPE_UNKNOWN; + } + + directory = xdstrndup(remote_path, end_slash - remote_path + 1); + end_slash = strrchr((char*) directory, DEFAULT_SLASH); + + do { + size_t n = end_slash - directory + 1; + + if (xdebug_hash_find(map, directory, n, (void**) &result)) { + if (result->type & XDEBUG_PATH_MAP_FLAGS_SKIP) { + xdfree(directory); + + goto skipped_match; + } + if (result->type == XDEBUG_PATH_MAP_TYPE_DIRECTORY) { + *local_line = remote_line; + + *local_path = xdebug_str_new(); + xdebug_str_add_fmt(*local_path, "%s%s", result->m.local_path->d, remote_path + n); + + xdfree(directory); + return XDEBUG_PATH_MAP_TYPE_DIRECTORY; + } + } + + end_slash = strrnchr(directory, DEFAULT_SLASH, n - 1); + } while (end_slash); + + xdfree(directory); + return XDEBUG_PATH_MAP_TYPE_UNKNOWN; + } + + if (result->type & XDEBUG_PATH_MAP_FLAGS_SKIP) { + goto skipped_match; + } + + switch (result->type) { + case XDEBUG_PATH_MAP_TYPE_DIRECTORY: + /* This should not happen during normal execution, because if a remote path is a + * directory, then the OS didn't actually provide a file path to map. But, it can be + * useful for testing an user-initiated mapping. */ + + /* 'break' intentially omitted */ + + case XDEBUG_PATH_MAP_TYPE_FILE: + *local_path = xdebug_str_copy(result->m.local_path); + *local_line = remote_line; + return result->type; + + case XDEBUG_PATH_MAP_TYPE_LINES: { + xdebug_str *result_path; + size_t result_line; + + if (!result->m.line_ranges) { + return XDEBUG_PATH_MAP_TYPE_UNKNOWN; + } + + if (!find_local_line_number_from_ranges(remote_line, result->m.line_ranges, &result_path, &result_line)) { + return XDEBUG_PATH_MAP_TYPE_UNKNOWN; + } + + if (!result_path) { + goto skipped_match; + } + + *local_path = xdebug_str_copy(result_path); + *local_line = result_line; + + return result->type; + } + + default: + assert(false); + } + + +skipped_match: + *local_path = NULL; + *local_line = -1; + + return XDEBUG_PATH_MAP_FLAGS_SKIP; +} + +static bool do_remote_binary_search(xdebug_vector *line_ranges, int low, int high, size_t local_line, xdebug_str **remote_path, size_t *remote_line) +{ + while (low <= high) { + int mid = low + (high - low) / 2; + xdebug_path_map_range *ptr = (xdebug_path_map_range*) xdebug_vector_element_get(line_ranges, mid); + + /* 1:1 match */ + if (ptr->local_begin == ptr->local_end && ptr->remote_begin == ptr->remote_end && local_line == ptr->local_begin) { + *remote_path = ptr->local_path; + *remote_line = ptr->remote_begin; + return true; + } + /* n:1 match */ + if (ptr->remote_begin == ptr->remote_end && (local_line >= ptr->local_begin) && (local_line <= ptr->local_end)) { + *remote_path = ptr->local_path; + *remote_line = ptr->remote_begin; + return true; + } + /* n:m match */ + if ((local_line >= ptr->local_begin) && (local_line <= ptr->local_end)) { + *remote_path = ptr->local_path; + *remote_line = local_line - ptr->local_begin + ptr->remote_begin; + return true; + } + + /* Not found, so choose between first or second half */ + if (local_line < ptr->local_begin) { + high = mid - 1; + } else { + low = mid + 1;
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/maps/maps_private.h
Added
@@ -0,0 +1,72 @@ +/* + +----------------------------------------------------------------------+ + | 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 __XDEBUG_MAPS_MAPS_PRIVATE_H__ +#define __XDEBUG_MAPS_MAPS_PRIVATE_H__ + +#include "../hash.h" +#include "../str.h" +#include "../vector.h" + +#define XDEBUG_PATH_MAP_TYPE_UNKNOWN 0x00 +#define XDEBUG_PATH_MAP_TYPE_DIRECTORY 0x01 +#define XDEBUG_PATH_MAP_TYPE_FILE 0x02 +#define XDEBUG_PATH_MAP_TYPE_LINES 0x03 +#define XDEBUG_PATH_MAP_TYPE_MASK 0x0f +#define XDEBUG_PATH_MAP_FLAGS_SKIP 0x10 +#define XDEBUG_PATH_MAP_FLAGS_MASK 0xf0 + +typedef struct xdebug_path_map_range xdebug_path_map_range; + +struct xdebug_path_map_range { + int remote_begin; + int remote_end; + int local_flags; + xdebug_str *local_path; + int local_begin; + int local_end; +}; + +typedef struct xdebug_path_mapping { + int type; + int ref_count; + xdebug_str *remote_path; + union { + xdebug_str *local_path; /* Only used for SKIP, DIRECTORY and FILE types */ + xdebug_vector *line_ranges; /* Only used for LINES type */ + } m; +} xdebug_path_mapping; + +typedef struct xdebug_path_maps { + xdebug_hash *remote_to_local_map; + xdebug_hash *local_to_remote_map; +} xdebug_path_maps; + +xdebug_path_maps *xdebug_path_maps_ctor(void); +void xdebug_path_maps_dtor(xdebug_path_maps *maps); + +int remote_to_local(xdebug_path_maps *maps, const char *remote_path, size_t remote_line, xdebug_str **local_path, size_t *local_line); +int local_to_remote(xdebug_path_maps *maps, const char *local_path, size_t local_line, xdebug_str **remote_path, size_t *remote_line); + +void xdebug_path_map_range_set(xdebug_path_map_range *from, int remote_begin, int remote_end, int local_flags, xdebug_str *local_path, int local_begin, int local_end); +void xdebug_path_map_range_copy(xdebug_path_map_range *from, xdebug_path_map_range *to); +void xdebug_path_map_range_dtor(xdebug_path_map_range *range); + +xdebug_path_mapping *xdebug_path_mapping_ctor(int type); +void xdebug_path_mapping_dtor(void *mapping); +xdebug_path_mapping *xdebug_path_mapping_copy(xdebug_path_mapping *mapping); + +#endif
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/maps/parser.c
Added
@@ -0,0 +1,912 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2025 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 <stdbool.h> +#include <stdio.h> +#include <stddef.h> +#include <stdlib.h> +#include <string.h> + +#include "maps_private.h" +#include "parser.h" + +#include "../hash.h" +#include "../mm.h" +#include "../normalize_path.h" +#include "../str.h" +#include "../trim.h" +#include "../xdebug_strndup.h" + +typedef struct path_maps_parser_state { + int error_code; + int error_line; + char *error_message; + + bool copy_error; + + char *current_local_prefix; + char *current_remote_prefix; + + char *current_working_directory; + FILE *current_file; + size_t current_line_no; + + xdebug_hash *file_rules; +} path_maps_parser_state; + +static void path_maps_parser_state_ctor(struct path_maps_parser_state *state) +{ + state->error_code = PATH_MAPS_OK; + state->error_message = NULL; + + state->copy_error = false; + + state->current_file = NULL; + state->current_line_no = 0; + state->current_local_prefix = NULL; + state->current_remote_prefix = NULL; + state->current_working_directory = NULL; + + state->file_rules = xdebug_hash_alloc(256, xdebug_path_mapping_dtor); +} + +static void path_maps_parser_state_dtor(struct path_maps_parser_state *state) +{ + state->error_code = PATH_MAPS_OK; + if (state->error_message) { + xdfree(state->error_message); + } + if (state->current_local_prefix) { + xdfree(state->current_local_prefix); + state->current_local_prefix = NULL; + } + if (state->current_remote_prefix) { + xdfree(state->current_remote_prefix); + state->current_remote_prefix = NULL; + } + if (state->current_working_directory) { + xdfree(state->current_working_directory); + state->current_working_directory = NULL; + } + if (state->current_file) { + fclose(state->current_file); + state->current_file = NULL; + } + if (state->file_rules) { + xdebug_hash_destroy(state->file_rules); + } +} + +static void state_set_error(path_maps_parser_state *state, int error_code, const char *error_message) +{ + state->error_code = error_code; + state->error_line = state->current_line_no; + if (state->error_message) { + xdfree(state->error_message); + } + state->error_message = xdstrdup(error_message); +} + +static int state_get_error_code(path_maps_parser_state *state) +{ + return state->error_code; +} + +static int state_get_error_line(path_maps_parser_state *state) +{ + return state->error_line; +} + +static char *state_get_error_message(path_maps_parser_state *state) +{ + return xdstrdup(state->error_message); +} + +static bool state_open_file(path_maps_parser_state *state, const char *filename) +{ + FILE *tmp = fopen(filename, "r"); + + if (!tmp) { + state_set_error(state, PATH_MAPS_CANT_OPEN_FILE, "Can't open file"); + return false; + } + + state->current_file = tmp; + return true; +} + +static bool is_valid_prefix(path_maps_parser_state *state, const char *prefix) +{ + if (prefix0 == '\0') { + state_set_error(state, PATH_MAPS_INVALID_PREFIX, "Prefix is empty"); + return false; + } + + /* Relative prefix */ + if (prefix0 == '.') { + /* Valid, starting with ./ */ + if (prefix1 != '/') { + char *message = xdebug_sprintf("Prefix is not a valid relative path: '%s'", prefix); + state_set_error(state, PATH_MAPS_INVALID_PREFIX, message); + xdfree(message); + return false; + } + + return true; + } + + if (prefix0 != '/') { + char *message = xdebug_sprintf("Prefix is not an absolute or relative path: '%s'", prefix); + state_set_error(state, PATH_MAPS_INVALID_PREFIX, message); + xdfree(message); + return false; + } + + return true; +} + +static bool state_set_remote_prefix(path_maps_parser_state *state, const char *prefix) +{ + char *trimmed_prefix = xdebug_trim(prefix); + + if (!is_valid_prefix(state, trimmed_prefix)) { + xdfree(trimmed_prefix); + return false; + } + + state->current_remote_prefix = trimmed_prefix; + + return true; +} + +static bool state_set_local_prefix(path_maps_parser_state *state, const char *prefix) +{ + char *trimmed_prefix = xdebug_trim(prefix); + + if (!is_valid_prefix(state, trimmed_prefix)) { + xdfree(trimmed_prefix); + return false; + } + + state->current_local_prefix = trimmed_prefix; + + return true; +} + +const char *mapping_type_as_string = { + "unknown", + "directory", + "file", + "line-range", + "skip" +}; + +enum map_element { + REMOTE, + LOCAL
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/maps/parser.h
Added
@@ -0,0 +1,38 @@ +/* + +----------------------------------------------------------------------+ + | 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 __XDEBUG_MAPS_PARSER_H__ +#define __XDEBUG_MAPS_PARSER_H__ + +/* Parser error codes */ +#define PATH_MAPS_OK 0x0000 +#define PATH_MAPS_CANT_OPEN_FILE 0x0001 +#define PATH_MAPS_NO_RULES 0x0002 +#define PATH_MAPS_EMPTY_LINE 0x0003 +#define PATH_MAPS_NO_NEWLINE 0x0004 +#define PATH_MAPS_GARBAGE 0x0005 +#define PATH_MAPS_INVALID_PREFIX 0x0006 +#define PATH_MAPS_DOUBLE_SEPARATOR 0x0007 +#define PATH_MAPS_NO_SEPARATOR 0x0008 +#define PATH_MAPS_MISMATCHED_TYPES 0x0009 +#define PATH_MAPS_WRONG_RANGE 0x0010 +#define PATH_MAPS_DUPLICATE_RULES 0x0011 +#define PATH_MAPS_NOT_ABSOLUTE 0x0012 +#define PATH_MAPS_MIXING_PATH_AND_LINES 0x0013 + +bool xdebug_path_maps_parse_file(xdebug_path_maps *maps, const char *cwd, const char *filename, int *error_code, int *error_line, char **error_message); + +#endif
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/mm.h
Changed
(renamed from xdebug-3.4.3/src/lib/mm.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/normalize_path.c
Added
@@ -0,0 +1,54 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2025 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 <string.h> + +#include "mm.h" +#include "str.h" + +#ifdef PHP_WIN32 +char *xdebug_normalize_path_char(const char *path) +{ + char *new_path = xdstrdup(path); + char *ptr = new_path; + + do { + if ((*ptr) == '\\') { + *ptr = '/'; + } + ptr++; + } while (*ptr != '\0'); + + return new_path; +} + +void xdebug_normalize_path_xdebug_str_in_place(xdebug_str *path) +{ + int i; + + for (i = 0; i < XDEBUG_STR_LEN(path); i++) { + if (XDEBUG_STR_VAL(path)i == '\\') { + XDEBUG_STR_VAL(path)i = '/'; + } + } +} +#else +char *xdebug_normalize_path_char(const char *path) +{ + return xdstrdup(path); +} +#endif +
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/normalize_path.h
Added
@@ -0,0 +1,35 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2025 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_NORMALIZE_PATH_H__ +#define __HAVE_NORMALIZE_PATH_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +char *xdebug_normalize_path_char(const char *path); +#ifdef PHP_WIN32 +void xdebug_normalize_path_xdebug_str_in_place(xdebug_str *path); +#else +# define xdebug_normalize_path_xdebug_str_in_place(path) +#endif + +#ifdef __cplusplus +} +#endif + +#endif
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/php-header.h
Added
@@ -0,0 +1,24 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2025 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. | + +----------------------------------------------------------------------+ + */ + +#if !defined(_MSC_VER) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeclaration-after-statement" +#endif +#include "php.h" +#if !defined(_MSC_VER) +# pragma GCC diagnostic pop +#endif
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/set.c
Changed
(renamed from xdebug-3.4.3/src/lib/set.c)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/set.h
Changed
(renamed from xdebug-3.4.3/src/lib/set.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/str.c
Added
@@ -0,0 +1,288 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2025 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 <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <locale.h> +#include <assert.h> + +#ifndef XDEBUG_NO_PHP_FEATURES +# if !defined(_MSC_VER) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeclaration-after-statement" +# endif +# include "zend_smart_str.h" +# if !defined(_MSC_VER) +# pragma GCC diagnostic pop +# endif +# include "lib/php-header.h" +# include "ext/standard/php_string.h" +#endif + +#include "mm.h" +#include "str.h" + +inline static void realloc_if_needed(xdebug_str *xs, int size_to_fit) +{ + if (!xs->a || !xs->l || xs->l + size_to_fit > xs->a - 1) { + xs->d = xdrealloc(xs->d, xs->a + size_to_fit + XDEBUG_STR_PREALLOC); + xs->a = xs->a + size_to_fit + XDEBUG_STR_PREALLOC; + } + if (!xs->l) { + xs->d0 = '\0'; + } +} + +inline static void xdebug_str_internal_addl(xdebug_str *xs, const char *str, int le, int f) +{ + realloc_if_needed(xs, le); + + memcpy(xs->d + xs->l, str, le); + xs->dxs->l + le = '\0'; + xs->l = xs->l + le; + + if (f) { + xdfree((char*) str); + } +} + +void xdebug_str_add(xdebug_str *xs, const char *str, int f) +{ + xdebug_str_internal_addl(xs, str, strlen(str), f); +} + +void xdebug_str_addl(xdebug_str *xs, const char *str, int le, int f) +{ + xdebug_str_internal_addl(xs, str, le, f); +} + +void xdebug_str_add_str(xdebug_str *xs, const xdebug_str *str) +{ + xdebug_str_internal_addl(xs, str->d, str->l, 0); +} + +#ifndef XDEBUG_NO_PHP_FEATURES +void xdebug_str_add_zstr(xdebug_str *xs, const zend_string *str) +{ + xdebug_str_internal_addl(xs, ZSTR_VAL(str), ZSTR_LEN(str), 0); +} +#endif + +void xdebug_str_addc(xdebug_str *xs, char letter) +{ + realloc_if_needed(xs, 1); + + xs->dxs->l = letter; + xs->dxs->l + 1 = '\0'; + xs->l = xs->l + 1; +} + +void xdebug_str_add_uint64(xdebug_str *xs, uint64_t num) +{ + char buffer21; + char *pos; + int digit; + + pos = &buffer20; + *pos = '\0'; + + do { + digit = num % 10; + num = num / 10; + if (digit < 10) { + *--pos = '0' + digit; + } else { + *--pos = 'a' + digit - 10; + } + } while (num != 0L); + + xdebug_str_internal_addl(xs, pos, &buffer20 - pos, 0); +} + +#if PHP_VERSION_ID >= 80200 +void xdebug_str_add_va_fmt(xdebug_str *xs, const char *fmt, va_list argv) +{ + int size; + int n; + va_list argv_size, argv_copy; + + realloc_if_needed(xs, 1); + size = xs->a - xs->l; + + va_copy(argv_size, argv); + n = vsnprintf(xs->d + xs->l, size, fmt, argv_size); + va_end(argv_size); + if (n > -1 && n < size) { + xs->l += n; + return; + } + + realloc_if_needed(xs, n + 1); + size = xs->a - xs->l; + + va_copy(argv_copy, argv); + n = vsnprintf(xs->d + xs->l, size, fmt, argv_copy); + va_end(argv_copy); + + if (n > -1 && n < size) { + xs->l += n; + return; + } + + assert(0); +} +#else +void xdebug_str_add_va_fmt(xdebug_str *xs, const char *fmt, va_list argv) +{ + smart_str buf = {0}; + + php_printf_to_smart_str(&buf, fmt, argv); + + if (!buf.s) { + return; + } + + xdebug_str_add_zstr(xs, buf.s); + + smart_str_free(&buf); +} +#endif + +void xdebug_str_add_fmt(xdebug_str *xs, const char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + xdebug_str_add_va_fmt(xs, fmt, args); + va_end(args); +} + +char *xdebug_sprintf(const char* fmt, ...) +{ + va_list args; + xdebug_str tmp_str = {0}; + + va_start(args, fmt); + xdebug_str_add_va_fmt(&tmp_str, fmt, args); + va_end(args); + + return tmp_str.d; +} + +void xdebug_str_chop(xdebug_str *xs, size_t c) +{ + if (c > xs->l) { + /* Do nothing if the chop amount is larger than the buffer size */ + } else { + xs->l -= c; + xs->dxs->l = '\0'; + } +} + +xdebug_str *xdebug_str_new(void) +{ + xdebug_str *tmp = xdmalloc(sizeof(xdebug_str));
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/str.h
Added
@@ -0,0 +1,83 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2025 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_STR_H__ +#define __HAVE_XDEBUG_STR_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdarg.h> +#include <stdbool.h> +#include <stddef.h> +#include <stdint.h> + +#ifndef XDEBUG_NO_PHP_FEATURES +# include "lib/php-header.h" +#endif + +#include "mm.h" + +#define XDEBUG_STR_INITIALIZER { 0, 0, NULL, 0, true } +#define XDEBUG_STR_PREALLOC 1024 + +#define XDEBUG_STR_WRAP_CHAR(v) (&((xdebug_str){strlen(v), strlen(v)+1, ((char*)(v))})) + +#define XDEBUG_STR_VAL(str) (str->d) +#define XDEBUG_STR_LEN(str) (str->l) + +typedef struct xdebug_str { + size_t l; + size_t a; + char *d; + size_t rc; // refcount + bool is_static; // not an allocated xdebug_str +} xdebug_str; + +void xdebug_str_add(xdebug_str *xs, const char *str, int f); +void xdebug_str_addl(xdebug_str *xs, const char *str, int le, int f); +void xdebug_str_add_str(xdebug_str *xs, const xdebug_str *str); +#ifndef XDEBUG_NO_PHP_FEATURES +void xdebug_str_add_zstr(xdebug_str *xs, const zend_string *str); +#endif +void xdebug_str_add_fmt(xdebug_str *xs, const char *fmt, ...); +void xdebug_str_add_va_fmt(xdebug_str *xs, const char *fmt, va_list argv); +void xdebug_str_addc(xdebug_str *xs, char letter); +void xdebug_str_add_uint64(xdebug_str *xs, uint64_t num); +#define xdebug_str_add_literal(s,l) xdebug_str_addl((s), (l), sizeof(l)-1, 0) +#define xdebug_str_add_const(s,l) xdebug_str_addl((s), (l), strlen(l), 0) + +void xdebug_str_chop(xdebug_str *xs, size_t c); + +xdebug_str *xdebug_str_new(void); +xdebug_str *xdebug_str_create_from_char(char *c); +#define xdebug_str_create_from_const_char(c) xdebug_str_create_from_char((char*) (c)) +xdebug_str *xdebug_str_create(const char *c, size_t len); +xdebug_str *xdebug_str_copy(xdebug_str *orig); // uses refcounting +xdebug_str *xdebug_str_clone(xdebug_str *orig); // new allocation + copying data +void xdebug_str_destroy(xdebug_str *s); +void xdebug_str_free(xdebug_str *s); + +bool xdebug_str_is_equal(xdebug_str *s1, xdebug_str *s2); + +char* xdebug_sprintf(const char* fmt, ...); + +#ifdef __cplusplus +} +#endif + +#endif
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/stripcslashes.c
Added
@@ -0,0 +1,89 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2026 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 <ctype.h> +#include <stddef.h> +#include <stdlib.h> + +#ifndef XDEBUG_NO_PHP_FEATURES +# include "compat.h" +#else +# ifndef XDEBUG_BREAK_INTENTIONALLY_MISSING +# define XDEBUG_BREAK_INTENTIONALLY_MISSING +# endif +#endif // XDEBUG_NO_PHP_FEATURES + +void xdebug_stripcslashes(char *str, int *len) +{ + char *source, *target, *end; + int nlen = *len, i; + char numtmp4; + + for (source=str, end=str+nlen, target=str; source < end; source++) { + if (*source == '\\' && source+1 < end) { + source++; + switch (*source) { + case 'n': *target++='\n'; nlen--; break; + case 'r': *target++='\r'; nlen--; break; + case 'a': *target++='\a'; nlen--; break; + case 't': *target++='\t'; nlen--; break; + case 'v': *target++='\v'; nlen--; break; + case 'b': *target++='\b'; nlen--; break; + case 'f': *target++='\f'; nlen--; break; + case '\\': *target++='\\'; nlen--; break; + case 'x': + if (source+1 < end && isxdigit((int)(*(source+1)))) { + numtmp0 = *++source; + if (source+1 < end && isxdigit((int)(*(source+1)))) { + numtmp1 = *++source; + numtmp2 = '\0'; + nlen-=3; + } else { + numtmp1 = '\0'; + nlen-=2; + } + *target++=(char)strtol(numtmp, NULL, 16); + break; + } + XDEBUG_BREAK_INTENTIONALLY_MISSING + + default: + i=0; + while (source < end && *source >= '0' && *source <= '7' && i<3) { + numtmpi++ = *source++; + } + if (i) { + numtmpi='\0'; + *target++=(char)strtol(numtmp, NULL, 8); + nlen-=i; + source--; + } else { + *target++=*source; + nlen--; + } + } + } else { + *target++=*source; + } + } + + if (nlen != 0) { + *target='\0'; + } + + *len = nlen; +} +
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/stripcslashes.h
Added
@@ -0,0 +1,30 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2026 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_STRIPCSLASHES_H__ +#define __XDEBUG_STRIPCSLASHES_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +void xdebug_stripcslashes(char *str, int *len); + +#ifdef __cplusplus +} +#endif + +#endif // __XDEBUG_STRIPCSLASHES_H__
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/strrnchr.h
Added
@@ -0,0 +1,35 @@ +/* +ISC License + +© 2017, 2018, 2021, 2022, 2023, 2024 Mattias Andrée <m@maandree.se> + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +/* From: https://github.com/maandree/libsimple/blob/9b483673c0c8a52d81127a23788fa4c976f2b10f/strrnchr.c */ +static char *strrnchr(const char *s_, int c_, size_t n) +{ + char *s = *(char **)(void *)&s_, c = (char)c_; + char *end = &sn, *r = NULL; + + for (; s != end; s++) { + if (*s == c) { + r = s; + } + if (!*s) { + break; + } + } + return r; +} +
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/timing.c
Changed
(renamed from xdebug-3.4.3/src/lib/timing.c)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/timing.h
Changed
(renamed from xdebug-3.4.3/src/lib/timing.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/trim.c
Added
@@ -0,0 +1,48 @@ +/* + +----------------------------------------------------------------------+ + | 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. | + +----------------------------------------------------------------------+ + */ +#include <stddef.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include "mm.h" + +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; +}
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/trim.h
Added
@@ -0,0 +1,30 @@ +/* + +----------------------------------------------------------------------+ + | 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 __HAVE_LIB_TRIM_H__ +#define __HAVE_LIB_TRIM_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +char *xdebug_trim(const char *str); + +#ifdef __cplusplus +} +#endif + +#endif
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/usefulstuff.c
Added
@@ -0,0 +1,745 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2025 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 "compat.h" + +#include "mm.h" +#include "crc32.h" +#include "str.h" + +#include "lib_private.h" +#include "usefulstuff.h" +#include "log.h" + +#if PHP_VERSION_ID >= 80200 +# include "ext/random/php_random.h" +#else +# include "ext/standard/php_lcg.h" +#endif +#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'; + } + } +} + +bool xdebug_is_printable(const char *str, size_t len) +{ + size_t i; + + for (i = 0; i < len; i++) { + if (!isprint(stri)) { + return false; + } + } + + return true; +} + +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; +} + +/* not all versions of php export this */ +static int xdebug_htoi(char *s) +{ + int value; + int c; + + c = s0; + if (isupper(c)) { + c = tolower(c); + } + value = (c >= '0' && c <= '9' ? c - '0' : c - 'a' + 10) * 16; + + c = s1; + if (isupper(c)) {
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/usefulstuff.h
Added
@@ -0,0 +1,46 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2025 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_USEFULSTUFF_H__ +#define __HAVE_USEFULSTUFF_H__ + +#include "php_xdebug.h" +#include "src/lib/compat.h" + +typedef struct xdebug_arg { + int c; + char **args; +} xdebug_arg; + +xdebug_arg *xdebug_arg_ctor(void); +void xdebug_arg_dtor(xdebug_arg *arg); + +xdebug_str* xdebug_join(const char *delim, xdebug_arg *args, int begin, int end); +void xdebug_explode(const char *delim, const char *str, xdebug_arg *args, int limit); +bool xdebug_is_printable(const char *str, size_t len); +const char* xdebug_memnstr(const char *haystack, const char *needle, int needle_len, const char *end); +char* xdebug_strrstr(const char* haystack, const char* needle); + +char *xdebug_zstr_path_to_url(zend_string *string); +char *xdebug_xdebug_str_path_to_url(xdebug_str *string); +char *xdebug_path_from_url(zend_string *fileurl); + +FILE *xdebug_fopen(char *fname, const char *mode, const char *extension, char **new_fname); +int xdebug_format_output_filename(char **filename, char *format, char *script_name); +int xdebug_format_file_link(char **filename, const char *error_filename, int error_lineno); +int xdebug_format_filename(char **formatted_name, const char *default_format, zend_string *filename); + +#endif
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/var.c
Added
@@ -0,0 +1,1229 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2025 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 "zend_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/xdebug_strndup.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); + if (EG(exception)) { + zend_clear_exception(); + } + + 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");
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/var.h
Changed
(renamed from xdebug-3.4.3/src/lib/var.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/var_export_html.c
Changed
(renamed from xdebug-3.4.3/src/lib/var_export_html.c)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/var_export_html.h
Changed
(renamed from xdebug-3.4.3/src/lib/var_export_html.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/var_export_line.c
Added
@@ -0,0 +1,462 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2025 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) PG(serialize_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.5.3.tgz/xdebug-3.5.3/src/lib/var_export_line.h
Changed
(renamed from xdebug-3.4.3/src/lib/var_export_line.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/var_export_text.c
Changed
(renamed from xdebug-3.4.3/src/lib/var_export_text.c)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/var_export_text.h
Changed
(renamed from xdebug-3.4.3/src/lib/var_export_text.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/var_export_xml.c
Added
@@ -0,0 +1,867 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2025 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 "xdebug_strndup.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; + zend_object *zobj; +} 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, zend_object *zobj) +{ + zval **zv = &zv_nptr; + xdebug_object_item *item; + + item = xdcalloc(1, sizeof(xdebug_object_item)); + item->type = object_type; + item->zv = *zv; + item->zobj = zobj; + + 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_object *zobj, 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->zobj = zobj; + 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)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/var_export_xml.h
Changed
(renamed from xdebug-3.4.3/src/lib/var_export_xml.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/vector.h
Added
@@ -0,0 +1,128 @@ +/* + +----------------------------------------------------------------------+ + | 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 __XDEBUG_VECTOR_H__ +#define __XDEBUG_VECTOR_H__ + +#include <stddef.h> +#include <string.h> +#include "mm.h" + +typedef void (*xdebug_vector_dtor)(void *); + +typedef struct _xdebug_vector { + size_t capacity; + size_t count; + + size_t element_size; + void *data; + xdebug_vector_dtor dtor; +} xdebug_vector; + +static void __xdebug_grow_vector_if_needed(xdebug_vector *v) +{ + if (v->count + 1 > v->capacity) { + if (v->capacity == 0) { + v->capacity = 32; + } else { + v->capacity = v->capacity * 3 / 2; + } + + v->data = xdrealloc(v->data, v->capacity * v->element_size); + } +} + +static inline void *xdebug_vector_push(xdebug_vector *v) +{ + void *tmp_top = NULL; + + __xdebug_grow_vector_if_needed(v); + + v->count++; + + tmp_top = ((char*) v->data + ((v->count - 1) * v->element_size)); + memset(tmp_top, '\0', v->element_size); + + return tmp_top; +} + +static inline void xdebug_vector_pop(xdebug_vector *v) +{ + v->dtor(((char*) v->data + ((v->count - 1) * v->element_size))); + v->count--; +} + +static inline void *xdebug_vector_element_get(xdebug_vector *v, size_t index) +{ + if (!v || index >= v->count) { + return NULL; + } + return ((char*) v->data + (index * (v)->element_size)); +} + +static inline int xdebug_vector_element_is_valid(xdebug_vector *v, void *element) +{ + if ((char*) element < (char*) v->data) { + return 0; + } + if ((char*) element > ((char*) v->data + ((v->count - 1) * v->element_size))) { + return 0; + } + + return 1; +} + +#define XDEBUG_VECTOR_HEAD(v) xdebug_vector_element_get((v), 0) +#define XDEBUG_VECTOR_TAIL(v) xdebug_vector_element_get((v), (v)->count-1) + +#define XDEBUG_VECTOR_COUNT(v) (v)->count + +static inline xdebug_vector *xdebug_vector_alloc(size_t element_size, xdebug_vector_dtor dtor) +{ + xdebug_vector *tmp; + + tmp = (xdebug_vector*) xdmalloc(sizeof(xdebug_vector)); + tmp->capacity = 0; + tmp->count = 0; + tmp->data = NULL; + tmp->dtor = dtor; + tmp->element_size = element_size; + + return tmp; +} + +static inline void xdebug_vector_destroy(xdebug_vector *v) +{ + while (XDEBUG_VECTOR_COUNT(v)) { + xdebug_vector_pop(v); + } + xdfree(v->data); + xdfree(v); +} + +static inline xdebug_vector *xdebug_vector_clone(xdebug_vector *v) +{ + xdebug_vector *tmp = xdebug_vector_alloc(v->element_size, v->dtor); + + tmp->count = v->count; + + tmp->data = xdrealloc(tmp->data, v->capacity * v->element_size); + memcpy(tmp->data, v->data, v->capacity * v->element_size); + + return tmp; +} + +#endif /* __XDEBUG_VECTOR_H__ */
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/xdebug_strndup.c
Added
@@ -0,0 +1,41 @@ +/* + +----------------------------------------------------------------------+ + | 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. | + +----------------------------------------------------------------------+ + */ +#include <stddef.h> +#include <stdlib.h> +#include <string.h> + +#include "mm.h" +#include "xdebug_strndup.h" + +/** + * Duplicate zend_strndup in core to avoid mismatches + * in C-runtime libraries when xdebug and core are built + * with different run-time libraries. + */ +char *xdebug_strndup(const char *s, int length) +{ + char *p; + + p = (char *) xdmalloc(length + 1); + if (p == NULL) { + return p; + } + if (length) { + memcpy(p, s, length); + } + plength = 0; + return p; +}
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/xdebug_strndup.h
Added
@@ -0,0 +1,30 @@ +/* + +----------------------------------------------------------------------+ + | 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 __HAVE_XDEBUG_STRNDUP_H__ +#define __HAVE_XDEBUG_STRNDUP_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +char* xdebug_strndup(const char *s, int length); + +#ifdef __cplusplus +} +#endif + +#endif
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/xml.c
Changed
(renamed from xdebug-3.4.3/src/lib/xml.c)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/lib/xml.h
Changed
(renamed from xdebug-3.4.3/src/lib/xml.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/profiler/profiler.c
Added
@@ -0,0 +1,566 @@ +/* + +----------------------------------------------------------------------+ + | 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. | + +----------------------------------------------------------------------+ + */ + +#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 "Zend/zend_exceptions.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) +{ +#if PHP_VERSION_ID < 80400 + /* Overload the "exit" opcode */ + xdebug_set_opcode_handler(ZEND_EXIT, xdebug_profiler_exit_handler); +#endif +} + +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(); +} + +void xdebug_profiler_exit_function_handler(void) +{ + function_stack_entry *fse = XDEBUG_VECTOR_TAIL(XG_BASE(stack)); + + deinit_if_active(); + + xdebug_profiler_free_function_details(fse); +} + +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; + }
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/profiler/profiler.h
Changed
(renamed from xdebug-3.4.3/src/profiler/profiler.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/profiler/profiler_private.h
Changed
(renamed from xdebug-3.4.3/src/profiler/profiler_private.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/tracing/trace_computerized.c
Changed
(renamed from xdebug-3.4.3/src/tracing/trace_computerized.c)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/tracing/trace_computerized.h
Changed
(renamed from xdebug-3.4.3/src/tracing/trace_computerized.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/tracing/trace_flamegraph.c
Changed
(renamed from xdebug-3.4.3/src/tracing/trace_flamegraph.c)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/tracing/trace_flamegraph.h
Changed
(renamed from xdebug-3.4.3/src/tracing/trace_flamegraph.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/tracing/trace_html.c
Changed
(renamed from xdebug-3.4.3/src/tracing/trace_html.c)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/tracing/trace_html.h
Changed
(renamed from xdebug-3.4.3/src/tracing/trace_html.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/tracing/trace_textual.c
Changed
(renamed from xdebug-3.4.3/src/tracing/trace_textual.c)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/tracing/trace_textual.h
Changed
(renamed from xdebug-3.4.3/src/tracing/trace_textual.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/src/tracing/tracing.c
Added
@@ -0,0 +1,779 @@ +/* + +----------------------------------------------------------------------+ + | 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.5.3.tgz/xdebug-3.5.3/src/tracing/tracing.h
Added
@@ -0,0 +1,82 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2025 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" + +#if !defined(_MSC_VER) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeclaration-after-statement" +#endif +#include "zend_generators.h" +#if !defined(_MSC_VER) +# pragma GCC diagnostic pop +#endif + +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.5.3.tgz/xdebug-3.5.3/src/tracing/tracing_private.h
Changed
(renamed from xdebug-3.4.3/src/tracing/tracing_private.h)
View file
xdebug-3.5.3.tgz/xdebug-3.5.3/xdebug.c
Added
@@ -0,0 +1,862 @@ +/* + +----------------------------------------------------------------------+ + | 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. | + +----------------------------------------------------------------------+ + */ + +#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" +#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT +# 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.5.3.tgz/xdebug-3.5.3/xdebug.ini
Added
@@ -0,0 +1,1425 @@ +; This file is generated by the 'xdebug.org:html/docs/convert.php' robot +; for Xdebug 3.5.3 — 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. +; +; Xdebug also supports a few other ways of specifying the host to connect to, +; but these methods are not always available. xdebug_info() shows whether the +; ``xdebug://*`` methods are available. +; +; xdebug://gateway +; Use the system defined network gateway. +; +; *Supported on Linux only.* +; +; xdebug://nameserver +; Use the system defined private network nameserver. +; +; *Supported on Linux only, and not with distributions that use musl libc +; 1, such as Alpine Linux.* +; +; unix:///path/to/sock +; A Unix domain socket 2. +; +; *Supported on non-Windows platforms, and only supported by select few +; debugging clients.* +; +; 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. +; +; 1 https://en.wikipedia.org/wiki/Musl +; 2 https://en.wikipedia.org/wiki/Unix_domain_socket +; +; .. 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. +;
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
.