From 25fbb5f6816e4db4cea29970eea2ab8e66724946 Mon Sep 17 00:00:00 2001 From: robekras Date: Sat, 19 Mar 2011 22:04:06 +0000 Subject: [PATCH] 1) Made breakpoint working for direct script debugging (php cli) on Win systems. 2) Fixed direct script debugging (Bug introduced by my last changes). --- .../php/launching/PHPSourceLookupParticipant.java | 44 ++++++++++++++------ .../phpeclipse/xdebug/php/model/XDebugTarget.java | 10 ++++- 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/launching/PHPSourceLookupParticipant.java b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/launching/PHPSourceLookupParticipant.java index 5397391..f913069 100644 --- a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/launching/PHPSourceLookupParticipant.java +++ b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/launching/PHPSourceLookupParticipant.java @@ -1,5 +1,6 @@ package net.sourceforge.phpeclipse.xdebug.php.launching; +import java.net.URI; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -12,12 +13,14 @@ import net.sourceforge.phpeclipse.xdebug.php.model.XDebugStackFrame; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.MultiStatus; import org.eclipse.core.runtime.Path; import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunchConfigurationType; import org.eclipse.debug.core.model.IStackFrame; import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant; import org.eclipse.debug.core.sourcelookup.ISourceContainer; @@ -62,12 +65,21 @@ public class PHPSourceLookupParticipant extends AbstractSourceLookupParticipant String local; List pathMap; PathMapItem pmi = null; + Object test; + IProject project; projectName = getDirector().getLaunchConfiguration().getAttribute (IXDebugConstants.ATTR_PHP_PROJECT, ""); - pathMap = getDirector().getLaunchConfiguration().getAttribute(IXDebugConstants.ATTR_PHP_PATHMAP, (List) null); - + pathMap = getDirector().getLaunchConfiguration().getAttribute (IXDebugConstants.ATTR_PHP_PATHMAP, (List) null); + project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); + + if (getDirector ().getLaunchConfiguration ().getType ().getName ().equals ("PHP XDebug Script")) { + remoteDebug = false; + } + else { + remoteDebug = true; + } + fileName = ((XDebugStackFrame) stackFrame).getFullSourceName (); // Get the filename as it is submitted by XDebug - //file = ""; if (remoteDebug) { // Is it a remote debugging session path = new Path (fileName); // Create a IPath object for the server side filename @@ -76,7 +88,7 @@ public class PHPSourceLookupParticipant extends AbstractSourceLookupParticipant if (remoteSourcePath.isPrefixOf (path)) { // Is the server side filename with the remote source path path = path.removeFirstSegments (remoteSourcePath.matchingFirstSegments (path)); // Remove the remote source path //file = path.toString (); // The filename without the remote source path - projectPath = (PHPeclipsePlugin.getWorkspace().getRoot().getProject(projectName).getLocation()); // Get the absolute project path + projectPath = (ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).getLocation()); // Get the absolute project path return (projectPath.append (path)).toOSString (); // Return the filename as absolute client side path } @@ -104,7 +116,7 @@ public class PHPSourceLookupParticipant extends AbstractSourceLookupParticipant localPath = new Path (local); // Create new IPath object for the local/client side path path = localPath.append (path); // Prepend the project relative path to filename - projectPath = (PHPeclipsePlugin.getWorkspace().getRoot().getProject(projectName).getLocation()); // Get the absolute project path + projectPath = (ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).getLocation()); // Get the absolute project path // return path; return (projectPath.append (path)).toString (); // Return the filename as absolute client side path @@ -138,13 +150,13 @@ public class PHPSourceLookupParticipant extends AbstractSourceLookupParticipant return fileName; } else { // no remote debug -/* - IWorkspaceRoot root = PHPLaunchingPlugin.getWorkspace().getRoot(); - Path filePath = new Path(fileName); - + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + IPath filePath = new Path(fileName); + if (root.getFileForLocation(filePath) == null) { - IProject proj = root.getProject(projectName); - IFile[] files = root.findFilesForLocation(filePath); + IProject proj = root.getProject (projectName); + IFile[] files = root.findFilesForLocation (filePath); + for (int i = 0; i < files.length; i++) { if (files[i].getProject().equals(proj)) { fileName = proj.getFullPath().append(files[i].getProjectRelativePath()).toOSString(); @@ -152,7 +164,13 @@ public class PHPSourceLookupParticipant extends AbstractSourceLookupParticipant } } } -*/ + else { + projectPath = (ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).getLocation()); + filePath = filePath.removeFirstSegments (projectPath.matchingFirstSegments (filePath)); + + return filePath.toString (); + } + return fileName; } } @@ -160,7 +178,7 @@ public class PHPSourceLookupParticipant extends AbstractSourceLookupParticipant /* (non-Javadoc) * @see org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant#findSourceElements(java.lang.Object) */ - public Object[] findSourceElements(Object object) throws CoreException { + public Object[] findSourceElements (Object object) throws CoreException { String name = null; if (object == null) { diff --git a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugTarget.java b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugTarget.java index 79e6366..11bb134 100644 --- a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugTarget.java +++ b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugTarget.java @@ -25,6 +25,7 @@ import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarkerDelta; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugPlugin; @@ -743,8 +744,13 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, IDebugE hitCount = Integer.parseInt(attribute.getNodeValue()); } } - - if(PHPDebugUtils.unescapeString(filename).endsWith(endfilename) + + Path path1 = new Path (PHPDebugUtils.unescapeString (filename)); + Path path2 = new Path (endfilename); + + if (path1.toString ().endsWith (path2.toString ()) +// if (strPath1.endsWith (strPath2) + //if(PHPDebugUtils.unescapeString(filename).endsWith(endfilename) && (lineBreakpoint.getLineNumber() == lineNumber) ) { if (marker.getAttribute(XDebugLineBreakpoint.HIT_COUNT, 0) > 0) { if (marker.getAttribute(XDebugLineBreakpoint.HIT_COUNT, 0) == hitCount) { -- 1.7.1