View Issue Details

IDProjectCategoryView StatusLast Update
0002405XdebugPath Mappingpublic2026-02-16 15:20
Reportermho22 Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Product Version3.5.1 
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

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2026-02-16 15:20 mho22 New Issue