Closed twoseascharlie closed 1 year ago
Ok, so the core issue, if I understand correctly, is you want to step through phar files. The contents of the phar file is somewhere else and you want to path-map the phar file to that location.
I haven't done much with phars in this extension, so I'll do some tests to see how Xdebug behaves.
One possible option would be that vscode-php-debug gets the phar-er file contents via the debug protocol, another would be that vscode is able to extract the contents itself. Third is what you are doing here, path mappings.
Will try to look at this soon.
Ok, so the core issue, if I understand correctly, is you want to step through phar files. The contents of the phar file is somewhere else and you want to path-map the phar file to that location.
Yes that's correct. I am running php remotely via ssh and have a samba mount to develop with vscode on windows. I have some source located at some path and I am bundling that up in a tar (same behavior with a phar) and I'm trying to use path mappings to debug through the source in a vscode workspace. It works on 5.6, but not on php >= 7.0. If I make the updates to vscode-php-debug I posted and send a phar://
path to xdebug, I can hit breakpoints.
Thanks for taking a look!
I have reimplemented the whole path mapping logic. I have not tried it with PHAR yet, but it should work. Will test and let you know. PR #879
Thanks for the updates! I pulled your changes and can confirm that I am able to debug through archives now when using phar://
prefixed path mappings.
I did some more testing on my end and I did notice a regression:
I have these 2 path mappings that correspond to files that are not bundled in a phar/tar, before your changes, I was able to hit breakpoints as expected, but with your recent changes, they no longer work:
"pathMappings": {
"/home/pi/files/utils/php/phuild/phuild/phuild.php": "w:\\home\\pi\\files\\utils\\php\\phuild\\phuild\\.build\\phuild.php",
"/home/pi/files/utils/php/phuild/phuild/prodBuild.php": "w:\\home\\pi\\files\\utils\\php\\phuild\\phuild\\.build\\prodBuild.php",
}
On a very quick debug through your changes, it seems like forcing the path to end in a /
is causing the issue since these are files:
src/paths.ts line:72
not sure if direct file mappings were supposed to be formally supported, but they did used to work and do come in handy,
You are right, that would not work now. I didn't think anyone would map individual files. I'll look at this too.
I didn't want to change the trailing slash logic, so I added one extra step to look for exact length matching.
I'm not sure yet if I want to keep the forcing of trailing slash. Previous implementation used path resolving to figure out if both paths had the same root. I changed the implementation to work internally with URLs and simpler sting prefix matching. The reason I added the trailing slash is to not match in the middle of a folder name like [/var/fold]er/file
.
Again I appreciate the feedback, there are cases I just didn't consider. You are a true pathMappings power user 😀
sure that makes sense, I pulled your latest changes again and can confirm that phar paths and individual file mapping works 😀
Again I appreciate the feedback, there are cases I just didn't consider. You are a true pathMappings power user 😀
ha, thanks! I appreciate your responsiveness and quick updates! this plugin has been very useful, thanks for continuing to make it great!
Closing this as confirmed the release fixes the issue. 🎉 Thanks for merging this one Damjan!
PHP version: 5.6, 7.3 (tested on 5.6- 8.1) Xdebug version: v2.5.5, v3.1.2 VS Code extension version: v1.30.0
Your launch.json:
Xdebug php.ini config:
php 5.6:
php 7.3:
Xdebug logfile (from setting
xdebug.log
in php.ini):from 5.6:
from 7.3:
VS Code extension logfile (from setting
"log": true
in launch.json):from 5.6:
from 7.3:
Code snippet to reproduce:
set a breakpoint on the echo line Expected: breakpoint is hit Actual: breakpoint is NOT hit on versions after php5.6
I have done some debugging through the
vscode-php-debug
extension and it looks like you are always sending afile://
uri path to the server.I tried prepending the pathMappings with phar://, but then the uri gets sent like file://phar:///home/pi/files/...
ex:
I have done some test hacking and if I send a
phar://
uri path to the server, I do see breakpoints get hit on php7.3Not sure I have time to wrap this up in a formal PR right now. Can you please take a look and let me know what you think? I'm pretty sure I just got lucky that it worked in php5.6. Newer versions of php/xdebug don't seem to support debugging through archives using the
file://
scheme/protocol. But they do work when specifying thephar://
scheme/protocol. It would be great if this plugin could be updated to support that.