Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Right-click on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: Jan Ploski <jploski@us...> - 2008-04-02 15:11:08
|
Update of /cvsroot/e-p-i-c/org.epic.debug/src/org/epic/debug/db In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv14435/src/org/epic/debug/db Modified Files: PerlThreadBreakpoints.java BreakpointMap.java Log Message: Fixed bug [ 1932366 ] Adding/removing breakpoints unreliable when not suspended. Index: PerlThreadBreakpoints.java =================================================================== RCS file: /cvsroot/e-p-i-c/org.epic.debug/src/org/epic/debug/db/PerlThreadBreakpoints.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- PerlThreadBreakpoints.java 26 Jul 2007 14:54:00 -0000 1.3 +++ PerlThreadBreakpoints.java 2 Apr 2008 15:10:58 -0000 1.4 @@ -29,9 +29,9 @@ private final IBreakpointListener listener = new IBreakpointListener() { public void breakpointAdded(IBreakpoint breakpoint) { - if (!(breakpoint instanceof PerlBreakpoint)) return; + if (!(breakpoint instanceof PerlLineBreakpoint)) return; - PerlBreakpoint bp = (PerlBreakpoint) breakpoint; + PerlLineBreakpoint bp = (PerlLineBreakpoint) breakpoint; try { if (!bp.isEnabled()) return; } catch (CoreException e) @@ -40,7 +40,24 @@ return; } if (thread.isSuspended()) addBreakpoint(bp); - else pendingBreakpoints.add(bp); + else + { + try + { + // If we had a pending remove for this breakpoint, + // it is cancelled by this newer add request. + // Otherwise, we have to create a pending add. + + if (pendingBreakpoints.remove(bp, false)) + activeBreakpoints.add(bp); + else + pendingBreakpoints.add(bp); + } + catch (CoreException e) + { + PerlDebugPlugin.log(e); + } + } } public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) @@ -69,11 +86,34 @@ public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) { - if (!(breakpoint instanceof PerlBreakpoint)) return; + if (!(breakpoint instanceof PerlLineBreakpoint)) return; - PerlBreakpoint bp = (PerlBreakpoint) breakpoint; + PerlLineBreakpoint bp = (PerlLineBreakpoint) breakpoint; if (thread.isSuspended()) removeBreakpoint(bp); - else pendingBreakpoints.add(bp); + else + { + try + { + // If we had a pending add for this breakpoint, + // it is cancelled by this newer remove request. + // Otherwise, we have to create a pending remove. + + if (pendingBreakpoints.remove(bp, true)) + { + // nothing to do + } + else + { + activeBreakpoints.remove(bp); + pendingBreakpoints.add(bp); + bp.pendingRemove(); + } + } + catch (CoreException e) + { + PerlDebugPlugin.log(e); + } + } } }; Index: BreakpointMap.java =================================================================== RCS file: /cvsroot/e-p-i-c/org.epic.debug/src/org/epic/debug/db/BreakpointMap.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- BreakpointMap.java 27 May 2007 14:30:35 -0000 1.2 +++ BreakpointMap.java 2 Apr 2008 15:10:58 -0000 1.3 @@ -1,11 +1,18 @@ package org.epic.debug.db; import java.io.IOException; -import java.util.*; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; -import org.epic.debug.*; +import org.epic.debug.PerlBreakpoint; +import org.epic.debug.PerlDebugPlugin; +import org.epic.debug.PerlLineBreakpoint; /** * Used to map each source file path to a set of PerlBreakpoints. @@ -21,7 +28,7 @@ breakpoints = new HashMap(); } - public void add(PerlBreakpoint bp) + public synchronized void add(PerlBreakpoint bp) { String path = canonPath(bp.getResourcePath()); if (path == null) return; @@ -35,7 +42,7 @@ set.add(bp); } - public boolean contains(PerlBreakpoint bp) + public synchronized boolean contains(PerlBreakpoint bp) { String path = canonPath(bp.getResourcePath()); if (path == null) return false; @@ -46,16 +53,16 @@ return set.contains(bp); } - public Set getBreakpoints(IPath path) + public synchronized Set getBreakpoints(IPath path) { String canonPath = canonPath(path); if (canonPath == null) return Collections.EMPTY_SET; Set set = (Set) breakpoints.get(canonPath); - return set != null ? set : Collections.EMPTY_SET; + return set != null ? new HashSet(set) : Collections.EMPTY_SET; } - public PerlBreakpoint getBreakpoint(IPath path, int line) + public synchronized PerlBreakpoint getBreakpoint(IPath path, int line) { String canonPath = canonPath(path); @@ -80,18 +87,43 @@ } return null; } + + public synchronized boolean remove(PerlLineBreakpoint bp, boolean enabled) + throws CoreException + { + String path = canonPath(bp.getResourcePath()); + + Set set = (Set) breakpoints.get(path); + if (set == null) return false; + + int lineNumber = bp.getLineNumber(); + + for (Iterator i = set.iterator(); i.hasNext();) + { + PerlBreakpoint other = (PerlBreakpoint) i.next(); + if (!(other instanceof PerlLineBreakpoint)) continue; + + if (((PerlLineBreakpoint) other).getLineNumber() == lineNumber && + other.isEnabled() == enabled) + { + i.remove(); + return true; + } + } + return false; + } - public boolean remove(PerlBreakpoint bp) + public synchronized boolean remove(PerlBreakpoint bp) { String path = canonPath(bp.getResourcePath()); Set set = (Set) breakpoints.get(path); - if (set == null) return (false); + if (set == null) return false; return set.remove(bp); } - private String canonPath(IPath path) + private synchronized String canonPath(IPath path) { // here we do the path comparisons on canonical path to avoid // any ambiguities due to symlinks and the like |