View Issue Details

IDProjectCategoryView StatusLast Update
0002405XdebugPath Mappingpublic2026-03-24 10:09
Reportermho22 Assigned Toderick  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.5.1 
Fixed in Version3.5dev 
Summary0002405: Handle minimum path in .xdebug directory discovery
Description

This is some kind of unusual behavior but I stumbled upon this lately in one of my use cases. This is why I wanted to suggest this pull request. It is mainly focused on the .xdebug directory discovery for path mappings/skippings. Long story short : It couldn't find my .xdebug directory located at the root of my environment.

Here is a more precise use case :

Based on these lines in src/lib/maps/maps.c > line 183 :

current_dir = parts->c > 2 ? xdebug_join(slash, parts, 0, parts->c - 2) : NULL;
parent_dir = parts->c > 3 ? xdebug_join(slash, parts, 0, parts->c - 3) : NULL;
grand_dir = parts->c > 4 ? xdebug_join(slash, parts, 0, parts->c - 4) : NULL;

If my current debugged file is /foo/bar/baz/qux/file.php, then :

file_path = "/foo/bar/baz/qux/file.php"

current_dir = "/foo/bar/baz/qux"
parent_dir = "/foo/bar/baz"
grand_dir = "/foo/bar"
Nice. Now :

If my current debugging directory is /foo/bar/file.php, then :

file_path = "/foo/bar/file.php"

current_dir = "/foo/bar"
parent_dir = "/foo"
grand_dir = (NULL)
While grand_dir should probably return "/" instead (or almost "").

My suggestion would be to simply replace > with >=.

Currently it gives this :

file_path = "/foo/bar/file.php"

current_dir = "/foo/bar"
parent_dir = "/foo"
grand_dir = (NULL)

[42] [Path Mapping] INFO: Scanning for map files with pattern '/foo/.xdebug/.map'
[42] [Path Mapping] DEBUG: No map files found with pattern '/foo/.xdebug/
.map'
[42] [Path Mapping] INFO: Scanning for map files with pattern '/foo/bar/.xdebug/.map'
[42] [Path Mapping] DEBUG: No map files found with pattern '/foo/bar/.xdebug/
.map'
[42] [Path Mapping] DEBUG: Found 0 path mapping rules

While with my suggestion :

file_path = "/foo/bar/file.php"

current_dir = "/foo/bar"
parent_dir = "/foo"
grand_dir = ""
[42] [Path Mapping] INFO: Scanning for map files with pattern '/.xdebug/.map'
[42] [Path Mapping] INFO: Reading mapping file '/.xdebug/paths.map'
[42] [Path Mapping] INFO: Scanning for map files with pattern '/foo/.xdebug/
.map'
[42] [Path Mapping] DEBUG: No map files found with pattern '/foo/.xdebug/.map'
[42] [Path Mapping] INFO: Scanning for map files with pattern '/foo/bar/.xdebug/
.map'
[42] [Path Mapping] DEBUG: No map files found with pattern '/foo/bar/.xdebug/*.map'
[42] [Path Mapping] DEBUG: Found 3 path mapping rules

What do you think?

TagsNo tags attached.
Operating SystemmacOS 26.3
PHP Version8.5.0-8.5.4

Activities

derick

2026-03-23 16:00

administrator   ~0007478

https://github.com/xdebug/xdebug/pull/1062

derick

2026-03-23 16:33

administrator   ~0007480

https://github.com/xdebug/xdebug/pull/1070

derick

2026-03-24 10:09

administrator   ~0007482

Merged for Xdebug 3.5.2 — thanks!

Issue History

Date Modified Username Field Change
2026-02-16 15:20 mho22 New Issue
2026-03-23 16:00 derick Note Added: 0007478
2026-03-23 16:33 derick Note Added: 0007480
2026-03-24 10:09 derick Assigned To => derick
2026-03-24 10:09 derick Status new => closed
2026-03-24 10:09 derick Resolution open => fixed
2026-03-24 10:09 derick Fixed in Version => 3.5dev
2026-03-24 10:09 derick Note Added: 0007482