SublimeXdebug
SublimeXdebug copied to clipboard
Breakpoints do not work with remote xdebug [remote path mapping]
The breakpoints I have set from my host operating system's Sublime does not break for code executing on a shared file system from PHP within the guest operating system because the file system paths xdebug is sending is in the form of /var/www/somewhere/index.php and the path that Sublime is familiar with in the host OS is in the form of C:\Users\bran\sites\index.php.
Is this a configurational issue or a feature missing from SublimeXdebug?
This is kind of a known design flaw. I haven't thought of a good method to address this but I will try to come up with something.
Would it be a good idea to implement 2 more configurational variables in the .sublime-project file?
xdebug.remote_basepath = /var/www/somewhere/ xdebug.local_basepath = C:\Users\bran\sites\
And do a find and replace on the interactions with file paths?
That would work in the short term, but there could be multiple paths that need to be replaced, paths for different remotes, etc. Obviously the simplest to implement is what you describe but it won't address all issues.
http://tiger-fish.com/blog/drupal-debugging-code-inside-vagrant-instance-using-xdebug
There's a screenshot to how PHPStorm handles the mapping.
I think it's a missing feature. This sounds like we need to add a configuration setting to map remote server paths to local project paths. In this case, the path mapping would be something like /var/www/somewhere/ => C:\Users\bran\sites. Netbeans and PHPEclipse do this through debugging profiles and allow the user to setup multiple profiles in a single project then choose the profile to use for a given debugging session (dev and production profiles, for instance).
[Sorry, I replied before reading your full discussion.]
@Kindari, sounds like we're thinking along the same lines with support for multiple remotes. I'd take a stab at it but I'm pretty busy the next few weeks.
I think this is right. How should we decide which configuration to use? When starting the debugger, if multiple definitions defined, show a list? assume last used? host based on connect?
It doesn't look like this project supports multiple remote hosts at the moment? It only uses the one 'xdebug' variable in the project settings file.
The configuration might look something like this:
"xdebug":
{
"dev":
{
"url": "http://server1"
"map": { "remote_path": "local_path", ... }
},
"production":
{
"url": "http://server2"
"map": { "remote_path": "local_path", ... }
},
...
}
where "dev" and "production" in this example are debug profiles and "map" contains zero or more path mappings for the profile. In the case with one profile, we'd just launch that when starting a debug session. For multiple profiles, we could show a choice in a quick list? Or maybe mark one of the profiles as the default and add a key binding to launch the quick list to choose an alternate profile.
We can have the command take an optional parameter "dev" or "prod", thus forcing those configs. They can use that as part of the key bindings. If no param is passed, show a drop down list when there are more then one configs.
I will try and implement this over the weekend.
I have implemented this in an upcoming rewrite, See #36 for info. The rewrite is not available just yet but should be available for testing within a day or two. Will keep this issue open until then.
+1 for path mapping
Enabled and checked xdebug logs, and path mapping is about the only thing stopping me to use the plugin.
I'm not clear if the mapping for remote debugging is implemented in SublimeXdebug. I made debug using notepad + + and runs but does not perform sublimetext remote debug. Why?
PS: Sorry for the English, thanks!
+1
yep, useless plugin for me without remote breakpoints support :(
@enduk See #42 for a quick hack to make breakpoints work.
@mbirth I've changed XDebug.py according to your comment, restarted sublime but still no luck, when I press shift+f8 I get browser window with http://project.url/?XDEBUG_.... page loaded and in Sublime status bar there's a text something like "Page has been loaded, to continue debug reload the page".
And breakpoints doesn't work, even if they are located on the first statement in index.php Stack and context panes empty too. I've tried all comments regarding this, probably I'm doing something wrong if you get it working :)
@enduk Did you adapt the line local_path.replace( "/mnt/server/", "/" ) to your needs? In my case, the "/" of the remote server is mounted to "/mnt/server". That's why I replace all occurrences of the latter one by a slash.
Example:
On my machine, the file is in /mnt/server/var/www/htdocs/my/page/index.php and after replacement, remote_path now contains /var/www/htdocs/my/page/index.php - the exact location of the file on the remote machine.
@mbirth yes, sure, in my case:
def uri(self):
return 'file://' + os.path.realpath(self.view.file_name())
local_path = os.path.realpath(self.view.file_name())
remote_path = local_path.replace( "/lxc/name/", "/" )
return 'file://' + remote_path
where /lxc/name/ is root for linux guest
@enduk You have to remove the return 'file://' + os.path.realpath(...) for the rest of the function to get processed.
:+1: I was too tired to see this obvious mistake
Now I get:
Traceback (most recent call last):
File "./sublime_plugin.py", line 356, in run_
File "./Xdebug.py", line 448, in run
File "./Xdebug.py", line 467, in callback
AttributeError: 'NoneType' object has no attribute 'current'
I worked around this (on Windows) by doing this:
def uri(self):
#NJ - NEXT LINE IS ORIGINAL
#return 'file://' + os.path.realpath(self.view.file_name())
tmp = self.view.file_name()
discard, sep, short_file = tmp.rpartition('\\')
return 'file:///var/www/html/' + short_file
Where /var/www/html/ is the path on the remote machine.
Doing this, I am now able to get xdebug to break at the proper point, but I see no tabs in the panes where "Xdebug Context" and "Xdebug Stack" should be. My status looks ok:
I guess I'll open a new issue for that.