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 5
View file
php8-xdebug.changes
Changed
@@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Mon May 19 07:24:13 UTC 2025 - Angelo Grossini <angelo@intercom.it> + +- update to 3.4.3 + +------------------------------------------------------------------- Fri May 31 14:36:41 UTC 2024 - Angelo Grossini <angelo@intercom.it> - update to 3.3.2
View file
php8-xdebug.spec
Changed
@@ -19,7 +19,7 @@ %define pkg_name xdebug %define pkg_version %{version} Name: php8-%{pkg_name} -Version: 3.3.2 +Version: 3.4.3 Release: 0 Summary: Extended PHP debugger License: PHP-3.0
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/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.1:: - - git checkout --track origin/xdebug_3_1 - -Branches --------- - -There are two branches in operation: - -``master`` - This is were all new feature Pull Requests should be targeted at -``xdebug_3_1`` - This is were all bug fix Pull Requests should be targeted at. The - maintainer will add them to ``master`` too when merging the Pull Request. - -Working on a Pull Request -------------------------- - -- Make sure that your ``master`` and ``xdebug_3_1`` branches are up to date - with the ``upstream`` repository. -- Create an issue in the `issue tracker <https://bugs.xdebug.org>`_ (if none - exists yet). -- Switch to the right target branch (``master`` for features, ``xdebug_3_1`` - for bug fixes). -- Create a feature branch:: - - git checkout -b issue{issue number}-{description} - - For example:: - - git checkout -b issue1893-crash-with-fiber - -- For a bug fix, write one or more test cases to verify that the problem - currently exists, and also to define what the output should be. Xdebug uses - PHP's `phpt tests <https://qa.php.net/write-test.php>`_. The ``README.rst`` - file contains information on how to run the tests. - - Each of Xdebug's modes has a specific directory where to place tests. For - example, for code coverage that is ``tests/coverage``. Test case names - should follow the following pattern:: - - tests/{feature-group}bug0{issue-number}.phpt - - If you need more than one test, append ``-001`` after the issue number. - - Pull Requests without tests won't be accepted. - -- Fix and/or write the code. - -- Before you submit a PR, make sure each commit is a single logical unit. The - main commit that implements the issue, should have as commit message ``Fixed - issue #1893: `` followed by the Summary of the issue in the issue tracker. The - message should state what the change was about. For example:: - - Fixed issue #1893: Crash with ext-fiber with xdebug.mode=coverage - -- Before you submit a PR, make sure to rebase first on the branch that you - will be targeting, for example to rebase against the current bug fix - branch:: - - git fetch upstream && git rebase upstream/xdebug_3_1 - -- Push your changes to your remote repository:: - - git push origin {branch-name} - - For example:: - - git push origin issue1893-crash-with-fiber - -- Once you're satisfied, generate a pull request. Make sure that the title is - in one line, it's fine if it's a few characters larger than what GitHub - likes. Do not let the title spill over into the description with ``...```. - - In the description, explain what you changed, and why, and how your solution - is the right one. Feel free to include questions, and pointers to specific - things that need close review.
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/config.m4
Deleted
@@ -1,133 +0,0 @@ -dnl config.m4 for extension Xdebug - -PHP_ARG_ENABLE(xdebug, whether to enable Xdebug support, - --enable-xdebug Enable Xdebug support) - -PHP_ARG_ENABLE(xdebug-dev, whether to enable Xdebug developer build flags, - --enable-xdebug-dev Xdebug: Enable developer flags,, no) - -PHP_ARG_WITH(xdebug-compression, whether to compress profiler files (requires zlib), - --without-xdebug-compression Xdebug: Disable compression through zlib,yes,no) - -m4_include(m4/pkg.m4) -m4_include(m4/clocks.m4) - -if test "$PHP_XDEBUG" != "no"; then - AC_MSG_CHECKING(for supported PHP version) - PHP_XDEBUG_FOUND_VERSION=`${PHP_CONFIG} --version` - PHP_XDEBUG_FOUND_VERNUM=`${PHP_CONFIG} --vernum` - if test "$PHP_XDEBUG_FOUND_VERNUM" -lt "80000"; then - AC_MSG_ERROR(not supported. Need a PHP version >= 8.0.0 and < 8.5.0 (found $PHP_XDEBUG_FOUND_VERSION)) - else - if test "$PHP_XDEBUG_FOUND_VERNUM" -ge "80400"; then - AC_MSG_ERROR(not supported. Need a PHP version >= 8.0.0 and < 8.4.0 (found $PHP_XDEBUG_FOUND_VERSION)) - else - AC_MSG_RESULT(supported ($PHP_XDEBUG_FOUND_VERSION)) - fi - fi - - AC_DEFINE(HAVE_XDEBUG,1, ) - - old_CPPFLAGS=$CPPFLAGS - CPPFLAGS="$INCLUDES $CPPFLAGS" - - AC_XDEBUG_CLOCK - - AC_CHECK_HEADERS(netinet/in.h poll.h sys/poll.h) - case $host_os in - linux*) - AC_CHECK_HEADERS(linux/rtnetlink.h, , - case $host_os in - linux-musl*) - AC_MSG_ERROR(rtnetlink.h is required, install the linux-headers package: apk add --update linux-headers) - esac - AC_MSG_ERROR(rtnetlink.h is required, please make sure it is available by installing the correct package) - ) - esac - - PHP_CHECK_FUNC(res_ninit, resolv) - PHP_CHECK_FUNC(res_nclose, resolv) - - PHP_CHECK_LIBRARY(m, cos, PHP_ADD_LIBRARY(m,, XDEBUG_SHARED_LIBADD) ) - - if test "$PHP_XDEBUG_COMPRESSION" != "no"; then - PKG_CHECK_MODULES(ZLIB, zlib >= 1.2.9, - PHP_EVAL_LIBLINE($ZLIB_LIBS, XDEBUG_SHARED_LIBADD) - PHP_EVAL_INCLINE($ZLIB_CFLAGS) - - AC_DEFINE(HAVE_XDEBUG_ZLIB,1, ) - , ) - fi - - CPPFLAGS=$old_CPPFLAGS - - if test "$PHP_XDEBUG_DEV" = "yes"; then - AX_CHECK_COMPILE_FLAG(-Wbool-conversion, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wbool-conversion") - AX_CHECK_COMPILE_FLAG(-Wdeclaration-after-statement, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wdeclaration-after-statement") - AX_CHECK_COMPILE_FLAG(-Wdiscarded-qualifiers, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wdiscarded-qualifiers") - AX_CHECK_COMPILE_FLAG(-Wduplicate-enum, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wduplicate-enum") - AX_CHECK_COMPILE_FLAG(-Wempty-body, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wempty-body") - AX_CHECK_COMPILE_FLAG(-Wenum-compare, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wenum-compare") - AX_CHECK_COMPILE_FLAG(-Werror, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Werror") - AX_CHECK_COMPILE_FLAG(-Wextra, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wextra") - AX_CHECK_COMPILE_FLAG(-Wformat-nonliteral, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wformat-nonliteral") - AX_CHECK_COMPILE_FLAG(-Wformat-security, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wformat-security") - AX_CHECK_COMPILE_FLAG(-Wheader-guard, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wheader-guard") - AX_CHECK_COMPILE_FLAG(-Wincompatible-pointer-types-discards-qualifiers, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wincompatible-pointer-types-discards-qualifiers") - AX_CHECK_COMPILE_FLAG(-Wimplicit-fallthrough, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wimplicit-fallthrough") - AX_CHECK_COMPILE_FLAG(-Winit-self, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Winit-self") - AX_CHECK_COMPILE_FLAG(-Wlogical-not-parentheses, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wlogical-not-parentheses") - AX_CHECK_COMPILE_FLAG(-Wlogical-op, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wlogical-op") - AX_CHECK_COMPILE_FLAG(-Wlogical-op-parentheses, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wlogical-op-parentheses") - AX_CHECK_COMPILE_FLAG(-Wloop-analysis, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wloop-analysis") - AX_CHECK_COMPILE_FLAG(-Wmaybe-uninitialized, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wmaybe-uninitialized") - AX_CHECK_COMPILE_FLAG(-Wmissing-format-attribute, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wmissing-format-attribute") - AX_CHECK_COMPILE_FLAG(-Wno-missing-field-initializers, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wno-missing-field-initializers") - AX_CHECK_COMPILE_FLAG(-Wno-sign-compare, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wno-sign-compare") - AX_CHECK_COMPILE_FLAG(-Wno-unused-but-set-variable, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wno-unused-but-set-variable") - AX_CHECK_COMPILE_FLAG(-Wno-unused-parameter, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wno-unused-parameter") - AX_CHECK_COMPILE_FLAG(-Wno-variadic-macros, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wno-variadic-macros") - AX_CHECK_COMPILE_FLAG(-Wparentheses, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wparentheses") - AX_CHECK_COMPILE_FLAG(-Wpointer-bool-conversion, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wpointer-bool-conversion") - AX_CHECK_COMPILE_FLAG(-Wsizeof-array-argument, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wsizeof-array-argument") - AX_CHECK_COMPILE_FLAG(-Wstring-conversion, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wstring-conversion") - AX_CHECK_COMPILE_FLAG(-Wwrite-strings, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wwrite-strings") - AX_CHECK_COMPILE_FLAG(-Wpointer-arith, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wpointer-arith") - AX_CHECK_COMPILE_FLAG(-fdiagnostics-show-option, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fdiagnostics-show-option") - AX_CHECK_COMPILE_FLAG(-fno-exceptions, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fno-exceptions") - AX_CHECK_COMPILE_FLAG(-fno-omit-frame-pointer, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fno-omit-frame-pointer") - AX_CHECK_COMPILE_FLAG(-fno-optimize-sibling-calls, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fno-optimize-sibling-calls") - AX_CHECK_COMPILE_FLAG(-fsanitize-address, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fsanitize-address") - AX_CHECK_COMPILE_FLAG(-fstack-protector, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fstack-protector") - - MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS" - STD_CFLAGS="-g -O0 -Wall" - fi - - PHP_XDEBUG_CFLAGS="$STD_CFLAGS $MAINTAINER_CFLAGS" - - XDEBUG_BASE_SOURCES="src/base/base.c src/base/ctrl_socket.c src/base/filter.c" - XDEBUG_LIB_SOURCES="src/lib/usefulstuff.c src/lib/cmd_parser.c src/lib/compat.c src/lib/crc32.c src/lib/file.c src/lib/hash.c src/lib/headers.c src/lib/lib.c src/lib/llist.c src/lib/log.c src/lib/set.c src/lib/str.c src/lib/timing.c src/lib/var.c src/lib/var_export_html.c src/lib/var_export_line.c src/lib/var_export_text.c src/lib/var_export_xml.c src/lib/xml.c" - - XDEBUG_COVERAGE_SOURCES="src/coverage/branch_info.c src/coverage/code_coverage.c" - XDEBUG_DEBUGGER_SOURCES="src/debugger/com.c src/debugger/debugger.c src/debugger/handler_dbgp.c src/debugger/handlers.c src/debugger/ip_info.c" - XDEBUG_DEVELOP_SOURCES="src/develop/develop.c src/develop/monitor.c src/develop/php_functions.c src/develop/stack.c src/develop/superglobals.c" - XDEBUG_GCSTATS_SOURCES="src/gcstats/gc_stats.c" - XDEBUG_PROFILER_SOURCES="src/profiler/profiler.c" - XDEBUG_TRACING_SOURCES="src/tracing/trace_computerized.c src/tracing/trace_flamegraph.c src/tracing/trace_html.c src/tracing/trace_textual.c src/tracing/tracing.c" - - PHP_NEW_EXTENSION(xdebug, xdebug.c $XDEBUG_BASE_SOURCES $XDEBUG_LIB_SOURCES $XDEBUG_COVERAGE_SOURCES $XDEBUG_DEBUGGER_SOURCES $XDEBUG_DEVELOP_SOURCES $XDEBUG_GCSTATS_SOURCES $XDEBUG_PROFILER_SOURCES $XDEBUG_TRACING_SOURCES, $ext_shared,,$PHP_XDEBUG_CFLAGS,,yes) - PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(xdebug)/src/base) - PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(xdebug)/src/lib) - PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(xdebug)/src/coverage) - PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(xdebug)/src/debugger) - PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(xdebug)/src/develop) - PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(xdebug)/src/gcstats) - PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(xdebug)/src/profiler) - PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(xdebug)/src/tracing) - PHP_SUBST(XDEBUG_SHARED_LIBADD) - PHP_ADD_MAKEFILE_FRAGMENT - - PHP_ADD_INCLUDE($ext_srcdir/src) - PHP_ADD_INCLUDE($ext_builddir/src) -fi
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/config.w32
Deleted
@@ -1,49 +0,0 @@ -// vim:ft=javascript - -ARG_WITH("xdebug", "Xdebug support", "no"); - -ARG_WITH("xdebug-compression", "whether to compress profiler files (requires zlib)", "no"); - -if (PHP_XDEBUG != 'no') { - var XDEBUG_BASE_SOURCES="base.c filter.c" - var XDEBUG_LIB_SOURCES="usefulstuff.c cmd_parser.c compat.c crc32.c file.c hash.c headers.c lib.c llist.c log.c set.c str.c timing.c var.c var_export_html.c var_export_line.c var_export_text.c var_export_xml.c xml.c" - - var XDEBUG_COVERAGE_SOURCES="branch_info.c code_coverage.c" - var XDEBUG_DEBUGGER_SOURCES="com.c debugger.c handler_dbgp.c handlers.c" - var XDEBUG_DEVELOP_SOURCES="develop.c monitor.c php_functions.c stack.c superglobals.c" - var XDEBUG_GCSTATS_SOURCES="gc_stats.c" - var XDEBUG_PROFILER_SOURCES="profiler.c" - var XDEBUG_TRACING_SOURCES="trace_computerized.c trace_flamegraph.c trace_html.c trace_textual.c tracing.c" - - var files = "xdebug.c"; - - if (typeof(ZEND_EXTENSION) == 'undefined') { - EXTENSION('xdebug', files); - } else { - ZEND_EXTENSION('xdebug', files); - } - ADD_FLAG("CFLAGS_XDEBUG", " /I " + configure_module_dirname + " "); - ADD_FLAG("CFLAGS_XDEBUG", " /I " + configure_module_dirname + "/src "); - ADD_SOURCES(configure_module_dirname + "/src/base", XDEBUG_BASE_SOURCES, "xdebug"); - ADD_SOURCES(configure_module_dirname + "/src/lib", XDEBUG_LIB_SOURCES, "xdebug"); - ADD_SOURCES(configure_module_dirname + "/src/coverage", XDEBUG_COVERAGE_SOURCES, "xdebug"); - ADD_SOURCES(configure_module_dirname + "/src/debugger", XDEBUG_DEBUGGER_SOURCES, "xdebug"); - ADD_SOURCES(configure_module_dirname + "/src/develop", XDEBUG_DEVELOP_SOURCES, "xdebug"); - ADD_SOURCES(configure_module_dirname + "/src/gcstats", XDEBUG_GCSTATS_SOURCES, "xdebug"); - ADD_SOURCES(configure_module_dirname + "/src/profiler", XDEBUG_PROFILER_SOURCES, "xdebug"); - ADD_SOURCES(configure_module_dirname + "/src/tracing", XDEBUG_TRACING_SOURCES, "xdebug"); - - // PHP_ZLIB is "yes"/"no" for in-tree builds, but boolean for phpize builds - var XDEBUG_ZLIB = (!MODE_PHPIZE && PHP_ZLIB == "yes") || (MODE_PHPIZE && PHP_ZLIB); - - if (PHP_XDEBUG_COMPRESSION != "no") { - if (((!XDEBUG_ZLIB) && (CHECK_LIB("zlib_a.lib;zlib.lib", "xdebug", PHP_XDEBUG))) || - (PHP_ZLIB_SHARED && CHECK_LIB("zlib.lib", "xdebug", PHP_XDEBUG)) || - (XDEBUG_ZLIB && (!PHP_ZLIB_SHARED)) - ) { - AC_DEFINE('HAVE_XDEBUG_ZLIB', 1); - } - } - - AC_DEFINE("HAVE_XDEBUG", 1, "Xdebug support"); -}
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/php_xdebug.h
Deleted
@@ -1,111 +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 PHP_XDEBUG_H -#define PHP_XDEBUG_H - -#define XDEBUG_NAME "Xdebug" -#define XDEBUG_VERSION "3.3.2" -#define XDEBUG_AUTHOR "Derick Rethans" -#define XDEBUG_COPYRIGHT "Copyright (c) 2002-2024 by Derick Rethans" -#define XDEBUG_COPYRIGHT_SHORT "Copyright (c) 2002-2024" -#define XDEBUG_URL "https://xdebug.org" -#define XDEBUG_URL_FAQ "https://xdebug.org/docs/faq#api" - -#include "lib/php-header.h" - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "base/base_globals.h" -#include "coverage/branch_info.h" -#include "coverage/code_coverage.h" -#include "debugger/debugger.h" -#include "develop/develop.h" -#include "lib/lib.h" -#include "gcstats/gc_stats.h" -#include "profiler/profiler.h" -#include "tracing/tracing.h" -#include "lib/compat.h" -#include "lib/hash.h" -#include "lib/llist.h" -#include "lib/vector.h" -#include "lib/timing.h" - -extern zend_module_entry xdebug_module_entry; -#define phpext_xdebug_ptr &xdebug_module_entry - -#define OUTPUT_NOT_CHECKED -1 -#define OUTPUT_IS_TTY 1 -#define OUTPUT_NOT_TTY 0 - -#ifdef PHP_WIN32 -#define PHP_XDEBUG_API __declspec(dllexport) -#else -#define PHP_XDEBUG_API -#endif - -#ifdef ZTS -#include "TSRM.h" -#endif - -#include "main/SAPI.h" - -#define XDEBUG_ALLOWED_HALT_LEVELS (E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE ) - -PHP_MINIT_FUNCTION(xdebug); -PHP_MSHUTDOWN_FUNCTION(xdebug); -PHP_RINIT_FUNCTION(xdebug); -PHP_RSHUTDOWN_FUNCTION(xdebug); -PHP_MINFO_FUNCTION(xdebug); -ZEND_MODULE_POST_ZEND_DEACTIVATE_D(xdebug); - -int xdebug_is_output_tty(); - -ZEND_BEGIN_MODULE_GLOBALS(xdebug) - struct { - xdebug_base_globals_t base; - xdebug_coverage_globals_t coverage; - xdebug_debugger_globals_t debugger; - xdebug_develop_globals_t develop; - xdebug_gc_stats_globals_t gc_stats; - xdebug_library_globals_t library; - xdebug_profiler_globals_t profiler; - xdebug_tracing_globals_t tracing; - } globals; - struct { - xdebug_base_settings_t base; - xdebug_coverage_settings_t coverage; - xdebug_debugger_settings_t debugger; - xdebug_develop_settings_t develop; - xdebug_gc_stats_settings_t gc_stats; - xdebug_library_settings_t library; - xdebug_profiler_settings_t profiler; - xdebug_tracing_settings_t tracing; - } settings; -ZEND_END_MODULE_GLOBALS(xdebug) - -#ifdef ZTS -#define XG(v) TSRMG(xdebug_globals_id, zend_xdebug_globals *, v) -#else -#define XG(v) (xdebug_globals.v) -#endif - -#define XG_BASE(v) (XG(globals.base.v)) -#define XINI_BASE(v) (XG(settings.base.v)) - -#endif
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/run-xdebug-tests.php
Deleted
@@ -1,4042 +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.3.2.tgz/xdebug-3.3.2/src/base/base.c
Deleted
@@ -1,1602 +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 "TSRM.h" -#include "php_globals.h" -#include "zend_closures.h" -#include "zend_exceptions.h" -#if PHP_VERSION_ID >= 80200 -# include "zend_attributes.h" -#endif - -#include "zend_interfaces.h" - -#if PHP_VERSION_ID >= 80100 -# include "base_private.h" -# include "Zend/zend_fibers.h" -# include "Zend/zend_observer.h" -#endif - -#include "php_xdebug.h" -#include "php_xdebug_arginfo.h" - -#include "base.h" -#include "filter.h" -#ifdef __linux__ -# include "ctrl_socket.h" -#endif -#include "develop/develop.h" -#include "develop/stack.h" -#include "gcstats/gc_stats.h" -#include "lib/lib_private.h" -#include "lib/log.h" -#include "lib/var_export_line.h" -#include "lib/var.h" -#include "profiler/profiler.h" - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - -/* True globals for overloaded functions */ -zif_handler orig_error_reporting_func = NULL; -zif_handler orig_set_time_limit_func = NULL; -zif_handler orig_pcntl_exec_func = NULL; -zif_handler orig_pcntl_fork_func = NULL; - -#if PHP_VERSION_ID >= 80100 -void (*xdebug_old_error_cb)(int type, zend_string *error_filename, const uint32_t error_lineno, zend_string *message); -void (*xdebug_new_error_cb)(int type, zend_string *error_filename, const uint32_t error_lineno, zend_string *message); -static void xdebug_error_cb(int orig_type, zend_string *error_filename, const uint32_t error_lineno, zend_string *message); -#else -void (*xdebug_old_error_cb)(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message); -void (*xdebug_new_error_cb)(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message); -static void xdebug_error_cb(int orig_type, const char *error_filename, const uint32_t error_lineno, zend_string *message); -#endif - -/* execution redirection functions */ -zend_op_array* (*old_compile_file)(zend_file_handle* file_handle, int type); -static void (*xdebug_old_execute_ex)(zend_execute_data *execute_data); -static void (*xdebug_old_execute_internal)(zend_execute_data *current_execute_data, zval *return_value); - -/* error_cb and execption hook overrides */ -void xdebug_base_use_original_error_cb(void); -void xdebug_base_use_xdebug_error_cb(void); -void xdebug_base_use_xdebug_throw_exception_hook(void); - -/* Forward declarations for function overides */ -PHP_FUNCTION(xdebug_set_time_limit); -PHP_FUNCTION(xdebug_error_reporting); -PHP_FUNCTION(xdebug_pcntl_exec); -PHP_FUNCTION(xdebug_pcntl_fork); - - -/* {{{ zend_op_array xdebug_compile_file (file_handle, type) - * This function provides a hook for the execution of bananas */ -static zend_op_array *xdebug_compile_file(zend_file_handle *file_handle, int type) -{ - zend_op_array *op_array; - - op_array = old_compile_file(file_handle, type); - - if (!op_array) { - return NULL; - } - - xdebug_coverage_compile_file(op_array); - xdebug_debugger_compile_file(op_array); - - return op_array; -} -/* }}} */ - -/* I don't like this API, but the function_stack_entry does not keep this as a - * pointer, and hence we need two APIs for freeing :-S */ -void xdebug_func_dtor_by_ref(xdebug_func *elem) -{ - if (elem->function) { - zend_string_release(elem->function); - } - if (elem->object_class) { - zend_string_release(elem->object_class); - } - if (elem->scope_class) { - zend_string_release(elem->scope_class); - } - if (elem->include_filename) { - zend_string_release(elem->include_filename); - } -} - -void xdebug_func_dtor(xdebug_func *elem) -{ - xdebug_func_dtor_by_ref(elem); - xdfree(elem); -} - -static void function_stack_entry_dtor(void *elem) -{ - unsigned int i; - function_stack_entry *e = elem; - - xdebug_func_dtor_by_ref(&e->function); - - if (e->filename) { - zend_string_release(e->filename); - } - - if (e->var) { - for (i = 0; i < e->varc; i++) { - if (e->vari.name) { - zend_string_release(e->vari.name); - } - zval_ptr_dtor(&(e->vari.data)); - } - xdfree(e->var); - } - - if (e->declared_vars) { - xdebug_llist_destroy(e->declared_vars, NULL); - e->declared_vars = NULL; - } - - if (e->profile.call_list) { - xdebug_llist_destroy(e->profile.call_list, NULL); - e->profile.call_list = NULL; - } -} - -int xdebug_include_or_eval_handler(XDEBUG_OPCODE_HANDLER_ARGS) -{ - const zend_op *opline = execute_data->opline; - zval *inc_filename; - zval tmp_inc_filename; - int is_var; - - if (opline->extended_value != ZEND_EVAL) { - return xdebug_call_original_opcode_handler_if_set(opline->opcode, XDEBUG_OPCODE_HANDLER_ARGS_PASSTHRU); - } - - inc_filename = xdebug_get_zval(execute_data, opline->op1_type, &opline->op1, &is_var); - - /* If there is no inc_filename, we're just bailing out instead */ - if (!inc_filename) { - return xdebug_call_original_opcode_handler_if_set(opline->opcode, XDEBUG_OPCODE_HANDLER_ARGS_PASSTHRU); - } - - if (Z_TYPE_P(inc_filename) != IS_STRING) { - tmp_inc_filename = *inc_filename; - zval_copy_ctor(&tmp_inc_filename); - convert_to_string(&tmp_inc_filename); - inc_filename = &tmp_inc_filename; - } - - /* Now let's store this info */ - if (XG_BASE(last_eval_statement)) { - zend_string_release(XG_BASE(last_eval_statement)); - } - XG_BASE(last_eval_statement) = zend_string_init(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename), 0); - - if (inc_filename == &tmp_inc_filename) { - zval_dtor(&tmp_inc_filename); - } - - return xdebug_call_original_opcode_handler_if_set(opline->opcode, XDEBUG_OPCODE_HANDLER_ARGS_PASSTHRU); -} - -static int find_line_number_for_current_execute_point(zend_execute_data *edata)
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/base/base_globals.h
Deleted
@@ -1,95 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#ifndef __XDEBUG_BASE_GLOBALS_H__ -#define __XDEBUG_BASE_GLOBALS_H__ - -#include "lib/hash.h" -#include "lib/llist.h" -#include "lib/vector.h" - - -#if PHP_WIN32 -typedef void (WINAPI *WIN_PRECISE_TIME_FUNC)(LPFILETIME); -#endif - -typedef struct _xdebug_nanotime_context { - uint64_t start_abs; - uint64_t last_abs; -#if PHP_WIN32 | HAVE_XDEBUG_CLOCK_GETTIME | HAVE_XDEBUG_CLOCK_GETTIME_NSEC_NP - uint64_t start_rel; - uint64_t last_rel; - int use_rel_time; -#endif -#if PHP_WIN32 - WIN_PRECISE_TIME_FUNC win_precise_time_func; - uint64_t win_freq; -#endif -} xdebug_nanotime_context; - - -typedef struct _xdebug_base_globals_t { - xdebug_vector *stack; -#if PHP_VERSION_ID >= 80100 - xdebug_hash *fiber_stacks; -#endif - xdebug_nanotime_context nanotime_context; - uint64_t start_nanotime; - unsigned int prev_memory; - int output_is_tty; - zend_bool in_debug_info; - zend_long error_reporting_override; - zend_bool error_reporting_overridden; - unsigned int function_count; - zend_string *last_eval_statement; - char *last_exception_trace; - - /* in-execution checking */ - zend_bool in_execution; - zend_bool in_var_serialisation; - - /* Systemd Private Temp */ - char *private_tmp; - -#ifdef __linux__ - /* Control Socket */ - char *control_socket_path; - int control_socket_fd; - zend_long control_socket_last_trigger; -#endif - - /* filters */ - zend_long filter_type_code_coverage; - zend_long filter_type_stack; - zend_long filter_type_tracing; - xdebug_llist *filters_code_coverage; - xdebug_llist *filters_stack; - xdebug_llist *filters_tracing; - - /* PHP versions */ - const char *php_version_compile_time; - const char *php_version_run_time; -} xdebug_base_globals_t; - -typedef struct _xdebug_base_settings_t { -#ifdef __linux__ - int control_socket_granularity; - zend_long control_socket_threshold_ms; -#endif - zend_long max_nesting_level; -} xdebug_base_settings_t; - -#endif // __XDEBUG_BASE_GLOBALS_H__
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/base/ctrl_socket.c
Deleted
@@ -1,373 +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 __linux__ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/socket.h> -#include <sys/un.h> -#include <arpa/inet.h> -#include <signal.h> -#include <string.h> -#include <errno.h> - -#include "php_xdebug.h" - -#include "ctrl_socket.h" -#include "lib/cmd_parser.h" -#include "lib/log.h" -#include "lib/xml.h" - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - -typedef struct { - int code; - const char *message; -} xdebug_error_entry; - -static xdebug_error_entry xdebug_error_codes24 = { - { 0, "no error" }, - { 1, "parse error in command" }, - { 2, "duplicate arguments in command" }, - { 3, "invalid or missing options" }, - { 4, "unimplemented command" }, - { 5, "command is not available" }, - { 400, "step debugger is not enabled" }, - { 401, "step debugger did not activate" }, - { -1, NULL } -}; - -static const char *error_message_from_code(int code) -{ - xdebug_error_entry *error_entry = &xdebug_error_codes0; - - while (error_entry->message) { - if (code == error_entry->code) { - return error_entry->message; - } - error_entry++; - } - return NULL; -} - -#define ADD_REASON_MESSAGE(c) { \ - xdebug_xml_node *message = xdebug_xml_node_init("message"); \ - xdebug_xml_add_text(message, xdstrdup(error_message_from_code(c))); \ - xdebug_xml_add_child(error, message); \ -} - - -#define CTRL_FUNC_PARAMETERS xdebug_xml_node **retval, xdebug_dbgp_arg *args -#define CTRL_FUNC(name) static void xdebug_ctrl_handle_##name(CTRL_FUNC_PARAMETERS) -#define CTRL_FUNC_ENTRY(name) { #name, xdebug_ctrl_handle_##name }, - -typedef struct xdebug_ctrl_cmd { - const char *name; - void (*handler)(CTRL_FUNC_PARAMETERS); - int flags; -} xdebug_ctrl_cmd; - -/* Command definition list */ -CTRL_FUNC(ps); -CTRL_FUNC(pause); - -static xdebug_ctrl_cmd ctrl_commands = { - CTRL_FUNC_ENTRY(ps) - CTRL_FUNC_ENTRY(pause) - { NULL, NULL } -}; - -/* Command handler selection */ -static xdebug_ctrl_cmd* lookup_cmd(char *cmd) -{ - xdebug_ctrl_cmd *ptr = ctrl_commands; - - while (ptr->name) { - if (strcmp(ptr->name, cmd) == 0) { - return ptr; - } - ptr++; - } - return NULL; -} - -static xdebug_str *make_message(xdebug_xml_node *message) -{ - xdebug_str xml_message = XDEBUG_STR_INITIALIZER; - xdebug_str *ret = xdebug_str_new(); - - xdebug_xml_return_node(message, &xml_message); - - xdebug_str_add_literal(ret, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); - xdebug_str_add(ret, xml_message.d, 0); - xdebug_str_addc(ret, '\0'); - xdebug_str_destroy(&xml_message); - - return ret; -} - - -static void handle_command(int fd, const char *line) -{ - char *cmd = NULL; - xdebug_dbgp_arg *args; - int res = 0; - xdebug_ctrl_cmd *command; - xdebug_str *message; - xdebug_xml_node *retval; - res = xdebug_cmd_parse(line, (char**) &cmd, (xdebug_dbgp_arg**) &args); - - retval = xdebug_xml_node_init("ctrl-response"); - xdebug_xml_add_attribute(retval, "xmlns:xdebug-ctrl", "https://xdebug.org/ctrl/xdebug"); - - command = lookup_cmd(cmd); - if (command) { - command->handler(&retval, args); - } else { - xdebug_xml_node *error; - error = xdebug_xml_node_init("error"); - xdebug_xml_add_attribute_ex(error, "code", xdebug_sprintf("%lu", XDEBUG_ERROR_COMMAND_UNAVAILABLE), 0, 1); - ADD_REASON_MESSAGE(XDEBUG_ERROR_COMMAND_UNAVAILABLE); - xdebug_xml_add_child(retval, error); - } - - message = make_message(retval); - write(fd, message->d, message->l); - - xdfree(cmd); - xdebug_cmd_arg_dtor(args); -} - -CTRL_FUNC(ps) -{ - xdebug_xml_node *response, *engine, *file, *pid, *time, *memory; - char *pid_str, *time_str, *memory_str; - function_stack_entry *fse = XDEBUG_VECTOR_HEAD(XG_BASE(stack)); - double time_elapsed = XDEBUG_SECONDS_SINCE_START(xdebug_get_nanotime()); - - response = xdebug_xml_node_init("ps"); - xdebug_xml_add_attribute(response, "success", "1"); - - engine = xdebug_xml_node_init("engine"); - xdebug_xml_add_attribute(engine, "version", XDEBUG_VERSION); - xdebug_xml_add_text(engine, xdstrdup(XDEBUG_NAME)); - xdebug_xml_add_child(response, engine); - - file = xdebug_xml_node_init("fileuri"); - xdebug_xml_add_text(file, ZSTR_VAL(fse->filename)); - xdebug_xml_add_child(response, file); - - pid = xdebug_xml_node_init("pid"); - pid_str = xdebug_sprintf("%lu", xdebug_get_pid()); - xdebug_xml_add_text(pid, pid_str); - xdebug_xml_add_child(response, pid); - - time = xdebug_xml_node_init("time"); - time_str = xdebug_sprintf("%f", time_elapsed); - xdebug_xml_add_text(time, time_str); - xdebug_xml_add_child(response, time); - - memory = xdebug_xml_node_init("memory"); - memory_str = xdebug_sprintf("%ld", zend_memory_usage(0) / 1024); - xdebug_xml_add_text(memory, memory_str); - xdebug_xml_add_child(response, memory); - - xdebug_xml_add_child(*retval, response); -} - -CTRL_FUNC(pause) -{ - xdebug_xml_node *response, *pid, *action; - char *pid_str; - - response = xdebug_xml_node_init("pause"); - xdebug_xml_add_attribute(response, "success", "1");
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/coverage/code_coverage.c
Deleted
@@ -1,1194 +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.3.2.tgz/xdebug-3.3.2/src/debugger/com.c
Deleted
@@ -1,790 +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.3.2.tgz/xdebug-3.3.2/src/debugger/com.h
Deleted
@@ -1,71 +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_XDEBUG_COM_H__ -#define __HAVE_XDEBUG_COM_H__ - -#include "handlers.h" - -#define XDEBUG_CLIENT_PORT_S "9003" -#define XDEBUG_CLOUD_PORT 9020L - -#if WIN32|WINNT -# define SOCK_ERR INVALID_SOCKET -# define SOCK_CONN_ERR SOCKET_ERROR -# define SOCK_RECV_ERR SOCKET_ERROR -#else -# define SOCK_ERR -1 -# define SOCK_CONN_ERR -1 -# define SOCK_RECV_ERR -1 -#endif -#define SOCK_TIMEOUT_ERR -2 -#define SOCK_ACCESS_ERR -3 - -#if WIN32|WINNT -#define SCLOSE(a) closesocket(a) -#define SSENDL(a,b,c) send(a,b,c,0) -#define SSEND(a,b) send(a,b,strlen(b),0) -#define SREAD(a,b,c) recv(a,b,c,0) -#else -#define SCLOSE(a) close(a) -#define SSENDL(a,b,c) write(a,b,c) -#define SSEND(a,b) write(a,b,strlen(b)) -#define SREAD(a,b,c) read(a,b,c) -#endif - - -#define SENDMSG(socket, str) { \ - char *message_buffer; \ - \ - message_buffer = str; \ - SSEND(socket, message_buffer); \ - xdfree(message_buffer); \ -} - -void xdebug_close_socket(int socket); - -/* Remote connection activation and house keeping */ -#define xdebug_is_debug_connection_active() !!XG_DBG(remote_connection_enabled) -void xdebug_abort_debugger(void); -void xdebug_restart_debugger(void); -void xdebug_mark_debug_connection_active(void); -void xdebug_mark_debug_connection_not_active(void); -void xdebug_mark_debug_connection_pending(void); -void xdebug_debug_init_if_requested_at_startup(void); -void xdebug_debug_init_if_requested_on_error(void); -void xdebug_debug_init_if_requested_on_xdebug_break(void); - -#endif
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/debugger/debugger.c
Deleted
@@ -1,1041 +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.3.2.tgz/xdebug-3.3.2/src/debugger/debugger_private.h
Deleted
@@ -1,51 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2021 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#ifndef __XDEBUG_DEBUGGER_PRIVATE_H__ -#define __XDEBUG_DEBUGGER_PRIVATE_H__ - -#include "debugger.h" - -#include "lib/lib.h" - -typedef struct _fd_buf fd_buf; - -struct _fd_buf { - char *buffer; - int buffer_size; -}; - -typedef struct _xdebug_function_lines_map_item xdebug_function_lines_map_item; - -struct _xdebug_function_lines_map_item { - size_t line_start; - size_t line_end; - size_t line_span; - xdebug_set *lines_breakable; -}; - -typedef struct _xdebug_lines_list xdebug_lines_list; - -struct _xdebug_lines_list { - size_t count; /* How many function/line mappings are in the list */ - size_t size; /* How many function/line mappings are allocated */ - xdebug_function_lines_map_item **functions; -}; - -#define XG_DBG(v) (XG(globals.debugger.v)) -#define XINI_DBG(v) (XG(settings.debugger.v)) - -#endif
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/debugger/handler_dbgp.c
Deleted
@@ -1,3039 +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 <errno.h> -#include <sys/types.h> - -#ifndef PHP_WIN32 -#include <unistd.h> -#endif - -#include "lib/php-header.h" -#include "SAPI.h" - -#include "ext/standard/php_string.h" -#include "ext/standard/url.h" -#include "main/php_version.h" -#include "main/php_network.h" -#include "ext/standard/base64.h" -#include "TSRM.h" - -#include "php_globals.h" -#include "php_xdebug.h" - -#include "com.h" -#include "handler_dbgp.h" -#include "debugger_private.h" - -#include "coverage/code_coverage.h" -#include "develop/stack.h" -#include "lib/compat.h" -#include "lib/hash.h" -#include "lib/llist.h" -#include "lib/log.h" -#include "lib/mm.h" -#include "lib/var_export_xml.h" -#include "lib/vector.h" -#include "lib/xml.h" - -#ifdef PHP_WIN32 -#include "win32/time.h" -#include <process.h> -#endif -#include <fcntl.h> - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - -xdebug_remote_handler xdebug_handler_dbgp = { - xdebug_dbgp_init, - xdebug_dbgp_deinit, - xdebug_dbgp_error, - xdebug_dbgp_break_on_line, - xdebug_dbgp_breakpoint, - xdebug_dbgp_resolve_breakpoints, - xdebug_dbgp_stream_output, - xdebug_dbgp_notification, - xdebug_dbgp_user_notify, - xdebug_dbgp_register_eval_id, -}; - -static char *create_eval_key_id(int id); -static void line_breakpoint_resolve_helper(xdebug_con *context, xdebug_lines_list *lines_list, xdebug_brk_info *brk_info); - -/***************************************************************************** -** Constants and strings for statii and reasons -*/ - -/* Status structure */ -#define DBGP_STATUS_STARTING 1 -#define DBGP_STATUS_STOPPING 2 -#define DBGP_STATUS_STOPPED 3 -#define DBGP_STATUS_RUNNING 4 -#define DBGP_STATUS_BREAK 5 -#define DBGP_STATUS_DETACHED 6 - -const char *xdebug_dbgp_status_strings7 = - {"", "starting", "stopping", "stopped", "running", "break", "detached"}; - -#define DBGP_REASON_OK 0 -#define DBGP_REASON_ERROR 1 -#define DBGP_REASON_ABORTED 2 -#define DBGP_REASON_EXCEPTION 3 - -const char *xdebug_dbgp_reason_strings4 = - {"ok", "error", "aborted", "exception"}; - -#define XDEBUG_ERROR_OK 0 -#define XDEBUG_ERROR_PARSE 1 -#define XDEBUG_ERROR_DUP_ARG 2 -#define XDEBUG_ERROR_INVALID_ARGS 3 -#define XDEBUG_ERROR_UNIMPLEMENTED 4 -#define XDEBUG_ERROR_COMMAND_UNAVAILABLE 5 - -#define XDEBUG_ERROR_CANT_OPEN_FILE 100 -#define XDEBUG_ERROR_STREAM_REDIRECT_FAILED 101 /* unused */ - -#define XDEBUG_ERROR_BREAKPOINT_NOT_SET 200 -#define XDEBUG_ERROR_BREAKPOINT_TYPE_NOT_SUPPORTED 201 -#define XDEBUG_ERROR_BREAKPOINT_INVALID 202 -#define XDEBUG_ERROR_BREAKPOINT_NO_CODE 203 -#define XDEBUG_ERROR_BREAKPOINT_INVALID_STATE 204 -#define XDEBUG_ERROR_NO_SUCH_BREAKPOINT 205 -#define XDEBUG_ERROR_EVALUATING_CODE 206 -#define XDEBUG_ERROR_INVALID_EXPRESSION 207 /* unused */ - -#define XDEBUG_ERROR_PROPERTY_NON_EXISTENT 300 -#define XDEBUG_ERROR_PROPERTY_NON_EXISTANT 300 /* compatibility typo */ -#define XDEBUG_ERROR_STACK_DEPTH_INVALID 301 -#define XDEBUG_ERROR_CONTEXT_INVALID 302 /* unused */ - -#define XDEBUG_ERROR_PROFILING_NOT_STARTED 800 - -#define XDEBUG_ERROR_ENCODING_NOT_SUPPORTED 900 - -typedef struct { - int code; - const char *message; -} xdebug_error_entry; - -static xdebug_error_entry xdebug_error_codes24 = { - { 0, "no error" }, - { 1, "parse error in command" }, - { 2, "duplicate arguments in command" }, - { 3, "invalid or missing options" }, - { 4, "unimplemented command" }, - { 5, "command is not available" }, - { 100, "can not open file" }, - { 101, "stream redirect failed" }, - { 200, "breakpoint could not be set" }, - { 201, "breakpoint type is not supported" }, - { 202, "invalid breakpoint line" }, - { 203, "no code on breakpoint line" }, - { 204, "invalid breakpoint state" }, - { 205, "no such breakpoint" }, - { 206, "error evaluating code" }, - { 207, "invalid expression" }, - { 300, "can not get property" }, - { 301, "stack depth invalid" }, - { 302, "context invalid" }, - { 800, "profiler not started" }, - { 900, "encoding not supported" }, - { 998, "an internal exception in the debugger" }, - { 999, "unknown error" }, - { -1, NULL } -}; - -static const char *error_message_from_code(int code) -{ - xdebug_error_entry *error_entry = &xdebug_error_codes0; - - while (error_entry->message) { - if (code == error_entry->code) { - return error_entry->message; - } - error_entry++; - } - return NULL; -} - -#define XDEBUG_STR_SWITCH_DECL char *__switch_variable -#define XDEBUG_STR_SWITCH(s) __switch_variable = (s); -#define XDEBUG_STR_CASE(s) if (strcmp(__switch_variable, s) == 0) { -#define XDEBUG_STR_CASE_END } else -#define XDEBUG_STR_CASE_DEFAULT { -#define XDEBUG_STR_CASE_DEFAULT_END } - -#define XDEBUG_TYPES_COUNT 8 -const char *xdebug_dbgp_typemapXDEBUG_TYPES_COUNT3 = { - /* common, lang, schema */ - {"bool", "bool", "xsd:boolean"}, - {"int", "int", "xsd:decimal"}, - {"float", "float", "xsd:double"}, - {"string", "string", "xsd:string"}, - {"null", "null", NULL}, - {"hash", "array", NULL}, - {"object", "object", NULL}, - {"resource", "resource", NULL} -}; - - -typedef struct { - int value; - const char *name; -} xdebug_breakpoint_entry; - -#define XDEBUG_BREAKPOINT_TYPES_COUNT 6 -xdebug_breakpoint_entry xdebug_breakpoint_typesXDEBUG_BREAKPOINT_TYPES_COUNT = {
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/develop/develop.h
Deleted
@@ -1,85 +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_DEVELOP_H__ -#define __XDEBUG_DEVELOP_H__ - -#define XDEBUG_LAST_EXCEPTION_TRACE_SLOTS 8 - -typedef struct _xdebug_develop_globals_t { - /* used for function monitoring */ - zend_bool do_monitor_functions; - xdebug_hash *functions_to_monitor; - xdebug_llist *monitored_functions_found; /* List of functions found */ - - /* superglobals */ - xdebug_llist server; - xdebug_llist get; - xdebug_llist post; - xdebug_llist cookie; - xdebug_llist files; - xdebug_llist env; - xdebug_llist request; - xdebug_llist session; - - /* used for collection errors */ - xdebug_llist *collected_errors; - - /* scream */ - zend_bool in_at; - - /* last exception stack trace */ - struct { - int next_slot; - zend_object *obj_ptrXDEBUG_LAST_EXCEPTION_TRACE_SLOTS; - zval stack_traceXDEBUG_LAST_EXCEPTION_TRACE_SLOTS; - } last_exception_trace; -} xdebug_develop_globals_t; - -typedef struct _xdebug_develop_settings_t { - - zend_long max_stack_frames; - zend_bool show_ex_trace; - zend_bool show_error_trace; - zend_bool show_local_vars; - zend_bool force_display_errors; - zend_long force_error_reporting; - zend_long halt_level; - - zend_long cli_color; - - /* superglobals */ - zend_bool dump_globals; - zend_bool dump_once; - zend_bool dump_undefined; - - /* scream */ - zend_bool do_scream; -} xdebug_develop_settings_t; - -void xdebug_init_develop_globals(xdebug_develop_globals_t *xg); -void xdebug_deinit_develop_globals(xdebug_develop_globals_t *xg); - -void xdebug_develop_minit(); -void xdebug_develop_mshutdown(); -void xdebug_develop_rinit(); -void xdebug_develop_post_deactivate(); -void xdebug_develop_rshutdown(); - -void xdebug_develop_throw_exception_hook(zend_object *exception, zval *file, zval *line, zval *code, char *code_str, zval *message); -void xdebug_monitor_handler(function_stack_entry *fse); - -#endif
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/develop/stack.c
Deleted
@@ -1,1352 +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.3.2.tgz/xdebug-3.3.2/src/develop/superglobals.c
Deleted
@@ -1,209 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#include "lib/php-header.h" -#include "SAPI.h" - -#include "php_xdebug.h" -#include "superglobals.h" - -#include "lib/compat.h" -#include "lib/lib.h" -#include "lib/var_export_html.h" -#include "lib/var_export_line.h" - -extern ZEND_DECLARE_MODULE_GLOBALS(xdebug); - -void xdebug_superglobals_dump_dtor(void *user, void *ptr) -{ - free(ptr); -} - -static void dump_hash_elem(zval *z, const char *name, long index_key, const char *elem, int html, xdebug_str *str) -{ - if (html) { - if (elem) { - xdebug_str_add_fmt(str, "<tr><td colspan='2' align='right' bgcolor='#eeeeec' valign='top'><pre>$%s'%s' =</pre></td>", name, elem); - } else { - xdebug_str_add_fmt(str, "<tr><td colspan='2' align='right' bgcolor='#eeeeec' valign='top'><pre>$%s%ld =</pre></td>", name, index_key); - } - } - - if (z != NULL) { - xdebug_str *val; - - if (html) { - val = xdebug_get_zval_value_html(NULL, z, 0, NULL); - - xdebug_str_add_literal(str, "<td colspan='3' bgcolor='#eeeeec'>"); - xdebug_str_add_str(str, val); - xdebug_str_add_literal(str, "</td>"); - } else { - val = xdebug_get_zval_value_line(z, 0, NULL); - - if (elem) { - xdebug_str_add_fmt(str, "\n $%s'%s' = ", name, elem); - } else { - xdebug_str_add_fmt(str, "\n $%s%ld = ", name, index_key); - } - xdebug_str_add_str(str, val); - } - - xdebug_str_free(val); - } else { - /* not found */ - if (html) { - xdebug_str_add_literal(str, "<td colspan='3' bgcolor='#eeeeec'><i>undefined</i></td>"); - } else if (elem) { - xdebug_str_add_fmt(str, "\n $%s'%s' is undefined", name, elem); - } else { - xdebug_str_add_fmt(str, "\n $%s%ld is undefined", name, index_key); - } - } - - if (html) { - xdebug_str_add_literal(str, "</tr>\n"); - } -} - -static int dump_hash_elem_va(zval *pDest, zend_ulong index_key, zend_string *hash_key, const char *name, int html, xdebug_str *str) -{ - if (HASH_KEY_IS_NUMERIC(hash_key)) { - dump_hash_elem(pDest, name, index_key, NULL, html, str); - } else { - dump_hash_elem(pDest, name, 0, HASH_APPLY_KEY_VAL(hash_key), html, str); - } - - return SUCCESS; -} - -static void dump_hash(xdebug_llist *l, const char *name, int name_len, int html, xdebug_str *str) -{ - zval *z; - zend_ulong num; - zend_string *key; - zval *val; - HashTable *ht = NULL; - xdebug_llist_element *elem; - - if (!XDEBUG_LLIST_COUNT(l)) { - return; - } - - { - zend_string *s_name = zend_string_init(name, name_len, 0); - if ((z = zend_hash_find(&EG(symbol_table), s_name))) { - if (Z_TYPE_P(z) == IS_REFERENCE) { - z = &z->value.ref->val; - } - if (Z_TYPE_P(z) == IS_ARRAY) { - ht = Z_ARRVAL_P(z); - } - } - zend_string_release(s_name); - } - - if (html) { - xdebug_str_add_fmt(str, "<tr><th colspan='5' align='left' bgcolor='#e9b96e'>Dump <i>$%s</i></th></tr>\n", name); - } else { - xdebug_str_add_fmt(str, "\nDump $%s", name); - } - - elem = XDEBUG_LLIST_HEAD(l); - - while (elem != NULL) { - zend_string *s; - - s = zend_string_init(elem->ptr, strlen(elem->ptr), 0); - - if (ht && (*((char *) (elem->ptr)) == '*')) { - ZEND_HASH_FOREACH_KEY_VAL_IND(ht, num, key, val) { - dump_hash_elem_va(val, num, key, name, html, str); - } ZEND_HASH_FOREACH_END(); - } else if (ht && (z = zend_hash_find(ht, s))) { - dump_hash_elem(z, name, 0, elem->ptr, html, str); - } else if (XINI_DEV(dump_undefined)) { - dump_hash_elem(NULL, name, 0, elem->ptr, html, str); - } - - elem = XDEBUG_LLIST_NEXT(elem); - - zend_string_release(s); - } -} - -char* xdebug_get_printable_superglobals(int html) -{ - xdebug_str str = XDEBUG_STR_INITIALIZER; - - dump_hash(&XG_DEV(server), "_SERVER", HASH_KEY_SIZEOF("_SERVER"), html, &str); - dump_hash(&XG_DEV(get), "_GET", HASH_KEY_SIZEOF("_GET"), html, &str); - dump_hash(&XG_DEV(post), "_POST", HASH_KEY_SIZEOF("_POST"), html, &str); - dump_hash(&XG_DEV(cookie), "_COOKIE", HASH_KEY_SIZEOF("_COOKIE"), html, &str); - dump_hash(&XG_DEV(files), "_FILES", HASH_KEY_SIZEOF("_FILES"), html, &str); - dump_hash(&XG_DEV(env), "_ENV", HASH_KEY_SIZEOF("_ENV"), html, &str); - dump_hash(&XG_DEV(session), "_SESSION", HASH_KEY_SIZEOF("_SESSION"), html, &str); - dump_hash(&XG_DEV(request), "_REQUEST", HASH_KEY_SIZEOF("_REQUEST"), html, &str); - - return str.d; -} - -void xdebug_superglobals_dump_tok(xdebug_llist *l, char *str) -{ - char *tok; - const char *sep = ","; - - tok = strtok(str, sep); - while (tok != NULL) { - char *p = tok + strlen(tok) - 1; - - while ((*tok == ' ') || (*tok == '\t')) { - tok++; - } - - while ((p > tok) && ((*p == ' ') || (*p == '\t'))) { - p--; - } - - *(p+1) = 0; - - /* we need to strdup each element so that we can safely free it */ - xdebug_llist_insert_next(l, NULL, strdup(tok)); - - tok = strtok(NULL, sep); - } -} - -PHP_FUNCTION(xdebug_dump_superglobals) -{ - int html = PG(html_errors); - char *superglobal_info = NULL; - - if (html) { - php_printf("<table class='xdebug-superglobals' dir='ltr' border='1' cellspacing='0'>\n"); - } - - superglobal_info = xdebug_get_printable_superglobals(html);
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/compat.h
Deleted
@@ -1,84 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#ifndef __HAVE_XDEBUG_COMPAT_H__ -#define __HAVE_XDEBUG_COMPAT_H__ - -#include "lib/php-header.h" -#include "str.h" - -#include "ext/standard/head.h" -#include "ext/standard/php_var.h" -#define xdebug_php_var_dump php_var_dump - -char *xdebug_str_to_str(char *haystack, size_t length, const char *needle, size_t needle_len, const char *str, size_t str_len, size_t *new_len); - -unsigned char *xdebug_base64_encode(unsigned char *data, size_t data_len, size_t *new_len); -unsigned char *xdebug_base64_decode(unsigned char *data, size_t data_len, size_t *new_len); - -zend_string *xdebug_addslashes(zend_string *str); -void xdebug_stripcslashes(char *string, int *new_len); - -zend_ulong xdebug_get_pid(void); - -void xdebug_setcookie(const char *name, int name_len, char *value, int value_len, time_t expires, const char *path, int path_len, const char *domain, int domain_len, int secure, int url_encode, int httponly); -char *xdebug_get_compiled_variable_name(zend_op_array *op_array, uint32_t var, int *cv_len); - -/* Recursion protection is done differently from PHP 7.3 onwards */ -zend_bool xdebug_zend_hash_is_recursive(HashTable* ht); -zend_bool xdebug_zend_hash_apply_protection_begin(HashTable* ht); -zend_bool xdebug_zend_hash_apply_protection_end(HashTable* ht); - -#ifndef ZSTR_INIT_LITERAL -# define ZSTR_INIT_LITERAL(s, persistent) (zend_string_init((s), strlen(s), (persistent))) -#endif - -# define XDEBUG_MAKE_STD_ZVAL(zv) \ - zv = ecalloc(sizeof(zval), 1); - -# define HASH_KEY_SIZEOF(k) (sizeof(k) - 1) -# define HASH_KEY_STRLEN(k) (strlen(k)) -# define HASH_KEY_IS_NUMERIC(k) ((k) == NULL) -# define HASH_APPLY_KEY_VAL(k) (k)->val -# define HASH_APPLY_KEY_LEN(k) (k)->len + 1 - -# define STR_NAME_VAL(k) (k)->val -# define STR_NAME_LEN(k) (k)->len - -# if defined (__GNUC__) -# define XDEBUG_GNUC_CHECK_VERSION(major, minor) \ - ((__GNUC__ > (major)) || \ - ((__GNUC__ == (major)) && (__GNUC_MINOR__ >= (minor)))) -# else -# define XDEBUG_GNUC_CHECK_VERSION(major, minor) 0 -# endif - -# if XDEBUG_GNUC_CHECK_VERSION(7, 0) -# define XDEBUG_BREAK_INTENTIONALLY_MISSING __attribute__ ((fallthrough)); -# else -# define XDEBUG_BREAK_INTENTIONALLY_MISSING -# endif - -# if XDEBUG_GNUC_CHECK_VERSION(2, 7) || __has_attribute(format) -# define XDEBUG_ATTRIBUTE_FORMAT(type, idx, first) __attribute__ ((format(type, idx, first))) -# else -# define XDEBUG_ATTRIBUTE_FORMAT(type, idx, first) -# endif - -#define XDEBUG_OPCODE_HANDLER_ARGS zend_execute_data *execute_data -#define XDEBUG_OPCODE_HANDLER_ARGS_PASSTHRU execute_data - -#endif
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/lib.c
Deleted
@@ -1,811 +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 "headers.h" - -#include "lib_private.h" -#include "log.h" - -extern ZEND_DECLARE_MODULE_GLOBALS(xdebug); - -void xdebug_init_library_globals(xdebug_library_globals_t *xg) -{ - xg->headers = NULL; - xg->mode_from_environment = 0; - - xg->log_file = 0; - - xg->active_execute_data = NULL; - xg->opcode_handlers_set = xdebug_set_create(256); - memset(xg->original_opcode_handlers, 0, sizeof(xg->original_opcode_handlers)); - memset(xg->opcode_multi_handlers, 0, sizeof(xg->opcode_multi_handlers)); - - XINI_LIB(log_level) = 0; - xg->diagnosis_buffer = NULL; -} - - -void xdebug_library_zend_startup(void) -{ - xdebug_lib_zend_startup_overload_sapi_headers(); -} - -void xdebug_library_zend_shutdown(void) -{ - xdebug_lib_zend_shutdown_restore_sapi_headers(); -} - - -void xdebug_library_minit(void) -{ - xdebug_set_opcode_multi_handler(ZEND_ASSIGN); - xdebug_set_opcode_multi_handler(ZEND_ASSIGN_DIM); - xdebug_set_opcode_multi_handler(ZEND_ASSIGN_OBJ); - xdebug_set_opcode_multi_handler(ZEND_ASSIGN_STATIC_PROP); - xdebug_set_opcode_multi_handler(ZEND_QM_ASSIGN); - xdebug_set_opcode_multi_handler(ZEND_INCLUDE_OR_EVAL); -} - -static void xdebug_multi_opcode_handler_dtor(xdebug_multi_opcode_handler_t *ptr) -{ - if (ptr->next) { - xdebug_multi_opcode_handler_dtor(ptr->next); - } - xdfree(ptr); -} - -void xdebug_library_mshutdown(void) -{ - int i; - - /* Restore all opcode handlers that we have set */ - for (i = 0; i < 256; i++) { - if (XG_LIB(opcode_multi_handlers)i != NULL) { - xdebug_multi_opcode_handler_dtor(XG_LIB(opcode_multi_handlers)i); - } - xdebug_unset_opcode_handler(i); - } - - xdebug_set_free(XG_LIB(opcode_handlers_set)); -} - -void xdebug_library_rinit(void) -{ - XG_LIB(diagnosis_buffer) = xdebug_str_new(); - xdebug_open_log(); - - XG_LIB(headers) = xdebug_llist_alloc(xdebug_llist_string_dtor); - - XG_LIB(dumped) = 0; - XG_LIB(do_collect_errors) = 0; - - XG_LIB(trait_location_map) = xdebug_hash_alloc(256, (xdebug_hash_dtor_t) zend_string_release); -} - -void xdebug_library_post_deactivate(void) -{ - /* Clean up collected headers */ - xdebug_llist_destroy(XG_LIB(headers), NULL); - XG_LIB(headers) = NULL; - - xdebug_hash_destroy(XG_LIB(trait_location_map)); - - xdebug_close_log(); - xdebug_str_free(XG_LIB(diagnosis_buffer)); - XG_LIB(diagnosis_buffer) = NULL; -} - - -void xdebug_disable_opcache_optimizer(void) -{ - zend_string *key = zend_string_init(ZEND_STRL("opcache.optimization_level"), 1); - zend_string *value = zend_string_init(ZEND_STRL("0"), 1); - - zend_alter_ini_entry(key, value, ZEND_INI_SYSTEM, ZEND_INI_STAGE_STARTUP); - - zend_string_release(key); - zend_string_release(value); -} - - -static int xdebug_lib_set_mode_item(const char *mode, int len) -{ - if (strncmp(mode, "off", len) == 0) { - xdebug_global_mode |= XDEBUG_MODE_OFF; - return 1; - } - if (strncmp(mode, "develop", len) == 0) { - xdebug_global_mode |= XDEBUG_MODE_DEVELOP; - return 1; - } - if (strncmp(mode, "coverage", len) == 0) { - xdebug_global_mode |= XDEBUG_MODE_COVERAGE; - return 1; - } - if (strncmp(mode, "debug", len) == 0) { - xdebug_global_mode |= XDEBUG_MODE_STEP_DEBUG; - return 1; - } - if (strncmp(mode, "gcstats", len) == 0) { - xdebug_global_mode |= XDEBUG_MODE_GCSTATS; - return 1; - } - if (strncmp(mode, "profile", len) == 0) { - xdebug_global_mode |= XDEBUG_MODE_PROFILING; - return 1; - } - if (strncmp(mode, "trace", len) == 0) { - xdebug_global_mode |= XDEBUG_MODE_TRACING; - return 1; - } - - return 0; -} - -static int xdebug_lib_set_mode_from_setting(const char *mode) -{ - const char *mode_ptr = mode; - char *comma = NULL; - int errors = 0; - - xdebug_global_mode = 0; - - comma = strchr(mode_ptr, ','); - while (comma) { - errors += !xdebug_lib_set_mode_item(mode_ptr, comma - mode_ptr); - mode_ptr = comma + 1; - while (*mode_ptr == ' ') { - mode_ptr++; - } - comma = strchr(mode_ptr, ','); - } - errors += !xdebug_lib_set_mode_item(mode_ptr, strlen(mode_ptr)); - - return !errors; -} - -int xdebug_lib_set_mode(const char *mode) -{ - char *config = getenv("XDEBUG_MODE"); - int result = 0; - - /* XDEBUG_MODE environment variable */ - if (config && strlen(config)) { - result = xdebug_lib_set_mode_from_setting(config); - - if (!result) { - xdebug_log_ex(XLOG_CHAN_CONFIG, XLOG_CRIT, "ENVMODE", "Invalid mode '%s' set for 'XDEBUG_MODE' environment variable, fall back to 'xdebug.mode' configuration setting", config); - } else { - XG_LIB(mode_from_environment) = 1; - return result; - } - } - - /* 'xdebug.mode' configuration setting */
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/lib.h
Deleted
@@ -1,326 +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_LIBRARY_H__ -#define __XDEBUG_LIBRARY_H__ - -#ifdef ZTS -# include "TSRM.h" -#endif - -#include "zend.h" -#include "zend_API.h" -#include "compat.h" - -extern int xdebug_global_mode; - -typedef struct xdebug_var_name { - zend_string *name; - zval data; - int is_variadic; -} xdebug_var_name; - -#define XFUNC_UNKNOWN 0x00 -#define XFUNC_NORMAL 0x01 -#define XFUNC_STATIC_MEMBER 0x02 -#define XFUNC_MEMBER 0x03 - -#define XFUNC_INCLUDES 0x10 -#define XFUNC_EVAL 0x10 -#define XFUNC_INCLUDE 0x11 -#define XFUNC_INCLUDE_ONCE 0x12 -#define XFUNC_REQUIRE 0x13 -#define XFUNC_REQUIRE_ONCE 0x14 -#define XFUNC_MAIN 0x15 -#if PHP_VERSION_ID >= 80100 -# define XFUNC_FIBER 0x16 -#endif - -#define XFUNC_ZEND_PASS 0x20 - -#define XDEBUG_IS_NORMAL_FUNCTION(f) ((f)->type == XFUNC_NORMAL || (f)->type == XFUNC_STATIC_MEMBER || (f)->type == XFUNC_MEMBER) - -#define XDEBUG_REGISTER_LONG_CONSTANT(__c) REGISTER_LONG_CONSTANT(#__c, __c, CONST_CS|CONST_PERSISTENT) - -#define XDEBUG_NONE 0 -#define XDEBUG_JIT 1 -#define XDEBUG_REQ 2 - -#define XDEBUG_BREAK 1 -#define XDEBUG_STEP 2 - -#define XDEBUG_BUILT_IN 0 -#define XDEBUG_USER_DEFINED 1 - -#define XDEBUG_MAX_FUNCTION_LEN 1024 - -#define XDEBUG_TRACE_OPTION_APPEND 0x01 -#define XDEBUG_TRACE_OPTION_COMPUTERIZED 0x02 -#define XDEBUG_TRACE_OPTION_HTML 0x04 -#define XDEBUG_TRACE_OPTION_NAKED_FILENAME 0x08 -#define XDEBUG_TRACE_OPTION_FLAMEGRAPH_COST 0x10 -#define XDEBUG_TRACE_OPTION_FLAMEGRAPH_MEM 0x20 - -#define XDEBUG_CC_OPTION_UNUSED 1 -#define XDEBUG_CC_OPTION_DEAD_CODE 2 -#define XDEBUG_CC_OPTION_BRANCH_CHECK 4 - -#define STATUS_STARTING 0 -#define STATUS_STOPPING 1 -#define STATUS_STOPPED 2 -#define STATUS_RUNNING 3 -#define STATUS_BREAK 4 - -#define REASON_OK 0 -#define REASON_ERROR 1 -#define REASON_ABORTED 2 -#define REASON_EXCEPTION 3 - -#define XDEBUG_CMDLOOP_NONBLOCK 0 -#define XDEBUG_CMDLOOP_BLOCK 1 - -#define XDEBUG_CMDLOOP_NONBAIL 0 -#define XDEBUG_CMDLOOP_BAIL 1 - -typedef struct _xdebug_func { - zend_string *object_class; - zend_string *scope_class; - zend_string *function; - zend_string *include_filename; - int type; - int internal; -} xdebug_func; - -typedef struct xdebug_profile { - uint64_t nanotime; - uint64_t nanotime_mark; - long memory; - long mem_mark; - xdebug_llist *call_list; -} xdebug_profile; - -typedef struct _function_stack_entry { - /* function properties */ - xdebug_func function; - unsigned int function_nr; - unsigned short user_defined:1; - unsigned short level:15; - - /* argument properties */ - unsigned short varc; - xdebug_var_name *var; - zval *return_value; - xdebug_llist *declared_vars; - HashTable *symbol_table; - zend_execute_data *execute_data; - unsigned char is_variadic; - unsigned char is_trampoline; - unsigned char arg_done; - - /* debugging properties */ - bool has_line_breakpoints; - - /* filter properties */ - unsigned char filtered_code_coverage; - unsigned char filtered_stack; - unsigned char filtered_tracing; - - /* coverage properties */ - bool code_coverage_init; - char *code_coverage_function_name; - zend_string *code_coverage_filename; - - /* location properties */ - int lineno; - zend_string *filename; - - /* tracing properties */ - signed long memory; - signed long prev_memory; - uint64_t nanotime; - bool function_call_traced; - - /* profiling properties */ - xdebug_profile profile; - struct { - int lineno; - zend_string *filename; - zend_string *function; - } profiler; - - /* misc properties */ - zend_op_array *op_array; -#if PHP_VERSION_ID >= 80100 - void (*soap_error_cb)(int type, zend_string *error_filename, const uint32_t error_lineno, zend_string *message); -#else - void (*soap_error_cb)(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message); -#endif -} function_stack_entry; - -function_stack_entry *xdebug_get_stack_frame(int nr); - - -xdebug_hash* xdebug_declared_var_hash_from_llist(xdebug_llist *list); -int xdebug_trigger_enabled(int setting, const char *var_name, char *var_value); - -typedef struct _xdebug_multi_opcode_handler_t xdebug_multi_opcode_handler_t; - -struct _xdebug_multi_opcode_handler_t -{ - user_opcode_handler_t handler; - xdebug_multi_opcode_handler_t *next; -}; - -typedef struct _xdebug_library_globals_t { - int start_with_request; /* One of the XDEBUG_START_WITH_REQUEST_* constants */ - int start_upon_error; /* One of the XDEBUG_START_UPON_ERROR_* constants */ - int mode_from_environment; /* Keeps track whether the mode was set with XDEBUG_MODE for diagnostics purposes */ - - zend_execute_data *active_execute_data; - function_stack_entry *active_stack_entry; - HashTable *active_symbol_table; - zval *active_object; - - /* Headers */ - xdebug_llist *headers; -
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/log.c
Deleted
@@ -1,938 +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 "php_xdebug.h" -#include "ext/standard/info.h" - -#include "headers.h" - -#include "lib_private.h" -#include "log.h" -#include "var.h" - -#define DOCS_LINK_ICON "⊕" - -char* xdebug_lib_docs_base(void) -{ - char *env = getenv("XDEBUG_DOCS_BASE"); - - if (env) { - return env; - } - - return (char*) "https://xdebug.org/docs/"; -} - -extern ZEND_DECLARE_MODULE_GLOBALS(xdebug); - -const char *xdebug_level_msg_prefix11 = { - "C", "E", "", "W", "", "", "", "I", "", "", "D" -}; -const char *xdebug_log_prefix11 = { - "CRIT:", "ERR: ", "", "WARN: ", "", "", "", "INFO: ", "", "", "DEBUG: " -}; -const char *xdebug_log_prefix_emoji11 = { - "☠", "🛑 ", "", "⚠️ ", "", "", "", "🛈 ", "", "", "• " -}; -const char *xdebug_channel_msg_prefix8 = { - "CFG-", "LOG-", "DBG-", "GC-", "PROF-", "TRACE-", "COV-", "BASE-" -}; -const char *xdebug_channel_name8 = { - "Config ", "Log Files ", "Step Debug ", "GC Stats ", "Profiler ", "Tracing ", "Coverage ", "Base " -}; - -static inline int xdebug_internal_log(int channel, int log_level, const char *message) -{ - zend_ulong pid; - - if (!XG_LIB(log_file)) { - return 0; - } - - pid = xdebug_get_pid(); - - if (!XG_LIB(log_opened_message_sent) && XG_LIB(log_open_timestring)) { - XG_LIB(log_opened_message_sent) = 1; - - fprintf(XG_LIB(log_file), "" ZEND_ULONG_FMT " Log opened at %s\n", pid, XG_LIB(log_open_timestring)); - fflush(XG_LIB(log_file)); - xdfree(XG_LIB(log_open_timestring)); - XG_LIB(log_open_timestring) = NULL; - } - - fprintf( - XG_LIB(log_file), - "" ZEND_ULONG_FMT " %s%s%s\n", - pid, - xdebug_channel_namechannel, - xdebug_log_prefixlog_level, - message - ); - - fflush(XG_LIB(log_file)); - - return 1; -} - -#define TR_START "<tr><td class=\"e\">" -#define TR_END "</td></tr>\n" - -static inline void xdebug_diagnostic_log(int channel, int log_level, const char *error_code, const char *message) -{ - if (!XG_LIB(diagnosis_buffer) || log_level > XLOG_WARN) { - return; - } - - if (sapi_module.phpinfo_as_text) { - xdebug_str_add(XG_LIB(diagnosis_buffer), xdebug_channel_namechannel, 0); - xdebug_str_add(XG_LIB(diagnosis_buffer), xdebug_log_prefixlog_level, 0); - xdebug_str_add(XG_LIB(diagnosis_buffer), message, 0); - } else { - xdebug_str_add_const(XG_LIB(diagnosis_buffer), "<tr><td class=\"i\">"); - xdebug_str_add(XG_LIB(diagnosis_buffer), xdebug_log_prefix_emojilog_level, 0); - xdebug_str_add_const(XG_LIB(diagnosis_buffer), "</td><td class=\"v\">"); - xdebug_str_add(XG_LIB(diagnosis_buffer), xdebug_channel_namechannel, 0); - xdebug_str_add(XG_LIB(diagnosis_buffer), message, 0); - xdebug_str_add_const(XG_LIB(diagnosis_buffer), "</td><td class=\"d\"><a href=\""); - xdebug_str_add(XG_LIB(diagnosis_buffer), xdebug_lib_docs_base(), 0); - xdebug_str_add_const(XG_LIB(diagnosis_buffer), "errors#"); - xdebug_str_add(XG_LIB(diagnosis_buffer), xdebug_channel_msg_prefixchannel, 0); - xdebug_str_add(XG_LIB(diagnosis_buffer), xdebug_level_msg_prefixlog_level, 0); - if (error_code) { - xdebug_str_addc(XG_LIB(diagnosis_buffer), '-'); - xdebug_str_add(XG_LIB(diagnosis_buffer), error_code, 0); - } - xdebug_str_add_const(XG_LIB(diagnosis_buffer), "\">" DOCS_LINK_ICON "</a></td></tr>"); - } - - xdebug_str_addc(XG_LIB(diagnosis_buffer), '\n'); -} - -static inline void xdebug_php_log(int channel, int log_level, const char *error_code, const char *message) -{ - xdebug_str formatted_message = XDEBUG_STR_INITIALIZER; - - if (log_level > XLOG_ERR) { - return; - } - - xdebug_str_add_const(&formatted_message, "Xdebug: "); - xdebug_str_add(&formatted_message, xdebug_channel_namechannel, 0); - xdebug_str_add(&formatted_message, message, 0); - - if (error_code && log_level == XLOG_CRIT) { - xdebug_str_add_const(&formatted_message, " (See: "); - xdebug_str_add(&formatted_message, xdebug_lib_docs_base(), 0); - xdebug_str_add_const(&formatted_message, "errors#"); - xdebug_str_add(&formatted_message, xdebug_channel_msg_prefixchannel, 0); - xdebug_str_add(&formatted_message, xdebug_level_msg_prefixlog_level, 0); - xdebug_str_addc(&formatted_message, '-'); - xdebug_str_add(&formatted_message, error_code, 0); - xdebug_str_addc(&formatted_message, ')'); - } - - php_log_err(formatted_message.d); - - xdebug_str_destroy(&formatted_message); -} - -void XDEBUG_ATTRIBUTE_FORMAT(printf, 4, 5) xdebug_log_ex(int channel, int log_level, const char *error_code, const char *fmt, ...) -{ - xdebug_str message = XDEBUG_STR_INITIALIZER; - va_list argv; - int logged_to_xdebug_log = 0; - - if (XINI_LIB(log_level) < log_level) { - return; - } - - va_start(argv, fmt); - xdebug_str_add_va_fmt(&message, fmt, argv); - va_end(argv); - - logged_to_xdebug_log = xdebug_internal_log(channel, log_level, message.d); - - xdebug_diagnostic_log(channel, log_level, error_code, message.d); - - if (!logged_to_xdebug_log || XINI_LIB(log_level) == XLOG_CRIT) { - xdebug_php_log(channel, log_level, error_code, message.d); - } - - xdebug_str_destroy(&message); -} - -static void log_filename_not_opened(int channel, const char *directory, const char *filename) -{ - xdebug_str full_filename = XDEBUG_STR_INITIALIZER; - - if (directory) { - xdebug_str_add(&full_filename, directory, 0); - if (!IS_SLASH(directorystrlen(directory) - 1)) { - xdebug_str_addc(&full_filename, DEFAULT_SLASH); - } - } - xdebug_str_add(&full_filename, filename, 0); - - xdebug_log_ex(channel, XLOG_ERR, "OPEN", "File '%s' could not be opened.", full_filename.d); - - xdebug_str_destroy(&full_filename); -} - -void xdebug_log_diagnose_permissions(int channel, const char *directory, const char *filename) -{ -#ifndef WIN32 - struct stat dir_info;
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/str.c
Deleted
@@ -1,257 +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 <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <locale.h> - -#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); -} - -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); -} - -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'; - - return tmp; -} - -xdebug_str *xdebug_str_create_from_char(char *c) -{ - return xdebug_str_create(c, strlen(c)); -} - -xdebug_str *xdebug_str_copy(xdebug_str *orig) -{ - xdebug_str *tmp = xdebug_str_new(); - - tmp->l = tmp->a = orig->l; - tmp->a++; - tmp->d = xdmalloc(tmp->a); - memcpy(tmp->d, orig->d, tmp->l); - tmp->dorig->l = '\0'; - - return tmp; -} - -void xdebug_str_destroy(xdebug_str *s) -{ - if (s->d) {
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/timing.c
Deleted
@@ -1,216 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2021 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#include "php_xdebug.h" - -#if PHP_WIN32 -# include "win32/time.h" -# include <versionhelpers.h> -#else -# include <sys/time.h> -#endif - -#if HAVE_XDEBUG_CLOCK_GETTIME_NSEC_NP -# if defined(__APPLE) -# include <mach/mach_time.h> -# endif -#endif - -#include "timing.h" - -#define NANOTIME_MIN_STEP 10 - -#if PHP_WIN32 -# define WIN_NANOS_IN_TICK 100 -# define WIN_TICKS_SINCE_1601_JAN_1 116444736000000000ULL -#endif - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - -static uint64_t xdebug_get_nanotime_abs(xdebug_nanotime_context *nanotime_context) -{ -#if PHP_WIN32 - // Windows, win_precise_time_func is only available on Win 8 and later. - { - FILETIME filetime; - - if (nanotime_context->win_precise_time_func != NULL) { - nanotime_context->win_precise_time_func(&filetime); - return ((((uint64_t)filetime.dwHighDateTime << 32) + (uint64_t)filetime.dwLowDateTime) - WIN_TICKS_SINCE_1601_JAN_1) - * WIN_NANOS_IN_TICK; - } - } -#endif - -#if HAVE_GETTIMEOFDAY | PHP_WIN32 - // Fallback to gettimeofday() if better platform specific time is not - // available. gettimeofday() is always available in PHP on Windows, as it's - // expose through 'win32/time.ch' - { - struct timeval tp; - - if (gettimeofday(&tp, NULL) == 0) { - return (uint64_t)tp.tv_sec * NANOS_IN_SEC + (uint64_t)tp.tv_usec * NANOS_IN_MICROSEC; - } - } -#endif - - // We give up - php_error(E_WARNING, "Xdebug could not determine a suitable clock source on your system"); - return 0; -} - -#if PHP_WIN32 -static uint64_t xdebug_counter_and_freq_to_nanotime(uint64_t counter, uint64_t freq) -{ - uint32_t mul = 1, freq32; - uint64_t q, r; - - while (freq >= (1ULL << 32)) { - freq /= 2; - mul *= 2; - } - freq32 = (uint32_t)freq; - - q = counter / freq32; - r = counter % freq32; - return (q * NANOS_IN_SEC + (r * NANOS_IN_SEC) / freq32) * mul; -} -#endif - - -// Windows 7 and lower -#if PHP_WIN32 -static uint64_t xdebug_get_nanotime_rel(xdebug_nanotime_context *nanotime_context) -{ - LARGE_INTEGER tcounter; - - if (nanotime_context->win_precise_time_func == NULL) { - QueryPerformanceCounter(&tcounter); - return xdebug_counter_and_freq_to_nanotime((uint64_t)tcounter.QuadPart, nanotime_context->win_freq); - } -} - -// Mac -// should be fast but can be relative -#elif HAVE_XDEBUG_CLOCK_GETTIME_NSEC_NP -static uint64_t xdebug_get_nanotime_rel(xdebug_nanotime_context *nanotime_context) -{ - return clock_gettime_nsec_np(CLOCK_UPTIME_RAW); -} - -// Linux/Unix with clock_gettime -#elif HAVE_XDEBUG_CLOCK_GETTIME -static uint64_t xdebug_get_nanotime_rel(xdebug_nanotime_context *nanotime_context) -{ - struct timespec ts; - - if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) { - return (uint64_t)ts.tv_sec * NANOS_IN_SEC + (uint64_t)ts.tv_nsec; - } - - return 0; -} -#endif - -void xdebug_nanotime_init(xdebug_base_globals_t *base) -{ - xdebug_nanotime_context context = {0}; - -#if PHP_WIN32 - LARGE_INTEGER tcounter; - - if (IsWindows8OrGreater()) { - context.win_precise_time_func = (WIN_PRECISE_TIME_FUNC)GetProcAddress( - GetModuleHandle(TEXT("kernel32.dll")), - "GetSystemTimePreciseAsFileTime" - ); - } else { - context.win_precise_time_func = NULL; - QueryPerformanceFrequency(&tcounter); - context.win_freq = (uint64_t)tcounter.QuadPart; - context.use_rel_time = 1; - } - -#elif HAVE_XDEBUG_CLOCK_GETTIME | HAVE_XDEBUG_CLOCK_GETTIME_NSEC_NP - context.use_rel_time = 1; -#endif - - context.start_abs = xdebug_get_nanotime_abs(&context); - context.last_abs = 0; -#if PHP_WIN32 | HAVE_XDEBUG_CLOCK_GETTIME | HAVE_XDEBUG_CLOCK_GETTIME_NSEC_NP - context.start_rel = xdebug_get_nanotime_rel(&context); - context.last_rel = 0; -#endif - - base->nanotime_context = context; -} - -uint64_t xdebug_get_nanotime(void) -{ - uint64_t nanotime; - xdebug_nanotime_context *context; - - context = &XG_BASE(nanotime_context); - -#if PHP_WIN32 | HAVE_XDEBUG_CLOCK_GETTIME | HAVE_XDEBUG_CLOCK_GETTIME_NSEC_NP - /* Relative timing */ - if (context->use_rel_time) { - nanotime = xdebug_get_nanotime_rel(context); - - if (nanotime < context->last_rel + NANOTIME_MIN_STEP) { - context->last_rel += NANOTIME_MIN_STEP; - nanotime = context->last_rel; - } - context->last_rel = nanotime; - nanotime = context->start_abs + (nanotime - context->start_rel); - - return nanotime; - } -#endif - - /* Absolute timing */ - nanotime = xdebug_get_nanotime_abs(context); - - if (nanotime < context->last_abs + NANOTIME_MIN_STEP) { - context->last_abs += NANOTIME_MIN_STEP; - nanotime = context->last_abs; - } - context->last_abs = nanotime; - - return nanotime; -} - -char* xdebug_nanotime_to_chars(uint64_t nanotime, unsigned char precision) -{ - char *res;
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/usefulstuff.c
Deleted
@@ -1,725 +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" - -#include "ext/standard/php_lcg.h" -#include "ext/standard/flock_compat.h" -#include "main/php_ini.h" - -#ifndef NAME_MAX -# ifdef _AIX -# include <unistd.h> -# define NAME_MAX pathconf("/dev/null",_PC_NAME_MAX) -# else -# define NAME_MAX (MAXNAMELEN-1) -# endif -#endif - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - -xdebug_arg *xdebug_arg_ctor(void) -{ - xdebug_arg *tmp = /*(xdebug_arg*)*/ xdmalloc(sizeof(xdebug_arg)); - - tmp->args = NULL; - tmp->c = 0; - - return tmp; -} - -void xdebug_arg_dtor(xdebug_arg *arg) -{ - int i; - - for (i = 0; i < arg->c; i++) { - xdfree(arg->argsi); - } - if (arg->args) { - xdfree(arg->args); - } - xdfree(arg); -} - -xdebug_str* xdebug_join(const char *delim, xdebug_arg *args, int begin, int end) -{ - int i; - xdebug_str *ret = xdebug_str_new(); - - if (begin < 0) { - begin = 0; - } - if (end > args->c - 1) { - end = args->c - 1; - } - for (i = begin; i < end; i++) { - xdebug_str_add(ret, args->argsi, 0); - xdebug_str_add(ret, delim, 0); - } - xdebug_str_add(ret, args->argsend, 0); - return ret; -} - -void xdebug_explode(const char *delim, const char *str, xdebug_arg *args, int limit) -{ - const char *p1, *p2, *endp; - - endp = str + strlen(str); - - p1 = str; - p2 = xdebug_memnstr(str, delim, strlen(delim), endp); - - if (p2 == NULL) { - args->c++; - args->args = (char**) xdrealloc(args->args, sizeof(char*) * args->c); - args->argsargs->c - 1 = (char*) xdmalloc(strlen(str) + 1); - memcpy(args->argsargs->c - 1, p1, strlen(str)); - args->argsargs->c - 1strlen(str) = '\0'; - } else { - do { - args->c++; - args->args = (char**) xdrealloc(args->args, sizeof(char*) * args->c); - args->argsargs->c - 1 = (char*) xdmalloc(p2 - p1 + 1); - memcpy(args->argsargs->c - 1, p1, p2 - p1); - args->argsargs->c - 1p2 - p1 = '\0'; - p1 = p2 + strlen(delim); - } while ((p2 = xdebug_memnstr(p1, delim, strlen(delim), endp)) != NULL && (limit == -1 || --limit > 1)); - - if (p1 <= endp) { - args->c++; - args->args = (char**) xdrealloc(args->args, sizeof(char*) * args->c); - args->argsargs->c - 1 = (char*) xdmalloc(endp - p1 + 1); - memcpy(args->argsargs->c - 1, p1, endp - p1); - args->argsargs->c - 1endp - p1 = '\0'; - } - } -} - -const char* xdebug_memnstr(const char *haystack, const char *needle, int needle_len, const char *end) -{ - const char *p = haystack; - char first = *needle; - - /* let end point to the last character where needle may start */ - end -= needle_len; - - while (p <= end) { - while (*p != first) - if (++p > end) - return NULL; - if (memcmp(p, needle, needle_len) == 0) - return p; - p++; - } - return NULL; -} - -char* xdebug_strrstr(const char* haystack, const char* needle) -{ - char *loc = NULL; - char *found = NULL; - size_t pos = 0; - - while ((found = strstr(haystack + pos, needle)) != 0) { - loc = found; - pos = (found - haystack) + 1; - } - - return loc; -} - -char *xdebug_trim(const char *str) -{ - char *trimmed = NULL, *begin = (char *) str, *end = NULL; - - /* trim leading space */ - while (isspace((unsigned char) *begin)) { - ++begin; - } - - /* All spaces */ - if (*begin == '\0') { - return xdstrdup(""); - } - - /* trim trailing space */ - end = begin + strlen(begin) - 1; - while (end > begin && isspace((unsigned char) *end)) { - --end; - } - end++; - - trimmed = xdmalloc(end - begin + 1); - memcpy(trimmed, begin, (end - begin)); - trimmed(end - begin) = '\0'; - - return trimmed; -} - -/* not all versions of php export this */ -static int xdebug_htoi(char *s) -{
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/var.c
Deleted
@@ -1,1198 +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 "ext/standard/url.h" -#include "zend.h" -#include "zend_exceptions.h" -#include "zend_extensions.h" -#include "ext/standard/php_smart_string.h" -#include "zend_smart_str.h" -#include "zend_closures.h" - -#include "php_xdebug.h" - -#include "lib/compat.h" -#include "lib/lib_private.h" -#include "lib/mm.h" -#include "lib/var.h" -#include "lib/var_export_html.h" -#include "lib/var_export_line.h" -#include "lib/xml.h" - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - -static inline int object_or_ancestor_is_internal(zval dzval) -{ - zend_class_entry *tmp_ce = Z_OBJCE(dzval); - - do { - if (tmp_ce->type == ZEND_INTERNAL_CLASS) { - return 1; - } - tmp_ce = tmp_ce->parent; - } while (tmp_ce); - - return 0; -} - -typedef struct _xdebug_zend_closure_copy { - zend_object std; - zend_function func; - zval this_ptr; - zend_class_entry *called_scope; - zif_handler orig_internal_handler; -} xdebug_zend_closure_copy; - -static int object_with_missing_closure_variables(zval dzval) -{ - zend_class_entry *tmp_ce = NULL; - xdebug_zend_closure_copy *closure = NULL; - - if (Z_TYPE(dzval) != IS_OBJECT) { - return 0; - } - - tmp_ce = Z_OBJCE(dzval); - if (tmp_ce != zend_ce_closure) { - return 0; - } - - closure = (xdebug_zend_closure_copy *) Z_OBJ(dzval); - - if (closure->func.type == ZEND_USER_FUNCTION && closure->func.op_array.static_variables) { - HashTable *static_variables = ZEND_MAP_PTR_GET(closure->func.op_array.static_variables_ptr); - - if (!static_variables) { - return 1; - } - } - - return 0; -} - -HashTable *xdebug_objdebug_pp(zval **zval_pp, int flags) -{ - zval dzval = **zval_pp; - HashTable *tmp; - - if ( - !XG_BASE(in_debug_info) && - (object_or_ancestor_is_internal(dzval) || (flags & XDEBUG_VAR_OBJDEBUG_USE_DEBUGINFO)) && - !object_with_missing_closure_variables(dzval) && - Z_OBJ_HANDLER(dzval, get_debug_info) && - !EG(exception) - ) { - void *original_trace_context; - zend_object *orig_exception; - - xdebug_tracing_save_trace_context(&original_trace_context); - XG_BASE(in_debug_info) = 1; - orig_exception = EG(exception); - EG(exception) = NULL; - - tmp = zend_get_properties_for(&dzval, ZEND_PROP_PURPOSE_DEBUG); - - XG_BASE(in_debug_info) = 0; - xdebug_tracing_restore_trace_context(original_trace_context); - EG(exception) = orig_exception; - - return tmp; - } else { - return zend_get_properties_for(&dzval, ZEND_PROP_PURPOSE_VAR_EXPORT); - } - return NULL; -} - -char* xdebug_error_type_simple(int type) -{ - switch (type) { - case E_ERROR: - case E_CORE_ERROR: - case E_COMPILE_ERROR: - case E_USER_ERROR: - return xdstrdup("fatal-error"); - break; - case E_RECOVERABLE_ERROR: - return xdstrdup("recoverable-fatal-error"); - break; - case E_WARNING: - case E_CORE_WARNING: - case E_COMPILE_WARNING: - case E_USER_WARNING: - return xdstrdup("warning"); - break; - case E_PARSE: - return xdstrdup("parse-error"); - break; - case E_NOTICE: - case E_USER_NOTICE: - return xdstrdup("notice"); - break; - case E_STRICT: - return xdstrdup("strict-standards"); - break; - case E_DEPRECATED: - case E_USER_DEPRECATED: - return xdstrdup("deprecated"); - break; - case 0: - return xdstrdup("xdebug"); - break; - default: - return xdstrdup("unknown-error"); - break; - } -} - -char* xdebug_error_type(int type) -{ - switch (type) { - case E_ERROR: - case E_CORE_ERROR: - case E_COMPILE_ERROR: - case E_USER_ERROR: - return xdstrdup("Fatal error"); - break; - case E_RECOVERABLE_ERROR: - return xdstrdup("Recoverable fatal error"); - break; - case E_WARNING: - case E_CORE_WARNING: - case E_COMPILE_WARNING: - case E_USER_WARNING: - return xdstrdup("Warning"); - break; - case E_PARSE: - return xdstrdup("Parse error"); - break; - case E_NOTICE: - case E_USER_NOTICE: - return xdstrdup("Notice"); - break; - case E_STRICT: - return xdstrdup("Strict standards"); - break; - case E_DEPRECATED: - case E_USER_DEPRECATED: - return xdstrdup("Deprecated"); - break; - case 0: - return xdstrdup("Xdebug"); - break; - default: - return xdstrdup("Unknown error"); - break;
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/var.h
Deleted
@@ -1,90 +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 "php_xdebug.h" - -#include "lib/compat.h" -#include "lib/lib.h" -#include "lib/str.h" -#include "lib/xml.h" - -#ifndef __HAVE_XDEBUG_VAR_H__ -#define __HAVE_XDEBUG_VAR_H__ - -/* Set correct int format to use */ -#include "Zend/zend_long.h" -#if SIZEOF_ZEND_LONG == 4 -# define XDEBUG_INT_FMT "%ld" -#else -# define XDEBUG_INT_FMT "%lld" -#endif - -typedef struct -{ - int page; /* The number of the page to retrieve */ - int current_element_nr; - int start_element_nr; - int end_element_nr; -} xdebug_var_runtime_page; - -typedef struct xdebug_var_export_options { - int max_children; - int max_data; - int max_depth; - int show_hidden; - int extended_properties; /* Whether the feature is enabled */ - int encode_as_extended_property; /* Whether the current node's elements need to be encoded */ - int show_location; - xdebug_var_runtime_page *runtime; - int no_decoration; -} xdebug_var_export_options; - -#define XDEBUG_VAR_TYPE_NORMAL 0x00 -#define XDEBUG_VAR_TYPE_STATIC 0x01 -#define XDEBUG_VAR_TYPE_CONSTANT 0x02 - -void xdebug_get_php_symbol(zval *retval, xdebug_str* name); - -xdebug_var_export_options* xdebug_var_export_options_from_ini(void); -xdebug_var_export_options* xdebug_var_get_nolimit_options(void); - -xdebug_str* xdebug_get_property_type(zval* object, zval *val); -xdebug_str* xdebug_get_property_info(char *mangled_property, int mangled_len, const char **modifier, char **class_name); - -#define XDEBUG_VAR_OBJDEBUG_DEFAULT 0x00 -#define XDEBUG_VAR_OBJDEBUG_USE_DEBUGINFO 0x01 -HashTable *xdebug_objdebug_pp(zval **zval_pp, int flags); - - -#define XDEBUG_VAR_ATTR_TEXT 0 -#define XDEBUG_VAR_ATTR_HTML 1 -void xdebug_add_variable_attributes(xdebug_str *str, zval *struc, zend_bool fancy); - - -char* xdebug_xmlize(char *s_string, size_t len, size_t *newlen); -char* xdebug_error_type_simple(int type); -char* xdebug_error_type(int type); -zval *xdebug_get_zval(zend_execute_data *zdata, int node_type, const znode_op *node, int *is_var); -zval *xdebug_get_zval_with_opline(zend_execute_data *zdata, const zend_op *opline, int node_type, const znode_op *node, int *is_var); - -#define XDEBUG_SHOW_FNAME_DEFAULT 0 -#define XDEBUG_SHOW_FNAME_ALLOW_HTML 1<<1 -#define XDEBUG_SHOW_FNAME_IGNORE_SCOPE 1<<2 -#define XDEBUG_SHOW_FNAME_ADD_FILE_NAME 1<<3 -char* xdebug_show_fname(xdebug_func t, int flags); - -#endif
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/var_export_html.c
Deleted
@@ -1,462 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2021 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#include "var_export_html.h" -#include "lib_private.h" -#include "Zend/zend_closures.h" -#if PHP_VERSION_ID >= 80100 -# include "zend_enum.h" -#endif - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - -/***************************************************************************** -** Fancy variable printing routines -*/ - -#define COLOR_POINTER "#888a85" -#define COLOR_BOOL "#75507b" -#define COLOR_LONG "#4e9a06" -#define COLOR_NULL "#3465a4" -#define COLOR_DOUBLE "#f57900" -#define COLOR_STRING "#cc0000" -#define COLOR_EMPTY "#888a85" -#define COLOR_ARRAY "#ce5c00" -#define COLOR_OBJECT "#8f5902" -#define COLOR_RESOURCE "#2e3436" - -static int xdebug_array_element_export_html(zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, xdebug_str *str, int debug_zval, xdebug_var_export_options *options) -{ - zval **zv = &zv_nptr; - size_t newlen; - char *tmp_str; - - if (options->runtimelevel.current_element_nr >= options->runtimelevel.start_element_nr && - options->runtimelevel.current_element_nr < options->runtimelevel.end_element_nr) - { - xdebug_str_add_fmt(str, "%*s", (level * 4) - 2, ""); - - if (HASH_KEY_IS_NUMERIC(hash_key)) { /* numeric key */ - xdebug_str_add_fmt(str, XDEBUG_INT_FMT " <font color='%s'>=></font> ", index_key, COLOR_POINTER); - } else { /* string key */ - xdebug_str_addc(str, '\''); - tmp_str = xdebug_xmlize((char*) HASH_APPLY_KEY_VAL(hash_key), HASH_APPLY_KEY_LEN(hash_key) - 1, &newlen); - xdebug_str_addl(str, tmp_str, newlen, 0); - efree(tmp_str); - xdebug_str_add_fmt(str, "' <font color='%s'>=></font> ", COLOR_POINTER); - } - xdebug_var_export_html(zv, str, level + 1, debug_zval, options); - } - if (options->runtimelevel.current_element_nr == options->runtimelevel.end_element_nr) { - xdebug_str_add_fmt(str, "%*s", (level * 4) - 2, ""); - xdebug_str_add_literal(str, "<i>more elements...</i>\n"); - } - options->runtimelevel.current_element_nr++; - return 0; -} - -static int xdebug_object_element_export_html(zval *object, zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, xdebug_str *str, int debug_zval, xdebug_var_export_options *options, char *class_name) -{ - zval **zv = &zv_nptr; - - if (options->runtimelevel.current_element_nr >= options->runtimelevel.start_element_nr && - options->runtimelevel.current_element_nr < options->runtimelevel.end_element_nr) - { - xdebug_str_add_fmt(str, "%*s", (level * 4) - 2, ""); - - if (!HASH_KEY_IS_NUMERIC(hash_key)) { - char *prop_class_name; - xdebug_str *property_name; - xdebug_str *property_type = NULL; - const char *modifier; - - property_type = xdebug_get_property_type(object, zv_nptr); - property_name = xdebug_get_property_info((char*) HASH_APPLY_KEY_VAL(hash_key), HASH_APPLY_KEY_LEN(hash_key), &modifier, &prop_class_name); - - xdebug_str_add_fmt(str, "<i>%s</i> ", modifier); - if (property_type) { - xdebug_str_add_fmt(str, "<i>%s</i> ", property_type->d); - } - xdebug_str_addc(str, '\''); - xdebug_str_add_str(str, property_name); - if (strcmp(modifier, "private") != 0 || strcmp(class_name, prop_class_name) == 0) { - xdebug_str_add_fmt(str, "' <font color='%s'>=></font> ", COLOR_POINTER); - } else { - xdebug_str_add_fmt(str, "' <small>(%s)</small> <font color='%s'>=></font> ", prop_class_name, COLOR_POINTER); - } - - if (property_type) { - xdebug_str_free(property_type); - } - xdebug_str_free(property_name); - xdfree(prop_class_name); - } else { - xdebug_str_add_fmt(str, "<i>public</i> " XDEBUG_INT_FMT " <font color='%s'>=></font> ", index_key, COLOR_POINTER); - } - xdebug_var_export_html(zv, str, level + 1, debug_zval, options); - } - if (options->runtimelevel.current_element_nr == options->runtimelevel.end_element_nr) { - xdebug_str_add_fmt(str, "%*s", (level * 4) - 2, ""); - xdebug_str_add_literal(str, "<i>more elements...</i>\n"); - } - options->runtimelevel.current_element_nr++; - return 0; -} - -static void handle_closure(xdebug_str *str, zval *obj, int level) -{ - const zend_function *closure_function; - - if (Z_TYPE_P(obj) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(obj), zend_ce_closure)) { - return; - } - - closure_function = zend_get_closure_method_def(Z_OBJ_P(obj)); - - xdebug_str_add_fmt(str, "%*s<i>virtual</i> 'closure' <font color='%s'>'", (level * 4) - 2, "", COLOR_STRING); - - if (closure_function->common.scope) { - if (closure_function->common.fn_flags & ZEND_ACC_STATIC) { - xdebug_str_add_zstr(str, closure_function->common.scope->name); - xdebug_str_add_literal(str, "::"); - } else { - xdebug_str_add_literal(str, "$this->"); - } - } - xdebug_str_add_zstr(str, closure_function->common.function_name); - - xdebug_str_add_literal(str, "'</font>\n"); -} - - -void xdebug_var_export_html(zval **struc, xdebug_str *str, int level, int debug_zval, xdebug_var_export_options *options) -{ - HashTable *myht; - char* tmp_str; - size_t newlen; - zend_ulong num; - zend_string *key; - zval *val; - zval *tmpz; - int z_type; - - z_type = Z_TYPE_P(*struc); - - if (debug_zval) { - xdebug_add_variable_attributes(str, *struc, XDEBUG_VAR_ATTR_HTML); - } - if (z_type == IS_INDIRECT) { - tmpz = Z_INDIRECT_P(*struc); - struc = &tmpz; - z_type = Z_TYPE_P(*struc); - } - if (z_type == IS_REFERENCE) { - tmpz = &((*struc)->value.ref->val); - struc = &tmpz; - z_type = Z_TYPE_P(*struc); - } - - switch (z_type) { - case IS_TRUE: - xdebug_str_add_fmt(str, "<small>boolean</small> <font color='%s'>true</font>", COLOR_BOOL); - break; - - case IS_FALSE: - xdebug_str_add_fmt(str, "<small>boolean</small> <font color='%s'>false</font>", COLOR_BOOL); - break; - - case IS_NULL: - xdebug_str_add_fmt(str, "<font color='%s'>null</font>", COLOR_NULL); - break; - - case IS_LONG: - xdebug_str_add_fmt(str, "<small>int</small> <font color='%s'>" XDEBUG_INT_FMT "</font>", COLOR_LONG, Z_LVAL_P(*struc)); - break; - - case IS_DOUBLE: - xdebug_str_add_fmt(str, "<small>float</small> <font color='%s'>%.*H</font>", COLOR_DOUBLE, (int) EG(precision), Z_DVAL_P(*struc)); - break; - - case IS_STRING: - xdebug_str_add_fmt(str, "<small>string</small> <font color='%s'>'", COLOR_STRING); - if ((size_t) Z_STRLEN_P(*struc) > (size_t) options->max_data) { - tmp_str = xdebug_xmlize(Z_STRVAL_P(*struc), options->max_data, &newlen); - xdebug_str_addl(str, tmp_str, newlen, 0); - efree(tmp_str); - xdebug_str_add_literal(str, "'...</font>");
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/var_export_line.c
Deleted
@@ -1,445 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#include "lib/php-header.h" -#include "ext/standard/php_string.h" -#include "Zend/zend_closures.h" -#if PHP_VERSION_ID >= 80100 -# include "zend_enum.h" -#endif - -#include "var_export_line.h" - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - -static int xdebug_array_element_export(zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, xdebug_str *str, int debug_zval, xdebug_var_export_options *options) -{ - zval **zv = &zv_nptr; - - if (options->runtimelevel.current_element_nr >= options->runtimelevel.start_element_nr && - options->runtimelevel.current_element_nr < options->runtimelevel.end_element_nr) - { - if (HASH_KEY_IS_NUMERIC(hash_key)) { /* numeric key */ - xdebug_str_add_fmt(str, XDEBUG_INT_FMT " => ", index_key); - } else { /* string key */ - zend_string *tmp_zstr; - - tmp_zstr = php_addcslashes(hash_key, (char*) "'\\\0..\37", 7); - - xdebug_str_addc(str, '\''); - xdebug_str_add_zstr(str, tmp_zstr); - xdebug_str_add_literal(str, "' => "); - - zend_string_release(tmp_zstr); - } - xdebug_var_export_line(zv, str, level + 2, debug_zval, options); - xdebug_str_add_literal(str, ", "); - } - if (options->runtimelevel.current_element_nr == options->runtimelevel.end_element_nr) { - xdebug_str_add_literal(str, "..., "); - } - options->runtimelevel.current_element_nr++; - return 0; -} - -static int xdebug_object_element_export(zval *object, zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, xdebug_str *str, int debug_zval, xdebug_var_export_options *options, char *class_name) -{ - zval **zv = &zv_nptr; - - if (options->runtimelevel.current_element_nr >= options->runtimelevel.start_element_nr && - options->runtimelevel.current_element_nr < options->runtimelevel.end_element_nr) - { - if (!HASH_KEY_IS_NUMERIC(hash_key)) { - xdebug_str *property_name; - xdebug_str *property_type = NULL; - char *prop_class_name; - const char *modifier; - - property_type = xdebug_get_property_type(object, zv_nptr); - property_name = xdebug_get_property_info((char*) HASH_APPLY_KEY_VAL(hash_key), HASH_APPLY_KEY_LEN(hash_key), &modifier, &prop_class_name); - xdebug_str_add(str, modifier, 0); - if (property_type) { - xdebug_str_addc(str, ' '); - xdebug_str_add_str(str, property_type); - } - xdebug_str_add_literal(str, " $"); - if (strcmp(modifier, "private") != 0 || strcmp(class_name, prop_class_name) == 0) { - xdebug_str_add_str(str, property_name); - xdebug_str_add_literal(str, " = "); - } else { - xdebug_str_addc(str, '{'); - xdebug_str_add(str, prop_class_name, 0); - xdebug_str_addc(str, '}'); - xdebug_str_add_str(str, property_name); - xdebug_str_add_literal(str, " = "); - } - - if (property_type) { - xdebug_str_free(property_type); - } - xdebug_str_free(property_name); - xdfree(prop_class_name); - } else { - xdebug_str_add_fmt(str, "public $%d = ", index_key); - } - xdebug_var_export_line(zv, str, level + 2, debug_zval, options); - xdebug_str_add_literal(str, "; "); - } - if (options->runtimelevel.current_element_nr == options->runtimelevel.end_element_nr) { - xdebug_str_add_literal(str, "...; "); - } - options->runtimelevel.current_element_nr++; - return 0; -} - -#if PHP_VERSION_ID < 80200 -static void handle_closure(xdebug_str *str, zval *obj) -{ - const zend_function *closure_function; - - if (Z_TYPE_P(obj) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(obj), zend_ce_closure)) { - return; - } - - closure_function = zend_get_closure_method_def(Z_OBJ_P(obj)); - - xdebug_str_add_literal(str, "virtual $closure = \""); - - if (closure_function->common.scope) { - if (closure_function->common.fn_flags & ZEND_ACC_STATIC) { - xdebug_str_add(str, ZSTR_VAL(closure_function->common.scope->name), 0); - xdebug_str_add_literal(str, "::"); - } else { - xdebug_str_add_literal(str, "$this->"); - } - } - xdebug_str_add_zstr(str, closure_function->common.function_name); - - xdebug_str_add_literal(str, "\", "); -} -#endif - -void xdebug_var_export_line(zval **struc, xdebug_str *str, int level, int debug_zval, xdebug_var_export_options *options) -{ - HashTable *myht; - zend_ulong num; - zend_string *key; - zval *val; - zval *tmpz; - int z_type; - - if (!struc || !(*struc)) { - return; - } - - z_type = Z_TYPE_P(*struc); - - if (debug_zval) { - xdebug_add_variable_attributes(str, *struc, XDEBUG_VAR_ATTR_TEXT); - } - if (z_type == IS_INDIRECT) { - tmpz = Z_INDIRECT_P(*struc); - struc = &tmpz; - z_type = Z_TYPE_P(*struc); - } - if (z_type == IS_REFERENCE) { - tmpz = &((*struc)->value.ref->val); - struc = &tmpz; - z_type = Z_TYPE_P(*struc); - } - - switch (z_type) { - case IS_TRUE: - xdebug_str_add_literal(str, "TRUE"); - break; - - case IS_FALSE: - xdebug_str_add_literal(str, "FALSE"); - break; - - case IS_NULL: - xdebug_str_add_literal(str, "NULL"); - break; - - case IS_LONG: - xdebug_str_add_fmt(str, XDEBUG_INT_FMT, Z_LVAL_P(*struc)); - break; - - case IS_DOUBLE: - xdebug_str_add_fmt(str, "%.*H", (int) EG(precision), Z_DVAL_P(*struc)); - break; - - case IS_STRING: { - if (options->no_decoration) { - xdebug_str_add_zstr(str, Z_STR_P(*struc)); - } else if ((size_t) Z_STRLEN_P(*struc) <= (size_t) options->max_data) { - zend_string *tmp_zstr; - - tmp_zstr = php_addcslashes(Z_STR_P(*struc), (char*) "'\\\0..\37", 7); - - xdebug_str_addc(str, '\''); - xdebug_str_add_zstr(str, tmp_zstr); - xdebug_str_addc(str, '\''); - - zend_string_release(tmp_zstr); - } else { - zend_string *tmp_zstr = php_addcslashes_str(ZSTR_VAL(Z_STR_P(*struc)), options->max_data, (char*) "'\\\0..\37", 7);
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/var_export_text.c
Deleted
@@ -1,505 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#include "lib/php-header.h" -#include "ext/standard/php_string.h" -#include "Zend/zend_closures.h" -#if PHP_VERSION_ID >= 80100 -# include "zend_enum.h" -#endif - - -#include "php_xdebug.h" - -#include "var_export_text.h" - -static void xdebug_var_export_text_ansi(zval **struc, xdebug_str *str, int mode, int level, int debug_zval, xdebug_var_export_options *options); -#define xdebug_var_export_text(struc, str, level, debug_zval, options) xdebug_var_export_text_ansi(struc, str, 0, level, debug_zval, options); -#define xdebug_var_export_ansi(struc, str, level, debug_zval, options) xdebug_var_export_text_ansi(struc, str, 1, level, debug_zval, options); - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - - -/***************************************************************************** -** Plain text/ANSI coloured variable printing routines -*/ - -#define ANSI_COLOR_POINTER (mode == 1 ? "0m" : "") -#define ANSI_COLOR_BOOL (mode == 1 ? "35m" : "") -#define ANSI_COLOR_LONG (mode == 1 ? "32m" : "") -#define ANSI_COLOR_NULL (mode == 1 ? "34m" : "") -#define ANSI_COLOR_DOUBLE (mode == 1 ? "33m" : "") -#define ANSI_COLOR_STRING (mode == 1 ? "31m" : "") -#define ANSI_COLOR_EMPTY (mode == 1 ? "30m" : "") -#define ANSI_COLOR_ARRAY (mode == 1 ? "33m" : "") -#define ANSI_COLOR_OBJECT (mode == 1 ? "31m" : "") -#define ANSI_COLOR_RESOURCE (mode == 1 ? "36m" : "") -#define ANSI_COLOR_MODIFIER (mode == 1 ? "32m" : "") -#define ANSI_COLOR_RESET (mode == 1 ? "0m" : "") -#define ANSI_COLOR_BOLD (mode == 1 ? "1m" : "") -#define ANSI_COLOR_BOLD_OFF (mode == 1 ? "22m" : "") - -static int xdebug_array_element_export_text_ansi(zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, int mode, xdebug_str *str, int debug_zval, xdebug_var_export_options *options) -{ - zval **zv = &zv_nptr; - - if (options->runtimelevel.current_element_nr >= options->runtimelevel.start_element_nr && - options->runtimelevel.current_element_nr < options->runtimelevel.end_element_nr) - { - xdebug_str_add_fmt(str, "%*s", (level * 2), ""); - - if (HASH_KEY_IS_NUMERIC(hash_key)) { /* numeric key */ - xdebug_str_add_fmt(str, "" XDEBUG_INT_FMT " %s=>%s\n", index_key, ANSI_COLOR_POINTER, ANSI_COLOR_RESET); - } else { /* string key */ - zend_string *tmp, *tmp2; - - tmp = php_str_to_str(ZSTR_VAL(hash_key), ZSTR_LEN(hash_key), (char*) "'", 1, (char*) "\\'", 2); - tmp2 = php_str_to_str(ZSTR_VAL(tmp), ZSTR_LEN(tmp), (char*) "\0", 1, (char*) "\\0", 2); - if (tmp) { - zend_string_release(tmp); - } - xdebug_str_addc(str, '\''); - if (tmp2) { - xdebug_str_add_zstr(str, tmp2); - zend_string_release(tmp2); - } - xdebug_str_add_literal(str, "' =>\n"); - } - xdebug_var_export_text_ansi(zv, str, mode, level + 1, debug_zval, options); - } - if (options->runtimelevel.current_element_nr == options->runtimelevel.end_element_nr) { - xdebug_str_add_fmt(str, "\n%*s(more elements)...\n", (level * 2), ""); - } - options->runtimelevel.current_element_nr++; - return 0; -} - -static int xdebug_object_element_export_text_ansi(zval *object, zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, int mode, xdebug_str *str, int debug_zval, xdebug_var_export_options *options) -{ - zval **zv = &zv_nptr; - - if (options->runtimelevel.current_element_nr >= options->runtimelevel.start_element_nr && - options->runtimelevel.current_element_nr < options->runtimelevel.end_element_nr) - { - xdebug_str_add_fmt(str, "%*s", (level * 2), ""); - - if (!HASH_KEY_IS_NUMERIC(hash_key)) { - char *class_name; - xdebug_str *property_name; - const char *modifier; - xdebug_str *property_type = NULL; - - property_type = xdebug_get_property_type(object, zv_nptr); - - property_name = xdebug_get_property_info((char*) HASH_APPLY_KEY_VAL(hash_key), HASH_APPLY_KEY_LEN(hash_key), &modifier, &class_name); - xdebug_str_add_fmt( - str, "%s%s%s%s%s%s%s $", - ANSI_COLOR_MODIFIER, ANSI_COLOR_BOLD, modifier, ANSI_COLOR_BOLD_OFF, property_type ? " " : "", property_type ? property_type->d : "", ANSI_COLOR_RESET - ); - xdebug_str_add_str(str, property_name); - xdebug_str_add_fmt(str, " %s=>%s\n", ANSI_COLOR_POINTER, ANSI_COLOR_RESET); - - if (property_type) { - xdebug_str_free(property_type); - } - xdebug_str_free(property_name); - xdfree(class_name); - } else { - xdebug_str_add_fmt(str, "%s%spublic%s%s ${" XDEBUG_INT_FMT "} %s=>%s\n", - ANSI_COLOR_MODIFIER, ANSI_COLOR_BOLD, ANSI_COLOR_BOLD_OFF, ANSI_COLOR_RESET, - index_key, ANSI_COLOR_POINTER, ANSI_COLOR_RESET - ); - } - xdebug_var_export_text_ansi(zv, str, mode, level + 1, debug_zval, options); - } - if (options->runtimelevel.current_element_nr == options->runtimelevel.end_element_nr) { - xdebug_str_add_fmt(str, "\n%*s(more elements)...\n", (level * 2), ""); - } - options->runtimelevel.current_element_nr++; - return 0; -} - -#if PHP_VERSION_ID < 80200 -static void handle_closure(xdebug_str *str, zval *obj, int level, int mode) -{ - const zend_function *closure_function; - - if (Z_TYPE_P(obj) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(obj), zend_ce_closure)) { - return; - } - - closure_function = zend_get_closure_method_def(Z_OBJ_P(obj)); - - xdebug_str_add_fmt( - str, "%*s%s%svirtual%s $closure =>\n%*s\"", - (level * 4) - 2, "", - ANSI_COLOR_MODIFIER, ANSI_COLOR_BOLD, ANSI_COLOR_RESET, - (level * 4) - 2, "" - ); - - if (closure_function->common.scope) { - if (closure_function->common.fn_flags & ZEND_ACC_STATIC) { - xdebug_str_add_fmt(str, "%s", ANSI_COLOR_OBJECT); - xdebug_str_add_zstr(str, closure_function->common.scope->name); - xdebug_str_add_fmt(str, "%s::", ANSI_COLOR_RESET); - } else { - xdebug_str_add_fmt(str, "%s$this%s->", ANSI_COLOR_OBJECT, ANSI_COLOR_RESET); - } - } - - xdebug_str_add_fmt(str, "%s", ANSI_COLOR_STRING); - xdebug_str_add_zstr(str, closure_function->common.function_name); - xdebug_str_add_fmt(str, "%s\"\n", ANSI_COLOR_RESET); -} -#endif - -static void xdebug_var_export_text_ansi(zval **struc, xdebug_str *str, int mode, int level, int debug_zval, xdebug_var_export_options *options) -{ - HashTable *myht; - char* tmp_str; - int tmp_len; - zend_ulong num; - zend_string *key; - zval *val; - zval *tmpz; - int z_type; - - if (!struc || !(*struc)) { - return; - } - - xdebug_str_add_fmt(str, "%*s", (level * 2) - 2, ""); - - z_type = Z_TYPE_P(*struc); - - if (debug_zval) { - xdebug_add_variable_attributes(str, *struc, XDEBUG_VAR_ATTR_TEXT); - } - if (z_type == IS_INDIRECT) { - tmpz = Z_INDIRECT_P(*struc); - struc = &tmpz; - z_type = Z_TYPE_P(*struc); - } - if (z_type == IS_REFERENCE) { - tmpz = &((*struc)->value.ref->val); - struc = &tmpz; - z_type = Z_TYPE_P(*struc);
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/lib/var_export_xml.c
Deleted
@@ -1,827 +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 "var_export_xml.h" -#include "Zend/zend_closures.h" - -static xdebug_str *prepare_variable_name(xdebug_str *name) -{ - xdebug_str *tmp_name; - - if (name->d0 == '$' || name->d0 == ':') { - tmp_name = xdebug_str_copy(name); - } else { - tmp_name = xdebug_str_new(); - xdebug_str_addc(tmp_name, '$'); - xdebug_str_add_str(tmp_name, name); - } - if (tmp_name->dtmp_name->l - 2 == ':' && tmp_name->dtmp_name->l - 1 == ':') { - xdebug_str_chop(tmp_name, 2); - } - return tmp_name; -} - -/* - * Returns whether we should attempt to encode name, fullname, and value as XML - * elements instead of attribute values, because XML doesn't support nearly all - * characters under ASCII 0x32. - */ -static int encoding_requested(char *value, size_t value_len) -{ - size_t i; - - for (i = 0; i < value_len; i++) { - if (valuei < 0x20) { - return 1; - } - } - return 0; -} - -static void check_if_extended_properties_are_needed(xdebug_var_export_options *options, xdebug_str *name, xdebug_str *fullname, zval *value) -{ - if (!options->extended_properties || options->encode_as_extended_property) { - return; - } - - /* Checking name */ - if (name && encoding_requested(name->d, name->l)) { - options->encode_as_extended_property = 1; - return; - } - - /* Checking full name */ - if (fullname && encoding_requested(fullname->d, fullname->l)) { - options->encode_as_extended_property = 1; - return; - } - - /* Checking for the value portion */ - if (!value) { - return; - } - if (Z_TYPE_P(value) == IS_STRING) { - if (encoding_requested(Z_STRVAL_P(value), Z_STRLEN_P(value))) { - options->encode_as_extended_property = 1; - return; - } - } - if (Z_TYPE_P(value) == IS_OBJECT) { - if (encoding_requested(STR_NAME_VAL(Z_OBJCE_P(value)->name), STR_NAME_LEN(Z_OBJCE_P(value)->name))) { - options->encode_as_extended_property = 1; - return; - } - } -} - -static void add_xml_attribute_or_element(xdebug_var_export_options *options, xdebug_xml_node *node, const char *field, int field_len, xdebug_str *value) -{ - if (options->encode_as_extended_property || (encoding_requested(value->d, value->l) && options->extended_properties)) { - xdebug_xml_node *element; - unsigned char *tmp_base64; - size_t new_len; - - options->encode_as_extended_property = 1; - - element = xdebug_xml_node_init(field); - xdebug_xml_add_attribute(element, "encoding", "base64"); - - tmp_base64 = xdebug_base64_encode((unsigned char*) value->d, value->l, &new_len); - xdebug_xml_add_text_ex(element, (char*) tmp_base64, new_len, 1, 0); - - xdebug_xml_add_child(node, element); - } else { - xdebug_xml_add_attribute_exl(node, field, field_len, xdstrndup(value->d, value->l), value->l, 0, 1); - } -} - -void xdebug_var_xml_attach_uninitialized_var(xdebug_var_export_options *options, xdebug_xml_node *node, xdebug_str *name) -{ - xdebug_xml_node *contents = NULL; - xdebug_str *tmp_name; - - contents = xdebug_xml_node_init("property"); - options->encode_as_extended_property = 0; - - tmp_name = prepare_variable_name(name); - add_xml_attribute_or_element(options, contents, "name", 4, tmp_name); - add_xml_attribute_or_element(options, contents, "fullname", 8, tmp_name); - xdebug_str_free(tmp_name); - - xdebug_xml_add_attribute(contents, "type", "uninitialized"); - xdebug_xml_add_child(node, contents); -} - -/***************************************************************************** -** XML node printing routines -*/ - -#define XDEBUG_OBJECT_ITEM_TYPE_PROPERTY 0 -#define XDEBUG_OBJECT_ITEM_TYPE_STATIC_PROPERTY 1<<0 -#define XDEBUG_OBJECT_ITEM_TYPE_READONLY 1<<1 - - -typedef struct -{ - char type; - char *name; - int name_len; - unsigned long index_key; - zval *zv; -} xdebug_object_item; - -static void merged_hash_object_item_dtor(zval *data) -{ - xdebug_object_item *item = Z_PTR_P(data); - - xdfree(item); -} - -static int object_item_add_to_merged_hash(zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, HashTable *merged, int object_type) -{ - zval **zv = &zv_nptr; - xdebug_object_item *item; - - item = xdcalloc(1, sizeof(xdebug_object_item)); - item->type = object_type; - item->zv = *zv; - - if (hash_key) { - item->name = (char*) HASH_APPLY_KEY_VAL(hash_key); - item->name_len = HASH_APPLY_KEY_LEN(hash_key) - 1; - item->index_key = hash_key->h; - } else { - item->name = xdebug_sprintf(XDEBUG_INT_FMT, index_key); - item->name_len = strlen(item->name); - } - - zend_hash_next_index_insert_ptr(merged, item); - - return 0; -} - -static int object_item_add_zend_prop_to_merged_hash(zend_property_info *zpp, HashTable *merged, int object_type, zend_class_entry *ce) -{ - xdebug_object_item *item; - - if ((zpp->flags & ZEND_ACC_STATIC) == 0) { - return 0; - } - - item = xdmalloc(sizeof(xdebug_object_item)); - item->type = object_type; - item->zv = &CE_STATIC_MEMBERS(ce)zpp->offset; - item->name = (char*) STR_NAME_VAL(zpp->name); - item->name_len = STR_NAME_LEN(zpp->name); - - zend_hash_next_index_insert_ptr(merged, item); - - return 0; -} - -static void add_unencoded_text_value_attribute_or_element(xdebug_var_export_options *options, xdebug_xml_node *node, char *value) -{ - if (options->encode_as_extended_property) { - xdebug_xml_node *element; - unsigned char *tmp_base64;
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/profiler/profiler.c
Deleted
@@ -1,554 +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 "php_xdebug.h" -#include "profiler.h" -#include "profiler_private.h" - -#include "lib/log.h" -#include "lib/mm.h" -#include "lib/str.h" -#include "lib/var.h" -#include "lib/usefulstuff.h" - -ZEND_EXTERN_MODULE_GLOBALS(xdebug) - -int xdebug_profiler_exit_handler(XDEBUG_OPCODE_HANDLER_ARGS); - -void xdebug_init_profiler_globals(xdebug_profiler_globals_t *xg) -{ - xg->active = 0; -} - -void xdebug_profiler_minit(void) -{ - /* Overload the "exit" opcode */ - xdebug_set_opcode_handler(ZEND_EXIT, xdebug_profiler_exit_handler); -} - -void xdebug_profiler_mshutdown(void) -{ -} - -void xdebug_profiler_rinit(void) -{ - xdebug_file_init(&XG_PROF(profile_file)); - XG_PROF(profile_filename_refs) = NULL; - XG_PROF(profile_functionname_refs) = NULL; - XG_PROF(profile_last_filename_ref) = 0; - XG_PROF(php_internal_seen_before) = 0; - XG_PROF(profile_last_functionname_ref) = 0; - XG_PROF(active) = 0; -} - -static void deinit_if_active(void) -{ - if (!XG_PROF(active)) { - return; - } - - xdebug_profiler_deinit(); -} - -void xdebug_profiler_post_deactivate(void) -{ - deinit_if_active(); -} - -void xdebug_profiler_pcntl_exec_handler(void) -{ - deinit_if_active(); -} - -int xdebug_profiler_exit_handler(XDEBUG_OPCODE_HANDLER_ARGS) -{ - const zend_op *cur_opcode = execute_data->opline; - - deinit_if_active(); - - return xdebug_call_original_opcode_handler_if_set(cur_opcode->opcode, XDEBUG_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -void xdebug_profiler_init_if_requested(zend_op_array *op_array) -{ - if (XG_PROF(active)) { - return; - } - - if (EG(flags) & EG_FLAGS_IN_SHUTDOWN) { - return; - } - - if (xdebug_lib_start_with_request(XDEBUG_MODE_PROFILING) || xdebug_lib_start_with_trigger(XDEBUG_MODE_PROFILING, NULL)) { - xdebug_profiler_init((char*) STR_NAME_VAL(op_array->filename)); - } -} - -void xdebug_profiler_execute_ex(function_stack_entry *fse, zend_op_array *op_array) -{ - if (!XG_PROF(active)) { - return; - } - - /* Calculate all elements for profile entries */ - xdebug_profiler_add_function_details_user(fse, op_array); - xdebug_profiler_function_begin(fse); -} - -void xdebug_profiler_execute_ex_end(function_stack_entry *fse) -{ - xdebug_profiler_function_end(fse); - xdebug_profiler_free_function_details(fse); -} - -void xdebug_profiler_execute_internal(function_stack_entry *fse) -{ - if (!XG_PROF(active)) { - return; - } - - xdebug_profiler_add_function_details_internal(fse); - xdebug_profiler_function_begin(fse); -} - -void xdebug_profiler_execute_internal_end(function_stack_entry *fse) -{ - if (!XG_PROF(active)) { - return; - } - - xdebug_profiler_function_end(fse); - xdebug_profiler_free_function_details(fse); -} - -void xdebug_profile_call_entry_dtor(void *dummy, void *elem) -{ - xdebug_call_entry *ce = elem; - - if (ce->function) { - zend_string_release(ce->function); - } - if (ce->filename) { - zend_string_release(ce->filename); - } - xdfree(ce); -} - -static void profiler_write_header(xdebug_file *file, char *script_name) -{ - if (XINI_PROF(profiler_append)) { - xdebug_file_printf(file, "\n==== NEW PROFILING FILE ==============================================\n"); - } - xdebug_file_printf(file, "version: 1\ncreator: xdebug %s (PHP %s)\n", XDEBUG_VERSION, XG_BASE(php_version_run_time)); - xdebug_file_printf(file, "cmd: %s\npart: 1\npositions: line\n\n", script_name); - xdebug_file_printf(file, "events: Time_(10ns) Memory_(bytes)\n\n"); - xdebug_file_flush(file); -} - -#define NANOTIME_SCALE_10NS(nanotime) ((unsigned long)(((nanotime) + 5) / 10)) - -void xdebug_profiler_init(char *script_name) -{ - char *filename = NULL, *fname = NULL; - char *output_dir = NULL; - - if (XG_PROF(active)) { - return; - } - - if (!strlen(XINI_PROF(profiler_output_name)) || - xdebug_format_output_filename(&fname, XINI_PROF(profiler_output_name), script_name) <= 0 - ) { - /* Invalid or empty xdebug.profiler_output_name */ - return; - } - - /* Add a slash if none is present in the output_dir setting */ - output_dir = xdebug_lib_get_output_dir(); /* not duplicated */ - - if (IS_SLASH(output_dirstrlen(output_dir) - 1)) { - filename = xdebug_sprintf("%s%s", output_dir, fname); - } else { - filename = xdebug_sprintf("%s%c%s", output_dir, DEFAULT_SLASH, fname); - } - - if (!xdebug_file_open(&XG_PROF(profile_file), filename, NULL, XINI_PROF(profiler_append) ? "ab" : "wb")) { - xdebug_log_diagnose_permissions(XLOG_CHAN_PROFILE, output_dir, fname);
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/profiler/profiler.h
Deleted
@@ -1,72 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Xdebug | - +----------------------------------------------------------------------+ - | Copyright (c) 2002-2022 Derick Rethans | - +----------------------------------------------------------------------+ - | This source file is subject to version 1.01 of the Xdebug license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | https://xdebug.org/license.php | - | If you did not receive a copy of the Xdebug license and are unable | - | to obtain it through the world-wide-web, please send a note to | - | derick@xdebug.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - */ - -#ifndef __XDEBUG_PROFILER_H__ -#define __XDEBUG_PROFILER_H__ - -#include "lib/php-header.h" -#include "TSRM.h" -#include "lib/file.h" -#include "lib/lib.h" - -#include "php_xdebug.h" - -typedef struct _xdebug_profiler_globals_t { - zend_bool active; - uint64_t profiler_start_nanotime; - xdebug_file profile_file; - xdebug_hash *profile_filename_refs; - int profile_last_filename_ref; - int php_internal_seen_before; - xdebug_hash *profile_functionname_refs; - int profile_last_functionname_ref; -} xdebug_profiler_globals_t; - -typedef struct _xdebug_profiler_settings_t { - char *profiler_output_name; /* "pid" or "crc32" */ - zend_bool profiler_append; -} xdebug_profiler_settings_t; - -void xdebug_init_profiler_globals(xdebug_profiler_globals_t *xg); -void xdebug_profiler_minit(void); -void xdebug_profiler_mshutdown(void); -void xdebug_profiler_rinit(void); -void xdebug_profiler_post_deactivate(void); - -void xdebug_profiler_pcntl_exec_handler(void); - -void xdebug_profiler_init_if_requested(zend_op_array *op_array); -void xdebug_profiler_execute_ex(function_stack_entry *fse, zend_op_array *op_array); -void xdebug_profiler_execute_ex_end(function_stack_entry *fse); -void xdebug_profiler_execute_internal(function_stack_entry *fse); -void xdebug_profiler_execute_internal_end(function_stack_entry *fse); - -void xdebug_profiler_init(char *script_name); -void xdebug_profiler_deinit(); - -void xdebug_profiler_add_function_details_user(function_stack_entry *fse, zend_op_array *op_array); -void xdebug_profiler_add_function_details_internal(function_stack_entry *fse); -void xdebug_profiler_free_function_details(function_stack_entry *fse); - -void xdebug_profiler_function_begin(function_stack_entry *fse); -void xdebug_profiler_function_end(function_stack_entry *fse); - -void xdebug_profile_call_entry_dtor(void *dummy, void *elem); - -char *xdebug_get_profiler_filename(void); - -PHP_FUNCTION(xdebug_get_profiler_filename); -#endif
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/src/tracing/tracing.c
Deleted
@@ -1,784 +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.3.2.tgz/xdebug-3.3.2/xdebug.c
Deleted
@@ -1,852 +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 HAVE_CONFIG_H -#include "config.h" -#endif - -#include "lib/php-header.h" -#include "main/php_version.h" -#include "lib/compat.h" - -#if HAVE_XDEBUG - -#ifndef PHP_WIN32 -#include <sys/time.h> -#include <unistd.h> -#else -#include "win32/time.h" -#include <process.h> -#endif - -#include "TSRM.h" -#include "SAPI.h" -#include "zend_extensions.h" -#include "main/php_ini.h" -#include "ext/standard/head.h" -#include "ext/standard/html.h" -#include "ext/standard/info.h" -#include "ext/standard/php_string.h" -#include "php_globals.h" -#include "main/php_output.h" -#include "ext/standard/php_var.h" - -#include "php_xdebug.h" -#include "php_xdebug_arginfo.h" - -#include "base/base.h" -#ifdef __linux__ -# include "base/ctrl_socket.h" -#endif -#include "base/filter.h" -#include "coverage/code_coverage.h" -#include "develop/monitor.h" -#include "develop/stack.h" -#include "develop/superglobals.h" -#include "debugger/com.h" -#include "gcstats/gc_stats.h" -#include "lib/usefulstuff.h" -#include "lib/lib.h" -#include "lib/llist.h" -#include "lib/log.h" -#include "lib/mm.h" -#include "lib/var_export_html.h" -#include "lib/var_export_line.h" -#include "lib/var_export_text.h" -#include "profiler/profiler.h" -#include "tracing/tracing.h" - -static zend_result (*xdebug_orig_post_startup_cb)(void); -static zend_result xdebug_post_startup(void); - -int xdebug_include_or_eval_handler(zend_execute_data *execute_data); - -/* True globals */ -int zend_xdebug_initialised = 0; -int xdebug_global_mode = 0; - -zend_module_entry xdebug_module_entry = { - STANDARD_MODULE_HEADER, - "xdebug", - ext_functions, - PHP_MINIT(xdebug), - PHP_MSHUTDOWN(xdebug), - PHP_RINIT(xdebug), - PHP_RSHUTDOWN(xdebug), - PHP_MINFO(xdebug), - XDEBUG_VERSION, - NO_MODULE_GLOBALS, - ZEND_MODULE_POST_ZEND_DEACTIVATE_N(xdebug), - STANDARD_MODULE_PROPERTIES_EX -}; - -ZEND_DECLARE_MODULE_GLOBALS(xdebug) - -#if COMPILE_DL_XDEBUG -ZEND_GET_MODULE(xdebug) -# ifdef ZTS -ZEND_TSRMLS_CACHE_DEFINE(); -# endif -#endif - -static PHP_INI_MH(OnUpdateServer) -{ - DUMP_TOK(server); -} - -static PHP_INI_MH(OnUpdateGet) -{ - DUMP_TOK(get); -} - -static PHP_INI_MH(OnUpdatePost) -{ - DUMP_TOK(post); -} - -static PHP_INI_MH(OnUpdateCookie) -{ - DUMP_TOK(cookie); -} - -static PHP_INI_MH(OnUpdateFiles) -{ - DUMP_TOK(files); -} - -static PHP_INI_MH(OnUpdateEnv) -{ - DUMP_TOK(env); -} - -static PHP_INI_MH(OnUpdateRequest) -{ - DUMP_TOK(request); -} - -static PHP_INI_MH(OnUpdateSession) -{ - DUMP_TOK(session); -} - -static PHP_INI_MH(OnUpdateStartWithRequest) -{ - if (!new_value) { - return FAILURE; - } - - if (!xdebug_lib_set_start_with_request(ZSTR_VAL(new_value))) { - return FAILURE; - } - - return SUCCESS; -} - -static PHP_INI_MH(OnUpdateStartUponError) -{ - if (!new_value) { - return FAILURE; - } - - if (!xdebug_lib_set_start_upon_error(ZSTR_VAL(new_value))) { - return FAILURE; - } - - return SUCCESS; -} - -static PHP_INI_MH(OnUpdateRemovedSetting) -{ - if (! (EG(error_reporting) & E_DEPRECATED)) { - return SUCCESS; - } - if (new_value && ZSTR_LEN(new_value) > 0 && strncmp("This setting", ZSTR_VAL(new_value), 11) != 0) { - xdebug_log_ex( - XLOG_CHAN_CONFIG, XLOG_CRIT, "REMOVED", - "The setting '%s' has been removed, see the upgrading guide at %supgrade_guide#changed-%s", - ZSTR_VAL(entry->name), xdebug_lib_docs_base(), ZSTR_VAL(entry->name) - ); - } - return FAILURE; -} - -static PHP_INI_MH(OnUpdateChangedSetting) -{ - if (! (EG(error_reporting) & E_DEPRECATED)) { - return SUCCESS; - } - if (new_value && ZSTR_LEN(new_value) > 0 && strncmp("This setting", ZSTR_VAL(new_value), 11) != 0) { - xdebug_log_ex( - XLOG_CHAN_CONFIG, XLOG_CRIT, "CHANGED", - "The setting '%s' has been renamed, see the upgrading guide at %supgrade_guide#changed-%s", - ZSTR_VAL(entry->name), xdebug_lib_docs_base(), ZSTR_VAL(entry->name) - ); - } - return FAILURE; -}
View file
xdebug-3.3.2.tgz/xdebug-3.3.2/xdebug.ini
Deleted
@@ -1,1275 +0,0 @@ -; This file is generated by the 'xdebug.org:html/docs/convert.php' robot -; for Xdebug 3.3.2 — do not modify by hand - -; ----------------------------------------------------------------------------- -; xdebug.cli_color -; -; Type: integer, Default value: 0 -; -; If this setting is 1, Xdebug will color var_dumps and stack traces output when -; in CLI mode and when the output is a tty. On Windows, the ANSICON 1 tool -; needs to be installed. -; -; 1 http://adoxa.altervista.org/ansicon/ -; -; If the setting is 2, then Xdebug will always color var_dumps and stack trace, -; no matter whether it's connected to a tty or whether ANSICON is installed. In -; this case, you might end up seeing escape codes. -; -; See this article 1 for some more information. -; -; 1 https://derickrethans.nl/cli-color.html -; -; .. note:: -; -; This setting can additionally be configured through the -; ``XDEBUG_CONFIG``environment variable 1. 1 -; /docs/all_settings#XDEBUG_CONFIG -; -; -;xdebug.cli_color = 0 - -; ----------------------------------------------------------------------------- -; xdebug.client_discovery_header -; -; Type: string, Default value: "HTTP_X_FORWARDED_FOR,REMOTE_ADDR" -; -; If xdebug.client_discovery_header is configured to be a non-empty string, then -; the value is used as key in the ``$_SERVER`` superglobal array to determine -; which header to use to find the IP address or hostname to use for 'connecting -; back to'. This setting is only used in combination with -; xdebug.discover_client_host and is otherwise ignored. -; -; For example, if xdebug.client_discovery_header is set to -; ``HTTP_FORWARD_HOST``, then Xdebug will check -; ``$_SERVER'HTTP_FORWARD_HOST'`` to obtain the IP address to use for -; 'connecting back'. -; -; It is possible to configure multiple fallbacks by using a comma separated list -; of values. For example if you want to use ``HTTP_FORWARD_HOST`` first, and -; then also want to check ``REMOTE_ADDR``, then you set -; xdebug.client_discovery_header to ``HTTP_FORWARD_HOST,REMOTE_ADDR``. -; -; .. warning:: -; -; PHP automatically prepends ``HTTP_``, and converts ``-`` to ``_``, for -; received HTTP header names. The ``THIS-IS-MY-HOST`` HTTP header is -; converted into ``$_SERVER'HTTP_THIS_IS_MY_HOST'``. Therefore, the -; xdebug.client_discovery_header needs to be set to ``HTTP_THIS_IS_MY_HOST`` -; to match this. -; -; If you have logging enabled, and set the xdebug.log_level setting to ``10``, -; then Xdebug will list every header, the header value, and the used header (if -; any) when attempting to find the IP address to connect back to. -; -; .. note:: -; -; Xdebug 3.2 and later no longer fall back to the -; ``$_SERVER'HTTP_X_FORWARDED_FOR'`` and ``$_SERVER'REMOTE_ADDR'`` header -; values by default. If you want these headers to be used as well, you -; specifically need to add these to the list of headers, by setting -; xdebug.client_discovery_header to -; ``YOUR_OWN_HEADER,HTTP_X_FORWARDED_FOR,REMOTE_ADDR``. -; -; -;xdebug.client_discovery_header = "HTTP_X_FORWARDED_FOR,REMOTE_ADDR" - -; ----------------------------------------------------------------------------- -; xdebug.client_host -; -; Type: string, Default value: localhost -; -; Configures the IP address or hostname where Xdebug will attempt to connect to -; when initiating a debugging connection. This address should be the address of -; the machine where your IDE or debugging client is listening for incoming -; debugging connections. -; -; On non-Windows platforms, it is also possible to configure a Unix domain -; socket 1 which is supported by only a select view debugging clients. In that -; case, instead of the hostname or IP address, use ``unix:///path/to/sock``. -; -; 1 https://en.wikipedia.org/wiki/Unix_domain_socket -; -; If xdebug.discover_client_host is enabled then Xdebug will only use the value -; of this setting in case Xdebug can not connect to an IDE using the information -; it obtained from HTTP headers. In that case, the value of this setting acts as -; a fallback only. -; -; .. note:: -; -; This setting can additionally be configured through the -; ``XDEBUG_CONFIG``environment variable 1. 1 -; /docs/all_settings#XDEBUG_CONFIG -; -; -;xdebug.client_host = localhost - -; ----------------------------------------------------------------------------- -; xdebug.client_port -; -; Type: integer, Default value: 9003 -; -; The port to which Xdebug tries to connect on the remote host. Port ``9003`` is -; the default for both Xdebug and the Command Line Debug Client. As many clients -; use this port number, it is best to leave this setting unchanged. -; -; .. note:: -; -; This setting can additionally be configured through the -; ``XDEBUG_CONFIG``environment variable 1. 1 -; /docs/all_settings#XDEBUG_CONFIG -; -; -;xdebug.client_port = 9003 - -; ----------------------------------------------------------------------------- -; xdebug.cloud_id -; -; Type: string, Default value: -; -; With this setting you configure Xdebug for use with Xdebug Cloud 1. It needs -; to match one of the tokens from your profile page 2. -; -; 1 https://xdebug.cloud -; 2 https://xdebug.cloud/profile#tokens -; -; Your IDE needs to be configured with the same token for Xdebug and your IDE to -; communicate through Xdebug Cloud. -; -; | In PhpStorm you can find this setting under: -; | File | Settings | PHP | Debug | Xdebug Cloud for Windows and Linux -; | PhpStorm | Preferences | PHP | Debug | Xdebug Cloud for macOS -; -; -;xdebug.cloud_id = - -; ----------------------------------------------------------------------------- -; xdebug.collect_assignments -; -; Type: boolean, Default value: false -; -; This setting, defaulting to 0, controls whether Xdebug should add variable -; assignments to function traces. Assign-by-var ( ``=&``) assignments are -; included too. -; -; -;xdebug.collect_assignments = false - -; ----------------------------------------------------------------------------- -; xdebug.collect_params -; -; Introduced in version 3.3 -; -; Type: boolean, Default value: true -; -; If enabled (default), files created with the Function Trace feature will -; include all arguments to functions and methods. -; -; When disabled, the argument to each function and method will not be present in -; the trace files. -; -; -;xdebug.collect_params = true - -; ----------------------------------------------------------------------------- -; xdebug.collect_return -; -; Type: boolean, Default value: false -; -; This setting, defaulting to 0, controls whether Xdebug should write the return -; value of function calls to the trace files. -; -; -;xdebug.collect_return = false - -; ----------------------------------------------------------------------------- -; xdebug.connect_timeout_ms -; -; Type: integer, Default value: 200 -; -; The amount of time in milliseconds that Xdebug will wait for on an IDE to -; acknowledge an incoming debugging connection. The default value of 200 ms -; should in most cases be enough. In case you often get dropped debugging -; requests, perhaps because you have a high latency network, or a development -; box far away from your IDE, or have a slow firewall, then you can should -; increase this value. -; -; Please note that increasing this value might mean that your requests seem to -; 'hang' in case Xdebug tries to establish a connection, but your IDE is not -; listening.
View file
xdebug-3.3.2.tgz/package.xml -> xdebug-3.4.3.tgz/package.xml
Changed
@@ -1,5 +1,5 @@ <?xml version="1.0" encoding="ISO-8859-1"?> -<package packagerversion="1.10.13" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> +<package packagerversion="1.10.15" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> <name>xdebug</name> <channel>pecl.php.net</channel> <summary>Xdebug is a debugging and productivity extension for PHP</summary> @@ -32,11 +32,11 @@ <email>derick@xdebug.org</email> <active>yes</active> </lead> - <date>2024-04-15</date> - <time>12:55:17</time> + <date>2025-05-14</date> + <time>09:39:21</time> <version> - <release>3.3.2</release> - <api>3.3.2</api> + <release>3.4.3</release> + <api>3.4.3</api> </version> <stability> <release>stable</release> @@ -44,13 +44,18 @@ </stability> <license filesource="LICENSE" uri="https://xdebug.org/license/1.03">Xdebug-1.03</license> <notes> -Mon, Apr 15, 2024 - Xdebug 3.3.2 +Wed, May 14, 2025 - Xdebug 3.4.3 = Fixed bugs: - - Fixed issue #2216: With PHP8.3 and Apache 2.4.58 error_reporting() causing Apache process to hang - - Fixed issue #2230: Crash when xdebug and blackfire extensions are active - - Fixed issue #2233: High and continuous Apache server CPU use + - 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 </notes> <contents> <dir name="/"> @@ -58,20 +63,20 @@ <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="e248d2f6f7dac8567156947ce773ab6a" name="src/base/base.c" role="src" /> + <file md5sum="c7aecda0faa7e572a734b67b25b74a07" name="src/base/base.c" role="src" /> <file md5sum="7db372db630677292df705a90c07e21c" name="src/base/base.h" role="src" /> - <file md5sum="1502ac3e0d317e059f1c75db2b03346e" name="src/base/base_globals.h" role="src" /> + <file md5sum="462f11891e8d2b7db11857161abb8f10" 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="0f458f12744ae7226d53e3488f2a12a1" name="src/base/ctrl_socket.c" role="src" /> + <file md5sum="3faec657adf80bbc8cf06eca7f1e620f" name="src/base/ctrl_socket.c" role="src" /> <file md5sum="8663469dde1558dab7a03f0814501483" name="src/base/ctrl_socket.h" role="src" /> - <file md5sum="9795180682fad3c69098bfdd07dc968b" name="src/lib/usefulstuff.c" role="src" /> + <file md5sum="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="ab0a3ccfa6b3626e761b5d690fd28f38" name="src/lib/compat.h" 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" /> @@ -80,9 +85,9 @@ <file md5sum="77bef9854199eb280ecbd97a83737648" name="src/lib/hash.h" role="src" /> <file md5sum="46e1530b296f71bf2d00e282b32de691" name="src/lib/headers.c" role="src" /> <file md5sum="b05e34ecc50ab77d02933c583d88551b" name="src/lib/headers.h" role="src" /> - <file md5sum="72312d3dd877a81ab58df7ee7c606fe6" name="src/lib/lib.c" role="src" /> - <file md5sum="ea8c529b09a8988bf0a2313ba04617be" name="src/lib/lib.h" role="src" /> - <file md5sum="0336d9bd732b83f5f024a6782efc74ce" name="src/lib/log.c" role="src" /> + <file md5sum="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="8026528d3daa7d18021442eddbf60176" name="src/lib/lib_private.h" role="src" /> <file md5sum="88171fff82c5233a96d05341e0fcdcf9" name="src/lib/llist.c" role="src" /> @@ -91,56 +96,56 @@ <file md5sum="39d07a6b4e982c8d5787e188a93c8af9" 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="3290e703fe7174012b5a45b423e3ca08" name="src/lib/str.c" role="src" /> + <file md5sum="06957affcf5343b01df7b9b90cb23a8d" name="src/lib/str.c" role="src" /> <file md5sum="34d98f97b0e5a32a459a083bae66edfb" name="src/lib/str.h" role="src" /> - <file md5sum="326ce360a40b63e768992aee68fe0c9d" name="src/lib/timing.c" role="src" /> + <file md5sum="5b9f132ac452b6a5077bd401a3af0099" name="src/lib/timing.c" role="src" /> <file md5sum="637e3b5e753e6afc8b014b02cec7b0ec" name="src/lib/timing.h" role="src" /> - <file md5sum="0476851515ef257cb58ec938ebe3c758" name="src/lib/var.c" role="src" /> - <file md5sum="253b8efe31b2bbe7c808aea188fe78e1" name="src/lib/var.h" role="src" /> - <file md5sum="f5d2a1cebc83fe2ae38eff20681463e6" name="src/lib/var_export_html.c" role="src" /> + <file md5sum="024ca4b6d121244fd98bab98f30c1e61" 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="51340e6c1d3b77ec4509dc51bd2089fe" name="src/lib/var_export_line.c" role="src" /> + <file md5sum="986a17594601b6e83d20c1dc2a470f5d" name="src/lib/var_export_line.c" role="src" /> <file md5sum="a865240b02e1f698ce57098f01693399" name="src/lib/var_export_line.h" role="src" /> - <file md5sum="5980e5132000a9d1838b22cccb949412" name="src/lib/var_export_text.c" 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="1697176c9ff834e91c6633b333b00de5" name="src/lib/var_export_xml.c" role="src" /> + <file md5sum="07c7dd11f25ad530b0147a8d40944740" name="src/lib/var_export_xml.c" role="src" /> <file md5sum="dc4f5766d9ebe581d6de6319fcc966ab" name="src/lib/var_export_xml.h" role="src" /> <file md5sum="8d1a4cb863697a98bf063b6a4ab79050" name="src/lib/vector.h" role="src" /> <file md5sum="a637b4abdfcc5a1a74ea7fcb94ebf0db" name="src/lib/xml.c" role="src" /> <file md5sum="bf00317cca78941bc659bf15b07fe385" name="src/lib/xml.h" role="src" /> <file md5sum="3bf888cd6a2d69da7738f278cb108561" name="src/coverage/branch_info.c" role="src" /> <file md5sum="963e2650561b374f99943254bda93688" name="src/coverage/branch_info.h" role="src" /> - <file md5sum="d031d68f6e5a952ef7fc2ea22c8bc0b1" name="src/coverage/code_coverage.c" 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="b0a609f56e0d13cf7f6c915af1774512" name="src/coverage/code_coverage_private.h" role="src" /> <file md5sum="89a65d3495bdf205766dd72377f451ab" name="src/develop/develop.c" role="src" /> - <file md5sum="2c7fd0d0257b2db17e5fea6a2a148c8c" name="src/develop/develop.h" role="src" /> + <file md5sum="f7cf8df6eb57d3a4fbd41ce614a6fc5b" name="src/develop/develop.h" role="src" /> <file md5sum="8bc34c16b460129c99c0a43ef3db87e4" name="src/develop/develop_private.h" role="src" /> <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="a9044ac300d13ef719e4d6ffc6e4ed83" name="src/develop/stack.c" role="src" /> + <file md5sum="5934860c8fd20d6ea1cedfe248ca9aad" name="src/develop/stack.c" role="src" /> <file md5sum="8befdeb139efc9a471dc9a3277ca771c" name="src/develop/stack.h" role="src" /> - <file md5sum="a27d21b79bdf5acbe4725c7eeb8b1fb7" name="src/develop/superglobals.c" role="src" /> + <file md5sum="f8075b29ea1cd537822b1640cc847888" name="src/develop/superglobals.c" role="src" /> <file md5sum="3a2f095163c396e8945274b6d4595eaf" name="src/develop/superglobals.h" role="src" /> - <file md5sum="2c9240f952b0ead40b961f1bcf90569c" name="src/debugger/com.c" role="src" /> - <file md5sum="ca34901978214b6b1eb942b7bfc18b20" name="src/debugger/com.h" role="src" /> - <file md5sum="a0c3a663a287c4a43c9f85411edd290a" name="src/debugger/debugger.c" role="src" /> + <file md5sum="aded20852ffec095aef78ef958250155" 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="57dc7787f58e11c1b703b3c2e32808fe" name="src/debugger/debugger_private.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="40202ff2822142d1f4d16108d35f7293" name="src/debugger/handler_dbgp.c" 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="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="d0104dfd8d732115c0c5593dad045df4" name="src/profiler/profiler.c" role="src" /> - <file md5sum="96f3f967d882ca71daa2e4225660319e" name="src/profiler/profiler.h" role="src" /> + <file md5sum="d1db003b2ba10291853a94a8b6066085" 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="774b937f1fb9713390b94c37787d3bb3" name="src/tracing/tracing.c" role="src" /> + <file md5sum="e1d47d5878c5b58916432c6a122b8847" name="src/tracing/tracing.c" role="src" /> <file md5sum="a9f7754a35cc95addebc3e417c21eb55" name="src/tracing/tracing.h" role="src" /> <file md5sum="f1319418b7165faac0ff1f1ce23467db" name="src/tracing/tracing_private.h" role="src" /> <file md5sum="68281302e760e1f3b7a727b2d90ca6e1" name="src/tracing/trace_computerized.c" role="src" /> @@ -151,17 +156,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="838e98563d4d4f3a6389fe6085542636" name="config.m4" role="src" /> - <file md5sum="0803fcb73f722283712c6650a4b1c42f" name="config.w32" role="src" /> + <file md5sum="954d53d2f8e6ccf9db8baf3bcd443811" name="config.m4" role="src" /> + <file md5sum="899406f5ace0030d435509c2fe4afe39" name="config.w32" role="src" /> <file md5sum="8f9a93feba6ff23c4bc1bc2929babcc4" name="CREDITS" role="doc" /> <file md5sum="afd6ce4aa04fdc346e5b3c6e634bd75c" name="LICENSE" role="doc" /> - <file md5sum="62fd32efac50fe04f53800cb2fcac540" name="xdebug.ini" role="doc" /> + <file md5sum="a1c7dbacec64553da9e8ff0a333093f0" name="xdebug.ini" role="doc" /> <file md5sum="82ad7174e13d1bb8c64835f8cefeb494" name="Makefile.frag" role="src" /> - <file md5sum="7aac837000f978786669cd9f4290c3ba" name="CONTRIBUTING.rst" role="doc" /> + <file md5sum="28b8704fb7000ab7ac61e7417596a7bb" name="CONTRIBUTING.rst" role="doc" /> <file md5sum="225ebff41647c56edec110dd491fce14" name="README.rst" role="doc" /> - <file md5sum="78e0afbfe3bac92272625d00faf03f20" name="run-xdebug-tests.php" role="src" /> - <file md5sum="a41c0e324582530077bfd956d0a39ec3" name="xdebug.c" role="src" /> - <file md5sum="f513ed9529064bbf0fec98fef15daf12" name="php_xdebug.h" role="src" /> + <file md5sum="99f2fde690d7f4380f54d05166615873" name="run-xdebug-tests.php" role="src" /> + <file md5sum="f0be1174bf28465213fb218420b3a49b" name="xdebug.c" role="src" /> + <file md5sum="419fc24aaa1dd79fb49d8b5d5eed880a" name="php_xdebug.h" role="src" /> <file md5sum="73bd04f8dea1031f54b2ff3f5688ecab" name="php_xdebug_arginfo.h" role="src" /> </dir> </contents> @@ -169,7 +174,7 @@ <required> <php> <min>8.0.0</min> - <max>8.3.99</max> + <max>8.4.99</max> </php> <pearinstaller> <min>1.9.1</min> @@ -180,6 +185,152 @@ <zendextsrcrelease /> <changelog> <release>
View file
xdebug-3.4.3.tgz/xdebug-3.4.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.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/CREDITS
Changed
(renamed from xdebug-3.3.2/CREDITS)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/LICENSE
Changed
(renamed from xdebug-3.3.2/LICENSE)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/Makefile.frag
Changed
(renamed from xdebug-3.3.2/Makefile.frag)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/README.rst
Changed
(renamed from xdebug-3.3.2/README.rst)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/config.m4
Added
@@ -0,0 +1,134 @@ +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
Added
@@ -0,0 +1,58 @@ +// 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/contrib/tracefile-analyser.php
Changed
(renamed from xdebug-3.3.2/contrib/tracefile-analyser.php)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/contrib/xt.vim
Changed
(renamed from xdebug-3.3.2/contrib/xt.vim)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/m4/clocks.m4
Changed
(renamed from xdebug-3.3.2/m4/clocks.m4)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/m4/pkg.m4
Changed
(renamed from xdebug-3.3.2/m4/pkg.m4)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/php_xdebug.h
Added
@@ -0,0 +1,111 @@ +/* + +----------------------------------------------------------------------+ + | 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/php_xdebug_arginfo.h
Changed
(renamed from xdebug-3.3.2/php_xdebug_arginfo.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/run-xdebug-tests.php
Added
@@ -0,0 +1,4057 @@ +#!/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
Added
@@ -0,0 +1,1634 @@ +/* + +----------------------------------------------------------------------+ + | 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.h
Changed
(renamed from xdebug-3.3.2/src/base/base.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/base/base_globals.h
Added
@@ -0,0 +1,96 @@ +/* + +----------------------------------------------------------------------+ + | 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/base_private.h
Changed
(renamed from xdebug-3.3.2/src/base/base_private.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/base/ctrl_socket.c
Added
@@ -0,0 +1,374 @@ +/* + +----------------------------------------------------------------------+ + | 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/base/ctrl_socket.h
Changed
(renamed from xdebug-3.3.2/src/base/ctrl_socket.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/base/filter.c
Changed
(renamed from xdebug-3.3.2/src/base/filter.c)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/base/filter.h
Changed
(renamed from xdebug-3.3.2/src/base/filter.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/coverage/branch_info.c
Changed
(renamed from xdebug-3.3.2/src/coverage/branch_info.c)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/coverage/branch_info.h
Changed
(renamed from xdebug-3.3.2/src/coverage/branch_info.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/coverage/code_coverage.c
Added
@@ -0,0 +1,1268 @@ +/* + +----------------------------------------------------------------------+ + | 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
Changed
(renamed from xdebug-3.3.2/src/coverage/code_coverage.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/coverage/code_coverage_private.h
Changed
(renamed from xdebug-3.3.2/src/coverage/code_coverage_private.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/debugger/com.c
Added
@@ -0,0 +1,828 @@ +/* + +----------------------------------------------------------------------+ + | 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/com.h
Added
@@ -0,0 +1,72 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#ifndef __HAVE_XDEBUG_COM_H__ +#define __HAVE_XDEBUG_COM_H__ + +#include "handlers.h" + +#define XDEBUG_CLIENT_PORT_S "9003" +#define XDEBUG_CLOUD_PORT 9020L + +#if WIN32|WINNT +# define SOCK_ERR INVALID_SOCKET +# define SOCK_CONN_ERR SOCKET_ERROR +# define SOCK_RECV_ERR SOCKET_ERROR +#else +# define SOCK_ERR -1 +# define SOCK_CONN_ERR -1 +# define SOCK_RECV_ERR -1 +#endif +#define SOCK_TIMEOUT_ERR -2 +#define SOCK_ACCESS_ERR -3 + +#if WIN32|WINNT +#define SCLOSE(a) closesocket(a) +#define SSENDL(a,b,c) send(a,b,c,0) +#define SSEND(a,b) send(a,b,strlen(b),0) +#define SREAD(a,b,c) recv(a,b,c,0) +#else +#define SCLOSE(a) close(a) +#define SSENDL(a,b,c) write(a,b,c) +#define SSEND(a,b) write(a,b,strlen(b)) +#define SREAD(a,b,c) read(a,b,c) +#endif + + +#define SENDMSG(socket, str) { \ + char *message_buffer; \ + \ + message_buffer = str; \ + SSEND(socket, message_buffer); \ + xdfree(message_buffer); \ +} + +void xdebug_close_socket(int socket); + +/* Remote connection activation and house keeping */ +#define xdebug_is_debug_connection_active() !!XG_DBG(remote_connection_enabled) +void xdebug_abort_debugger(void); +void xdebug_restart_debugger(void); +void xdebug_mark_debug_connection_active(void); +void xdebug_mark_debug_connection_not_active(void); +void xdebug_mark_debug_connection_pending(void); +void xdebug_debug_init_if_requested_at_startup(void); +void xdebug_debug_init_if_requested_on_connect_to_client(void); +void xdebug_debug_init_if_requested_on_error(void); +void xdebug_debug_init_if_requested_on_xdebug_break(void); + +#endif
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/debugger/debugger.c
Added
@@ -0,0 +1,1078 @@ +/* + +----------------------------------------------------------------------+ + | 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
Changed
(renamed from xdebug-3.3.2/src/debugger/debugger.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/debugger/debugger_private.h
Added
@@ -0,0 +1,53 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2021 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#ifndef __XDEBUG_DEBUGGER_PRIVATE_H__ +#define __XDEBUG_DEBUGGER_PRIVATE_H__ + +#include "debugger.h" + +#include "lib/lib.h" + +typedef struct _fd_buf fd_buf; + +struct _fd_buf { + char *buffer; + int buffer_size; +}; + +typedef struct _xdebug_function_lines_map_item xdebug_function_lines_map_item; + +struct _xdebug_function_lines_map_item { + size_t line_start; + size_t line_end; + size_t line_span; + xdebug_set *lines_breakable; +}; + +typedef struct _xdebug_lines_list xdebug_lines_list; + +struct _xdebug_lines_list { + size_t count; /* How many function/line mappings are in the list */ + size_t size; /* How many function/line mappings are allocated */ + xdebug_function_lines_map_item **functions; +}; + +#define XG_DBG(v) (XG(globals.debugger.v)) +#define XINI_DBG(v) (XG(settings.debugger.v)) + +bool xdebug_should_ignore(void); + +#endif
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/debugger/handler_dbgp.c
Added
@@ -0,0 +1,3047 @@ +/* + +----------------------------------------------------------------------+ + | 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
Changed
(renamed from xdebug-3.3.2/src/debugger/handler_dbgp.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/debugger/handlers.c
Changed
(renamed from xdebug-3.3.2/src/debugger/handlers.c)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/debugger/handlers.h
Changed
(renamed from xdebug-3.3.2/src/debugger/handlers.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/debugger/ip_info.c
Changed
(renamed from xdebug-3.3.2/src/debugger/ip_info.c)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/debugger/ip_info.h
Changed
(renamed from xdebug-3.3.2/src/debugger/ip_info.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/develop/develop.c
Changed
(renamed from xdebug-3.3.2/src/develop/develop.c)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/develop/develop.h
Added
@@ -0,0 +1,85 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#ifndef __XDEBUG_DEVELOP_H__ +#define __XDEBUG_DEVELOP_H__ + +#define XDEBUG_LAST_EXCEPTION_TRACE_SLOTS 8 + +typedef struct _xdebug_develop_globals_t { + /* used for function monitoring */ + zend_bool do_monitor_functions; + xdebug_hash *functions_to_monitor; + xdebug_llist *monitored_functions_found; /* List of functions found */ + + /* superglobals */ + xdebug_llist server; + xdebug_llist get; + xdebug_llist post; + xdebug_llist cookie; + xdebug_llist files; + xdebug_llist env; + xdebug_llist request; + xdebug_llist session; + + /* used for collection errors */ + xdebug_llist *collected_errors; + + /* scream */ + zend_bool in_at; + + /* last exception stack trace */ + struct { + int next_slot; + zend_object *obj_ptrXDEBUG_LAST_EXCEPTION_TRACE_SLOTS; + zval stack_traceXDEBUG_LAST_EXCEPTION_TRACE_SLOTS; + } last_exception_trace; +} xdebug_develop_globals_t; + +typedef struct _xdebug_develop_settings_t { + + zend_long max_stack_frames; + zend_bool show_ex_trace; + zend_bool show_error_trace; + zend_bool show_local_vars; + zend_bool force_display_errors; + zend_long force_error_reporting; + zend_long halt_level; + + zend_long cli_color; + + /* superglobals */ + zend_bool dump_globals; + zend_bool dump_once; + zend_bool dump_undefined; + + /* scream */ + zend_bool do_scream; +} xdebug_develop_settings_t; + +void xdebug_init_develop_globals(xdebug_develop_globals_t *xg); +void xdebug_deinit_develop_globals(xdebug_develop_globals_t *xg); + +void xdebug_develop_minit(INIT_FUNC_ARGS); +void xdebug_develop_mshutdown(); +void xdebug_develop_rinit(); +void xdebug_develop_post_deactivate(); +void xdebug_develop_rshutdown(); + +void xdebug_develop_throw_exception_hook(zend_object *exception, zval *file, zval *line, zval *code, char *code_str, zval *message); +void xdebug_monitor_handler(function_stack_entry *fse); + +#endif
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/develop/develop_private.h
Changed
(renamed from xdebug-3.3.2/src/develop/develop_private.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/develop/monitor.c
Changed
(renamed from xdebug-3.3.2/src/develop/monitor.c)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/develop/monitor.h
Changed
(renamed from xdebug-3.3.2/src/develop/monitor.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/develop/php_functions.c
Changed
(renamed from xdebug-3.3.2/src/develop/php_functions.c)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/develop/stack.c
Added
@@ -0,0 +1,1353 @@ +/* + +----------------------------------------------------------------------+ + | 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/develop/stack.h
Changed
(renamed from xdebug-3.3.2/src/develop/stack.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/develop/superglobals.c
Added
@@ -0,0 +1,210 @@ +/* + +----------------------------------------------------------------------+ + | 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 "SAPI.h" + +#include "php_xdebug.h" +#include "superglobals.h" + +#include "lib/compat.h" +#include "lib/lib.h" +#include "lib/var_export_html.h" +#include "lib/var_export_line.h" + +extern ZEND_DECLARE_MODULE_GLOBALS(xdebug); + +void xdebug_superglobals_dump_dtor(void *user, void *ptr) +{ + free(ptr); +} + +static void dump_hash_elem(zval *z, const char *name, long index_key, const char *elem, int html, xdebug_str *str) +{ + if (html) { + if (elem) { + xdebug_str_add_fmt(str, "<tr><td colspan='2' align='right' bgcolor='#eeeeec' valign='top'><pre>$%s'%s' =</pre></td>", name, elem); + } else { + xdebug_str_add_fmt(str, "<tr><td colspan='2' align='right' bgcolor='#eeeeec' valign='top'><pre>$%s%ld =</pre></td>", name, index_key); + } + } + + if (z != NULL) { + xdebug_str *val; + + if (html) { + val = xdebug_get_zval_value_html(NULL, z, 0, NULL); + + xdebug_str_add_literal(str, "<td colspan='3' bgcolor='#eeeeec'>"); + xdebug_str_add_str(str, val); + xdebug_str_add_literal(str, "</td>"); + } else { + val = xdebug_get_zval_value_line(z, 0, NULL); + + if (elem) { + xdebug_str_add_fmt(str, "\n $%s'%s' = ", name, elem); + } else { + xdebug_str_add_fmt(str, "\n $%s%ld = ", name, index_key); + } + xdebug_str_add_str(str, val); + } + + xdebug_str_free(val); + } else { + /* not found */ + if (html) { + xdebug_str_add_literal(str, "<td colspan='3' bgcolor='#eeeeec'><i>undefined</i></td>"); + } else if (elem) { + xdebug_str_add_fmt(str, "\n $%s'%s' is undefined", name, elem); + } else { + xdebug_str_add_fmt(str, "\n $%s%ld is undefined", name, index_key); + } + } + + if (html) { + xdebug_str_add_literal(str, "</tr>\n"); + } +} + +static int dump_hash_elem_va(zval *pDest, zend_ulong index_key, zend_string *hash_key, const char *name, int html, xdebug_str *str) +{ + if (HASH_KEY_IS_NUMERIC(hash_key)) { + dump_hash_elem(pDest, name, index_key, NULL, html, str); + } else { + dump_hash_elem(pDest, name, 0, HASH_APPLY_KEY_VAL(hash_key), html, str); + } + + return SUCCESS; +} + +static void dump_hash(xdebug_llist *l, const char *name, int name_len, int html, xdebug_str *str) +{ + zval *z; + zend_ulong num; + zend_string *key; + zval *val; + HashTable *ht = NULL; + xdebug_llist_element *elem; + + if (!XDEBUG_LLIST_COUNT(l)) { + return; + } + + { + zend_string *s_name = zend_string_init(name, name_len, 0); + if ((z = zend_hash_find(&EG(symbol_table), s_name))) { + if (Z_TYPE_P(z) == IS_REFERENCE) { + z = &z->value.ref->val; + } + if (Z_TYPE_P(z) == IS_ARRAY) { + ht = Z_ARRVAL_P(z); + } + } + zend_string_release(s_name); + } + + if (html) { + xdebug_str_add_fmt(str, "<tr><th colspan='5' align='left' bgcolor='#e9b96e'>Dump <i>$%s</i></th></tr>\n", name); + } else { + xdebug_str_add_fmt(str, "\nDump $%s", name); + } + + elem = XDEBUG_LLIST_HEAD(l); + + while (elem != NULL) { + zend_string *s; + + s = zend_string_init(elem->ptr, strlen(elem->ptr), 0); + + if (ht && (*((char *) (elem->ptr)) == '*')) { + ZEND_HASH_FOREACH_KEY_VAL_IND(ht, num, key, val) { + dump_hash_elem_va(val, num, key, name, html, str); + } ZEND_HASH_FOREACH_END(); + } else if (ht && (z = zend_hash_find(ht, s))) { + dump_hash_elem(z, name, 0, elem->ptr, html, str); + } else if (XINI_DEV(dump_undefined)) { + dump_hash_elem(NULL, name, 0, elem->ptr, html, str); + } + + elem = XDEBUG_LLIST_NEXT(elem); + + zend_string_release(s); + } +} + +char* xdebug_get_printable_superglobals(int html) +{ + xdebug_str str = XDEBUG_STR_INITIALIZER; + + dump_hash(&XG_DEV(server), "_SERVER", HASH_KEY_SIZEOF("_SERVER"), html, &str); + dump_hash(&XG_DEV(get), "_GET", HASH_KEY_SIZEOF("_GET"), html, &str); + dump_hash(&XG_DEV(post), "_POST", HASH_KEY_SIZEOF("_POST"), html, &str); + dump_hash(&XG_DEV(cookie), "_COOKIE", HASH_KEY_SIZEOF("_COOKIE"), html, &str); + dump_hash(&XG_DEV(files), "_FILES", HASH_KEY_SIZEOF("_FILES"), html, &str); + dump_hash(&XG_DEV(env), "_ENV", HASH_KEY_SIZEOF("_ENV"), html, &str); + dump_hash(&XG_DEV(session), "_SESSION", HASH_KEY_SIZEOF("_SESSION"), html, &str); + dump_hash(&XG_DEV(request), "_REQUEST", HASH_KEY_SIZEOF("_REQUEST"), html, &str); + + return str.d; +} + +void xdebug_superglobals_dump_tok(xdebug_llist *l, char *str) +{ + char *tok; + const char *sep = ","; + + tok = strtok(str, sep); + while (tok != NULL) { + char *p = tok + strlen(tok) - 1; + + while ((*tok == ' ') || (*tok == '\t')) { + tok++; + } + + while ((p > tok) && ((*p == ' ') || (*p == '\t'))) { + p--; + } + + *(p+1) = 0; + + /* we need to strdup each element so that we can safely free it */ + xdebug_llist_insert_next(l, NULL, strdup(tok)); + + tok = strtok(NULL, sep); + } +} + +PHP_FUNCTION(xdebug_dump_superglobals) +{ + int html = PG(html_errors); + char *superglobal_info = NULL; + + if (html) { + php_printf("<table class='xdebug-superglobals' dir='ltr' border='1' cellspacing='0'>\n"); + } + + superglobal_info = xdebug_get_printable_superglobals(html);
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/develop/superglobals.h
Changed
(renamed from xdebug-3.3.2/src/develop/superglobals.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/gcstats/gc_stats.c
Changed
(renamed from xdebug-3.3.2/src/gcstats/gc_stats.c)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/gcstats/gc_stats.h
Changed
(renamed from xdebug-3.3.2/src/gcstats/gc_stats.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/gcstats/gc_stats_private.h
Changed
(renamed from xdebug-3.3.2/src/gcstats/gc_stats_private.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/cmd_parser.c
Changed
(renamed from xdebug-3.3.2/src/lib/cmd_parser.c)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/cmd_parser.h
Changed
(renamed from xdebug-3.3.2/src/lib/cmd_parser.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/compat.c
Changed
(renamed from xdebug-3.3.2/src/lib/compat.c)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/compat.h
Added
@@ -0,0 +1,84 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2022 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#ifndef __HAVE_XDEBUG_COMPAT_H__ +#define __HAVE_XDEBUG_COMPAT_H__ + +#include "lib/php-header.h" +#include "str.h" + +#include "ext/standard/head.h" +#include "ext/standard/php_var.h" +#define xdebug_php_var_dump php_var_dump + +char *xdebug_str_to_str(char *haystack, size_t length, const char *needle, size_t needle_len, const char *str, size_t str_len, size_t *new_len); + +unsigned char *xdebug_base64_encode(unsigned char *data, size_t data_len, size_t *new_len); +unsigned char *xdebug_base64_decode(unsigned char *data, size_t data_len, size_t *new_len); + +zend_string *xdebug_addslashes(zend_string *str); +void xdebug_stripcslashes(char *string, int *new_len); + +zend_ulong xdebug_get_pid(void); + +void xdebug_setcookie(const char *name, int name_len, char *value, int value_len, time_t expires, const char *path, int path_len, const char *domain, int domain_len, int secure, int url_encode, int httponly); +char *xdebug_get_compiled_variable_name(zend_op_array *op_array, uint32_t var, int *cv_len); + +/* Recursion protection is done differently from PHP 7.3 onwards */ +zend_bool xdebug_zend_hash_is_recursive(HashTable* ht); +zend_bool xdebug_zend_hash_apply_protection_begin(HashTable* ht); +zend_bool xdebug_zend_hash_apply_protection_end(HashTable* ht); + +#ifndef ZSTR_INIT_LITERAL +# define ZSTR_INIT_LITERAL(s, persistent) (zend_string_init((s), strlen(s), (persistent))) +#endif + +# define XDEBUG_MAKE_STD_ZVAL(zv) \ + zv = ecalloc(1, sizeof(zval)); + +# define HASH_KEY_SIZEOF(k) (sizeof(k) - 1) +# define HASH_KEY_STRLEN(k) (strlen(k)) +# define HASH_KEY_IS_NUMERIC(k) ((k) == NULL) +# define HASH_APPLY_KEY_VAL(k) (k)->val +# define HASH_APPLY_KEY_LEN(k) (k)->len + 1 + +# define STR_NAME_VAL(k) (k)->val +# define STR_NAME_LEN(k) (k)->len + +# if defined (__GNUC__) +# define XDEBUG_GNUC_CHECK_VERSION(major, minor) \ + ((__GNUC__ > (major)) || \ + ((__GNUC__ == (major)) && (__GNUC_MINOR__ >= (minor)))) +# else +# define XDEBUG_GNUC_CHECK_VERSION(major, minor) 0 +# endif + +# if XDEBUG_GNUC_CHECK_VERSION(7, 0) +# define XDEBUG_BREAK_INTENTIONALLY_MISSING __attribute__ ((fallthrough)); +# else +# define XDEBUG_BREAK_INTENTIONALLY_MISSING +# endif + +# if XDEBUG_GNUC_CHECK_VERSION(2, 7) || __has_attribute(format) +# define XDEBUG_ATTRIBUTE_FORMAT(type, idx, first) __attribute__ ((format(type, idx, first))) +# else +# define XDEBUG_ATTRIBUTE_FORMAT(type, idx, first) +# endif + +#define XDEBUG_OPCODE_HANDLER_ARGS zend_execute_data *execute_data +#define XDEBUG_OPCODE_HANDLER_ARGS_PASSTHRU execute_data + +#endif
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/crc32.c
Changed
(renamed from xdebug-3.3.2/src/lib/crc32.c)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/crc32.h
Changed
(renamed from xdebug-3.3.2/src/lib/crc32.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/file.c
Changed
(renamed from xdebug-3.3.2/src/lib/file.c)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/file.h
Changed
(renamed from xdebug-3.3.2/src/lib/file.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/hash.c
Changed
(renamed from xdebug-3.3.2/src/lib/hash.c)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/hash.h
Changed
(renamed from xdebug-3.3.2/src/lib/hash.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/headers.c
Changed
(renamed from xdebug-3.3.2/src/lib/headers.c)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/headers.h
Changed
(renamed from xdebug-3.3.2/src/lib/headers.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/lib.c
Added
@@ -0,0 +1,882 @@ +/* + +----------------------------------------------------------------------+ + | 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
Added
@@ -0,0 +1,329 @@ +/* + +----------------------------------------------------------------------+ + | 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/lib_private.h
Changed
(renamed from xdebug-3.3.2/src/lib/lib_private.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/llist.c
Changed
(renamed from xdebug-3.3.2/src/lib/llist.c)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/llist.h
Changed
(renamed from xdebug-3.3.2/src/lib/llist.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/log.c
Added
@@ -0,0 +1,946 @@ +/* + +----------------------------------------------------------------------+ + | 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
Changed
(renamed from xdebug-3.3.2/src/lib/log.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/mm.h
Changed
(renamed from xdebug-3.3.2/src/lib/mm.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/php-header.h
Changed
(renamed from xdebug-3.3.2/src/lib/php-header.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/set.c
Changed
(renamed from xdebug-3.3.2/src/lib/set.c)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/set.h
Changed
(renamed from xdebug-3.3.2/src/lib/set.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/str.c
Added
@@ -0,0 +1,265 @@ +/* + +----------------------------------------------------------------------+ + | 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
Changed
(renamed from xdebug-3.3.2/src/lib/str.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/timing.c
Added
@@ -0,0 +1,254 @@ +/* + +----------------------------------------------------------------------+ + | 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" + +#if PHP_WIN32 +# include "win32/time.h" +# include <versionhelpers.h> +#else +# include <sys/time.h> +#endif + +#if HAVE_XDEBUG_CLOCK_GETTIME_NSEC_NP +# if defined(__APPLE) +# include <mach/mach_time.h> +# endif +#endif + +#include "timing.h" + +#define NANOTIME_MIN_STEP 10 + +#if PHP_WIN32 +# define WIN_NANOS_IN_TICK 100 +# define WIN_TICKS_SINCE_1601_JAN_1 116444736000000000ULL +#endif + +ZEND_EXTERN_MODULE_GLOBALS(xdebug) + +static uint64_t xdebug_get_nanotime_abs(xdebug_nanotime_context *nanotime_context) +{ +#if PHP_WIN32 + // Windows, win_precise_time_func is only available on Win 8 and later. + { + FILETIME filetime; + + if (nanotime_context->win_precise_time_func != NULL) { + nanotime_context->win_precise_time_func(&filetime); + return ((((uint64_t)filetime.dwHighDateTime << 32) + (uint64_t)filetime.dwLowDateTime) - WIN_TICKS_SINCE_1601_JAN_1) + * WIN_NANOS_IN_TICK; + } + } +#endif + +#if HAVE_GETTIMEOFDAY | PHP_WIN32 + // Fallback to gettimeofday() if better platform specific time is not + // available. gettimeofday() is always available in PHP on Windows, as it's + // expose through 'win32/time.ch' + { + struct timeval tp; + + if (gettimeofday(&tp, NULL) == 0) { + return (uint64_t)tp.tv_sec * NANOS_IN_SEC + (uint64_t)tp.tv_usec * NANOS_IN_MICROSEC; + } + } +#endif + + // We give up + php_error(E_WARNING, "Xdebug could not determine a suitable clock source on your system"); + return 0; +} + +#if PHP_WIN32 +static uint64_t xdebug_counter_and_freq_to_nanotime(uint64_t counter, uint64_t freq) +{ + uint32_t mul = 1, freq32; + uint64_t q, r; + + while (freq >= (1ULL << 32)) { + freq /= 2; + mul *= 2; + } + freq32 = (uint32_t)freq; + + q = counter / freq32; + r = counter % freq32; + return (q * NANOS_IN_SEC + (r * NANOS_IN_SEC) / freq32) * mul; +} +#endif + + +// Windows 7 and lower +#if PHP_WIN32 +static uint64_t xdebug_get_nanotime_rel(xdebug_nanotime_context *nanotime_context) +{ + LARGE_INTEGER tcounter; + + if (nanotime_context->win_precise_time_func == NULL) { + QueryPerformanceCounter(&tcounter); + return xdebug_counter_and_freq_to_nanotime((uint64_t)tcounter.QuadPart, nanotime_context->win_freq); + } +} + +// Mac +// should be fast but can be relative +#elif HAVE_XDEBUG_CLOCK_GETTIME_NSEC_NP +static uint64_t xdebug_get_nanotime_rel(xdebug_nanotime_context *nanotime_context) +{ + return clock_gettime_nsec_np(CLOCK_UPTIME_RAW); +} + +// Linux/Unix with clock_gettime +#elif HAVE_XDEBUG_CLOCK_GETTIME +static uint64_t xdebug_get_nanotime_rel(xdebug_nanotime_context *nanotime_context) +{ + struct timespec ts; + + if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) { + return (uint64_t)ts.tv_sec * NANOS_IN_SEC + (uint64_t)ts.tv_nsec; + } + + return 0; +} + +# ifdef __linux__ +bool detect_linux_working_tsc_clock(void) +{ + FILE *current_clocksource; + char contents64; + + current_clocksource = fopen("/sys/devices/system/clocksource/clocksource0/current_clocksource", "r"); + if (!current_clocksource) { + /* Inconclusive, assume working clock */ + return true; + } + + if (!fgets(contents, sizeof(contents), current_clocksource)) { + /* Can't read any clock source */ + fclose(current_clocksource); + return false; + } + + if (strcmp(contents, "tsc\n") != 0) { + /* Current clock is not 'tsc' (+ newline) */ + fclose(current_clocksource); + return false; + } + + fclose(current_clocksource); + return true; +} +# endif +#endif + +void xdebug_nanotime_init(xdebug_base_globals_t *base) +{ + xdebug_nanotime_context context = {0}; + + base->working_tsc_clock = -1; + +#if PHP_WIN32 + LARGE_INTEGER tcounter; + + if (IsWindows8OrGreater()) { + context.win_precise_time_func = (WIN_PRECISE_TIME_FUNC)GetProcAddress( + GetModuleHandle(TEXT("kernel32.dll")), + "GetSystemTimePreciseAsFileTime" + ); + } else { + context.win_precise_time_func = NULL; + QueryPerformanceFrequency(&tcounter); + context.win_freq = (uint64_t)tcounter.QuadPart; + context.use_rel_time = 1; + } + +#elif HAVE_XDEBUG_CLOCK_GETTIME | HAVE_XDEBUG_CLOCK_GETTIME_NSEC_NP + context.use_rel_time = 1; +#endif + + context.start_abs = xdebug_get_nanotime_abs(&context); + context.last_abs = 0; +#if PHP_WIN32 | HAVE_XDEBUG_CLOCK_GETTIME | HAVE_XDEBUG_CLOCK_GETTIME_NSEC_NP + context.start_rel = xdebug_get_nanotime_rel(&context); + context.last_rel = 0; +#endif + +#ifdef __linux__ +# if HAVE_XDEBUG_CLOCK_GETTIME + /* Detect if we have a 'broken' tsc clock on Linux for clock_gettime */ + base->working_tsc_clock = detect_linux_working_tsc_clock(); +# endif +#endif + + base->nanotime_context = context; +} +
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/timing.h
Changed
(renamed from xdebug-3.3.2/src/lib/timing.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/usefulstuff.c
Added
@@ -0,0 +1,729 @@ +/* + +----------------------------------------------------------------------+ + | 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
Changed
(renamed from xdebug-3.3.2/src/lib/usefulstuff.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/var.c
Added
@@ -0,0 +1,1218 @@ +/* + +----------------------------------------------------------------------+ + | 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.h
Added
@@ -0,0 +1,90 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2023 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#include "lib/php-header.h" +#include "php_xdebug.h" + +#include "lib/compat.h" +#include "lib/lib.h" +#include "lib/str.h" +#include "lib/xml.h" + +#ifndef __HAVE_XDEBUG_VAR_H__ +#define __HAVE_XDEBUG_VAR_H__ + +/* Set correct int format to use */ +#include "Zend/zend_long.h" +#if SIZEOF_ZEND_LONG == 4 +# define XDEBUG_INT_FMT "%ld" +#else +# define XDEBUG_INT_FMT "%lld" +#endif + +typedef struct +{ + int page; /* The number of the page to retrieve */ + int current_element_nr; + int start_element_nr; + int end_element_nr; +} xdebug_var_runtime_page; + +typedef struct xdebug_var_export_options { + int max_children; + int max_data; + int max_depth; + int show_hidden; + int extended_properties; /* Whether the feature is enabled */ + int encode_as_extended_property; /* Whether the current node's elements need to be encoded */ + int show_location; + xdebug_var_runtime_page *runtime; + int no_decoration; +} xdebug_var_export_options; + +#define XDEBUG_VAR_TYPE_NORMAL 0x00 +#define XDEBUG_VAR_TYPE_STATIC 0x01 +#define XDEBUG_VAR_TYPE_CONSTANT 0x02 + +void xdebug_get_php_symbol(zval *retval, xdebug_str* name); + +xdebug_var_export_options* xdebug_var_export_options_from_ini(void); +xdebug_var_export_options* xdebug_var_get_nolimit_options(void); + +xdebug_str* xdebug_get_property_type(zval* object, zval *val); +xdebug_str* xdebug_get_property_info(char *mangled_property, int mangled_len, const char **modifier, char **class_name); + +#define XDEBUG_VAR_OBJDEBUG_DEFAULT 0x00 +#define XDEBUG_VAR_OBJDEBUG_USE_DEBUGINFO 0x01 +HashTable *xdebug_objdebug_pp(zval **zval_pp, int flags); + + +#define XDEBUG_VAR_ATTR_TEXT 0 +#define XDEBUG_VAR_ATTR_HTML 1 +void xdebug_add_variable_attributes(xdebug_str *str, zval *struc, zend_bool fancy); + + +char* xdebug_xmlize(char *s_string, size_t len, size_t *newlen); +char* xdebug_error_type_simple(int type); +char* xdebug_error_type(int type); +zval *xdebug_get_zval(zend_execute_data *zdata, int node_type, const znode_op *node); +zval *xdebug_get_zval_with_opline(zend_execute_data *zdata, const zend_op *opline, int node_type, const znode_op *node); + +#define XDEBUG_SHOW_FNAME_DEFAULT 0 +#define XDEBUG_SHOW_FNAME_ALLOW_HTML 1<<1 +#define XDEBUG_SHOW_FNAME_IGNORE_SCOPE 1<<2 +#define XDEBUG_SHOW_FNAME_ADD_FILE_NAME 1<<3 +char* xdebug_show_fname(xdebug_func t, int flags); + +#endif
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/var_export_html.c
Added
@@ -0,0 +1,462 @@ +/* + +----------------------------------------------------------------------+ + | 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 "var_export_html.h" +#include "lib_private.h" +#include "Zend/zend_closures.h" +#if PHP_VERSION_ID >= 80100 +# include "zend_enum.h" +#endif + +ZEND_EXTERN_MODULE_GLOBALS(xdebug) + +/***************************************************************************** +** Fancy variable printing routines +*/ + +#define COLOR_POINTER "#888a85" +#define COLOR_BOOL "#75507b" +#define COLOR_LONG "#4e9a06" +#define COLOR_NULL "#3465a4" +#define COLOR_DOUBLE "#f57900" +#define COLOR_STRING "#cc0000" +#define COLOR_EMPTY "#888a85" +#define COLOR_ARRAY "#ce5c00" +#define COLOR_OBJECT "#8f5902" +#define COLOR_RESOURCE "#2e3436" + +static int xdebug_array_element_export_html(zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, xdebug_str *str, int debug_zval, xdebug_var_export_options *options) +{ + zval **zv = &zv_nptr; + size_t newlen; + char *tmp_str; + + if (options->runtimelevel.current_element_nr >= options->runtimelevel.start_element_nr && + options->runtimelevel.current_element_nr < options->runtimelevel.end_element_nr) + { + xdebug_str_add_fmt(str, "%*s", (level * 4) - 2, ""); + + if (HASH_KEY_IS_NUMERIC(hash_key)) { /* numeric key */ + xdebug_str_add_fmt(str, XDEBUG_INT_FMT " <font color='%s'>=></font> ", index_key, COLOR_POINTER); + } else { /* string key */ + xdebug_str_addc(str, '\''); + tmp_str = xdebug_xmlize((char*) HASH_APPLY_KEY_VAL(hash_key), HASH_APPLY_KEY_LEN(hash_key) - 1, &newlen); + xdebug_str_addl(str, tmp_str, newlen, 0); + efree(tmp_str); + xdebug_str_add_fmt(str, "' <font color='%s'>=></font> ", COLOR_POINTER); + } + xdebug_var_export_html(zv, str, level + 1, debug_zval, options); + } + if (options->runtimelevel.current_element_nr == options->runtimelevel.end_element_nr) { + xdebug_str_add_fmt(str, "%*s", (level * 4) - 2, ""); + xdebug_str_add_literal(str, "<i>more elements...</i>\n"); + } + options->runtimelevel.current_element_nr++; + return 0; +} + +static int xdebug_object_element_export_html(zval *object, zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, xdebug_str *str, int debug_zval, xdebug_var_export_options *options, char *class_name) +{ + zval **zv = &zv_nptr; + + if (options->runtimelevel.current_element_nr >= options->runtimelevel.start_element_nr && + options->runtimelevel.current_element_nr < options->runtimelevel.end_element_nr) + { + xdebug_str_add_fmt(str, "%*s", (level * 4) - 2, ""); + + if (!HASH_KEY_IS_NUMERIC(hash_key)) { + char *prop_class_name; + xdebug_str *property_name; + xdebug_str *property_type = NULL; + const char *modifier; + + property_type = xdebug_get_property_type(object, zv_nptr); + property_name = xdebug_get_property_info((char*) HASH_APPLY_KEY_VAL(hash_key), HASH_APPLY_KEY_LEN(hash_key), &modifier, &prop_class_name); + + xdebug_str_add_fmt(str, "<i>%s</i> ", modifier); + if (property_type) { + xdebug_str_add_fmt(str, "<i>%s</i> ", property_type->d); + } + xdebug_str_addc(str, '\''); + xdebug_str_add_str(str, property_name); + if (strcmp(modifier, "private") != 0 || strcmp(class_name, prop_class_name) == 0) { + xdebug_str_add_fmt(str, "' <font color='%s'>=></font> ", COLOR_POINTER); + } else { + xdebug_str_add_fmt(str, "' <small>(%s)</small> <font color='%s'>=></font> ", prop_class_name, COLOR_POINTER); + } + + if (property_type) { + xdebug_str_free(property_type); + } + xdebug_str_free(property_name); + xdfree(prop_class_name); + } else { + xdebug_str_add_fmt(str, "<i>public</i> " XDEBUG_INT_FMT " <font color='%s'>=></font> ", index_key, COLOR_POINTER); + } + xdebug_var_export_html(zv, str, level + 1, debug_zval, options); + } + if (options->runtimelevel.current_element_nr == options->runtimelevel.end_element_nr) { + xdebug_str_add_fmt(str, "%*s", (level * 4) - 2, ""); + xdebug_str_add_literal(str, "<i>more elements...</i>\n"); + } + options->runtimelevel.current_element_nr++; + return 0; +} + +static void handle_closure(xdebug_str *str, zval *obj, int level) +{ + const zend_function *closure_function; + + if (Z_TYPE_P(obj) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(obj), zend_ce_closure)) { + return; + } + + closure_function = zend_get_closure_method_def(Z_OBJ_P(obj)); + + xdebug_str_add_fmt(str, "%*s<i>virtual</i> 'closure' <font color='%s'>'", (level * 4) - 2, "", COLOR_STRING); + + if (closure_function->common.scope) { + if (closure_function->common.fn_flags & ZEND_ACC_STATIC) { + xdebug_str_add_zstr(str, closure_function->common.scope->name); + xdebug_str_add_literal(str, "::"); + } else { + xdebug_str_add_literal(str, "$this->"); + } + } + xdebug_str_add_zstr(str, closure_function->common.function_name); + + xdebug_str_add_literal(str, "'</font>\n"); +} + + +void xdebug_var_export_html(zval **struc, xdebug_str *str, int level, int debug_zval, xdebug_var_export_options *options) +{ + HashTable *myht; + char* tmp_str; + size_t newlen; + zend_ulong num; + zend_string *key; + zval *val; + zval *tmpz; + int z_type; + + z_type = Z_TYPE_P(*struc); + + if (debug_zval) { + xdebug_add_variable_attributes(str, *struc, XDEBUG_VAR_ATTR_HTML); + } + if (z_type == IS_INDIRECT) { + tmpz = Z_INDIRECT_P(*struc); + struc = &tmpz; + z_type = Z_TYPE_P(*struc); + } + if (z_type == IS_REFERENCE) { + tmpz = &((*struc)->value.ref->val); + struc = &tmpz; + z_type = Z_TYPE_P(*struc); + } + + switch (z_type) { + case IS_TRUE: + xdebug_str_add_fmt(str, "<small>boolean</small> <font color='%s'>true</font>", COLOR_BOOL); + break; + + case IS_FALSE: + xdebug_str_add_fmt(str, "<small>boolean</small> <font color='%s'>false</font>", COLOR_BOOL); + break; + + case IS_NULL: + xdebug_str_add_fmt(str, "<font color='%s'>null</font>", COLOR_NULL); + break; + + case IS_LONG: + xdebug_str_add_fmt(str, "<small>int</small> <font color='%s'>" XDEBUG_INT_FMT "</font>", COLOR_LONG, Z_LVAL_P(*struc)); + break; + + case IS_DOUBLE: + xdebug_str_add_fmt(str, "<small>float</small> <font color='%s'>%.*H</font>", COLOR_DOUBLE, (int) PG(serialize_precision), Z_DVAL_P(*struc)); + break; + + case IS_STRING: + xdebug_str_add_fmt(str, "<small>string</small> <font color='%s'>'", COLOR_STRING); + if ((size_t) Z_STRLEN_P(*struc) > (size_t) options->max_data) { + tmp_str = xdebug_xmlize(Z_STRVAL_P(*struc), options->max_data, &newlen); + xdebug_str_addl(str, tmp_str, newlen, 0); + efree(tmp_str); + xdebug_str_add_literal(str, "'...</font>");
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/var_export_html.h
Changed
(renamed from xdebug-3.3.2/src/lib/var_export_html.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/var_export_line.c
Added
@@ -0,0 +1,445 @@ +/* + +----------------------------------------------------------------------+ + | 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_line.h
Changed
(renamed from xdebug-3.3.2/src/lib/var_export_line.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/var_export_text.c
Added
@@ -0,0 +1,505 @@ +/* + +----------------------------------------------------------------------+ + | 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 "php_xdebug.h" + +#include "var_export_text.h" + +static void xdebug_var_export_text_ansi(zval **struc, xdebug_str *str, int mode, int level, int debug_zval, xdebug_var_export_options *options); +#define xdebug_var_export_text(struc, str, level, debug_zval, options) xdebug_var_export_text_ansi(struc, str, 0, level, debug_zval, options); +#define xdebug_var_export_ansi(struc, str, level, debug_zval, options) xdebug_var_export_text_ansi(struc, str, 1, level, debug_zval, options); + +ZEND_EXTERN_MODULE_GLOBALS(xdebug) + + +/***************************************************************************** +** Plain text/ANSI coloured variable printing routines +*/ + +#define ANSI_COLOR_POINTER (mode == 1 ? "0m" : "") +#define ANSI_COLOR_BOOL (mode == 1 ? "35m" : "") +#define ANSI_COLOR_LONG (mode == 1 ? "32m" : "") +#define ANSI_COLOR_NULL (mode == 1 ? "34m" : "") +#define ANSI_COLOR_DOUBLE (mode == 1 ? "33m" : "") +#define ANSI_COLOR_STRING (mode == 1 ? "31m" : "") +#define ANSI_COLOR_EMPTY (mode == 1 ? "30m" : "") +#define ANSI_COLOR_ARRAY (mode == 1 ? "33m" : "") +#define ANSI_COLOR_OBJECT (mode == 1 ? "31m" : "") +#define ANSI_COLOR_RESOURCE (mode == 1 ? "36m" : "") +#define ANSI_COLOR_MODIFIER (mode == 1 ? "32m" : "") +#define ANSI_COLOR_RESET (mode == 1 ? "0m" : "") +#define ANSI_COLOR_BOLD (mode == 1 ? "1m" : "") +#define ANSI_COLOR_BOLD_OFF (mode == 1 ? "22m" : "") + +static int xdebug_array_element_export_text_ansi(zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, int mode, xdebug_str *str, int debug_zval, xdebug_var_export_options *options) +{ + zval **zv = &zv_nptr; + + if (options->runtimelevel.current_element_nr >= options->runtimelevel.start_element_nr && + options->runtimelevel.current_element_nr < options->runtimelevel.end_element_nr) + { + xdebug_str_add_fmt(str, "%*s", (level * 2), ""); + + if (HASH_KEY_IS_NUMERIC(hash_key)) { /* numeric key */ + xdebug_str_add_fmt(str, "" XDEBUG_INT_FMT " %s=>%s\n", index_key, ANSI_COLOR_POINTER, ANSI_COLOR_RESET); + } else { /* string key */ + zend_string *tmp, *tmp2; + + tmp = php_str_to_str(ZSTR_VAL(hash_key), ZSTR_LEN(hash_key), (char*) "'", 1, (char*) "\\'", 2); + tmp2 = php_str_to_str(ZSTR_VAL(tmp), ZSTR_LEN(tmp), (char*) "\0", 1, (char*) "\\0", 2); + if (tmp) { + zend_string_release(tmp); + } + xdebug_str_addc(str, '\''); + if (tmp2) { + xdebug_str_add_zstr(str, tmp2); + zend_string_release(tmp2); + } + xdebug_str_add_literal(str, "' =>\n"); + } + xdebug_var_export_text_ansi(zv, str, mode, level + 1, debug_zval, options); + } + if (options->runtimelevel.current_element_nr == options->runtimelevel.end_element_nr) { + xdebug_str_add_fmt(str, "\n%*s(more elements)...\n", (level * 2), ""); + } + options->runtimelevel.current_element_nr++; + return 0; +} + +static int xdebug_object_element_export_text_ansi(zval *object, zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, int mode, xdebug_str *str, int debug_zval, xdebug_var_export_options *options) +{ + zval **zv = &zv_nptr; + + if (options->runtimelevel.current_element_nr >= options->runtimelevel.start_element_nr && + options->runtimelevel.current_element_nr < options->runtimelevel.end_element_nr) + { + xdebug_str_add_fmt(str, "%*s", (level * 2), ""); + + if (!HASH_KEY_IS_NUMERIC(hash_key)) { + char *class_name; + xdebug_str *property_name; + const char *modifier; + xdebug_str *property_type = NULL; + + property_type = xdebug_get_property_type(object, zv_nptr); + + property_name = xdebug_get_property_info((char*) HASH_APPLY_KEY_VAL(hash_key), HASH_APPLY_KEY_LEN(hash_key), &modifier, &class_name); + xdebug_str_add_fmt( + str, "%s%s%s%s%s%s%s $", + ANSI_COLOR_MODIFIER, ANSI_COLOR_BOLD, modifier, ANSI_COLOR_BOLD_OFF, property_type ? " " : "", property_type ? property_type->d : "", ANSI_COLOR_RESET + ); + xdebug_str_add_str(str, property_name); + xdebug_str_add_fmt(str, " %s=>%s\n", ANSI_COLOR_POINTER, ANSI_COLOR_RESET); + + if (property_type) { + xdebug_str_free(property_type); + } + xdebug_str_free(property_name); + xdfree(class_name); + } else { + xdebug_str_add_fmt(str, "%s%spublic%s%s ${" XDEBUG_INT_FMT "} %s=>%s\n", + ANSI_COLOR_MODIFIER, ANSI_COLOR_BOLD, ANSI_COLOR_BOLD_OFF, ANSI_COLOR_RESET, + index_key, ANSI_COLOR_POINTER, ANSI_COLOR_RESET + ); + } + xdebug_var_export_text_ansi(zv, str, mode, level + 1, debug_zval, options); + } + if (options->runtimelevel.current_element_nr == options->runtimelevel.end_element_nr) { + xdebug_str_add_fmt(str, "\n%*s(more elements)...\n", (level * 2), ""); + } + options->runtimelevel.current_element_nr++; + return 0; +} + +#if PHP_VERSION_ID < 80200 +static void handle_closure(xdebug_str *str, zval *obj, int level, int mode) +{ + const zend_function *closure_function; + + if (Z_TYPE_P(obj) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(obj), zend_ce_closure)) { + return; + } + + closure_function = zend_get_closure_method_def(Z_OBJ_P(obj)); + + xdebug_str_add_fmt( + str, "%*s%s%svirtual%s $closure =>\n%*s\"", + (level * 4) - 2, "", + ANSI_COLOR_MODIFIER, ANSI_COLOR_BOLD, ANSI_COLOR_RESET, + (level * 4) - 2, "" + ); + + if (closure_function->common.scope) { + if (closure_function->common.fn_flags & ZEND_ACC_STATIC) { + xdebug_str_add_fmt(str, "%s", ANSI_COLOR_OBJECT); + xdebug_str_add_zstr(str, closure_function->common.scope->name); + xdebug_str_add_fmt(str, "%s::", ANSI_COLOR_RESET); + } else { + xdebug_str_add_fmt(str, "%s$this%s->", ANSI_COLOR_OBJECT, ANSI_COLOR_RESET); + } + } + + xdebug_str_add_fmt(str, "%s", ANSI_COLOR_STRING); + xdebug_str_add_zstr(str, closure_function->common.function_name); + xdebug_str_add_fmt(str, "%s\"\n", ANSI_COLOR_RESET); +} +#endif + +static void xdebug_var_export_text_ansi(zval **struc, xdebug_str *str, int mode, int level, int debug_zval, xdebug_var_export_options *options) +{ + HashTable *myht; + char* tmp_str; + int tmp_len; + zend_ulong num; + zend_string *key; + zval *val; + zval *tmpz; + int z_type; + + if (!struc || !(*struc)) { + return; + } + + xdebug_str_add_fmt(str, "%*s", (level * 2) - 2, ""); + + z_type = Z_TYPE_P(*struc); + + if (debug_zval) { + xdebug_add_variable_attributes(str, *struc, XDEBUG_VAR_ATTR_TEXT); + } + if (z_type == IS_INDIRECT) { + tmpz = Z_INDIRECT_P(*struc); + struc = &tmpz; + z_type = Z_TYPE_P(*struc); + } + if (z_type == IS_REFERENCE) { + tmpz = &((*struc)->value.ref->val); + struc = &tmpz; + z_type = Z_TYPE_P(*struc);
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/var_export_text.h
Changed
(renamed from xdebug-3.3.2/src/lib/var_export_text.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/var_export_xml.c
Added
@@ -0,0 +1,874 @@ +/* + +----------------------------------------------------------------------+ + | 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/var_export_xml.h
Changed
(renamed from xdebug-3.3.2/src/lib/var_export_xml.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/vector.h
Changed
(renamed from xdebug-3.3.2/src/lib/vector.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/xml.c
Changed
(renamed from xdebug-3.3.2/src/lib/xml.c)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/lib/xml.h
Changed
(renamed from xdebug-3.3.2/src/lib/xml.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/profiler/profiler.c
Added
@@ -0,0 +1,566 @@ +/* + +----------------------------------------------------------------------+ + | 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/profiler/profiler.h
Added
@@ -0,0 +1,73 @@ +/* + +----------------------------------------------------------------------+ + | Xdebug | + +----------------------------------------------------------------------+ + | Copyright (c) 2002-2022 Derick Rethans | + +----------------------------------------------------------------------+ + | This source file is subject to version 1.01 of the Xdebug license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | https://xdebug.org/license.php | + | If you did not receive a copy of the Xdebug license and are unable | + | to obtain it through the world-wide-web, please send a note to | + | derick@xdebug.org so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ + +#ifndef __XDEBUG_PROFILER_H__ +#define __XDEBUG_PROFILER_H__ + +#include "lib/php-header.h" +#include "TSRM.h" +#include "lib/file.h" +#include "lib/lib.h" + +#include "php_xdebug.h" + +typedef struct _xdebug_profiler_globals_t { + zend_bool active; + uint64_t profiler_start_nanotime; + xdebug_file profile_file; + xdebug_hash *profile_filename_refs; + int profile_last_filename_ref; + int php_internal_seen_before; + xdebug_hash *profile_functionname_refs; + int profile_last_functionname_ref; +} xdebug_profiler_globals_t; + +typedef struct _xdebug_profiler_settings_t { + char *profiler_output_name; /* "pid" or "crc32" */ + zend_bool profiler_append; +} xdebug_profiler_settings_t; + +void xdebug_init_profiler_globals(xdebug_profiler_globals_t *xg); +void xdebug_profiler_minit(void); +void xdebug_profiler_mshutdown(void); +void xdebug_profiler_rinit(void); +void xdebug_profiler_post_deactivate(void); + +void xdebug_profiler_pcntl_exec_handler(void); +void xdebug_profiler_exit_function_handler(void); + +void xdebug_profiler_init_if_requested(zend_op_array *op_array); +void xdebug_profiler_execute_ex(function_stack_entry *fse, zend_op_array *op_array); +void xdebug_profiler_execute_ex_end(function_stack_entry *fse); +void xdebug_profiler_execute_internal(function_stack_entry *fse); +void xdebug_profiler_execute_internal_end(function_stack_entry *fse); + +void xdebug_profiler_init(char *script_name); +void xdebug_profiler_deinit(); + +void xdebug_profiler_add_function_details_user(function_stack_entry *fse, zend_op_array *op_array); +void xdebug_profiler_add_function_details_internal(function_stack_entry *fse); +void xdebug_profiler_free_function_details(function_stack_entry *fse); + +void xdebug_profiler_function_begin(function_stack_entry *fse); +void xdebug_profiler_function_end(function_stack_entry *fse); + +void xdebug_profile_call_entry_dtor(void *dummy, void *elem); + +char *xdebug_get_profiler_filename(void); + +PHP_FUNCTION(xdebug_get_profiler_filename); +#endif
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/profiler/profiler_private.h
Changed
(renamed from xdebug-3.3.2/src/profiler/profiler_private.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/tracing/trace_computerized.c
Changed
(renamed from xdebug-3.3.2/src/tracing/trace_computerized.c)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/tracing/trace_computerized.h
Changed
(renamed from xdebug-3.3.2/src/tracing/trace_computerized.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/tracing/trace_flamegraph.c
Changed
(renamed from xdebug-3.3.2/src/tracing/trace_flamegraph.c)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/tracing/trace_flamegraph.h
Changed
(renamed from xdebug-3.3.2/src/tracing/trace_flamegraph.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/tracing/trace_html.c
Changed
(renamed from xdebug-3.3.2/src/tracing/trace_html.c)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/tracing/trace_html.h
Changed
(renamed from xdebug-3.3.2/src/tracing/trace_html.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/tracing/trace_textual.c
Changed
(renamed from xdebug-3.3.2/src/tracing/trace_textual.c)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/tracing/trace_textual.h
Changed
(renamed from xdebug-3.3.2/src/tracing/trace_textual.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/tracing/tracing.c
Added
@@ -0,0 +1,782 @@ +/* + +----------------------------------------------------------------------+ + | 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
Changed
(renamed from xdebug-3.3.2/src/tracing/tracing.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/src/tracing/tracing_private.h
Changed
(renamed from xdebug-3.3.2/src/tracing/tracing_private.h)
View file
xdebug-3.4.3.tgz/xdebug-3.4.3/xdebug.c
Added
@@ -0,0 +1,859 @@ +/* + +----------------------------------------------------------------------+ + | 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
Added
@@ -0,0 +1,1277 @@ +; 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.
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
.