View Issue Details

IDProjectCategoryView StatusLast Update
0002411XdebugPath Mappingpublic2026-03-24 16:59
Reporterclubdrei_chris Assigned Toderick  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformLinux (Docker)OSUbuntuOS Version24.04
Product Version3.5.1 
Fixed in Version3.5dev 
Summary0002411: Native Path Mapping is not applied to the initial fileuri in the init packet
Description

Expected behavior:
When Native Path Mapping is enabled, Xdebug should apply the configured mapping to the initial DBGp debug-init request,
so the IDE receives the mapped file URI in the <init> packet.

According to https://xdebug.org/docs/all_settings this also seems to be the expected behavior:
"The fileuri attribute lists the entry point of your application, which can be useful to compare to breakpoint_set commands to see if path mappings are set-up correctly."

Actual behavior:
Xdebug does not apply Native Path Mapping to the initial DBGp fileuri. It sends the unmapped path in the <init> packet.
All paths send after the <init> packet are correct / rewritten.

Steps To Reproduce

Step 1 - Relevant Xdebug settings:
xdebug.path_mapping=1
xdebug.log=/tmp/xdebug.log
xdebug.log_level=10

Step 2 - Map file (/workspace/.xdebug/project.map):
/workspace/ = /home/chris/project-path-on-host-machine/

Step 3 - PHP script (/workspace/public/index.php):
<?php
echo "Hello world";

Step 4 - Start a DBGp listener / IDE and trigger a debug request

Step 5 - Inspect the init packet in /tmp/xdebug.log

Additional Information
  • My host with PhpStorm as the Xdebug listener is running Ubuntu 24.04.
  • The PHP application runs in a docker rootless container. Ubuntu 24.04 is used as the base image.
  • The attachment contains a minimal patch for Xdebug which fixes the issue for me. This is just a PoC created by AI, I have no experience with C.
  • Thanks for your amazing work!

php -v:
PHP 8.5.3 (cli) (built: Feb 13 2026 16:01:19) (NTS)
Copyright (c) The PHP Group
Built by Debian
Zend Engine v4.5.3, Copyright (c) Zend Technologies
with Xdebug v3.5.1, Copyright (c) 2002-2026, by Derick Rethans
with Zend OPcache v8.5.3, Copyright (c), by Zend Technologies

TagsNo tags attached.
Attached Files
xdebug-init-path-mapping.patch (1,131 bytes)   
diff --git a/src/debugger/handler_dbgp.c b/src/debugger/handler_dbgp.c
index 4eec9f3..0d9b4f1 100644
--- a/src/debugger/handler_dbgp.c
+++ b/src/debugger/handler_dbgp.c
@@ -2582,7 +2582,16 @@ int xdebug_dbgp_init(xdebug_con *context, int mode)
 	if (zend_string_equals_literal(context->program_name, "-") || zend_string_equals_literal(context->program_name, "Command line code")) {
 		xdebug_xml_add_attribute_ex(response, "fileuri", xdstrdup("dbgp://stdin"), 0, 1);
 	} else {
-		xdebug_xml_add_attribute_ex(response, "fileuri", xdebug_zstr_path_to_url(context->program_name), 0, 1);
+		xdebug_str *local_path;
+		size_t      local_line;
+		bool        must_free_path = false;
+
+		xdebug_debugger_map_remote_to_local(context->program_name, 0, &local_path, &local_line, &must_free_path);
+		xdebug_xml_add_attribute_ex(response, "fileuri", xdebug_xdebug_str_path_to_url(local_path), 0, 1);
+
+		if (must_free_path) {
+			xdebug_str_free(local_path);
+		}
 	}
 	xdebug_xml_add_attribute_ex(response, "language", "PHP", 0, 0);
 	xdebug_xml_add_attribute_ex(response, "xdebug:language_version", XG_BASE(php_version_run_time), 0, 0);
xdebug-init-path-mapping.patch (1,131 bytes)   
xdebug.log (9,432 bytes)   
[5860] Log opened at 2026-03-21 11:23:40.008839
[5860] [Path Mapping] INFO: Scanning for map files with pattern '/workspace/.xdebug/*.map'
[5860] [Path Mapping] INFO: Reading mapping file '/workspace/.xdebug/project.map'
[5860] [Path Mapping] INFO: Scanning for map files with pattern '/workspace/public/.xdebug/*.map'
[5860] [Path Mapping] DEBUG: No map files found with pattern '/workspace/public/.xdebug/*.map'
[5860] [Path Mapping] DEBUG: Found 1 path mapping rules
[5860] [Path Mapping] DEBUG: Map directory '/workspace/' to '/home/chris/project-path-on-host-machine/'
[5860] [Path Mapping] DEBUG: Map directory '/workspace/' to '/home/chris/project-path-on-host-machine/'
[5860] [Config] INFO: Control socket set up successfully: '@xdebug-ctrl.5860'
[5860] [Config] DEBUG: Checking if trigger 'XDEBUG_TRIGGER' is enabled for mode 'debug'
[5860] [Config] INFO: Trigger value for 'XDEBUG_TRIGGER' not found, falling back to 'XDEBUG_SESSION'
[5860] [Config] INFO: No shared secret: Activating
[5860] [Step Debug] INFO: Connecting to configured address/port: unix:///xdebug/xdebug.sock:9003.
[5860] [Step Debug] INFO: Connected to debugging client: unix:///xdebug/xdebug.sock:9003 (through xdebug.client_host/xdebug.client_port).
[5860] [Step Debug] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///workspace/public/index.php" language="PHP" xdebug:language_version="8.5.3" protocol_version="1.0" appid="5860" idekey="YOUR-NAME" xdebug:ctrl_socket="xdebug-ctrl.5860"><engine version="3.5.1"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2026 by Derick Rethans]]></copyright></init>

[5860] [Step Debug] <- feature_set -i 1 -n show_hidden -v 1
[5860] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="show_hidden" success="1"></response>

[5860] [Step Debug] <- feature_set -i 2 -n max_depth -v 1
[5860] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_depth" success="1"></response>

[5860] [Step Debug] <- feature_set -i 3 -n max_children -v 100
[5860] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="3" feature="max_children" success="1"></response>

[5860] [Step Debug] <- feature_set -i 4 -n extended_properties -v 1
[5860] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="4" feature="extended_properties" success="1"></response>

[5860] [Step Debug] <- feature_set -i 5 -n notify_ok -v 1
[5860] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="5" feature="notify_ok" success="1"></response>

[5860] [Step Debug] <- feature_set -i 6 -n resolved_breakpoints -v 1
[5860] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="6" feature="resolved_breakpoints" success="1"></response>

[5860] [Step Debug] <- feature_set -i 7 -n breakpoint_include_return_value -v 1
[5860] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="7" feature="breakpoint_include_return_value" success="1"></response>

[5860] [Step Debug] <- stdout -i 8 -c 1
[5860] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stdout" transaction_id="8" success="1"></response>

[5860] [Step Debug] <- status -i 9
[5860] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="status" transaction_id="9" status="starting" reason="ok"></response>

[5860] [Step Debug] <- step_into -i 10
[5860] [Path Mapping] INFO: Mapping remote location /workspace/public/index.php:3
[5860] [Path Mapping] INFO: Mapped location /workspace/public/index.php:3 to /home/chris/project-path-on-host-machine/public/index.php:3
[5860] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="10" status="break" reason="ok"><xdebug:message filename="file:///home/chris/project-path-on-host-machine/public/index.php" lineno="3"></xdebug:message></response>

[5860] [Step Debug] <- eval -i 11 -- Z2V0ZW52KCdQSFBfSURFX0NPTkZJRycpIT1mYWxzZQ==
[5860] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="11"><property type="bool"><![CDATA[0]]></property></response>

[5860] [Step Debug] <- eval -i 12 -- aXNzZXQoJF9TRVJWRVJbJ1NFUlZFUl9OQU1FJ10p
[5860] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="12"><property type="bool"><![CDATA[1]]></property></response>

[5860] [Step Debug] <- eval -i 13 -- KHN0cmluZykoJF9TRVJWRVJbJ1NFUlZFUl9OQU1FJ10p
[5860] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="13"><property type="string" size="43" encoding="base64">---REMOVED_SERVER_INFORMATION---</property></response>

[5860] [Step Debug] <- eval -i 14 -- KHN0cmluZykoJF9TRVJWRVJbJ1NFUlZFUl9QT1JUJ10p
[5860] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="14"><property type="string" size="3" encoding="base64"><![CDATA[NDQz]]></property></response>

[5860] [Step Debug] <- eval -i 15 -- KHN0cmluZykoJF9TRVJWRVJbJ1JFUVVFU1RfVVJJJ10p
[5860] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="15"><property type="string" size="1" encoding="base64"><![CDATA[Lw==]]></property></response>

[5860] [Step Debug] <- breakpoint_set -i 16 -t call -m TYPO3\CMS\Seo\XmlSitemap\XmlSitemapRenderer::render
[5860] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="16" id="58600001" resolved="resolved"></response>

[5860] [Step Debug] <- stack_get -i 17
[5860] [Path Mapping] INFO: Mapping remote location /workspace/public/index.php:3
[5860] [Path Mapping] INFO: Mapped location /workspace/public/index.php:3 to /home/chris/project-path-on-host-machine/public/index.php:3
[5860] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="17"><stack where="{main}" level="0" xdebug:facet="mapped" type="file" filename="file:///home/chris/project-path-on-host-machine/public/index.php" lineno="3"></stack></response>

[5860] [Step Debug] <- stack_get -i 18
[5860] [Path Mapping] INFO: Mapping remote location /workspace/public/index.php:3
[5860] [Path Mapping] INFO: Mapped location /workspace/public/index.php:3 to /home/chris/project-path-on-host-machine/public/index.php:3
[5860] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="18"><stack where="{main}" level="0" xdebug:facet="mapped" type="file" filename="file:///home/chris/project-path-on-host-machine/public/index.php" lineno="3"></stack></response>

[5860] [Step Debug] <- context_names -i 19
[5860] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_names" transaction_id="19"><context name="Locals" id="0"></context><context name="Superglobals" id="1"></context><context name="User defined constants" id="2"></context></response>

[5860] [Step Debug] <- context_get -i 20 -d 0 -c 0
[5860] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="20" context="0"></response>

[5860] [Step Debug] <- context_get -i 21 -d 0 -c 1
[5860] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="21" context="1">---REMOVED_SERVER_INFORMATION---</response>

[5860] [Step Debug] <- run -i 22
[5860] [Path Mapping] INFO: Mapping remote location /workspace/public/index.php:0
[5860] [Path Mapping] INFO: Mapped location /workspace/public/index.php:0 to /home/chris/project-path-on-host-machine/public/index.php:0
[5860] [Step Debug] -> <stream xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" type="stdout" encoding="base64"><![CDATA[SGVsbG8gd29ybGQgLSBpbmRleC5waHA=]]></stream>

[5860] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="22" status="stopping" reason="ok"></response>

[5860] [Step Debug] <- detach -i 23
[5860] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="detach" transaction_id="23" status="stopping" reason="ok"></response>

[5860] Log closed at 2026-03-21 11:23:44.218746
xdebug.log (9,432 bytes)   
Operating SystemUbuntu 24.04
PHP Version8.5.0-8.5.4

Activities

Issue History

Date Modified Username Field Change
2026-03-21 11:33 clubdrei_chris New Issue
2026-03-21 11:33 clubdrei_chris File Added: xdebug-init-path-mapping.patch
2026-03-21 11:33 clubdrei_chris File Added: xdebug.log
2026-03-24 16:59 derick Assigned To => derick
2026-03-24 16:59 derick Status new => closed
2026-03-24 16:59 derick Resolution open => fixed
2026-03-24 16:59 derick Fixed in Version => 3.5dev
2026-03-24 16:59 derick Note Added: 0007483