Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPawel Piech2012-11-05 17:31:36 -0500
committerPawel Piech2012-11-07 09:39:32 -0500
commit1d960d276ba232ebf56472fe60dc8b86405e12a0 (patch)
treebb03e9b47e7b2acbcbdd898cc78220f8e8ba2e62
parent47518882bdaa948c98f435d1dacd31bddaee66ef (diff)
downloadorg.eclipse.tcf-1d960d276ba232ebf56472fe60dc8b86405e12a0.tar.gz
org.eclipse.tcf-1d960d276ba232ebf56472fe60dc8b86405e12a0.tar.xz
org.eclipse.tcf-1d960d276ba232ebf56472fe60dc8b86405e12a0.zip
Bug 393615 - [breakpoints] It should not be possible to remove or modify foreign breakpoints.
-rw-r--r--plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/TCFBreakpointStatusListener.java33
-rw-r--r--plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFBreakpointsModel.java4
2 files changed, 34 insertions, 3 deletions
diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/TCFBreakpointStatusListener.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/TCFBreakpointStatusListener.java
index 9286bcec0..3b0e66f29 100644
--- a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/TCFBreakpointStatusListener.java
+++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/TCFBreakpointStatusListener.java
@@ -12,6 +12,7 @@ package org.eclipse.tcf.internal.cdt.ui;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -26,6 +27,7 @@ import org.eclipse.cdt.debug.internal.core.breakpoints.CFunctionBreakpoint;
import org.eclipse.cdt.debug.internal.core.breakpoints.CLineBreakpoint;
import org.eclipse.cdt.debug.internal.core.breakpoints.CWatchpoint;
import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IMarkerDelta;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.WorkspaceJob;
@@ -36,6 +38,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IBreakpointListener;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.tcf.internal.debug.model.ITCFBreakpointListener;
@@ -58,7 +61,7 @@ class TCFBreakpointStatusListener {
/** Ref count attribute for foreign breakpoints */
private static final String ATTR_REFCOUNT = "org.eclipse.tcf.cdt.refcount";
- private class BreakpointListener implements ITCFBreakpointListener {
+ private class BreakpointListener implements ITCFBreakpointListener, IBreakpointListener {
private final TCFBreakpointsStatus status;
private final Map<String,ICBreakpoint> installed = new HashMap<String,ICBreakpoint>();
@@ -69,6 +72,7 @@ class TCFBreakpointStatusListener {
status = launch.getBreakpointsStatus();
status.addListener(this);
bp_listeners.put(launch, this);
+ DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this);
for (String id : status.getStatusIDs()) breakpointStatusChanged(id);
}
@@ -78,6 +82,32 @@ class TCFBreakpointStatusListener {
if (bp == null) createOrUpdateBreakpoint(id);
}
+ public void breakpointAdded(IBreakpoint breakpoint) {}
+ public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) {
+ updateBreakpoint(breakpoint, false);
+ }
+ public void breakpointRemoved(final IBreakpoint breakpoint, IMarkerDelta delta) {
+ updateBreakpoint(breakpoint, true);
+ }
+
+ private void updateBreakpoint(IBreakpoint breakpoint, final boolean removed) {
+ try {
+ IMarker marker = breakpoint.getMarker();
+ if (marker == null || !marker.exists()) return;
+ if (TCFBreakpointsModel.isLocal(marker)) return;
+ final String marker_id = TCFBreakpointsModel.getBreakpointID(breakpoint);
+ Protocol.invokeLater(new Runnable() {
+ public void run() {
+ if (removed) {
+ foreign.remove(marker_id);
+ }
+ createOrUpdateBreakpoint(marker_id);
+ }
+ });
+
+ } catch (CoreException e) {}
+ }
+
private void updateStatus(String id, IBreakpoint bp) {
if (bp instanceof ICBreakpoint) {
boolean ok = false;
@@ -121,6 +151,7 @@ class TCFBreakpointStatusListener {
}
void dispose() {
+ DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(this);
for (ICBreakpoint cbp : installed.values()) {
decrementInstallCount(cbp);
}
diff --git a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFBreakpointsModel.java b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFBreakpointsModel.java
index 834f86dce..eb70ab32d 100644
--- a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFBreakpointsModel.java
+++ b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFBreakpointsModel.java
@@ -342,7 +342,7 @@ public class TCFBreakpointsModel {
* Return false if the properties represent a breakpoint created by some other TCF client.
*/
@SuppressWarnings("unchecked")
- public boolean isLocal(Map<String,Object> properties) {
+ public static boolean isLocal(Map<String,Object> properties) {
if (properties == null) return false;
Map<String,Object> client_data = (Map<String,Object>)properties.get(IBreakpoints.PROP_CLIENT_DATA);
if (client_data == null) return false;
@@ -356,7 +356,7 @@ public class TCFBreakpointsModel {
* @return true if the marker is owned by local instance of Eclipse.
* Return false if the marker represents a breakpoint created by some other TCF client.
*/
- public boolean isLocal(IMarker marker) {
+ public static boolean isLocal(IMarker marker) {
try {
Map<String,Object> marker_attrs = marker.getAttributes();
if (marker_attrs == null) return false;

Back to the top