From 0bd7f7f2b346ac79ccb5402df36f81de49b47879 Mon Sep 17 00:00:00 2001 From: Eugene Tarassov Date: Wed, 23 Apr 2014 14:26:46 -0700 Subject: TCF Core: Run Control service: added support for context states other than Suspended and Running. For example, state can be Sleeping, Reset, No Clock. --- .../cdt/ui/disassembly/TCFDisassemblyBackend.java | 2 +- .../internal/services/remote/RunControlProxy.java | 8 +++- .../src/org/eclipse/tcf/services/IRunControl.java | 32 ++++++++++++++ plugins/org.eclipse.tcf.debug.ui/plugin.xml | 2 +- .../tcf/internal/debug/ui/model/TCFModel.java | 9 +++- .../debug/ui/model/TCFNodeExecContext.java | 51 ++++++++++++++-------- 6 files changed, 82 insertions(+), 22 deletions(-) diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/disassembly/TCFDisassemblyBackend.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/disassembly/TCFDisassemblyBackend.java index 00f259b0a..438a52244 100644 --- a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/disassembly/TCFDisassemblyBackend.java +++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/disassembly/TCFDisassemblyBackend.java @@ -787,7 +787,7 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { insertedAnyAddress = true; } if (!insertedAnyAddress) { - // Insert error in case of incomplete disassembly + // Insert error in case of incomplete disassembly fCallback.insertError(startAddress, "cannot disassemble"); } } diff --git a/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/internal/services/remote/RunControlProxy.java b/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/internal/services/remote/RunControlProxy.java index 42678ddb3..b6318393a 100644 --- a/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/internal/services/remote/RunControlProxy.java +++ b/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/internal/services/remote/RunControlProxy.java @@ -128,7 +128,7 @@ public class RunControlProxy implements IRunControl { assert args.length == 5; error = toError(args[0]); susp = ((Boolean)args[1]).booleanValue(); - if (args[2] != null) pc = ((Number)args[2]).toString(); + if (args[2] != null) pc = ((Number)args[2]).toString(); reason = (String)args[3]; map = (Map)args[4]; } @@ -230,6 +230,12 @@ public class RunControlProxy implements IRunControl { assert args.length == 1; listener.containerResumed(toStringArray(args[0])); } + else if (name.equals("contextStateChanged")) { + assert args.length == 1; + if (listener instanceof RunControlListenerV1) { + ((RunControlListenerV1)listener).contextStateChanged((String)args[0]); + } + } else { throw new IOException("RunControl service: unknown event: " + name); } diff --git a/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/services/IRunControl.java b/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/services/IRunControl.java index e7e2cfced..ee7d45055 100644 --- a/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/services/IRunControl.java +++ b/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/services/IRunControl.java @@ -274,6 +274,24 @@ public interface IRunControl extends IService { */ static final String STATE_REVERSING = "Reversing"; + /** + * Context state parameter: + * String - name of a context that owns this context. + */ + static final String STATE_CONTEXT = "Context"; + + /** + * Context state parameter: + * String - name of CPU that is executing the context. + */ + static final String STATE_CPU = "CPU"; + + /** + * Context state parameter: + * String - name of current state if other than "Running", for example: "Sleeping", "Reset", "No Clock". + */ + static final String STATE_NAME = "StateName"; + /* Optional parameters of resume command ------------------------------- */ @@ -631,4 +649,18 @@ public interface IRunControl extends IService { */ void contextException(String context, String msg); } + + /** + * Service events listener interface - extended. + */ + interface RunControlListenerV1 extends RunControlListener { + + /** + * Called when context state changes and the context is not and was not in suspended state. + * Changes to and from suspended state should be reported by other events: + * contextSuspended, contextResumed, containerSuspended, containerResumed. + * @param context - ID of a context that changed state. + */ + void contextStateChanged(String context); + } } diff --git a/plugins/org.eclipse.tcf.debug.ui/plugin.xml b/plugins/org.eclipse.tcf.debug.ui/plugin.xml index e8ac98db9..10ce7735f 100644 --- a/plugins/org.eclipse.tcf.debug.ui/plugin.xml +++ b/plugins/org.eclipse.tcf.debug.ui/plugin.xml @@ -555,7 +555,7 @@ commandId="org.eclipse.tcf.debug.ui.commands.toggleQualifiedTypeNames" style="toggle"> - + diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModel.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModel.java index 9deeaed9d..594d15314 100644 --- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModel.java +++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModel.java @@ -377,7 +377,7 @@ public class TCFModel implements ITCFModel, IElementContentProvider, IElementLab } }; - private final IRunControl.RunControlListener run_listener = new IRunControl.RunControlListener() { + private final IRunControl.RunControlListener run_listener = new IRunControl.RunControlListenerV1() { public void containerResumed(String[] context_ids) { for (String id : context_ids) { @@ -490,6 +490,13 @@ public class TCFModel implements ITCFModel, IElementContentProvider, IElementLab } onMemoryChanged(id, false, true, false); } + + public void contextStateChanged(String id) { + TCFNode node = getNode(id); + if (node instanceof TCFNodeExecContext) { + ((TCFNodeExecContext)node).onContextStateChanged(); + } + } }; private final IMemoryMap.MemoryMapListener mmap_listener = new IMemoryMap.MemoryMapListener() { diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExecContext.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExecContext.java index 5bae32dbb..c33e24040 100644 --- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExecContext.java +++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExecContext.java @@ -1067,6 +1067,29 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner, ITCFExe return true; } + private String addStateName(StringBuffer label, TCFContextState state_data) { + String image_name = ImageCache.IMG_THREAD_UNKNOWN_STATE; + assert !state_data.is_suspended; + if (state_data.suspend_params != null) { + String name = (String)state_data.suspend_params.get(IRunControl.STATE_NAME); + if (name != null) { + label.append(" ("); + label.append(name); + label.append(")"); + return image_name; + } + } + if (state_data.isReversing()) { + image_name = ImageCache.IMG_THREAD_REVERSING; + label.append(" (Reversing)"); + } + else { + image_name = ImageCache.IMG_THREAD_RUNNNIG; + label.append(" (Running)"); + } + return image_name; + } + @Override protected boolean getData(ILabelUpdate result, Runnable done) { if (!run_context.validate(done)) return false; @@ -1121,14 +1144,7 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner, ITCFExe image_name = ImageCache.IMG_THREAD_UNKNOWN_STATE; if (state_data != null) { if (!state_data.is_suspended) { - if (state_data.isReversing()) { - image_name = ImageCache.IMG_THREAD_REVERSING; - label.append(" (Reversing)"); - } - else { - image_name = ImageCache.IMG_THREAD_RUNNNIG; - label.append(" (Running)"); - } + image_name = addStateName(label, state_data); } else { suspended_by_bp = IRunControl.REASON_BREAKPOINT.equals(state_data.suspend_reason); @@ -1160,14 +1176,7 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner, ITCFExe image_name = ImageCache.IMG_THREAD_UNKNOWN_STATE; if (state_data != null) { if (!state_data.is_suspended) { - if (state_data.isReversing()) { - image_name = ImageCache.IMG_THREAD_REVERSING; - label.append(" (Reversing)"); - } - else { - image_name = ImageCache.IMG_THREAD_RUNNNIG; - label.append(" (Running)"); - } + image_name = addStateName(label, state_data); } else { image_name = ImageCache.IMG_THREAD_SUSPENDED; @@ -1214,12 +1223,12 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner, ITCFExe label.append(" ("); label.append(r); if (state_data.suspend_params != null) { - String prs = (String)state_data.suspend_params.get("Context"); + String prs = (String)state_data.suspend_params.get(IRunControl.STATE_CONTEXT); if (prs != null) { label.append(", "); label.append(prs); } - String cpu = (String)state_data.suspend_params.get("CPU"); + String cpu = (String)state_data.suspend_params.get(IRunControl.STATE_CPU); if (cpu != null) { label.append(", "); label.append(cpu); @@ -1548,6 +1557,12 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner, ITCFExe } } + void onContextStateChanged() { + assert !isDisposed(); + state.reset(); + postStateChangedDelta(); + } + void onContextActionDone() { assert state.isValid(); if (state.getData() == null || state.getData().is_suspended) { -- cgit v1.2.3