Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraleherbau2011-05-09 09:18:20 -0400
committeraleherbau2011-05-09 09:18:20 -0400
commit383dacf787e43ee50adf19bec2eaee3b1b29c422 (patch)
tree2be1b4849b0816be48798b1bf5b84f10ca4d4df1
parent3eb3aac3d8ba18a4614a510cb222d60406fe9000 (diff)
downloadorg.eclipse.tcf-383dacf787e43ee50adf19bec2eaee3b1b29c422.tar.gz
org.eclipse.tcf-383dacf787e43ee50adf19bec2eaee3b1b29c422.tar.xz
org.eclipse.tcf-383dacf787e43ee50adf19bec2eaee3b1b29c422.zip
TCF Debugger: Support for restricting breakpoints to a debug session
-rw-r--r--plugins/org.eclipse.tm.tcf.cdt.ui/src/org/eclipse/tm/internal/tcf/cdt/ui/breakpoints/TCFBreakpointScopeExtension.java2
-rw-r--r--plugins/org.eclipse.tm.tcf.cdt.ui/src/org/eclipse/tm/internal/tcf/cdt/ui/breakpoints/TCFThreadFilterEditor.java44
-rw-r--r--plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFBreakpointsModel.java45
3 files changed, 71 insertions, 20 deletions
diff --git a/plugins/org.eclipse.tm.tcf.cdt.ui/src/org/eclipse/tm/internal/tcf/cdt/ui/breakpoints/TCFBreakpointScopeExtension.java b/plugins/org.eclipse.tm.tcf.cdt.ui/src/org/eclipse/tm/internal/tcf/cdt/ui/breakpoints/TCFBreakpointScopeExtension.java
index 34e4617b6..3b584dc67 100644
--- a/plugins/org.eclipse.tm.tcf.cdt.ui/src/org/eclipse/tm/internal/tcf/cdt/ui/breakpoints/TCFBreakpointScopeExtension.java
+++ b/plugins/org.eclipse.tm.tcf.cdt.ui/src/org/eclipse/tm/internal/tcf/cdt/ui/breakpoints/TCFBreakpointScopeExtension.java
@@ -20,7 +20,7 @@ import org.eclipse.tm.tcf.services.IBreakpoints;
public class TCFBreakpointScopeExtension implements ICBreakpointExtension {
- private static final String ATTR_CONTEXT_IDS = ITCFConstants.ID_TCF_DEBUG_MODEL + '.' + IBreakpoints.PROP_CONTEXTIDS;
+ static final String ATTR_CONTEXT_IDS = ITCFConstants.ID_TCF_DEBUG_MODEL + '.' + IBreakpoints.PROP_CONTEXTIDS;
private String[] fContextIds;
private ICBreakpoint fBreakpoint;
diff --git a/plugins/org.eclipse.tm.tcf.cdt.ui/src/org/eclipse/tm/internal/tcf/cdt/ui/breakpoints/TCFThreadFilterEditor.java b/plugins/org.eclipse.tm.tcf.cdt.ui/src/org/eclipse/tm/internal/tcf/cdt/ui/breakpoints/TCFThreadFilterEditor.java
index f6906b766..eff276171 100644
--- a/plugins/org.eclipse.tm.tcf.cdt.ui/src/org/eclipse/tm/internal/tcf/cdt/ui/breakpoints/TCFThreadFilterEditor.java
+++ b/plugins/org.eclipse.tm.tcf.cdt.ui/src/org/eclipse/tm/internal/tcf/cdt/ui/breakpoints/TCFThreadFilterEditor.java
@@ -50,16 +50,20 @@ public class TCFThreadFilterEditor {
private final String fId;
private final String fParentId;
private final boolean fIsContainer;
+ private final String fScopeId;
+ private final String fSessionId;
- Context(IRunControl.RunControlContext ctx) {
- this(ctx, null);
+ Context(IRunControl.RunControlContext ctx, Context parent) {
+ this(ctx, parent.fSessionId);
}
- Context(IRunControl.RunControlContext ctx, String suffix) {
+ Context(IRunControl.RunControlContext ctx, String sessionId) {
String name = ctx.getName() != null ? ctx.getName() : ctx.getID();
- if (suffix != null) {
- name += " - " + suffix;
+ if (sessionId != null) {
+ name += " - " + sessionId;
}
fName = name;
+ fSessionId = sessionId;
+ fScopeId = sessionId != null ? sessionId + '/' + ctx.getID() : ctx.getID();
fId = ctx.getID();
fParentId = ctx.getParentID();
fIsContainer = ctx.isContainer();
@@ -249,8 +253,9 @@ public class TCFThreadFilterEditor {
List<Object> targets = new ArrayList<Object>();
ILaunch[] launches = ((ILaunchManager) input).getLaunches();
for (int i = 0; i < launches.length; i++) {
- if (launches[i] instanceof TCFLaunch) {
- Context[] targetArray = syncGetContainers((TCFLaunch) launches[i]);
+ ILaunch launch = launches[i];
+ if (launch instanceof TCFLaunch && !launch.isTerminated()) {
+ Context[] targetArray = syncGetContainers((TCFLaunch) launch);
targets.addAll(Arrays.asList(targetArray));
}
}
@@ -282,10 +287,18 @@ public class TCFThreadFilterEditor {
// expand all to realize tree items
getThreadViewer().expandAll();
for (int i = 0; i < ctxIds.length; i++) {
- Context ctx = getContext(ctxIds[i]);
+ String id = ctxIds[i];
+ Context ctx = getContext(id);
if (ctx != null) {
fCheckHandler.checkContext(ctx, true);
fCheckHandler.updateParentCheckState(ctx);
+ } else if (id.indexOf('/') < 0) {
+ for (Context context : fContexts) {
+ if (id.equals(context.fId)) {
+ fCheckHandler.checkContext(context, true);
+ fCheckHandler.updateParentCheckState(context);
+ }
+ }
}
}
// expand checked items only
@@ -294,12 +307,13 @@ public class TCFThreadFilterEditor {
}
private Context getContainer(Context child) {
- return getContext(child.fParentId);
+ String parentId = child.fSessionId != null ? child.fSessionId + '/' + child.fParentId : child.fParentId;
+ return getContext(parentId);
}
private Context getContext(String id) {
for (Context ctx : fContexts) {
- if (ctx.fId.equals(id))
+ if (ctx.fScopeId.equals(id))
return ctx;
}
return null;
@@ -316,7 +330,7 @@ public class TCFThreadFilterEditor {
for (int i = 0; i < elements.length; ++i) {
Context ctx = (Context) elements[i];
if (!viewer.getGrayed(ctx)) {
- checkedIds.add(ctx.fId);
+ checkedIds.add(ctx.fScopeId);
}
}
threadIds = (String[]) checkedIds.toArray(new String[checkedIds.size()]);
@@ -335,7 +349,7 @@ public class TCFThreadFilterEditor {
return result;
}
final String launchCfgName = launch.getLaunchConfiguration().getName();
- result = new TCFTask<Context[]>() {
+ result = new TCFTask<Context[]>(launch.getChannel()) {
public void run() {
List<Context> containers = new ArrayList<Context>();
TCFModel model = TCFModelManager.getModelManager().getModel(launch);
@@ -365,7 +379,7 @@ public class TCFThreadFilterEditor {
return result;
}
final TCFLaunch launch = getLaunch(container);
- result = new TCFTask<Context[]>() {
+ result = new TCFTask<Context[]>(launch.getChannel()) {
public void run() {
List<Context> contexts = new ArrayList<Context>();
TCFModel model = TCFModelManager.getModelManager().getModel(launch);
@@ -378,7 +392,7 @@ public class TCFThreadFilterEditor {
TCFDataCache<IRunControl.RunControlContext> runCtxCache = exeCtx.getRunContext();
if (!runCtxCache.validate(this)) return;
IRunControl.RunControlContext runCtx = runCtxCache.getData();
- contexts.add(new Context(runCtx));
+ contexts.add(new Context(runCtx, container));
}
}
done((Context[]) contexts.toArray(new Context[contexts.size()]));
@@ -398,7 +412,7 @@ public class TCFThreadFilterEditor {
for (TCFLaunch launch : fContainersPerLaunch.keySet()) {
Context[] containers = fContainersPerLaunch.get(launch);
for (Context context : containers) {
- if (context.fId.equals(container.fId)) {
+ if (context.fScopeId.equals(container.fScopeId)) {
return launch;
}
}
diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFBreakpointsModel.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFBreakpointsModel.java
index 941b58813..5fdaf0198 100644
--- a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFBreakpointsModel.java
+++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFBreakpointsModel.java
@@ -29,6 +29,8 @@ import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IBreakpointListener;
import org.eclipse.debug.core.IBreakpointManager;
import org.eclipse.debug.core.IBreakpointManagerListener;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.tm.internal.tcf.debug.Activator;
import org.eclipse.tm.tcf.protocol.IChannel;
@@ -129,7 +131,7 @@ public class TCFBreakpointsModel implements IBreakpointListener, IBreakpointMana
if (!arr[i].isPersisted()) continue;
IMarker marker = arr[i].getMarker();
String file = getFilePath(marker.getResource());
- bps.add(toBreakpointAttributes(id, file, marker.getType(), marker.getAttributes()));
+ bps.add(toBreakpointAttributes(channel, id, file, marker.getType(), marker.getAttributes()));
id2bp.put(id, arr[i]);
}
if (!bps.isEmpty()) {
@@ -234,8 +236,8 @@ public class TCFBreakpointsModel implements IBreakpointListener, IBreakpointMana
public void run() {
if (disposed) return;
- tcf_attrs = toBreakpointAttributes(marker_id, marker_file, marker_type, marker_attrs);
for (final IChannel channel : channels) {
+ tcf_attrs = toBreakpointAttributes(channel, marker_id, marker_file, marker_type, marker_attrs);
service = channel.getRemoteService(IBreakpoints.class);
if (!isSupported(channel, breakpoint)) continue;
done = new IBreakpoints.DoneCommand() {
@@ -387,7 +389,7 @@ public class TCFBreakpointsModel implements IBreakpointListener, IBreakpointMana
return m;
}
- public Map<String,Object> toBreakpointAttributes(String id, String file, String type, Map<String,Object> p) {
+ public Map<String,Object> toBreakpointAttributes(IChannel channel, String id, String file, String type, Map<String,Object> p) {
assert !disposed;
assert Protocol.isDispatchThread();
Map<String,Object> m = new HashMap<String,Object>();
@@ -399,7 +401,7 @@ public class TCFBreakpointsModel implements IBreakpointListener, IBreakpointMana
if (!key.startsWith(ITCFConstants.ID_TCF_DEBUG_MODEL)) continue;
String tcfKey = key.substring(ITCFConstants.ID_TCF_DEBUG_MODEL.length() + 1);
if (IBreakpoints.PROP_CONTEXTIDS.equals(tcfKey)) {
- val = ((String) val).split(",\\s*");
+ val = filterContextIds(channel, ((String) val).split(",\\s*"));
}
m.put(tcfKey, val);
}
@@ -461,4 +463,39 @@ public class TCFBreakpointsModel implements IBreakpointListener, IBreakpointMana
if (skip_count != null && skip_count.intValue() > 0) m.put(IBreakpoints.PROP_IGNORECOUNT, skip_count);
return m;
}
+
+ /**
+ * Filter given array of scope ids of the form sessionId/contextId
+ * to those applicable to the given channel.
+ */
+ private String[] filterContextIds(IChannel channel, String[] scopeIds) {
+ String sessionId = getSessionId(channel);
+ List<String> contextIds = new ArrayList<String>();
+ for (String scopeId : scopeIds) {
+ if (scopeId.length() == 0) continue;
+ int slash = scopeId.indexOf('/');
+ if (slash < 0) {
+ contextIds.add(scopeId);
+ } else if (sessionId != null && sessionId.equals(scopeId.substring(0, slash))) {
+ contextIds.add(scopeId.substring(slash+1));
+ }
+ }
+ return (String[]) contextIds.toArray(new String[contextIds.size()]);
+ }
+
+ /**
+ * @return launch config name for given channel or <code>null</code>
+ */
+ private String getSessionId(IChannel channel) {
+ ILaunch[] launches = DebugPlugin.getDefault().getLaunchManager().getLaunches();
+ for (ILaunch launch : launches) {
+ if (launch instanceof TCFLaunch) {
+ if (channel == ((TCFLaunch) launch).getChannel()) {
+ ILaunchConfiguration lc = launch.getLaunchConfiguration();
+ return lc != null ? lc.getName() : null;
+ }
+ }
+ }
+ return null;
+ }
}

Back to the top