GeezerVison is showing github.com — feat: compatibility stubs for stripped Xdebug functions by pronskiy · Pull Request #48 · php-debugger/php-debugger
Conversation
pronskiy
commented
Apr 14, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Adds 34 stub functions for all Xdebug features that were stripped in Phase 1 (profiler, coverage, tracing, gcstats, develop). Each stub emits E_DEPRECATED with a clear message and returns a safe default value.
Fixes #45
Why
Code that calls removed Xdebug functions (e.g. xdebug_get_profiler_filename(), xdebug_start_code_coverage()) currently gets a fatal "undefined function" error. These stubs provide a graceful migration path — the functions exist, warn that they are unavailable, and return harmless defaults.
Changes
- New:
src/lib/compat_stubs.c, src/lib/compat_stubs.h — 37 stub implementations
- Modified:
config.m4, config.w32 — add new source file to build
- Modified:
php_xdebug.stub.php, php_xdebug_arginfo.h — register stubs
- Modified:
xdebug.c — include compat stubs header
Each stub emits E_DEPRECATED and returns a safe default (false, [], 0, etc.).
Example
$ php -dzend_extension=php_debugger.so -r "var_dump(xdebug_get_profiler_filename());"
Deprecated: xdebug_get_profiler_filename() is not available in php-debugger...
bool(false)
Covered modules
- Profiler: xdebug_get_profiler_filename
- Coverage: xdebug_start_code_coverage, xdebug_stop_code_coverage, xdebug_get_code_coverage, etc.
- Tracing: xdebug_start_trace, xdebug_stop_trace, xdebug_get_tracefile_name, etc.
- GC Stats: xdebug_get_gcstats_filename, xdebug_start_gcstats, xdebug_stop_gcstats, etc.
- Develop: xdebug_var_dump, xdebug_debug_zval, xdebug_call_class, xdebug_get_headers, etc.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
FeBe95 reacted with hooray emoji
Adds fallback implementations for all Xdebug functions that were
removed when non-debugger modules were stripped. Each stub emits
E_DEPRECATED and returns a safe default value.
Fixes #45
- Remove Xdebug license headers from new files (compat_stubs.c/h)
- Use macros (COMPAT_STUB_RETURN_FALSE, COMPAT_STUB_VOID, etc.) to
eliminate boilerplate — 262 lines down from 448
- Remove xdebug_get_headers from stub.php: it's the sentinel function
used by is_stripped_debugger() in the test harness. Registering it
caused all tests with skip conditions to stop skipping, producing
false failures on CI.
- Regenerate php_xdebug_arginfo.h
- Add `compat_stubs.phpt` test to verify stubs emit `E_DEPRECATED` and return safe defaults.
- Adjust `xdebug_debug_zval` and `xdebug_debug_zval_stdout` parameters.
- Update `xdebug_print_function_stack`: use default message, suppress unused parameter warnings.
- Remove redundant `php_var_dump` call in `xdebug_var_dump` stub.
- Regenerate `php_xdebug_arginfo.h` after stub updates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
pronskiy
added a commit
that referenced
this pull request
May 3, 2026
Registers php_debugger_info as a ZEND_FALIAS of xdebug_info so the
php_debugger_* function namespace has at least one user-visible entry
point alongside the php_debugger.* INI namespace.
Updates the static-build smoke test to assert php_debugger_info()
exists, replacing a stale assertion for php_debugger_break() (an alias
that was removed when arginfo got regenerated in #48).
pronskiy
added a commit
that referenced
this pull request
May 3, 2026
* feat: static build support (--enable-php-debugger)
Add support for compiling php_debugger as a static extension into php-src
using ./configure --enable-php-debugger (without --enable-shared).
Changes:
- MINIT self-registration: in static builds, the Zend extension is registered
from PHP_MINIT_FUNCTION since zend_startup_extensions() has already run by
the time MINIT fires. Manually calls xdebug_library_zend_startup() and
xdebug_debugger_zend_startup() to replicate xdebug_zend_startup() logic.
- xdebug_zend_startup() early return: prevents double module registration
when zend_startup_extensions() calls it after MINIT already initialized.
- php_php_debugger.h: bridge header providing phpext_php_debugger_ptr for
PHP's static extension table (main/internal_functions.c).
- config.m4: add PHP_ADD_INCLUDE($ext_srcdir) for header discovery.
- Fix COMPILE_DL_XDEBUG -> COMPILE_DL_PHP_DEBUGGER in RINIT ZTS guard.
Benchmark (PHP 8.6.0-dev, bench.php):
Vanilla PHP: 0.573s (baseline)
Static php_debugger: 0.605s (~5.6% overhead, observer API floor)
* ci: add static build smoke test workflow
Dedicated CI job that builds PHP from source with --enable-php-debugger
and verifies the extension loads correctly as a static build.
Only triggers on changes to config.m4, php_php_debugger.h, xdebug.c,
or the workflow itself — does not slow down the main test suite.
Smoke tests:
- Module list (php_debugger + xdebug compat)
- Zend extension registration
- extension_loaded() for both names
- INI settings (both prefixes)
- Function existence (both aliases)
* fix(ci): copy m4 macros to php-src root for buildconf
config.m4 includes m4/pkg.m4 and m4/clocks.m4 which resolve relative
to the php-src root, not the extension directory.
* fix(ci): ensure php-src clone before m4 copy
Remove cache step (not worth complexity for a rarely-triggered workflow).
Always clone fresh — simpler and more reliable.
* fix(ci): ensure m4 directory exists before copying macros
* feat: add php_debugger_info() alias for xdebug_info()
Registers php_debugger_info as a ZEND_FALIAS of xdebug_info so the
php_debugger_* function namespace has at least one user-visible entry
point alongside the php_debugger.* INI namespace.
Updates the static-build smoke test to assert php_debugger_info()
exists, replacing a stale assertion for php_debugger_break() (an alias
that was removed when arginfo got regenerated in #48).
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|