Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.tm.tcf.dsf/src/org/eclipse/tm/internal/tcf/dsf/services/TCFDSFBreakpoints.java')
-rw-r--r--plugins/org.eclipse.tm.tcf.dsf/src/org/eclipse/tm/internal/tcf/dsf/services/TCFDSFBreakpoints.java286
1 files changed, 188 insertions, 98 deletions
diff --git a/plugins/org.eclipse.tm.tcf.dsf/src/org/eclipse/tm/internal/tcf/dsf/services/TCFDSFBreakpoints.java b/plugins/org.eclipse.tm.tcf.dsf/src/org/eclipse/tm/internal/tcf/dsf/services/TCFDSFBreakpoints.java
index 6b1e00502..0d3c7cd00 100644
--- a/plugins/org.eclipse.tm.tcf.dsf/src/org/eclipse/tm/internal/tcf/dsf/services/TCFDSFBreakpoints.java
+++ b/plugins/org.eclipse.tm.tcf.dsf/src/org/eclipse/tm/internal/tcf/dsf/services/TCFDSFBreakpoints.java
@@ -10,12 +10,21 @@
*******************************************************************************/
package org.eclipse.tm.internal.tcf.dsf.services;
+import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Hashtable;
import java.util.Map;
+import java.util.Set;
+import org.eclipse.cdt.core.IAddress;
import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+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.Status;
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
@@ -35,11 +44,10 @@ import org.eclipse.tm.internal.tcf.debug.model.TCFLaunch;
import org.eclipse.tm.internal.tcf.dsf.Activator;
import org.eclipse.tm.tcf.protocol.IChannel;
import org.eclipse.tm.tcf.protocol.IToken;
+import org.eclipse.tm.tcf.services.IBreakpoints;
+import org.eclipse.tm.tcf.util.TCFDataCache;
import org.osgi.framework.BundleContext;
-
-// TODO IBreakpointHitEvent
-
public class TCFDSFBreakpoints extends AbstractDsfService implements org.eclipse.dd.dsf.debug.service.IBreakpoints {
private class BreakpointDMC extends AbstractDMContext implements IBreakpointDMContext {
@@ -47,6 +55,7 @@ public class TCFDSFBreakpoints extends AbstractDsfService implements org.eclipse
final String id;
final IBreakpoint bp;
final TCFDataCache<Map<String,Object>> status;
+ final Set<IBreakpointsTargetDMContext> targets;
boolean disposed;
@@ -61,28 +70,18 @@ public class TCFDSFBreakpoints extends AbstractDsfService implements org.eclipse
assert command == null;
assert !disposed;
if (tcf_bpt_service == null) {
- data = null;
- valid = true;
+ reset(null);
return true;
}
command = tcf_bpt_service.getStatus(id, new org.eclipse.tm.tcf.services.IBreakpoints.DoneGetStatus() {
public void doneGetStatus(IToken token, Exception err, Map<String,Object> status) {
- if (command != token) return;
- command = null;
- if (err != null) {
- data = null;
- error = err;
- }
- else {
- data = status;
- }
- valid = true;
- validate();
+ set(token, err, status);
}
});
return false;
}
};
+ targets = new HashSet<IBreakpointsTargetDMContext>();
}
@Override
@@ -98,80 +97,173 @@ public class TCFDSFBreakpoints extends AbstractDsfService implements org.eclipse
void dispose() {
assert !disposed;
cache.remove(id);
+ for (IBreakpointsTargetDMContext t : targets.toArray(
+ new IBreakpointsTargetDMContext[targets.size()])) onRemoved(t);
+ assert targets.isEmpty();
disposed = true;
}
+
+ void onAdded(final IBreakpointsTargetDMContext t) {
+ targets.add(t);
+ IBreakpointsAddedEvent e = new IBreakpointsAddedEvent() {
+ public IBreakpointsTargetDMContext getDMContext() {
+ return t;
+ }
+ public IBreakpointDMContext[] getBreakpoints() {
+ return new IBreakpointDMContext[]{ BreakpointDMC.this };
+ }
+ };
+ getSession().dispatchEvent(e, getProperties());
+ }
+
+ void onUpdated(final IBreakpointsTargetDMContext t) {
+ assert targets.contains(t);
+ IBreakpointsUpdatedEvent e = new IBreakpointsUpdatedEvent() {
+ public IBreakpointsTargetDMContext getDMContext() {
+ return t;
+ }
+ public IBreakpointDMContext[] getBreakpoints() {
+ return new IBreakpointDMContext[]{ BreakpointDMC.this };
+ }
+ };
+ getSession().dispatchEvent(e, getProperties());
+ }
+
+ void onRemoved(final IBreakpointsTargetDMContext t) {
+ targets.remove(t);
+ IBreakpointsRemovedEvent e = new IBreakpointsRemovedEvent() {
+ public IBreakpointsTargetDMContext getDMContext() {
+ return t;
+ }
+ public IBreakpointDMContext[] getBreakpoints() {
+ return new IBreakpointDMContext[]{ BreakpointDMC.this };
+ }
+ };
+ getSession().dispatchEvent(e, getProperties());
+ }
}
private class BreakpointData implements IBreakpointDMData {
final IBreakpoint bp;
- final BreakpointStatus status;
+ final Map<String,Object> attrs;
+ final Map<String,Object> status;
+ final String file;
- BreakpointData(IBreakpoint bp, BreakpointStatus status) {
+ @SuppressWarnings("unchecked")
+ BreakpointData(IBreakpoint bp, Map<String,Object> status) throws CoreException, IOException {
this.bp = bp;
this.status = status;
+ attrs = bp.getMarker().getAttributes();
+ IResource resource = bp.getMarker().getResource();
+ if (resource == ResourcesPlugin.getWorkspace().getRoot()) {
+ file = null;
+ }
+ else {
+ IPath p = resource.getRawLocation();
+ if (p == null) file = null;
+ else file = p.toFile().getCanonicalPath();
+ }
}
public IBreakpoint getPlatformBreakpoint() {
return bp;
}
- public BreakpointStatus getStatus() {
+ public Map<String,Object> getStatus() {
return status;
}
+
+ @SuppressWarnings("unchecked")
+ public IAddress[] getAddresses() {
+ if (status == null) return null;
+ Map<String,Collection<Number>> arr = (Map<String,Collection<Number>>)status.get(IBreakpoints.STATUS_PLANTED);
+ if (arr == null) return null;
+ int cnt = 0;
+ for (Collection<Number> c : arr.values()) cnt += c.size();
+ IAddress[] res = new IAddress[cnt];
+ int pos = 0;
+ for (Collection<Number> c : arr.values()) {
+ for (Number addr : c) res[pos++] = new TCFAddress(addr);
+ }
+ return res;
+ }
+
+ public String getBreakpointType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getCondition() {
+ return (String)attrs.get(ITCFConstants.ID_TCF_DEBUG_MODEL + '.' + IBreakpoints.PROP_CONDITION);
+ }
+
+ public String getExpression() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getFileName() {
+ return file;
+ }
+
+ public String getFunctionName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int getIgnoreCount() {
+ Integer count = (Integer)attrs.get(ITCFConstants.ID_TCF_DEBUG_MODEL + '.' + IBreakpoints.PROP_SKIP_COUNT);
+ if (count != null) return count.intValue();
+ return 0;
+ }
+
+ public int getLineNumber() {
+ Integer line = (Integer)attrs.get(IMarker.LINE_NUMBER);
+ if (line != null) return line.intValue();
+ return 0;
+ }
+
+ public boolean isEnabled() {
+ Boolean enabled = (Boolean)attrs.get(IBreakpoint.ENABLED);
+ return enabled != null && enabled.booleanValue() && bp_manager.isEnabled();
+ }
}
private final ITCFBreakpointListener bp_listener = new ITCFBreakpointListener() {
+ @SuppressWarnings("unchecked")
public void breakpointStatusChanged(String id) {
final BreakpointDMC dmc = cache.get(id);
if (dmc != null) {
- Map<String, Object> map = launch.getBreakpointsStatus().getStatus(dmc.id);
+ TCFDSFRunControl rc = getServicesTracker().getService(TCFDSFRunControl.class);
+ Map<String,Object> map = launch.getBreakpointsStatus().getStatus(dmc.id);
dmc.status.reset(map);
- IBreakpointDMEvent e = null;
- if (map == null) {
- e = new IBreakpointUninstalledDMEvent() {
- public IBreakpointDMContext getDMContext() {
- return dmc;
- }
- };
- }
- else if (map.get(org.eclipse.tm.tcf.services.IBreakpoints.STATUS_ERROR) != null) {
- e = new IBreakpointInstallFailedDMEvent() {
- public IBreakpointDMContext getDMContext() {
- return dmc;
- }
- };
- }
- else if (map.get(org.eclipse.tm.tcf.services.IBreakpoints.STATUS_PLANTED) != null) {
- e = new IBreakpointInstalledDMEvent() {
- public IBreakpointDMContext getDMContext() {
- return dmc;
- }
- };
+ Set<IBreakpointsTargetDMContext> add_targets = new HashSet<IBreakpointsTargetDMContext>();
+ Set<IBreakpointsTargetDMContext> rem_targets = new HashSet<IBreakpointsTargetDMContext>();
+ if (map != null) {
+ Map<String,Collection<Number>> arr = (Map<String,Collection<Number>>)map.get(IBreakpoints.STATUS_PLANTED);
+ if (arr != null) {
+ for (String ctx_id : arr.keySet()) add_targets.add(rc.getContext(ctx_id));
+ }
}
- else {
- e = new IBreakpointUninstalledDMEvent() {
- public IBreakpointDMContext getDMContext() {
- return dmc;
- }
- };
+ for (IBreakpointsTargetDMContext t : dmc.targets) {
+ if (add_targets.contains(t)) {
+ dmc.onUpdated(t);
+ add_targets.remove(t);
+ }
+ else {
+ rem_targets.add(t);
+ }
}
- getSession().dispatchEvent(e, getProperties());
+ for (IBreakpointsTargetDMContext t : rem_targets) dmc.onRemoved(t);
+ for (IBreakpointsTargetDMContext t : add_targets) dmc.onAdded(t);
}
}
public void breakpointRemoved(String id) {
final BreakpointDMC dmc = cache.get(id);
- if (dmc != null) {
- dmc.dispose();
- IBreakpointDMEvent e = new IBreakpointUninstalledDMEvent() {
- public IBreakpointDMContext getDMContext() {
- return dmc;
- }
- };
- getSession().dispatchEvent(e, getProperties());
- }
+ if (dmc != null) dmc.dispose();
}
};
@@ -179,6 +271,7 @@ public class TCFDSFBreakpoints extends AbstractDsfService implements org.eclipse
private final IChannel channel;
private final org.eclipse.tm.tcf.services.IBreakpoints tcf_bpt_service;
private final Map<String,BreakpointDMC> cache = new HashMap<String,BreakpointDMC>();
+ private final IBreakpointManager bp_manager = DebugPlugin.getDefault().getBreakpointManager();
public TCFDSFBreakpoints(DsfSession session, TCFLaunch launch, final RequestMonitor monitor) {
super(session);
@@ -188,7 +281,7 @@ public class TCFDSFBreakpoints extends AbstractDsfService implements org.eclipse
tcf_bpt_service = channel.getRemoteService(org.eclipse.tm.tcf.services.IBreakpoints.class);
initialize(new RequestMonitor(getExecutor(), monitor) {
@Override
- protected void handleOK() {
+ protected void handleSuccess() {
String[] class_names = {
org.eclipse.dd.dsf.debug.service.IBreakpoints.class.getName(),
TCFDSFBreakpoints.class.getName()
@@ -210,8 +303,7 @@ public class TCFDSFBreakpoints extends AbstractDsfService implements org.eclipse
return Activator.getBundleContext();
}
- public void getAllBreakpoints(IDMContext ctx, DataRequestMonitor<IBreakpointDMContext[]> rm) {
- IBreakpointManager bp_manager = DebugPlugin.getDefault().getBreakpointManager();
+ public void getBreakpoints(IBreakpointsTargetDMContext ctx, DataRequestMonitor<IBreakpointDMContext[]> rm) {
TCFBreakpointsModel m = TCFBreakpointsModel.getBreakpointsModel();
IBreakpoint[] arr = bp_manager.getBreakpoints(ITCFConstants.ID_TCF_DEBUG_MODEL);
ArrayList<IBreakpointDMContext> l = new ArrayList<IBreakpointDMContext>();
@@ -233,36 +325,13 @@ public class TCFDSFBreakpoints extends AbstractDsfService implements org.eclipse
rm.done();
}
- public void getBreakpoints(IDMContext dmc, IBreakpoint bp, DataRequestMonitor<IBreakpointDMContext[]> rm) {
- TCFBreakpointsModel m = TCFBreakpointsModel.getBreakpointsModel();
- ArrayList<IBreakpointDMContext> l = new ArrayList<IBreakpointDMContext>();
- if (m.isSupported(channel, bp)) {
- IMarker marker = bp.getMarker();
- String id = marker.getAttribute(ITCFConstants.ID_TCF_DEBUG_MODEL +
- '.' + org.eclipse.tm.tcf.services.IBreakpoints.PROP_ID, (String)null);
- if (id != null) {
- BreakpointDMC c = cache.get(id);
- if (c == null) c = new BreakpointDMC(this, id, bp);
- l.add(c);
- }
- }
- rm.setData(l.toArray(new IBreakpointDMContext[l.size()]));
- rm.done();
- }
-
- public void getBreakpointData(final IDMContext dmc, final DataRequestMonitor<IBreakpointDMData> rm) {
+ public void getBreakpointDMData(final IBreakpointDMContext dmc, final DataRequestMonitor<IBreakpointDMData> rm) {
if (dmc instanceof BreakpointDMC) {
BreakpointDMC bp = (BreakpointDMC)dmc;
if (!bp.status.validate()) {
- bp.status.addWaitingRequest(new IDataRequest() {
- public void cancel() {
- rm.setStatus(new Status(IStatus.CANCEL, Activator.PLUGIN_ID,
- REQUEST_FAILED, "Canceled", null)); //$NON-NLS-1$
- rm.setCanceled(true);
- rm.done();
- }
- public void done() {
- getBreakpointData(dmc, rm);
+ bp.status.wait(new Runnable() {
+ public void run() {
+ getBreakpointDMData(dmc, rm);
}
});
return;
@@ -273,17 +342,14 @@ public class TCFDSFBreakpoints extends AbstractDsfService implements org.eclipse
rm.done();
return;
}
- Map<String,Object> map = bp.status.getData();
- BreakpointStatus status = BreakpointStatus.FILTERED_OUT;
- if (map != null) {
- if (map.get(org.eclipse.tm.tcf.services.IBreakpoints.STATUS_ERROR) != null) {
- status = BreakpointStatus.FAILED_TO_INSTALL;
- }
- else if (map.get(org.eclipse.tm.tcf.services.IBreakpoints.STATUS_PLANTED) != null) {
- status = BreakpointStatus.INSTALLED;
- }
+ try {
+ rm.setData(new BreakpointData(bp.bp, bp.status.getData()));
+ }
+ catch (Exception x) {
+ rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ REQUEST_FAILED, "Data error", x)); //$NON-NLS-1$
+
}
- rm.setData(new BreakpointData(bp.bp, status));
}
else {
rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
@@ -295,7 +361,7 @@ public class TCFDSFBreakpoints extends AbstractDsfService implements org.eclipse
@SuppressWarnings("unchecked")
public void getModelData(IDMContext dmc, DataRequestMonitor<?> rm) {
if (dmc instanceof BreakpointDMC) {
- getBreakpointData((BreakpointDMC)dmc, (DataRequestMonitor<IBreakpointDMData>)rm);
+ getBreakpointDMData((BreakpointDMC)dmc, (DataRequestMonitor<IBreakpointDMData>)rm);
}
else {
rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
@@ -303,4 +369,28 @@ public class TCFDSFBreakpoints extends AbstractDsfService implements org.eclipse
rm.done();
}
}
+
+ public void insertBreakpoint(IBreakpointsTargetDMContext context, Map<String,Object> attributes,
+ DataRequestMonitor<IBreakpointDMContext> rm) {
+ // Clients are not allowed to call this method.
+ // Use IBreakpointManager instead.
+ rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ REQUEST_FAILED, "Not allowed", new Error())); //$NON-NLS-1$
+ rm.done();
+ }
+
+ public void removeBreakpoint(IBreakpointDMContext dmc, RequestMonitor rm) {
+ // Clients are not allowed to call this method.
+ // Use IBreakpointManager instead.
+ rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ REQUEST_FAILED, "Not allowed", new Error())); //$NON-NLS-1$
+ rm.done();
+ }
+
+ public void updateBreakpoint(IBreakpointDMContext dmc, Map<String,Object> delta, RequestMonitor rm) {
+ // Clients are not allowed to call this method.
+ rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ REQUEST_FAILED, "Not allowed", new Error())); //$NON-NLS-1$
+ rm.done();
+ }
}

Back to the top