diff options
author | eutarass | 2008-07-23 18:27:00 +0000 |
---|---|---|
committer | eutarass | 2008-07-23 18:27:00 +0000 |
commit | 739419bdf8bf4c5aab6e6a9261af981fd933f54e (patch) | |
tree | e3a47853e01c3ecd3688f9fab03fbc7e847c6466 | |
parent | d94e36986dcb0857a6c4fe5f5c477a3ad094f142 (diff) | |
download | org.eclipse.tcf-739419bdf8bf4c5aab6e6a9261af981fd933f54e.tar.gz org.eclipse.tcf-739419bdf8bf4c5aab6e6a9261af981fd933f54e.tar.xz org.eclipse.tcf-739419bdf8bf4c5aab6e6a9261af981fd933f54e.zip |
TCF debugger prototype: improved generation of model deltas - now deltas have valid index and children count
12 files changed, 204 insertions, 90 deletions
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/ResumeCommand.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/ResumeCommand.java index 9e2db6f55..645ffc54e 100644 --- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/ResumeCommand.java +++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/ResumeCommand.java @@ -22,6 +22,7 @@ import org.eclipse.debug.core.commands.IResumeHandler; import org.eclipse.tm.internal.tcf.debug.ui.Activator; import org.eclipse.tm.internal.tcf.debug.ui.model.TCFModel; import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNode; +import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNodeExecContext; import org.eclipse.tm.internal.tcf.debug.ui.model.TCFRunnable; import org.eclipse.tm.tcf.protocol.IToken; import org.eclipse.tm.tcf.services.IRunControl; @@ -46,17 +47,21 @@ public class ResumeCommand implements IResumeHandler { else node = model.getRootNode(); while (node != null && !node.isDisposed()) { if (!node.validateNode(this)) return; - IRunControl.RunControlContext ctx = node.getRunContext(); + IRunControl.RunControlContext ctx = null; + if (node instanceof TCFNodeExecContext) { + ctx = ((TCFNodeExecContext)node).getRunContext(); + } if (ctx == null) { node = node.getParent(); } else if (ctx.isContainer()) { if (ctx.canResume(IRunControl.RM_RESUME)) res = true; - node = null; + break; } else { - if (node.isSuspended() && ctx.canResume(IRunControl.RM_RESUME)) res = true; - node = null; + if (((TCFNodeExecContext)node).isSuspended() && + ctx.canResume(IRunControl.RM_RESUME)) res = true; + break; } } } @@ -78,13 +83,16 @@ public class ResumeCommand implements IResumeHandler { else node = model.getRootNode(); while (node != null && !node.isDisposed()) { if (!node.validateNode(this)) return; - IRunControl.RunControlContext ctx = node.getRunContext(); + IRunControl.RunControlContext ctx = null; + if (node instanceof TCFNodeExecContext) { + ctx = ((TCFNodeExecContext)node).getRunContext(); + } if (ctx == null) { node = node.getParent(); } else { set.add(ctx); - node = null; + break; } } } diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/StepCommand.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/StepCommand.java index 39b19894c..a9e8972f3 100644 --- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/StepCommand.java +++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/StepCommand.java @@ -21,6 +21,7 @@ import org.eclipse.jface.text.source.Annotation; import org.eclipse.tm.internal.tcf.debug.ui.Activator; import org.eclipse.tm.internal.tcf.debug.ui.model.TCFModel; import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNode; +import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNodeExecContext; import org.eclipse.tm.internal.tcf.debug.ui.model.TCFRunnable; import org.eclipse.tm.tcf.protocol.Protocol; import org.eclipse.tm.tcf.services.IRunControl; @@ -49,13 +50,16 @@ abstract class StepCommand implements IDebugCommandHandler { else node = model.getRootNode(); while (node != null && !node.isDisposed()) { if (!node.validateNode(this)) return; - IRunControl.RunControlContext ctx = node.getRunContext(); + IRunControl.RunControlContext ctx = null; + if (node instanceof TCFNodeExecContext) { + ctx = ((TCFNodeExecContext)node).getRunContext(); + } if (!canExecute(ctx)) { node = node.getParent(); } else { - if (node.isSuspended()) res = true; - node = null; + if (((TCFNodeExecContext)node).isSuspended()) res = true; + break; } } } @@ -77,13 +81,16 @@ abstract class StepCommand implements IDebugCommandHandler { else node = model.getRootNode(); while (node != null && !node.isDisposed()) { if (!node.validateNode(this)) return; - IRunControl.RunControlContext ctx = node.getRunContext(); + IRunControl.RunControlContext ctx = null; + if (node instanceof TCFNodeExecContext) { + ctx = ((TCFNodeExecContext)node).getRunContext(); + } if (!canExecute(ctx)) { node = node.getParent(); } else { set.add(ctx); - node = null; + break; } } } diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/SuspendCommand.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/SuspendCommand.java index 1c354cf0c..fa69c4454 100644 --- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/SuspendCommand.java +++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/SuspendCommand.java @@ -22,6 +22,7 @@ import org.eclipse.debug.core.commands.ISuspendHandler; import org.eclipse.tm.internal.tcf.debug.ui.Activator; import org.eclipse.tm.internal.tcf.debug.ui.model.TCFModel; import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNode; +import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNodeExecContext; import org.eclipse.tm.internal.tcf.debug.ui.model.TCFRunnable; import org.eclipse.tm.tcf.protocol.IToken; import org.eclipse.tm.tcf.services.IRunControl; @@ -46,17 +47,21 @@ public class SuspendCommand implements ISuspendHandler { else node = model.getRootNode(); while (node != null && !node.isDisposed()) { if (!node.validateNode(this)) return; - IRunControl.RunControlContext ctx = node.getRunContext(); + IRunControl.RunControlContext ctx = null; + if (node instanceof TCFNodeExecContext) { + ctx = ((TCFNodeExecContext)node).getRunContext(); + } if (ctx == null) { node = node.getParent(); } else if (ctx.isContainer()) { if (ctx.canSuspend()) res = true; - node = null; + break; } else { - if (node.isRunning() && ctx.canSuspend()) res = true; - node = null; + if (((TCFNodeExecContext)node).isRunning() && + ctx.canSuspend()) res = true; + break; } } } @@ -78,7 +83,10 @@ public class SuspendCommand implements ISuspendHandler { else node = model.getRootNode(); while (node != null && !node.isDisposed()) { if (!node.validateNode(this)) return; - IRunControl.RunControlContext ctx = node.getRunContext(); + IRunControl.RunControlContext ctx = null; + if (node instanceof TCFNodeExecContext) { + ctx = ((TCFNodeExecContext)node).getRunContext(); + } if (ctx == null) { node = node.getParent(); } diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/TerminateCommand.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/TerminateCommand.java index 1f5e9b241..dbd6bf26d 100644 --- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/TerminateCommand.java +++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/TerminateCommand.java @@ -22,6 +22,7 @@ import org.eclipse.debug.core.commands.ITerminateHandler; import org.eclipse.tm.internal.tcf.debug.ui.Activator; import org.eclipse.tm.internal.tcf.debug.ui.model.TCFModel; import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNode; +import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNodeExecContext; import org.eclipse.tm.internal.tcf.debug.ui.model.TCFRunnable; import org.eclipse.tm.tcf.protocol.IToken; import org.eclipse.tm.tcf.services.IRunControl; @@ -46,7 +47,10 @@ public class TerminateCommand implements ITerminateHandler { else node = model.getRootNode(); while (node != null && !node.isDisposed()) { if (!node.validateNode(this)) return; - IRunControl.RunControlContext ctx = node.getRunContext(); + IRunControl.RunControlContext ctx = null; + if (node instanceof TCFNodeExecContext) { + ctx = ((TCFNodeExecContext)node).getRunContext(); + } if (ctx != null && ctx.canTerminate()) { res = true; break; @@ -72,7 +76,10 @@ public class TerminateCommand implements ITerminateHandler { else node = model.getRootNode(); while (node != null && !node.isDisposed()) { if (!node.validateNode(this)) return; - IRunControl.RunControlContext ctx = node.getRunContext(); + IRunControl.RunControlContext ctx = null; + if (node instanceof TCFNodeExecContext) { + ctx = ((TCFNodeExecContext)node).getRunContext(); + } if (ctx != null && ctx.canTerminate()) { set.add(ctx); break; diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFAnnotationManager.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFAnnotationManager.java index dc38b51cc..b0497328e 100644 --- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFAnnotationManager.java +++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFAnnotationManager.java @@ -376,7 +376,14 @@ public class TCFAnnotationManager { if (adaptable instanceof TCFNode) { Protocol.invokeLater(new Runnable() { public void run() { - IRunControl.RunControlContext x = ((TCFNode)adaptable).getRunContext(); + IRunControl.RunControlContext x = null; + TCFNode n = (TCFNode)adaptable.getAdapter(TCFNode.class); + while (x == null && n != null) { + if (n instanceof TCFNodeExecContext) { + x = ((TCFNodeExecContext)n).getRunContext(); + } + n = n.parent; + } if (x != null && id.equals(x.getID())) { displayExec(new Runnable() { public void run() { diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFChildren.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFChildren.java index a9efd4cea..9ea27cf0c 100644 --- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFChildren.java +++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFChildren.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.tm.internal.tcf.debug.ui.model; +import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.LinkedHashMap; @@ -118,12 +119,27 @@ public abstract class TCFChildren extends TCFDataCache<Map<String,TCFNode>> { } /** + * Return index of given child node. + * @param n - a child node + * @return - node index or -1 if node is not found in children list + */ + int getIndexOf(TCFNode n) { + TCFNode[] arr = toArray(); + for (int i = 0; i < arr.length; i++) { + if (arr[i] == n) return i; + } + return -1; + } + + /** * Return current children nodes as an array. * @return array of nodes. */ TCFNode[] toArray() { assert isValid(); Map<String,TCFNode> data = getData(); - return data.values().toArray(new TCFNode[data.size()]); + TCFNode[] arr = data.values().toArray(new TCFNode[data.size()]); + Arrays.sort(arr); + return arr; } } diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModel.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModel.java index 83efa14ad..865f742f6 100644 --- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModel.java +++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModel.java @@ -574,8 +574,8 @@ public class TCFModel implements IElementContentProvider, IElementLabelProvider, line = src_ref.area.start_line; } } - displaySource(cnt, editor_id, editor_input, page, stack_frame.getRunContext().getID(), - stack_frame.getFrameNo() == 0, line); + displaySource(cnt, editor_id, editor_input, page, + stack_frame.parent.id, stack_frame.getFrameNo() == 0, line); } } } diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModelProxy.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModelProxy.java index e81b7e15c..362e9e4bb 100644 --- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModelProxy.java +++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModelProxy.java @@ -17,6 +17,7 @@ import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.internal.ui.viewers.provisional.AbstractModelProxy; import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta; import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxy; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta; import org.eclipse.jface.viewers.Viewer; import org.eclipse.tm.tcf.protocol.Protocol; @@ -65,15 +66,18 @@ public class TCFModelProxy extends AbstractModelProxy implements IModelProxy { boolean content_only = (flags & ~CONTENT_FLAGS) == 0; ModelDelta delta = map.get(node); if (delta == null) { + IPresentationContext p = getPresentationContext(); if (node.parent == null) { if (content_only && (root.getFlags() & IModelDelta.CONTENT) != 0) return null; - delta = root.addNode(model.getLaunch(), flags); + delta = root.addNode(model.getLaunch(), -1, flags, node.getChildrenCount(p)); } else { ModelDelta parent = makeDelta(root, map, node.parent, 0); if (parent == null) return null; if (content_only && (parent.getFlags() & IModelDelta.CONTENT) != 0) return null; - delta = parent.addNode(node, flags); + delta = parent.addNode( + node, node.parent.getNodeIndex(p, node), + flags, node.getChildrenCount(p)); } map.put(node, delta); } diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNode.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNode.java index fe4855b5d..f043dd150 100644 --- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNode.java +++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNode.java @@ -13,6 +13,7 @@ package org.eclipse.tm.internal.tcf.debug.ui.model; import java.math.BigInteger; import java.util.Collection; +import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.PlatformObject; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.ILaunch; @@ -30,8 +31,6 @@ import org.eclipse.debug.ui.sourcelookup.ISourceDisplay; import org.eclipse.tm.internal.tcf.debug.ui.ImageCache; import org.eclipse.tm.tcf.protocol.IChannel; import org.eclipse.tm.tcf.protocol.Protocol; -import org.eclipse.tm.tcf.services.IMemory; -import org.eclipse.tm.tcf.services.IRunControl; /** @@ -100,6 +99,15 @@ public abstract class TCFNode extends PlatformObject implements Comparable<TCFNo return disposed; } + /** + * Returns an object which is an instance of the given class + * associated with this object. Returns <code>null</code> if + * no such object can be found. + * + * @param adapter the class to adapt to + * @return the adapted object or <code>null</code> + * @see IAdaptable#getAdapter(Class) + */ @SuppressWarnings("unchecked") public Object getAdapter(Class adapter) { if (adapter == ILaunch.class) return model.getLaunch(); @@ -113,25 +121,31 @@ public abstract class TCFNode extends PlatformObject implements Comparable<TCFNo return super.getAdapter(adapter); } + /** + * Get parent node. + * @return parent node or null if the node is a root + */ public final TCFNode getParent() { assert Protocol.isDispatchThread(); return parent; } - - public IRunControl.RunControlContext getRunContext() { - return null; - } - - public IMemory.MemoryContext getMemoryContext() { - return null; - } - - public boolean isRunning() { - return false; + + /** + * Get index of a node in this node children list + * @param p - presentation context + * @return node index or -1 if unknown + */ + public int getNodeIndex(IPresentationContext p, TCFNode n) { + return -1; } - - public boolean isSuspended() { - return false; + + /** + * Get children count of the node. + * @param p - presentation context + * @return children count or -1 if unknown + */ + public int getChildrenCount(IPresentationContext p) { + return -1; } /** @@ -143,10 +157,6 @@ public abstract class TCFNode extends PlatformObject implements Comparable<TCFNo return null; } - boolean isNodeContentVisibleInContext(IPresentationContext p) { - return true; - } - /** * Retrieve children count for a presentation context. * @param result - children count update request. diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeExecContext.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeExecContext.java index 8535a6e68..12f6043cc 100644 --- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeExecContext.java +++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeExecContext.java @@ -11,7 +11,6 @@ package org.eclipse.tm.internal.tcf.debug.ui.model; import java.math.BigInteger; -import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; @@ -20,6 +19,7 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate; import org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate; import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate; import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.swt.graphics.RGB; import org.eclipse.tm.internal.tcf.debug.model.TCFContextState; @@ -150,21 +150,18 @@ public class TCFNodeExecContext extends TCFNode { return line_info_cache; } - @Override public IRunControl.RunControlContext getRunContext() { assert Protocol.isDispatchThread(); if (!run_context.isValid()) return null; return run_context.getData(); } - @Override public IMemory.MemoryContext getMemoryContext() { assert Protocol.isDispatchThread(); if (!mem_context.isValid()) return null; return mem_context.getData(); } - @Override public boolean isRunning() { assert Protocol.isDispatchThread(); if (!run_context.isValid()) return false; @@ -175,7 +172,6 @@ public class TCFNodeExecContext extends TCFNode { return s != null && !s.is_suspended; } - @Override public boolean isSuspended() { assert Protocol.isDispatchThread(); if (!run_context.isValid()) return false; @@ -214,6 +210,42 @@ public class TCFNodeExecContext extends TCFNode { } @Override + public int getNodeIndex(IPresentationContext p, TCFNode n) { + if (!run_context.isValid()) return -1; + IRunControl.RunControlContext ctx = run_context.getData(); + if (ctx != null && ctx.hasState()) { + if (!children_stack.isValid()) return -1; + if (IDebugUIConstants.ID_REGISTER_VIEW.equals(p.getId()) || + IDebugUIConstants.ID_VARIABLE_VIEW.equals(p.getId())) { + TCFNodeStackFrame frame = children_stack.getTopFrame(); + if (frame == null) return -1; + return frame.getNodeIndex(p, n); + } + return children_stack.getIndexOf(n); + } + if (!children_exec.isValid()) return -1; + return children_exec.getIndexOf(n); + } + + @Override + public int getChildrenCount(IPresentationContext p) { + if (!run_context.isValid()) return -1; + IRunControl.RunControlContext ctx = run_context.getData(); + if (ctx != null && ctx.hasState()) { + if (!children_stack.isValid()) return -1; + if (IDebugUIConstants.ID_REGISTER_VIEW.equals(p.getId()) || + IDebugUIConstants.ID_VARIABLE_VIEW.equals(p.getId())) { + TCFNodeStackFrame frame = children_stack.getTopFrame(); + if (frame == null) return -1; + return frame.getChildrenCount(p); + } + return children_stack.size(); + } + if (!children_exec.isValid()) return -1; + return children_exec.size(); + } + + @Override protected void getData(IChildrenCountUpdate result) { IRunControl.RunControlContext ctx = run_context.getData(); if (ctx != null && ctx.hasState()) { @@ -255,7 +287,6 @@ public class TCFNodeExecContext extends TCFNode { else { arr = children_exec.toArray(); } - Arrays.sort(arr); int offset = 0; int r_offset = result.getOffset(); int r_length = result.getLength(); diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeLaunch.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeLaunch.java index 6afc906d0..33e733461 100644 --- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeLaunch.java +++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeLaunch.java @@ -10,11 +10,10 @@ *******************************************************************************/ package org.eclipse.tm.internal.tcf.debug.ui.model; -import java.util.Arrays; - import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate; import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate; import org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; import org.eclipse.tm.tcf.services.IMemory; import org.eclipse.tm.tcf.services.IRunControl; @@ -40,6 +39,18 @@ public class TCFNodeLaunch extends TCFNode { } @Override + public int getNodeIndex(IPresentationContext p, TCFNode n) { + if (!children.isValid()) return -1; + return children.getIndexOf(n); + } + + @Override + public int getChildrenCount(IPresentationContext p) { + if (!children.isValid()) return -1; + return children.size(); + } + + @Override protected void getData(IChildrenCountUpdate result) { result.setChildCount(children.size()); } @@ -47,7 +58,6 @@ public class TCFNodeLaunch extends TCFNode { @Override protected void getData(IChildrenUpdate result) { TCFNode[] arr = children.toArray(); - Arrays.sort(arr); int offset = 0; int r_offset = result.getOffset(); int r_length = result.getLength(); diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeStackFrame.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeStackFrame.java index dd95f59e8..f2d35c61f 100644 --- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeStackFrame.java +++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeStackFrame.java @@ -11,7 +11,6 @@ package org.eclipse.tm.internal.tcf.debug.ui.model; import java.math.BigInteger; -import java.util.Arrays; import java.util.Map; import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate; @@ -19,6 +18,7 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate; import org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate; import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate; import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.swt.graphics.RGB; import org.eclipse.tm.internal.tcf.debug.model.TCFSourceRef; @@ -28,7 +28,6 @@ import org.eclipse.tm.tcf.protocol.IToken; import org.eclipse.tm.tcf.protocol.Protocol; import org.eclipse.tm.tcf.services.ILineNumbers; import org.eclipse.tm.tcf.services.IMemory; -import org.eclipse.tm.tcf.services.IRunControl; import org.eclipse.tm.tcf.services.IStackTrace; import org.eclipse.tm.tcf.services.ILineNumbers.CodeArea; import org.eclipse.tm.tcf.util.TCFDataCache; @@ -50,7 +49,7 @@ public class TCFNodeStackFrame extends TCFNode { @Override protected boolean startDataRetrieval() { assert command == null; - if (!isSuspended()) { + if (!parent.isSuspended()) { set(null, null, null); return true; } @@ -141,32 +140,12 @@ public class TCFNodeStackFrame extends TCFNode { children_regs.dispose(id); children_vars.dispose(id); } - - @Override - public IRunControl.RunControlContext getRunContext() { - return parent.getRunContext(); - } - - @Override - public IMemory.MemoryContext getMemoryContext() { - return parent.getMemoryContext(); - } public TCFDataCache<IStackTrace.StackTraceContext> getStackTraceContext() { return stack_trace_context; } @Override - public boolean isRunning() { - return parent.isRunning(); - } - - @Override - public boolean isSuspended() { - return parent.isSuspended(); - } - - @Override public BigInteger getAddress() { assert Protocol.isDispatchThread(); if (!stack_trace_context.isValid()) return null; @@ -193,6 +172,36 @@ public class TCFNodeStackFrame extends TCFNode { } @Override + public int getNodeIndex(IPresentationContext p, TCFNode n) { + if (IDebugUIConstants.ID_REGISTER_VIEW.equals(p.getId())) { + if (!children_regs.isValid()) return -1; + return children_regs.getIndexOf(n); + } + else if (IDebugUIConstants.ID_VARIABLE_VIEW.equals(p.getId())) { + if (!children_vars.isValid()) return -1; + return children_vars.getIndexOf(n); + } + else { + return 0; + } + } + + @Override + public int getChildrenCount(IPresentationContext p) { + if (IDebugUIConstants.ID_REGISTER_VIEW.equals(p.getId())) { + if (!children_regs.isValid()) return -1; + return children_regs.size(); + } + else if (IDebugUIConstants.ID_VARIABLE_VIEW.equals(p.getId())) { + if (!children_vars.isValid()) return -1; + return children_vars.size(); + } + else { + return 0; + } + } + + @Override protected void getData(IChildrenCountUpdate result) { if (IDebugUIConstants.ID_REGISTER_VIEW.equals(result.getPresentationContext().getId())) { result.setChildCount(children_regs.size()); @@ -215,19 +224,16 @@ public class TCFNodeStackFrame extends TCFNode { arr = children_vars.toArray(); } else { - arr = null; + arr = new TCFNode[0]; } - if (arr != null) { - Arrays.sort(arr); - int offset = 0; - int r_offset = result.getOffset(); - int r_length = result.getLength(); - for (TCFNode n : arr) { - if (offset >= r_offset && offset < r_offset + r_length) { - result.setChild(n, offset); - } - offset++; + int offset = 0; + int r_offset = result.getOffset(); + int r_length = result.getLength(); + for (TCFNode n : arr) { + if (offset >= r_offset && offset < r_offset + r_length) { + result.setChild(n, offset); } + offset++; } } @@ -249,7 +255,7 @@ public class TCFNodeStackFrame extends TCFNode { result.setImageDescriptor(ImageCache.getImageDescriptor(getImageName()), 0); Throwable error = stack_trace_context.getError(); if (error == null) error = line_info.getError(); - if (error != null && isSuspended()) { + if (error != null && ((TCFNodeExecContext)parent).isSuspended()) { result.setForeground(new RGB(255, 0, 0), 0); result.setLabel(error.getClass().getName() + ": " + error.getMessage(), 0); } @@ -273,7 +279,7 @@ public class TCFNodeStackFrame extends TCFNode { if (n instanceof BigInteger) i = (BigInteger)n; else i = new BigInteger(n.toString()); String s = i.toString(16); - IMemory.MemoryContext m = getMemoryContext(); + IMemory.MemoryContext m = ((TCFNodeExecContext)parent).getMemoryContext(); int sz = (m != null ? m.getAddressSize() : 4) * 2; int l = sz - s.length(); if (l < 0) l = 0; @@ -333,7 +339,7 @@ public class TCFNodeStackFrame extends TCFNode { @Override protected String getImageName() { - if (isRunning()) return ImageCache.IMG_STACK_FRAME_RUNNING; + if (((TCFNodeExecContext)parent).isRunning()) return ImageCache.IMG_STACK_FRAME_RUNNING; return ImageCache.IMG_STACK_FRAME_SUSPENDED; } |